From patchwork Fri Jan 24 09:28:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 232825 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 D9E0DC32771 for ; Fri, 24 Jan 2020 11:41:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A331920678 for ; Fri, 24 Jan 2020 11:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579866106; bh=xo47iMd4fSvK6849rhg7FJ/0OLUiD5TP2a9VzGl3glw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0g2Kw+Grf7x2D5iJwqp1URE7APgwg0wnkDr7fmK64Q6csk5UkX7U3ucNXBZk9Dtse OUUR0wLpgCVfN5vtwRYGWz9hQt7Af/oOcwiYFZE56aEUQuMGbCAbVZ439ysC6zXQRu klwpDCzQWM+Q4Ml26as7YXYowkxD4LSMzny8zQTw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390487AbgAXLRV (ORCPT ); Fri, 24 Jan 2020 06:17:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:54186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389371AbgAXLRR (ORCPT ); Fri, 24 Jan 2020 06:17:17 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (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 89E712087E; Fri, 24 Jan 2020 11:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864637; bh=xo47iMd4fSvK6849rhg7FJ/0OLUiD5TP2a9VzGl3glw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S0ViAeGJb+f4MKi0GQ+6/gl7vFs7wxrq1nZREmxABcPcGezmfcns40ynvlLZ6fXfJ juoV22FIZNvi2JOOXPFwBcL3pkSWBJAkmF3WJBnq8cNAhNrdZiIIYYWUPdFsY8dSUC d4begl5jDAQhR6su532LbNcc6o/hi4q58vFo96xg= 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.19 322/639] 6lowpan: Off by one handling ->nexthdr Date: Fri, 24 Jan 2020 10:28:12 +0100 Message-Id: <20200124093127.379892553@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@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)