NetBSD Problem Report #46536

From www@NetBSD.org  Sun Jun  3 14:04:07 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 3B43663BEE1
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  3 Jun 2012 14:04:07 +0000 (UTC)
Message-Id: <20120603140406.72E5663BA27@www.NetBSD.org>
Date: Sun,  3 Jun 2012 14:04:06 +0000 (UTC)
From: dsl@netbsd.org
Reply-To: dsl@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: some sysctl are incorrectly defined
X-Send-Pr-Version: www-1.0

>Number:         46536
>Category:       kern
>Synopsis:       some sysctl are incorrectly defined
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 03 14:05:00 +0000 2012
>Last-Modified:  Wed Aug 22 20:30:02 +0000 2012
>Originator:     David Laight
>Release:        netbsd-5 and netbsd-6
>Organization:
>Environment:
Source inspection after spotting something 'odd'.
>Description:
Some of the sysctl_createv() calls pass the address of C variables that don't match the passed CTLTYPE_xxx.
In particular some 64bit integers are reported as CTLTYPE_INT which will give problems on BE systems or when the values exceed 32 bits.

The following have been found:
  sys/dev/acpi/asus_acpi.c: passes some ACPI_INTEGER (uint64_t)
        for CTLTYPE_INT
  ACPI defines AcpiGbl_EnableAmlDebugObject as UINT8 but passes
        CTLTYPE_BOOL
  sys/dev/bluetooth/bcsp.c passes &sc->sc_le_muzzled as CTLTYPE_INT
        (not CTLTYPE_BOOL)
  sys/kern/vfs_bio.c passes some u_long as CTLTYPE_INT
  sys/miscfs/syncfs/sync_subr.c passes some time_t as CTLTYPE_INT

In addition the code in vfs_bio.c compies the values into an 'int'
temporary during the sysctl processing.
I'm not sure how many times that piece of code has been cloned!

>How-To-Repeat:
Most of the errors will show up on 64bit BE systems (eg sparc64).
The vfs_bio.c problems also show on amd64 when vm.bufmem_hiwater
exceeds 2^31 (probably needs 16GB main memory).
>Fix:
CVS head (post netbsd-6 branch) has been changed so that sysctl_createv()
can verify the type of the 'void *' pointer argument.
This required a few explicit casts to about 67 lines - so the full patch
isn't appropriate for pullup.


>Audit-Trail:
From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46536 CVS commit: [netbsd-6] src/sys
Date: Tue, 12 Jun 2012 17:13:58 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Tue Jun 12 17:13:58 UTC 2012

 Modified Files:
 	src/sys/dev/acpi [netbsd-6]: asus_acpi.c
 	src/sys/dev/bluetooth [netbsd-6]: bcsp.c
 	src/sys/kern [netbsd-6]: vfs_bio.c
 	src/sys/miscfs/syncfs [netbsd-6]: sync_subr.c

 Log Message:
 Pull up following revision(s) (requested by dsl in ticket #306):
 	sys/kern/vfs_bio.c: revision 1.238
 	sys/dev/bluetooth/bcsp.c: revision 1.21
 	sys/dev/acpi/asus_acpi.c: revision 1.24
 	sys/miscfs/syncfs/sync_subr.c: revision 1.48
 Some calls to sysctl_createv() have mismatches betwwen the data type
 and the CTLTYPE_xxx flags.
 Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
   sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c
 (mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
 The vm.bufmem_lowater (etc) sysctls needs to be processed with a
   64bit temporary value on 64bit systems.
 Fixes PR kern/46536.


 To generate a diff of this commit:
 cvs rdiff -u -r1.23 -r1.23.2.1 src/sys/dev/acpi/asus_acpi.c
 cvs rdiff -u -r1.20 -r1.20.8.1 src/sys/dev/bluetooth/bcsp.c
 cvs rdiff -u -r1.236 -r1.236.2.1 src/sys/kern/vfs_bio.c
 cvs rdiff -u -r1.47 -r1.47.8.1 src/sys/miscfs/syncfs/sync_subr.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Manuel Bouyer" <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46536 CVS commit: [netbsd-5] src/sys/kern
Date: Wed, 22 Aug 2012 20:25:57 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Wed Aug 22 20:25:57 UTC 2012

 Modified Files:
 	src/sys/kern [netbsd-5]: vfs_bio.c

 Log Message:
 Pull up following revision(s) (requested by dsl in ticket #1770):
 	sys/kern/vfs_bio.c: revision 1.239
 Fix processing of vm.bufmem_lowater and vm.bufmem_hiwater on 64bit systems.
 Use CTLTYPE_LONG for bufmem_lowater and bufmem_hiwater.
 Use separate temporaries for the 'int' percentage and the 'long'
   water marks.
 Shows up on amd64 now that the sysctl values are marked as 64bit.
 sparc64 has been badly broken for ages. Fix part of PR kern/46536


 To generate a diff of this commit:
 cvs rdiff -u -r1.210.4.1 -r1.210.4.2 src/sys/kern/vfs_bio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.