From mboxrd@z Thu Jan 1 00:00:00 1970 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, 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 E0CD7C2B9F7 for ; Wed, 12 May 2021 19:49:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB34F613EB for ; Wed, 12 May 2021 19:49:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382838AbhELTsH (ORCPT ); Wed, 12 May 2021 15:48:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:51956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352682AbhELSEA (ORCPT ); Wed, 12 May 2021 14:04:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DF78661412; Wed, 12 May 2021 18:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620842571; bh=NIA5fAMjpk1RwpqY4MlElviJvCZGHJESiiCEeAkUWAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DyLCzuT+/SmXTq/fS+kf4QBbGhz+kNABT43GyOSPfvFrsjM1nSBAl4wCxbTovpj1D RNyawaxo5sTSTgj5vBr/VdLWshrx+LyYwjpgvjmF/4aqc4Feu9B/kioCO0iNUHinzE pMp45+GepyEst7HwHswkHvxHOau94IQc+ki8108LZNHd7N6JtAlZQSo4zuhIhDdOQS lHsFFnssAhGfDgRcbvsWCRuI4UjtThmhP5xhaVT1vnwquXdyAiMIjKAnbcw2j6cTtu 42rBTL8PIWLOwudxnQC7AOvwusXGLs359J6XhAR8Pm+OzWSUKIA6m0L8a1LleEPULx cLbUbCoiz8HKw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Phillip Potter , syzbot+e267bed19bfc5478fb33@syzkaller.appspotmail.com, "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.11 27/35] net: hsr: check skb can contain struct hsr_ethhdr in fill_frame_info Date: Wed, 12 May 2021 14:01:57 -0400 Message-Id: <20210512180206.664536-27-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210512180206.664536-1-sashal@kernel.org> References: <20210512180206.664536-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Phillip Potter [ Upstream commit 2e9f60932a2c19e8a11b4a69d419f107024b05a0 ] Check at start of fill_frame_info that the MAC header in the supplied skb is large enough to fit a struct hsr_ethhdr, as otherwise this is not a valid HSR frame. If it is too small, return an error which will then cause the callers to clean up the skb. Fixes a KMSAN-found uninit-value bug reported by syzbot at: https://syzkaller.appspot.com/bug?id=f7e9b601f1414f814f7602a82b6619a8d80bce3f Reported-by: syzbot+e267bed19bfc5478fb33@syzkaller.appspotmail.com Signed-off-by: Phillip Potter Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/hsr/hsr_forward.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c index b4e06ae08834..90c72e4c0a8f 100644 --- a/net/hsr/hsr_forward.c +++ b/net/hsr/hsr_forward.c @@ -493,6 +493,10 @@ static int fill_frame_info(struct hsr_frame_info *frame, struct ethhdr *ethhdr; __be16 proto; + /* Check if skb contains hsr_ethhdr */ + if (skb->mac_len < sizeof(struct hsr_ethhdr)) + return -EINVAL; + memset(frame, 0, sizeof(*frame)); frame->is_supervision = is_supervision_frame(port->hsr, skb); frame->node_src = hsr_get_node(port, &hsr->node_db, skb, -- 2.30.2