Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2024786rwe; Fri, 2 Sep 2022 07:30:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR492FNknxjG+PlhBp/deFvHtgEbYkWjaS739yXxI0eQt+2SQrH27tl430BzV7lNdaqL5V3+ X-Received: by 2002:a17:906:3197:b0:73d:5e1a:44ac with SMTP id 23-20020a170906319700b0073d5e1a44acmr27054846ejy.512.1662129032702; Fri, 02 Sep 2022 07:30:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662129032; cv=none; d=google.com; s=arc-20160816; b=U4iKuQ5ll09uKEGTmT1mp2AqF7Qm38jTTYaHZNDL/ZOaokuGblrKOP1fgEFnnj6HyR Mj23LyPqNEbbiyTwBi3n/Lpidd8pug7jbAogPE5MXokwXq+JrCxH5nTGZ0QhwHfMnVkg /O25utP5dupQiGk8vwRGuEAIKbpfTdNDSunfNRrRNIrii3SrHlSuQSAwrl3IclkedQ2n TbkrPJ3nesyXSoa0eQGyuHqBYJB83QfRtNnO7v5nZ6nt/sm+cLgO8xfFQG4rrzfm9fCW NP+bJ6m7NSH0d3cdlSf9WM3Sur3GNrtpUxf+ecqbZAhlqPoZ2bRgEWYhOFy0QeRH+pTt j8rA== 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=7+/LBq8O15v3OoDs/lH/2Ve049s0G8Qsb7qEz2lgI4g=; b=sbNHGth6k2I9WVx6C3N3BXxA2hDODC1MBUe9GNRFNAVV6JlWxRw/yrLi1s7PTfpqth 2Xt79LxaXG5IxaQsVPM5d5sVf6CZrSDCUQSMFJHB5BAcCusVrl7uFLAEz8r+rfjl9fvI RNBJm8RxMvMr/W5B1uLAEJ0xlBuDBpLRt/cxu5rb0lrB0l8VQOlEWEBhOEUP+u/XHipp SExGtFVGL7/cALkU0S14iAie6Fo9AIhcOiCboit7VLuFYgYkiWAGtijKgSLrdDEU1gOM wvCunTvEoOGFsJRMMfEXTNojVyVc4u5Mi1uDmdiMelVY+MSdRtFZeiBXQsXRkm+2jNqw vWsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DXlDhQFk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a1709067c0b00b0073d847631d2si1672399ejo.158.2022.09.02.07.30.04; Fri, 02 Sep 2022 07:30:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DXlDhQFk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S238682AbiIBNDh (ORCPT + 99 others); Fri, 2 Sep 2022 09:03:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238556AbiIBNCy (ORCPT ); Fri, 2 Sep 2022 09:02:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B647F10DE5E; Fri, 2 Sep 2022 05:41:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E1C87621D7; Fri, 2 Sep 2022 12:34:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FE08C433D7; Fri, 2 Sep 2022 12:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662122053; bh=LxmUgb6DHu/nEN9Ip8AAMCJvj0MtM154amp6n9cA3RQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DXlDhQFkpQYrxcFZj+0ENpDUhEtmry/1n7c6tBTscAJ4gn7f3ksxokrUlg0BiRRSA 0A5P+PDVXAjSw7f1LwAavifajzSApCx2O08mk/DUhqV50hhTMLpIeebI1CidvM2UFS bQby0Ickpg2cMDWMVysPM7y8NMhAaAza+id0aU5Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+5ea725c25d06fb9114c4@syzkaller.appspotmail.com, Zhengchao Shao , "David S. Miller" Subject: [PATCH 5.15 72/73] net/af_packet: check len when min_header_len equals to 0 Date: Fri, 2 Sep 2022 14:19:36 +0200 Message-Id: <20220902121406.775375295@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121404.435662285@linuxfoundation.org> References: <20220902121404.435662285@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhengchao Shao commit dc633700f00f726e027846a318c5ffeb8deaaeda upstream. User can use AF_PACKET socket to send packets with the length of 0. When min_header_len equals to 0, packet_snd will call __dev_queue_xmit to send packets, and sock->type can be any type. Reported-by: syzbot+5ea725c25d06fb9114c4@syzkaller.appspotmail.com Fixes: fd1894224407 ("bpf: Don't redirect packets with invalid pkt_len") Signed-off-by: Zhengchao Shao Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/packet/af_packet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2989,8 +2989,8 @@ static int packet_snd(struct socket *soc if (err) goto out_free; - if (sock->type == SOCK_RAW && - !dev_validate_header(dev, skb->data, len)) { + if ((sock->type == SOCK_RAW && + !dev_validate_header(dev, skb->data, len)) || !skb->len) { err = -EINVAL; goto out_free; }