Received: by 10.192.165.156 with SMTP id m28csp914453imm; Wed, 18 Apr 2018 00:08:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/l8defC1W4Ofe0MiYHxaUDs3MZ9YmGtHzeXNQwtI0pS8eb097mF3V9EIkSxyfKi2I++0sM X-Received: by 10.99.7.86 with SMTP id 83mr833876pgh.211.1524035312175; Wed, 18 Apr 2018 00:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524035312; cv=none; d=google.com; s=arc-20160816; b=s5ub+pvOCNQWWpF1wKMriVqyYBGoonodzEvsZ8lpQ3Ib0fRD3xN5gsAR0xMXZNoM+S 1ROQlK+vL/XRmMTP+MHR3942EeVT3HMRZLkjutbzw+jp45XvgKnqap0BrdjYDkWPGzcT hsdadRou2FsSt4P78FTuaNUk1J5A3EoPAF4BNnV/W9EldEGIRbvIRwBYhRdYFKD/F3l2 OmjyoLe0+L7TwgckGvOHYkLi+UUXTjdgKCFoz34DSb9bUt+BOR9SYT7uEI6zUz7HWLzt BTXCI7mQwQuSK3Q5zicxpdv1EDJyUiENIPR8+1bnelwBh24OHTiEP+7UudW6hQK7IYsv Q9Uw== 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=F2lxAeZoNIyQjaD2Rl7MT2hDZzincM0walfM+zwExWM=; b=zfsi4LXzbKO0edDzkIo30DhOztoeAxgCRe+CvxN0/nijg6I+g8OgD2OUC16BitE43x YmAQ9Wi7kq9I5O0Q0XI0sQ+gtOHazqcr3O5YV+1hX2ZwfF2sokoCiM1sTKElo9n6k8CM R6Q8wZ1slkNDJoDRfBPrFg6e8qoCKoadLPntiKYN78s226jdZZT1HAeE8AAKMMMWiklH 4hdJ0pApm7nXJ79hC1FvVlXfOn7k1tVeqAUVnYmka58SH6tNFzDZ1Vw/bGE8uaTE3Aow 0+lx1YLyAbq33d4HuvmY0yeSODsDfMBm7dh1oKwLlqRGQWXS7KMMlh/tht+EGW1WK1mY pDkA== 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 l192si564957pge.365.2018.04.18.00.08.17; Wed, 18 Apr 2018 00:08:32 -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 S1752806AbeDRHHL (ORCPT + 99 others); Wed, 18 Apr 2018 03:07:11 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:36519 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752022AbeDRHHJ (ORCPT ); Wed, 18 Apr 2018 03:07:09 -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 1f8hBJ-0001Nd-NK; Wed, 18 Apr 2018 09:07:05 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1f8hBI-00055L-Ml; Wed, 18 Apr 2018 09:07:04 +0200 Date: Wed, 18 Apr 2018 09:07:04 +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 Subject: Re: [PATCH 1/1] i2c: dev: check i2c_msg len before memdup_user() to prevent ZERO_SIZE_PTR deref Message-ID: <20180418070704.35zj5chpdkirnmdt@pengutronix.de> References: <1524010605-21552-1-git-send-email-alex.popov@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1524010605-21552-1-git-send-email-alex.popov@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 Wed, Apr 18, 2018 at 03:16:45AM +0300, Alexander Popov wrote: > Currently i2cdev_ioctl_rdwr() doesn't check i2c_msg len against zero > before calling memdup_user(). If this len is zero memdup_user() returns > ZERO_SIZE_PTR, which is later considered as valid since > IS_ERR(ZERO_SIZE_PTR) is false. That causes ZERO_SIZE_PTR deref oops. You're saying that memdup_user(ptr, 0) reads from *ptr? I'd say this is a bug in memdup_user, not its user. If however the problem only happens later in if (msgs[i].flags & I2C_M_RECV_LEN) { if (!(msgs[i].flags & I2C_M_RD) || msgs[i].buf[0] < 1 || ...) Your commit log is wrong (and I think the patch, too). Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |