Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1825321pxb; Mon, 13 Sep 2021 06:24:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLH2Faf8lPJc/UVjw/O8YcqE+0Q4KN+FFDKgjQQjM94WhbX83jJ9wKQmW2AHaJIxRru8DM X-Received: by 2002:a05:6602:2cc5:: with SMTP id j5mr9025642iow.156.1631539466888; Mon, 13 Sep 2021 06:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631539466; cv=none; d=google.com; s=arc-20160816; b=vggfK5EBJJzrd3nBtsdxkISslYj1dM0SMxN+sJynpmmsBsLesuGUKE0I2mTn3S4BpW CdLvgViM3wh2Vt7hxKJlctX/5oX4w3du2sX615xy1Qu8Dt1TaHrjYjTvTcAL1webpxfF q97bT9b5lqSDNYiqaKceArLwPwV3npDWNAZW5AkAryZiQigBqC4TUNAHe6NvM9EK4GSa Y4xLH7lXjM50APFQzSaZ9XlVzE/HCOZpDM3+Y1tHG6T8ye+y50mPXHFD+uI0vDyrdNEQ Ri12Iju13EbIvVlxz87xIyFl17rY6GJlLWycqgcMj+986aK3vMaWsq2L/daR5Mt2vXAS 7IRg== 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=UIG/I/cxDYwP1SWfAayhts3qcBMn09O+LybFLyew63fwRyAl7pzzz/2GifB5DlCjae DnP3xdJEMCTu1qquYQHQJ6woFZDn0fNZOuxLbG6KHORABTINqR5vYECDGRAa4a9PjWsB XW59GOJwtqZShCPEk7LTLGJvSATlnkVkSymsSu7medfFuV6HWVGfAB7eH09Noff3U95+ g9dUey8gW6TXq4N+NsW7v5YOpZ42vdNv0U++hrtAZfi7qCWYXAXFkpXDCyzt0ztDaZDr Ymngtm2I7mfTkDf0carFY7OTDrQ/Is1uoJ4pdkCdXNrCVxmSPpkNeNZ3Fm8hmuh5XP4D FHVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Mp/7CWpz"; 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 p6si6234619ilj.154.2021.09.13.06.24.14; Mon, 13 Sep 2021 06:24:26 -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="Mp/7CWpz"; 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 S241445AbhIMNYO (ORCPT + 99 others); Mon, 13 Sep 2021 09:24:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:38100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240884AbhIMNVv (ORCPT ); Mon, 13 Sep 2021 09:21:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4377F61106; Mon, 13 Sep 2021 13:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539235; bh=JkzJl0hAJVRhrvvxcHei82EQ0T772Vh7JhSWg3QvjQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mp/7CWpzUmWGCqBWsUL6rmqCKDeeSRMKDWvIVDoSJiec55LGqKErqp1xHrwQnNHMY tA7FbrPdNw1OW7uc60JpAEMNmYhEuKWLJf61vVYyrbf3CBdXqCWWL2WXO0BOO6uJfP JjDknLfc1PBeWBBHVxWmflr+YX76bfJOifrcuUcA= 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.4 061/144] 6lowpan: iphc: Fix an off-by-one check of array index Date: Mon, 13 Sep 2021 15:14:02 +0200 Message-Id: <20210913131050.011719736@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@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