From: Jeff Layton Subject: Re: [PATCH 2/4] vfs: explicitly cast s_maxbytes in fiemap_check_ranges Date: Sat, 8 Aug 2009 07:20:31 -0400 Message-ID: <20090808072031.2c01a2aa@tlielax.poochiereds.net> References: <1249671461-9071-1-git-send-email-jlayton@redhat.com> <1249671461-9071-3-git-send-email-jlayton@redhat.com> <20090807221252.GA28019@cmpxchg.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, hch@infradead.org, rlove@google.com, msb@google.com, viro@zeniv.linux.org.uk To: Johannes Weiner Return-path: Received: from mx2.redhat.com ([66.187.237.31]:35333 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753210AbZHHLUm (ORCPT ); Sat, 8 Aug 2009 07:20:42 -0400 In-Reply-To: <20090807221252.GA28019@cmpxchg.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sat, 8 Aug 2009 00:12:52 +0200 Johannes Weiner wrote: > On Fri, Aug 07, 2009 at 02:57:39PM -0400, Jeff Layton wrote: > > If fiemap_check_ranges is passed a large enough value, then it's > > possible that the value would be cast to a signed value for comparison > > against s_maxbytes when we change it to loff_t. Make sure that doesn't > > happen by explicitly casting s_maxbytes to an unsigned value for the > > purposes of comparison. > > I think this is unneeded, C garuantees that in this case the signed > value will get promoted to an unsigned value, not the other way round. > After looking at this again, I think you're correct. do_sendfile was actually casting s_maxbytes to a signed value which is why it was broken there. I can drop this patch if the consensus is to do so. I still think however that it doesn't hurt to do explict casts when comparing signed and unsigned values to remove any potential for ambiguity. -- Jeff Layton