From patchwork Tue Jan 28 14:04:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 232480 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 99F7AC2D0DB for ; Tue, 28 Jan 2020 14:43:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6804024686 for ; Tue, 28 Jan 2020 14:43:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580222595; bh=Xw9YztzTE2/FOpzeBm47CYzucRq34DUyKjvMFYOZgkY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ugJPjv+mkpFDmmpmXK3QnJFeYf6YVnerHOqLDEjymaPFltEGYwmCCd9IdWrAvIJh8 XRvlAqklqt2hXaZxdeLHFbfiuUMiPY/Ynls4nbkBSvlTnXJf4QVXfmBSromm+Q6SZi zVf5/nZflnbY12eFPvEbu6a9Gcj/bA8NhpUZGYq4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727628AbgA1OLz (ORCPT ); Tue, 28 Jan 2020 09:11:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:32916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726986AbgA1OLy (ORCPT ); Tue, 28 Jan 2020 09:11:54 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 9CE4120678; Tue, 28 Jan 2020 14:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220714; bh=Xw9YztzTE2/FOpzeBm47CYzucRq34DUyKjvMFYOZgkY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WUcxpjkiZKN73/ukEsR/9BoAmMyiBaxxsmdMLzIEp1gapqE67ExeXL8A+zBHm5PPx 0ZTxl7VR3vJcLZHWOsPkllM2iZQvKd4isTquIZzit5X/HQHQ8ffSRiDamaDiICmKam v9VA7bmVkOVt0DG0A1FGp/9yDdzi6Or/pWmUW95U= 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.4 080/183] 6lowpan: Off by one handling ->nexthdr Date: Tue, 28 Jan 2020 15:04:59 +0100 Message-Id: <20200128135837.913039714@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135829.486060649@linuxfoundation.org> References: <20200128135829.486060649@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 7008d53e455c5..e61679bf09085 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)