From owner-freebsd-bugs@FreeBSD.ORG Tue Nov 10 07:00:15 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87DBF10656C5 for ; Tue, 10 Nov 2009 07:00:14 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BB5118FC3C for ; Tue, 10 Nov 2009 07:00:11 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nAA70B5L018968 for ; Tue, 10 Nov 2009 07:00:11 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id nAA70Bjp018967; Tue, 10 Nov 2009 07:00:11 GMT (envelope-from gnats) Resent-Date: Tue, 10 Nov 2009 07:00:11 GMT Resent-Message-Id: <200911100700.nAA70Bjp018967@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Kouhei Ueno Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15DC41065670 for ; Tue, 10 Nov 2009 06:51:32 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 04B958FC17 for ; Tue, 10 Nov 2009 06:51:32 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nAA6pVpS037411 for ; Tue, 10 Nov 2009 06:51:31 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id nAA6pVkE037410; Tue, 10 Nov 2009 06:51:31 GMT (envelope-from nobody) Message-Id: <200911100651.nAA6pVkE037410@www.freebsd.org> Date: Tue, 10 Nov 2009 06:51:31 GMT From: Kouhei Ueno To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/140441: order of arguments for mtx_init is incorrect in uipc_syscalls.c X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2009 07:00:17 -0000 >Number: 140441 >Category: kern >Synopsis: order of arguments for mtx_init is incorrect in uipc_syscalls.c >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Nov 10 07:00:10 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Kouhei Ueno >Release: FreeBSD 8.0-RC1 i386 >Organization: Fillot Inc. >Environment: FreeBSD burmese-bsddev.home.nyaxtstep.com 8.0-RC1 FreeBSD 8.0-RC1 #0: Thu Oct 15 20:36:40 JST 2009 root@burmese-bsddev.home.nyaxtstep.com:/usr/src/sys/i386/compile/IZNA i386 >Description: In sendfile implementation, kern_sendfile, mtx_init(9) is called with its arguments in incorrect order. The third argument should be type, and the fourth argument should be opts. These are swapped in the implementation. Fortunately, MTX_DEF is defined to be zero (which would equal NULL), so the original code will not cause any problem. But still it is very confusing to read. >How-To-Repeat: don't know >Fix: patch to uipc_syscalls.c --- uipc_syscalls.c 2009-08-03 17:13:06.000000000 +0900 +++ uipc_syscalls.c.fix 2009-11-10 15:17:18.000000000 +0900 @@ -1885,7 +1885,7 @@ if (uap->flags & SF_SYNC) { sfs = malloc(sizeof *sfs, M_TEMP, M_WAITOK); memset(sfs, 0, sizeof *sfs); - mtx_init(&sfs->mtx, "sendfile", MTX_DEF, 0); + mtx_init(&sfs->mtx, "sendfile", NULL, MTX_DEF); cv_init(&sfs->cv, "sendfile"); } >Release-Note: >Audit-Trail: >Unformatted: