From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 10 Jun 2008 05:12:43 +0200 From: Nick Piggin Subject: Re: [patch 20/21] fs: check for statfs overflow Message-ID: <20080610031243.GG19404@wotan.suse.de> References: <20080604112939.789444496@amd.local0.net> <20080604113113.523542750@amd.local0.net> <20080608120645.270bc581.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080608120645.270bc581.akpm@linux-foundation.org> Sender: owner-linux-mm@kvack.org Return-Path: To: Andrew Morton Cc: linux-mm@kvack.org List-ID: On Sun, Jun 08, 2008 at 12:06:45PM -0700, Andrew Morton wrote: > On Wed, 04 Jun 2008 21:29:59 +1000 npiggin@suse.de wrote: > > > Adds a check for an overflow in the filesystem size so if someone is > > checking with statfs() on a 16G hugetlbfs in a 32bit binary that it > > will report back EOVERFLOW instead of a size of 0. > > -ENOUNDERSTAND. > > Why won't a 16G filesystem work on a 32-bit binary? Well it should work, but if it calls statfs then it will overflow the f_bsize... ah, that should say 16G *block size* hugetlbfs. A 16G hugetlbfs with 2M blocks should work just fine. > > > Acked-by: Nishanth Aravamudan > > Signed-off-by: Jon Tollefson > > Signed-off-by: Nick Piggin > > --- > > > > fs/compat.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > Index: linux-2.6/fs/compat.c > > =================================================================== > > --- linux-2.6.orig/fs/compat.c 2008-06-04 20:47:31.000000000 +1000 > > +++ linux-2.6/fs/compat.c 2008-06-04 20:51:28.000000000 +1000 > > @@ -197,8 +197,8 @@ static int put_compat_statfs(struct comp > > { > > > > if (sizeof ubuf->f_blocks == 4) { > > - if ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail) & > > - 0xffffffff00000000ULL) > > + if ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail | > > + kbuf->f_bsize | kbuf->f_frsize) & 0xffffffff00000000ULL) > > return -EOVERFLOW; > > /* f_files and f_ffree may be -1; it's okay > > * to stuff that into 32 bits */ > > @@ -271,8 +271,8 @@ out: > > static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstatfs *kbuf) > > { > > if (sizeof ubuf->f_blocks == 4) { > > - if ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail) & > > - 0xffffffff00000000ULL) > > + if ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail | > > + kbuf->f_bsize | kbuf->f_frsize) & 0xffffffff00000000ULL) > > return -EOVERFLOW; > > /* f_files and f_ffree may be -1; it's okay > > * to stuff that into 32 bits */ > > Index: linux-2.6/fs/open.c > > =================================================================== > > --- linux-2.6.orig/fs/open.c 2008-06-04 20:47:31.000000000 +1000 > > +++ linux-2.6/fs/open.c 2008-06-04 20:51:28.000000000 +1000 > > @@ -63,7 +63,8 @@ static int vfs_statfs_native(struct dent > > memcpy(buf, &st, sizeof(st)); > > else { > > if (sizeof buf->f_blocks == 4) { > > - if ((st.f_blocks | st.f_bfree | st.f_bavail) & > > + if ((st.f_blocks | st.f_bfree | st.f_bavail | > > + st.f_bsize | st.f_frsize) & > > 0xffffffff00000000ULL) > > return -EOVERFLOW; > > /* > > > > -- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org