Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp66283pxb; Mon, 13 Sep 2021 13:06:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQ2tsEokoqlpdnRL9YdT7YtBSmH7BUfl5iLGb9+dRRLq9spXxyTRakMSKT2O86jKt19lqj X-Received: by 2002:a17:906:6148:: with SMTP id p8mr14336249ejl.17.1631563573461; Mon, 13 Sep 2021 13:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631563573; cv=none; d=google.com; s=arc-20160816; b=plVEQI3TyCH6W+zqMG+WXQ4oB4158l2Ne/bWeFtcE7A00tuQA8W7iaVx+qbaDDIYH3 11hpQ+r4KTD7AH0IBpHswaGV7EkxTpuQJ2ZQirgQzKAEUulgguvTLZacAI6pXRf2oo72 pKTOqptJ+EyMW2TIjga+dBAXkHziu5TaoEVJAUVjWi9oNp9SwWWnFxdNmiyQoAhaUEBY Aw7+PR+JOdfvzgWCxZ0ZAAGT7awB/drkTx0B+Hb8L+zWl4/uVGzIUexmgjMydZ+T6sO3 81dJgjs0paSIQLOjXgcDm6Xrq7E3dCOnpDbqxwi1f/NtCW3fgqCfd4POG1QkDV+cO90C bDhQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NQPGG3oiVIH8Yb8FsNgQrRh/axoRdHnG+uQhUjpve7E=; b=aHBTgFK9WSREiutl1J0WuKpgMJRGIbeBRMzB9IpHN/8J/0iorlHqeK6M2qZdH3r8Q8 0KBmUbPm00ryJMGX3lolxsAwKh9/jkaqKS/9zddtm/hUfUGkExgdxXR3gl0GCWfH/66h 97+su6NYQVMKVpBGsdexCL4pT8QRFvwDBKntJoYSEqFfpfJE5ArzESP3ycRlQ3CEnVqF TlMLJxSf7D9kOLssgTUPX2SFqNDWB+WuY1p7/z9xV0DhsK09Z580NdCmtsw97dfdvTfj Bz68Xb7okS1rzNK1CQ+qZC18sIG1TwIoEO/G9R9FviXjE2oY4BjIEFP4uTLSn5hgmT81 6k/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0o2Jr2fo; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si8142401ejc.333.2021.09.13.13.05.43; Mon, 13 Sep 2021 13:06:13 -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=@linuxfoundation.org header.s=korg header.b=0o2Jr2fo; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243487AbhIMNoY (ORCPT + 99 others); Mon, 13 Sep 2021 09:44:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:41184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242639AbhIMNip (ORCPT ); Mon, 13 Sep 2021 09:38:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4CD4661264; Mon, 13 Sep 2021 13:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539718; bh=JkzJl0hAJVRhrvvxcHei82EQ0T772Vh7JhSWg3QvjQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0o2Jr2fo6QYHHYUmyL3dgesO2uSxF51jyAsVBtnBuAUUzk0QjIqm06KUOAUdJqjwc 2OHZGUCBHzC8thaJvz6rpsnr3d33iI224QnxCDv2A3UatbZIcNlExuntt4csmR0EZ0 cMgy0tmgRm3zpAf1FMY0UEvyQM22XwdggUxnKnRw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.10 101/236] 6lowpan: iphc: Fix an off-by-one check of array index Date: Mon, 13 Sep 2021 15:13:26 +0200 Message-Id: <20210913131103.785011238@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 9af417610b6142e826fd1ee8ba7ff3e9a2133a5a ] The bounds check of id is off-by-one and the comparison should be >= rather >. Currently the WARN_ON_ONCE check does not stop the out of range indexing of &ldev->ctx.table[id] so also add a return path if the bounds are out of range. Addresses-Coverity: ("Illegal address computation"). Fixes: 5609c185f24d ("6lowpan: iphc: add support for stateful compression") Signed-off-by: Colin Ian King Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/6lowpan/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/6lowpan/debugfs.c b/net/6lowpan/debugfs.c index 1c140af06d52..600b9563bfc5 100644 --- a/net/6lowpan/debugfs.c +++ b/net/6lowpan/debugfs.c @@ -170,7 +170,8 @@ static void lowpan_dev_debugfs_ctx_init(struct net_device *dev, struct dentry *root; char buf[32]; - WARN_ON_ONCE(id > LOWPAN_IPHC_CTX_TABLE_SIZE); + if (WARN_ON_ONCE(id >= LOWPAN_IPHC_CTX_TABLE_SIZE)) + return; sprintf(buf, "%d", id); -- 2.30.2