Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp706319pxb; Tue, 14 Sep 2021 07:05:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwm/o/O0DmWZS5U5c0sJ0QNcnOT55Zde9524I+18KZUiQ+dy4va3XwGyO2/85dc1l+xYxU8 X-Received: by 2002:a2e:7303:: with SMTP id o3mr15070757ljc.273.1631628334560; Tue, 14 Sep 2021 07:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631628334; cv=none; d=google.com; s=arc-20160816; b=AxBMyrCY+8MjTFmKMa9dcwC+OddNdntoeYVCCvov6TrMV+ReWI/bzM2fUpsVEoOW0I hi0drSXTt3qVai3SvSW2rq9LR3A1itnmEclwF/yjNGme33XHVUyfJroSMzPT5BGsRuj1 XdwtsqnsLIezqXorPIfOHxzrecYOwv42Q/GKnRWLHI9iBNu/dy3JUxX4cpvw4s0hu408 Q0owjbNoRLtCaLpTqiSZDA5oSX3lenic3YslZ53cmfJaWDZ2A1BSbZdsJaSTrjcd8Wv3 qPozvBlJP0DWFPy66anu3AIqZkognNNpYx6nCaJzwQ0gOmYZrTIr+DiJ/5Doo1iE3Eo2 Ea8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=wLpknvgdOyW6A0yW8l9BGg3ldSZFzQqA07ke3tiZCkY=; b=WCsnY1u+bXgYXNvNcGUY7fC5YhjqsqRLB2b3LsNpavYbXBZRaUEbXJyzMOL/cfMD9e 4QNwJ3JImSWy8K9pXFW7IYtsQv3ikDWOVjdXMjbvONSjjpLRKqIPXhIf5jUlcKF1Gmyv sfkmOy4KDXLCW6aF33eV3ERRooDt2lPJQM1ubuoQqePHL4+rLuQR4a0+n0j0mgAxoiG0 PPqRy/OS4DJILCSyWOHKWfHVD2opyJds2tegKAsFi5tKwqpb4cf2bUxfjvC3MUg0MHJt /w2yrYI8Pc2ZhVt1cEVSeNu7/82+UsYR41N5vgot8eaA04FnzFkbAS/9fByBoLq19HBK bDMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm2 header.b="G/G6AZlq"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=ekyFh0hd; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m5si18254052lfc.568.2021.09.14.07.05.03; Tue, 14 Sep 2021 07:05:34 -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; dkim=pass header.i=@svenpeter.dev header.s=fm2 header.b="G/G6AZlq"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=ekyFh0hd; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233597AbhINOEG (ORCPT + 99 others); Tue, 14 Sep 2021 10:04:06 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:51613 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233550AbhINOEE (ORCPT ); Tue, 14 Sep 2021 10:04:04 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 41C3B5C01C0; Tue, 14 Sep 2021 10:02:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 14 Sep 2021 10:02:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=wLpknvgdOyW6A 0yW8l9BGg3ldSZFzQqA07ke3tiZCkY=; b=G/G6AZlq7M6KNE68rloL5gKhhboOu 15yU7TxQchD7JBBLMmkYJVBzkvvpOGZkSs7RUBsQy+DBOWLExqZGrZ3V/Aw2T4iL bVAEzpCIchVEXU2sOitsH1vSLXroRExvPYGhEoHI+k60YEf3RIWynNVbpD4aGtf/ zB6Z3PQR5ISyLlBnPGuqOS+G1hiagb0dVPQ6x9+7H5EAja/L8Nzwb/qo5CM8CXuq R1cJ6jGZ/dlHuY4dcevesgrD1ivAjo9+iJmK+H29boKxKDZqefbQVG3bIYrmSBmA UAH0/Vnn4yGosVODNW5Bl4Ds0Y3WxCFCm+xqHKtE08NhyhaipbZoc31Gg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=wLpknvgdOyW6A0yW8l9BGg3ldSZFzQqA07ke3tiZCkY=; b=ekyFh0hd 5e1n/msTTWiP8z40ZRMbnS4SPqks+VA+ulQwhkV3KWe+OT574n0KrhMsTaR6y0sh 3ocrujen29xhCz2YHpipjC2Kuci0gsbyooeVIWo9i0gLmuubEczo01OgKKV3FfSc zuGHk3u8JxcmWO/UFFPbdzughDKm3obWVlD95AHL8KydEXeOmHUjJ5Vw55yLwDba g0F9o0hDW8R1hoOF86UzuZWKd9Kzg7DMfkTebK9GRupVgcjwyx4w5d0CuC75SYlZ K6vvVPpkmCHrsXXuuuH0Ir/HHcGM8lFPu9HO3JIKev3QQY8Cs82O+lkALrpI1KLf sC+JnpG9+e2I7Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudegledgjedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 14 Sep 2021 10:02:45 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Sven Peter Subject: [PATCH v2 2/3] usb: typec: tipd: Add an additional overflow check Date: Tue, 14 Sep 2021 16:02:34 +0200 Message-Id: <20210914140235.65955-2-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210914140235.65955-1-sven@svenpeter.dev> References: <20210914140235.65955-1-sven@svenpeter.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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