From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds Subject: Re: negative seek offsets in VFS Date: Thu, 26 May 2005 12:39:19 -0700 (PDT) Message-ID: References: <20050525163905.GP86087@muc.de> <20050526151508.GZ29811@parcelfarce.linux.theplanet.co.uk> <20050526192526.GX86087@muc.de> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Al Viro , viro@www.linux.org.uk, linux-fsdevel@vger.kernel.org Return-path: Received: from fire.osdl.org ([65.172.181.4]:57522 "EHLO smtp.osdl.org") by vger.kernel.org with ESMTP id S261722AbVEZTha (ORCPT ); Thu, 26 May 2005 15:37:30 -0400 To: Andi Kleen In-Reply-To: <20050526192526.GX86087@muc.de> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Thu, 26 May 2005, Andi Kleen wrote: > > > I don't think there is a "positive loff_t", so I guess the code would have > > to be something like > > > > /* Wraparound? */ > > if ((u64)(pos + count) < count) > > goto Einval; > > Sometimes I think we should have a nice inline asm macro for that > that checks carry. Well, we'd need one in every size, and it's not common enough for us to care about performance, so.. > > if ((loff_t) (pos + count) < 0) > > if (!(file->f_mode & FMODE_ANY_OFFSET)) > > goto Einval; > > Looks good. But how to handle the broken devices viro worries about? > I would prefer not to open any new security holes, but it is a bit too > much code to audit all. Flag would be possible, but ugly. I would _only_ ever set that FMODE_ANY_OFFSET for /dev/mem or other devices that are known to be ok. IOW, this is not something that ever gets set by default, and the user cannot set it. Linus