From patchwork Fri Jan 24 09:29:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 233195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45D30C32771 for ; Fri, 24 Jan 2020 09:55:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1133020718 for ; Fri, 24 Jan 2020 09:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579859705; bh=xo47iMd4fSvK6849rhg7FJ/0OLUiD5TP2a9VzGl3glw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QkMMHRxf9i2oaeXNwZJrZBl7ygw4BT+/K9sIb2esos89kkjs+UpX4RfEC/KFkkRrn /b3rWzyLxZ2RFBg1TkIbD9kqXkW6l+0w9cSUnweeoy5Y932gkdy16HwVPbEgas91zH sZq7HITeoL0Weo//Gd8nLig9SDb/3AwxtBkuZXBs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388383AbgAXJzB (ORCPT ); Fri, 24 Jan 2020 04:55:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:58104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733081AbgAXJzA (ORCPT ); Fri, 24 Jan 2020 04:55:00 -0500 Received: from localhost (unknown [145.15.244.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 694C720709; Fri, 24 Jan 2020 09:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579859700; bh=xo47iMd4fSvK6849rhg7FJ/0OLUiD5TP2a9VzGl3glw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CaANKTqbV/8kCCW2CkgsRYdn+FGGp4qk4vHsQq+6ulwIfMonebq754th+VCxxDUUu L1VfC+2v4SdcNHtzfx0UzfQcIVsHCepuEKOeyv+sZDP1hc6/kvZlB4KaQ4X4fOQGvK jjhcmOIzmgaJ4ISBc3S5cGRIEHs6iTjpgBjUIic4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Jukka Rissanen , Alexander Aring , Marcel Holtmann , Sasha Levin Subject: [PATCH 4.14 175/343] 6lowpan: Off by one handling ->nexthdr Date: Fri, 24 Jan 2020 10:29:53 +0100 Message-Id: <20200124092943.039609589@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124092919.490687572@linuxfoundation.org> References: <20200124092919.490687572@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dan Carpenter [ Upstream commit f57c4bbf34439531adccd7d3a4ecc14f409c1399 ] NEXTHDR_MAX is 255. What happens here is that we take a u8 value "hdr->nexthdr" from the network and then look it up in lowpan_nexthdr_nhcs[]. The problem is that if hdr->nexthdr is 0xff then we read one element beyond the end of the array so the array needs to be one element larger. Fixes: 92aa7c65d295 ("6lowpan: add generic nhc layer interface") Signed-off-by: Dan Carpenter Acked-by: Jukka Rissanen Acked-by: Alexander Aring Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/6lowpan/nhc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/6lowpan/nhc.c b/net/6lowpan/nhc.c index 4fa2fdda174d0..9e56fb98f33cf 100644 --- a/net/6lowpan/nhc.c +++ b/net/6lowpan/nhc.c @@ -18,7 +18,7 @@ #include "nhc.h" static struct rb_root rb_root = RB_ROOT; -static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX]; +static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX + 1]; static DEFINE_SPINLOCK(lowpan_nhc_lock); static int lowpan_nhc_insert(struct lowpan_nhc *nhc)