From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933455AbbBBNEF (ORCPT ); Mon, 2 Feb 2015 08:04:05 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:22372 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932197AbbBBNDR (ORCPT ); Mon, 2 Feb 2015 08:03:17 -0500 Date: Mon, 2 Feb 2015 16:02:31 +0300 From: Dan Carpenter To: green@linuxhacker.ru Cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger , Oleg Drokin , Dmitry Eremin , Linux Kernel Mailing List Subject: Re: [PATCH 06/20] staging/lustre: fix comparison between signed and unsigned Message-ID: <20150202130231.GA5451@mwanda> References: <1422845539-26742-1-git-send-email-green@linuxhacker.ru> <1422845539-26742-7-git-send-email-green@linuxhacker.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1422845539-26742-7-git-send-email-green@linuxhacker.ru> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. regards, dan carpenter