Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp217830pxj; Thu, 20 May 2021 07:55:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyN2ghVKHvk+MMBp/+k/1i1y/IF2rT0MbNxmtPZYMZDjRKHJlDBtM3BdbeOpe1uwt2mHCf X-Received: by 2002:aa7:ca4d:: with SMTP id j13mr5376477edt.158.1621522518942; Thu, 20 May 2021 07:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621522518; cv=none; d=google.com; s=arc-20160816; b=Tq4ke2MZrHUBJr1I+meRNmBN0/Zv4CAN+vWmos2Ojb+oBGUcmdxAaubg8QHgsWo7zQ zrBODxIcP2gMFEuJjCLgC3zLBT/KVrRuF3lIxBI+YMuhi7g7c7VBvPtbGVbSh6mOMrAy +cYDN+FB3tsMSJcH6LSlGCgukbaZZvt8RBx9i8p6VYCawglnKjs5A+DzL1jTwvsOzAJg lRSMrxkgjIOUgPL8bpy9t0BqCeC570BM6kDCyLKML0MbYNcwCEhF3FyHd7Yy9hLNwsSz nlEKbN1pAdPLgM6zMq/PL8tds/V97SiKNziITsoKKU89gigRKbEUEqwiAUx3q5nUtGtM LiBw== 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=AyIBcT/1fP8R3hwPB9h8rvFvkDYL0QUeJfGIWG2k4ok=; b=DNUVBPbDK2Y4hw9gxP5I22apvVxzlcM6oFPleiWn8Dpp9be+XMDdOExftIjZ+ARl+M YqbaR3/tNlyvO37TtICSiH9bk7Q8Y2za/yDESCq7vtGlrRquN1Y45a7s5XHWTCjDeQlR 9UTxP3ffygGUdKKdBNFUOW3bJH14vE8tvg+DljXGfXLFXJlIA7rqvPXZD9V/UC2PbDPT xuxqAbV2JLfQzwSEPnVYE2f1XoWwkWJpZeSq3p/QoDSpWyR4v1ldudfDxX8ud/sSLtP9 hZznvsjWW0Zc1pgbG8rVgR8H8G843xMYBQaowAVYunFfy0ORfFAWRHlYrveK5YTyevny p5hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ds6pKKJV; 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 f16si2696805edy.298.2021.05.20.07.54.55; Thu, 20 May 2021 07:55:18 -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=ds6pKKJV; 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 S231732AbhETJ1n (ORCPT + 99 others); Thu, 20 May 2021 05:27:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:52996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231435AbhETJ0y (ORCPT ); Thu, 20 May 2021 05:26:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 056F861355; Thu, 20 May 2021 09:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621502733; bh=0CI2ZwNSZ4KkGK4JR7dWcrMIe/AmclU8g10YbHCsFBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ds6pKKJVf3OQTRQ3IYPA+vT8SCmN7nXclT0Ow4i2GSiOw52GVn3e6iaFC1LPEmM6y yeV5kYhLWzxmF42craIC8Nz1q8mN0JrPCH315FcCGoxswnEQtex4JKOOrwBcCccXhW yywd/AiRS1YkEYPjyPrwc/RIFXZUPvfiuxf8sna0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+e267bed19bfc5478fb33@syzkaller.appspotmail.com, Phillip Potter , "David S. Miller" , Sasha Levin Subject: [PATCH 5.12 33/45] net: hsr: check skb can contain struct hsr_ethhdr in fill_frame_info Date: Thu, 20 May 2021 11:22:21 +0200 Message-Id: <20210520092054.596219345@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092053.516042993@linuxfoundation.org> References: <20210520092053.516042993@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: 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 b218e4594009..6852e9bccf5b 100644 --- a/net/hsr/hsr_forward.c +++ b/net/hsr/hsr_forward.c @@ -520,6 +520,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