From emil@dmr.ath.cx  Thu May 21 14:48:28 2009
Return-Path: <emil@dmr.ath.cx>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F1FB2106566B
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 21 May 2009 14:48:28 +0000 (UTC)
	(envelope-from emil@dmr.ath.cx)
Received: from ipmail04.adl2.internode.on.net (ipmail04.adl2.internode.on.net [203.16.214.57])
	by mx1.freebsd.org (Postfix) with ESMTP id 784FB8FC12
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 21 May 2009 14:48:28 +0000 (UTC)
	(envelope-from emil@dmr.ath.cx)
Received: from ppp154-240.static.internode.on.net ([150.101.154.240])
  by ipmail04.adl2.internode.on.net with ESMTP; 22 May 2009 00:18:26 +0930
Received: by ppp154-240.static.internode.on.net (Poo-fix, from userid 1001)
	id 5E65F5C40; Fri, 22 May 2009 00:48:25 +1000 (EST)
Message-Id: <20090521144825.5E65F5C40@ppp154-240.static.internode.on.net>
Date: Fri, 22 May 2009 00:48:25 +1000 (EST)
From: Emil Mikulic <emikulic@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] vfs.bufspace sysctl wideness on amd64
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         134786
>Category:       amd64
>Synopsis:       [vfs] [patch] vfs.bufspace sysctl wideness on amd64
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jhb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 21 14:50:04 UTC 2009
>Closed-Date:    Wed Aug 19 15:16:36 UTC 2009
>Last-Modified:  Wed Aug 19 15:16:36 UTC 2009
>Originator:     Emil Mikulic
>Release:        FreeBSD 8-CURRENT
>Organization:
>Environment:
>Description:

On amd64, providing a 64-bit buffer to get the vfs.bufspace sysctl will
return a 64-bit (long) quantity, but providing a *larger* buffer will
only yield a 32-bit (int) quantity.

>How-To-Repeat:

len = 8;
sysctlbyname("vfs.bufspace", &buf, &len, NULL, 0);
/* len is still 8 */

len = 10;
sysctlbyname("vfs.bufspace", &buf, &len, NULL, 0);
/* len is 4! */

>Fix:

--- sys/kern/vfs_bio.c	2009-04-17 10:01:39.000000000 +0000
+++ sys/kern/vfs_bio.c.2	2009-05-09 09:27:16.000000000 +0000
@@ -288,15 +288,15 @@
     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
 static int
 sysctl_bufspace(SYSCTL_HANDLER_ARGS)
 {
 	long lvalue;
 	int ivalue;
 
-	if (sizeof(int) == sizeof(long) || req->oldlen == sizeof(long))
+	if (sizeof(int) == sizeof(long) || req->oldlen >= sizeof(long))
 		return (sysctl_handle_long(oidp, arg1, arg2, req));
 	lvalue = *(long *)arg1;
 	if (lvalue > INT_MAX)
 		/* On overflow, still write out a long to trigger ENOMEM. */
 		return (sysctl_handle_long(oidp, &lvalue, 0, req));
 	ivalue = lvalue;
 	return (sysctl_handle_int(oidp, &ivalue, 0, req));
>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: amd64/134786: commit references a PR
Date: Thu, 21 May 2009 16:18:55 +0000 (UTC)

 Author: jhb
 Date: Thu May 21 16:18:45 2009
 New Revision: 192543
 URL: http://svn.freebsd.org/changeset/base/192543
 
 Log:
   Only use the ABI compat shim for vfs.bufspace if the old buffer is smaller
   than a long.
   
   PR:		amd64/134786
   Submitted by:	Emil Mikulic  emikulic| gmail
   MFC after:	3 days
 
 Modified:
   head/sys/kern/vfs_bio.c
 
 Modified: head/sys/kern/vfs_bio.c
 ==============================================================================
 --- head/sys/kern/vfs_bio.c	Thu May 21 15:30:59 2009	(r192542)
 +++ head/sys/kern/vfs_bio.c	Thu May 21 16:18:45 2009	(r192543)
 @@ -293,7 +293,7 @@ sysctl_bufspace(SYSCTL_HANDLER_ARGS)
  	long lvalue;
  	int ivalue;
  
 -	if (sizeof(int) == sizeof(long) || req->oldlen == sizeof(long))
 +	if (sizeof(int) == sizeof(long) || req->oldlen >= sizeof(long))
  		return (sysctl_handle_long(oidp, arg1, arg2, req));
  	lvalue = *(long *)arg1;
  	if (lvalue > INT_MAX)
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: John Baldwin <jhb@freebsd.org>
To: freebsd-amd64@freebsd.org
Cc: Emil Mikulic <emikulic@gmail.com>,
 FreeBSD-gnats-submit@freebsd.org
Subject: Re: amd64/134786: [patch] vfs.bufspace sysctl wideness on amd64
Date: Thu, 21 May 2009 12:16:26 -0400

 Hummm.  I guess that is correct, though that is a bit odd.
 
 -- 
 John Baldwin

From: Emil Mikulic <emikulic@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: amd64/134786
Date: Wed, 19 Aug 2009 18:01:39 +1000

 As per dfilter in the audit trail, this is fixed in SVN.
 Please close the PR.
State-Changed-From-To: open->patched 
State-Changed-By: linimon 
State-Changed-When: Wed Aug 19 14:45:49 UTC 2009 
State-Changed-Why:  
Submitter confirms that the fix works for him.  Set as MFC remidner. 


Responsible-Changed-From-To: freebsd-amd64->jhb 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Aug 19 14:45:49 UTC 2009 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=134786 
State-Changed-From-To: patched->closed 
State-Changed-By: jhb 
State-Changed-When: Wed Aug 19 15:16:02 UTC 2009 
State-Changed-Why:  
Fix was MFC'd in r192812. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134786 
>Unformatted:
