Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp234981pxb; Wed, 15 Sep 2021 00:23:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEtnL54vEyIEbcdv6XDfPDhZNEF4QtX3jz4JDm5PM29Hgp9UbBguaH63gwGWXIJ7YNH3uD X-Received: by 2002:ac2:5fa3:: with SMTP id s3mr16218125lfe.605.1631690633251; Wed, 15 Sep 2021 00:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631690633; cv=none; d=google.com; s=arc-20160816; b=Q7ly56ED9SO8OJN4I8YIcqeMV0Lb5UvLz486VsipLkiKnc69j85vfHPEvO063sW7/u efL1erJGJdHSQLhjia3iG3ODSJnaefrC9La7bHcvtr2ERgtWvdFP8bxCSVZF4PbEzZgo nSEiH6FB26LQtVUToF+/RdXHb/uVjxVHyg0lNfo9whaEADPhS/7kggvmZFpo+lGbSEcW nDqFRbmlmDR+SKUKJCnWH3LT1vACj1OTzxRtyjdD/9zpA+HrxaAoGuxtRAnFvdGVKC4K ymLyAsxZ4Ody/7J2jmXxIpvdTghfEQsrOV1WO34BA0FxxHBBtTI+lJHjCH04evyFDY2Q LMxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=k5BtufNStI4L55FA5bc7HU4SsaFQVugap6tARRlagUI=; b=w3vF2LO08Kc5RQjFBUaG7BF7xEjQOiOW+RR4Jeip7mB3d6gefKxUlFrC+idTmEa8wn VI7jJYpZGo0qVrgwKhnAEMm+plWiijtqdShB+fxu6gl7zAWitO0Y2SbtFRErRs10h/fm QkC7GiMlVbN/GW8lbvREzaU8neYmDPD5Jw7jnDbthlh5qfce8mGCH9F6PR7TdLqYmwG/ HpCSyhMpTFnyzpi/FZqczw5t2FDPwol5kVYc29WF7hCk9jBw9HCtRPcajKqEROkdPw5D Ml7WtzmDWuzuY9woGFKLOD+UNTsrElopmNgS8s7XilBn+h8VCjyJr4mpqILiqXy+4xCX 0iJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e19si17930873lji.340.2021.09.15.00.23.02; Wed, 15 Sep 2021 00:23:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236542AbhIOHWp (ORCPT + 99 others); Wed, 15 Sep 2021 03:22:45 -0400 Received: from mga11.intel.com ([192.55.52.93]:45057 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231317AbhIOHWl (ORCPT ); Wed, 15 Sep 2021 03:22:41 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10107"; a="219059800" X-IronPort-AV: E=Sophos;i="5.85,294,1624345200"; d="scan'208";a="219059800" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2021 00:21:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,294,1624345200"; d="scan'208";a="610053032" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 15 Sep 2021 00:21:20 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Wed, 15 Sep 2021 10:21:19 +0300 Date: Wed, 15 Sep 2021 10:21:19 +0300 From: Heikki Krogerus To: Sven Peter Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] usb: typec: tipd: Add an additional overflow check Message-ID: References: <20210914140235.65955-1-sven@svenpeter.dev> <20210914140235.65955-2-sven@svenpeter.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210914140235.65955-2-sven@svenpeter.dev> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 14, 2021 at 04:02:34PM +0200, Sven Peter wrote: > tps6598x_block_read already checks for the maximum length of the read > but tps6598x_block_write does not. Add the symmetric check there as > well. > > Signed-off-by: Sven Peter Reviewed-by: Heikki Krogerus > --- > v1 -> v2: > - removed the WARN_ON to not crash machines running with panic-on-warn > as pointed out by greg k-h > > drivers/usb/typec/tipd/core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index c18ec3785592..8c79ba17a157 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -139,6 +139,9 @@ static int tps6598x_block_write(struct tps6598x *tps, u8 reg, > { > u8 data[TPS_MAX_LEN + 1]; > > + if (len + 1 > sizeof(data)) > + return -EINVAL; > + > if (!tps->i2c_protocol) > return regmap_raw_write(tps->regmap, reg, val, len); > > -- > 2.25.1 thanks, -- heikki