Received: by 10.192.165.148 with SMTP id m20csp3470419imm; Mon, 30 Apr 2018 00:14:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqSYo33aiL+SEvbAQW3mCXpTcI6tYh/OLDXJj2atd62vdlZGyC2tF83lJwcyXg3+fFIzIAT X-Received: by 2002:a17:902:b105:: with SMTP id q5-v6mr11646350plr.173.1525072446858; Mon, 30 Apr 2018 00:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525072446; cv=none; d=google.com; s=arc-20160816; b=COQ92OYjsd2h7u3+gTfXN1XGjboBGe4cAL6uS7eISICBKuWQxDp09DiLeGHNZEqAVA KR38ccWKU5UhIc7LnOErBHkuyoE//K0lmKYiNaJzqi2RDV3baaMJ04iGGvgyX/ZC9lkE EEPRwFPMk65/VomRJp2TS2qJF5wPSpwekIZ4d40hSqs2wsGBWM7kWE+SxkiqJd+NVM/g s7ubqRx+OcOk8gkoy4w4BQjT0qqHEg44N1R6nAmWWUyUJnSX/IpbJ2PtUammjh57vfEN QT5lnlFniBD7WedzmziwRaSBJbIklF6rmPVk/cmw80eCf8nYt4fUcA3DIOQZNB4TnfSV NpLw== 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=p9O8yibkIt/fZPV4WoUcZjlTwk+WDIJxJ1UD6Rml9qw=; b=CiUqF1qi/dcM5Qm7VWZD0EA5ggaGPo6jYV6AfQYs+Y63BbR4nvbk4DHW2EqkXjs8gX AcFJBBNka2ruiglpWw7btbDqcpY+90G7XSobNXkt/pjaRsM9eD5JztgcrwQzl0gjJWiV fDBKilghJnbacyXNVDG5AAnKlrUXRZ3vqlEkNDBk8lsVn91PEn6WtJUtiCveEeHVl0mo s4dI6VPFiZ4WvuSbtKFoy95SKCT88hxDTXXzzOox4JvEyZ2s5WWYbEa4uASn0kjaZKoh MPA1gQc3hhdmlxLbunMKYAp6SMA4s2rxHxbatBkGSVd7J+XZDljTP0BbUj4lCmdEB8pS qd2g== 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 g11-v6si5876519pgn.368.2018.04.30.00.13.52; Mon, 30 Apr 2018 00:14:06 -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 S1752134AbeD3HNQ (ORCPT + 99 others); Mon, 30 Apr 2018 03:13:16 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:60569 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751698AbeD3HNP (ORCPT ); Mon, 30 Apr 2018 03:13:15 -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 1fD2zo-0007m3-7t; Mon, 30 Apr 2018 09:13:12 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1fD2zm-0002kI-Ll; Mon, 30 Apr 2018 09:13:10 +0200 Date: Mon, 30 Apr 2018 09:13:10 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Wolfram Sang Cc: Alexander Popov , 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: <20180430071310.7s7glgig3cilw4dj@pengutronix.de> References: <1524140962-25639-1-git-send-email-alex.popov@linux.com> <20180427120658.wi32f7margtfazzp@ninjato> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180427120658.wi32f7margtfazzp@ninjato> 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 On Fri, Apr 27, 2018 at 02:06:58PM +0200, Wolfram Sang wrote: > On Thu, Apr 19, 2018 at 03:29:22PM +0300, Alexander Popov wrote: > > i2cdev_ioctl_rdwr() allocates i2c_msg.buf using memdup_user(), which > > returns ZERO_SIZE_PTR if i2c_msg.len is zero. > > > > Currently i2cdev_ioctl_rdwr() always dereferences the buf pointer in case > > of I2C_M_RD | I2C_M_RECV_LEN transfer. That causes a kernel oops in > > case of zero len. > > > > Let's check the len against zero before dereferencing buf pointer. > > > > This issue was triggered by syzkaller. > > > > Signed-off-by: Alexander Popov > > Applied to for-current with the arithmetic expression changed to '< 1' > to keep in sync with the previous one. Will push out soon, so you can > double check if you are interested. Thanks, I like it. An added bonus is also that you don't need to think about the type of msgs[i].len and what happens if it is negative. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |