From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756584AbcARUO5 (ORCPT ); Mon, 18 Jan 2016 15:14:57 -0500 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:48512 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755979AbcARUOw (ORCPT ); Mon, 18 Jan 2016 15:14:52 -0500 Message-ID: <1453148090.2363.13.camel@HansenPartnership.com> Subject: Re: [PATCH] scsi: fix potential integer signedness problem From: James Bottomley To: Insu Yun , martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: taesoo@gatech.edu, yeongjin.jang@gatech.edu, insu@gatech.edu, changwoo@gatech.edu Date: Mon, 18 Jan 2016 12:14:50 -0800 In-Reply-To: <1453146909-28314-1-git-send-email-wuninsu@gmail.com> References: <1453146909-28314-1-git-send-email-wuninsu@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2016-01-18 at 14:55 -0500, Insu Yun wrote: > Since len is signed integer variable, it is better to check > whether len is non-negative or not. > If non-negative value len gives, it can cause heap overflow. Hey, this patch is full of a ton of undocumented (and mostly spurious) whitespace changes, which make it very hard to see the actual patch > Signed-off-by: Insu Yun > --- > drivers/scsi/scsi_lib.c | 33 ++++++++++++++++++--------------- > 1 file changed, 18 insertions(+), 15 deletions(-) [...] Which is this, I think: > @@ -2349,6 +2349,9 @@ scsi_mode_select(struct scsi_device *sdev, int > pf, int sp, int modepage, > unsigned char *real_buffer; > int ret; > > + if (len < 0) > + return -EINVAL; > + > memset(cmd, 0, sizeof(cmd)); > cmd[1] = (pf ? 0x10 : 0) | (sp ? 0x01 : 0); What's the actual problem here? There's only one user of scsi_mode_select: an internal one which always sends in a positive length, so this check is entirely unnecessary. James