Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754459AbbBBPoD (ORCPT ); Mon, 2 Feb 2015 10:44:03 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:56550 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754086AbbBBPoB (ORCPT ); Mon, 2 Feb 2015 10:44:01 -0500 Date: Mon, 2 Feb 2015 07:44:00 -0800 From: Greg Kroah-Hartman To: Dan Carpenter Cc: green@linuxhacker.ru, devel@driverdev.osuosl.org, Dmitry Eremin , Andreas Dilger , Linux Kernel Mailing List , Oleg Drokin Subject: Re: [PATCH 06/20] staging/lustre: fix comparison between signed and unsigned Message-ID: <20150202154400.GB18209@kroah.com> References: <1422845539-26742-1-git-send-email-green@linuxhacker.ru> <1422845539-26742-7-git-send-email-green@linuxhacker.ru> <20150202130231.GA5451@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150202130231.GA5451@mwanda> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1079 Lines: 31 On Mon, Feb 02, 2015 at 04:02:31PM +0300, Dan Carpenter wrote: > On Sun, Feb 01, 2015 at 09:52:05PM -0500, green@linuxhacker.ru wrote: > > From: Dmitry Eremin > > > > Expression if (size != (ssize_t)size) is always false. > > Therefore no bounds check errors detected. > > The original code actually worked as designed. The integer overflow > could only happen on 32 bit systems and the test only was true for 32 > bit systems. > > > - if (size != (ssize_t)size) > > + if (size > ~((size_t)0)>>1) > > return -1; > > The problem is that the code was unclear. I think the new code is even > more complicated to look at. I agree, I don't even understand what the new code is doing. What is this code supposed to be protecting from? And -1? That should never be a return value... thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/