Received: by 10.192.165.148 with SMTP id m20csp328006imm; Thu, 19 Apr 2018 23:00:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx48wyzsrzWjtq6XLNKWm0MG+57/3bsVPHWrr6USlR4mSdtyPJsgHkM9+EQju7XdgGv/nlHd+ X-Received: by 2002:a17:902:6b03:: with SMTP id o3-v6mr8773760plk.213.1524204040349; Thu, 19 Apr 2018 23:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524204040; cv=none; d=google.com; s=arc-20160816; b=dqdXqWqzL1zDM5ZqsW60lVnWETDmoNBg7KoAkqb9Os7ZYukBo2KAWVptWPfMcroZ5S nTqPu/swXm4YfRplVDbtrYsukxPTjjh4DsZcaOGr2JbjlsBWWgeqKfgIyDp2dsrWV1+d gc6fnk0MxjqsGgBPJEugRjfXyzutJCNLKh6lxtowsHQX2l1Mz19ZgHlQWZR12l23su5H cIGgziNWfi/Ob9D7cemoH+erQxivLIfEGYYVRnH9tJ9pbKp96kqWCu8i5uuvQT2glN2X arFn0T0CedBvrCTLaXrpe99HEHueTFkIdmJeQVoRfXMG5rfSyqF6MuAf8CIVnBM3UPkK 5CCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=PpIGwfAQEKav6ZyF0pPiKUMmXc2JiXcHnx7eQuh+GwQ=; b=tcUrswXNfGERb0EAb9VahAwYBto/BroEYBbPAeibVB/Hq1cJiEAflgLHNl9iDKF7pN TTzovM11JMyHraJLKJ2obEe591399dxP+zx695JIop8UUgVDwWlrCgXU+uPgqrTOl74Y GrjQ13myNnA4xLBXUrpzZrZ86pqbcaRSeB2SAgw5XV4SEqy82XJGFH8AnOzjSumqbEYZ hmqRutP6swkllSQKItckCCG1J487/ajbmaopJr8H+mixCF7pYwUHtKEjJA21w3T16hfl JAk8aec4uApGu24Iv9JF7d2+D69c/r1qMaQzEPSfHugQfQUb7sOzh4tS+Tbj7Ib4xXn9 5Uxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t2-v6si4923576plo.235.2018.04.19.23.00.15; Thu, 19 Apr 2018 23:00:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753475AbeDTF61 (ORCPT + 99 others); Fri, 20 Apr 2018 01:58:27 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:34127 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751258AbeDTF60 (ORCPT ); Fri, 20 Apr 2018 01:58:26 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1f9P3v-0000zf-HL; Fri, 20 Apr 2018 07:58:23 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1f9P3u-0007cX-L1; Fri, 20 Apr 2018 07:58:22 +0200 Date: Fri, 20 Apr 2018 07:58:22 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Alexander Popov Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, sil2review@lists.osadl.org, Dmitry Vyukov , syzkaller@googlegroups.com Subject: Re: [v2 1/1] i2c: dev: prevent ZERO_SIZE_PTR deref in i2cdev_ioctl_rdwr() Message-ID: <20180420055822.qjs2hpkik5dr2fnp@pengutronix.de> References: <1524140962-25639-1-git-send-email-alex.popov@linux.com> <20180419134902.6l5jsf4wpqfiaskj@pengutronix.de> <22fe9bbe-f1d7-3a92-9528-df66c34816a5@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <22fe9bbe-f1d7-3a92-9528-df66c34816a5@linux.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Thu, Apr 19, 2018 at 08:01:46PM +0300, Alexander Popov wrote: > On 19.04.2018 16:49, Uwe Kleine-K?nig wrote: > >> @@ -280,6 +280,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client, > >> */ > >> if (msgs[i].flags & I2C_M_RECV_LEN) { > >> if (!(msgs[i].flags & I2C_M_RD) || > >> + !msgs[i].len || > > > > I'd prefer > > > > msgs[i].len > 0 > > Excuse me, it will be wrong. We stop if len is 0 to avoid the following > ZERO_SIZE_PTR dereference. right you are. I missed the negation. > > here instead of > > > > !msgs[i].len > > I can change it to "msgs[i].len == 0". But is it really important? > > I've carefully tested the current version with the original repro. It works correct. I don't doubt it, and the code generated is maybe even the same. The point I wanted to make is that !len is harder to read for a human than len < 1 (or another suitable arithmetic expression). But feel free to disagree and keep the code as is. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |