Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp163850rwj; Thu, 22 Dec 2022 00:54:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXv908oCtD6N6mqWwqhz8/5OsO+wwaj1YL4F6H8pcjQK3O+l+DuQqDY8nvXhunXYrQJnta+8 X-Received: by 2002:a17:906:8601:b0:7b2:91e8:1553 with SMTP id o1-20020a170906860100b007b291e81553mr3725940ejx.20.1671699299111; Thu, 22 Dec 2022 00:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671699299; cv=none; d=google.com; s=arc-20160816; b=WAc+swH4amdCpEdqkNRIik2/7P7gLQyahHqj+J1GmZTcBY9moV85AxC1Bzg1dwh2WZ 7N05T+KwH9gvYUHi0SMoFn4LtHDgo+QMeSfkarEhHf+xKHhv5nbfM+reD5HJ7UgS2wth pdBlaJC2vVJDF6yCQF76kUoCpXxWov5tHyPh0MFWkGSkzaXFZ+y/wEo7Le8pZq0xAoHA /fZAALOZN3I+f6kTdiy1ERlWWjDxssiVfPE0swQAPoJU0vGmbJ9ndJr8JGXoQkGsP5AQ +azlRIet6F1zx6zbScmmxhlgMlbnUSPEPxn+ugU+sOINCZeTtF0UhAS7T5sRqPJbMo56 WHuQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=TOfc7EGG83O/xS/Uaar9/uexk/8D+4jXs6c0U4ftxC0=; b=tnXT6GzWFlWLQp2tcMCcftXtMGkc1w/9qLEMlNsuUktAD43ZMt9MNgzOrhTbk6PUGU WSOJeoKO00nAh5S+mXueCB8i85w7jFtX3jQxJRnf1jQRnc62/kA2m2JOyNz3NUw5DCaY C6M396C4kayQbLIpsN5OA62/Heqjp5EI2Sv1hfAXgyeKkbVu3s/b/kGEfTbqe6HwJyOp TYzahek0ieA1VOXr3tLcJgeq+CvO3OAA1aV5Ik49r/sgLpALAV56PN6SbxqgTfGuaTQa AE1rKvolpRPdpnHYXj0BI7pfy0E846Gj8qE27zadw5jdxUNxxM5wDtt7Hc/1htuLKUQb hTbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gfHxNAQc; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a1709066c8600b007b5dd3e6995si3459273ejr.917.2022.12.22.00.54.43; Thu, 22 Dec 2022 00:54:59 -0800 (PST) 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=@linaro.org header.s=google header.b=gfHxNAQc; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230417AbiLVIgI (ORCPT + 67 others); Thu, 22 Dec 2022 03:36:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229630AbiLVIgE (ORCPT ); Thu, 22 Dec 2022 03:36:04 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 905BAB1D2 for ; Thu, 22 Dec 2022 00:36:02 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id u19so3207442ejm.8 for ; Thu, 22 Dec 2022 00:36:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=TOfc7EGG83O/xS/Uaar9/uexk/8D+4jXs6c0U4ftxC0=; b=gfHxNAQcIb72vXPpnCGJHdtH5YsR+5yf953FvOjGAhWm3ROz2AVyy9CDJBLeNf0Xsf g9Eh9BgzRGBI33iFH5EZMV1EyIo7qyQnOzqYxqpf0Gjth3XeVsWoNbJNSN2vNy6sOFuW Wsug4Breu+GJr9uWJSgyuWFyAkODYy3I0LhGAhQx8d/XTHDWTyujMAqRk8IKCo3XupVR EtXTA5QFtT71L7oUN1XfeOIi1qNPuI4Ftw7zc5iri5clz6gloEaAgmrsnTwzIJpV7zKC Y4ovHaf0puufxFDIxFt9QIkeiNIL/eHaZGlBfSNoMU4eDIyvuDDHx7q4G0Acjva9LNJa JpOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TOfc7EGG83O/xS/Uaar9/uexk/8D+4jXs6c0U4ftxC0=; b=oi/UK0+wCCRzTUkk3ARIPq6idXR23WM3q1l8hS3feO+e9aB/gH8iLPgWxOWp2VR0vp TjjGO/X9T0Yhjje/u9vgGysqJa7c/t3H+9EkkqUqePsIYwSK9O2qZXs0ea+etMbYfE+p tJ1EPOpJEYdRstIu/COw3sc/gYJVPR93Atbfdb2eiuWBW21A7G1r+lRpFoS+HpuWCeq0 YIn2h3aanHZPYqXX0aNydwtwZJa0APXUCqcs7uSN+nLc1WXfORXXg9za/pTRqt3fgZZM qmJ9YuuaSeHznxZ1nVgrC87u7dsQ0Ge+nJeBJdyMQJ1EsABjm4Bk0YKObJSEV8PIXeZt B7bQ== X-Gm-Message-State: AFqh2kolTCeXFTxtGYEjHoYVkFhID/y5i9kuh/F5UOVTl2l1Vd9abwkH NQhwRqq1AecgsDpsfatcSszu3g== X-Received: by 2002:a17:907:80ce:b0:7c1:26b9:c556 with SMTP id io14-20020a17090780ce00b007c126b9c556mr4429988ejc.15.1671698161125; Thu, 22 Dec 2022 00:36:01 -0800 (PST) Received: from alba.. ([82.77.81.131]) by smtp.gmail.com with ESMTPSA id t16-20020a1709060c5000b007c14ae38a80sm7987721ejf.122.2022.12.22.00.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Dec 2022 00:36:00 -0800 (PST) From: Tudor Ambarus To: stable@vger.kernel.org Cc: willemdebruijn.kernel@gmail.com, mst@redhat.com, jasowang@redhat.com, edumazet@google.com, virtualization@lists.linux-foundation.org, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, willemb@google.com, syzkaller@googlegroups.com, liuhangbin@gmail.com, linux-kernel@vger.kernel.org, joneslee@google.com, Tudor Ambarus Subject: [PATCH 0/2] net/af_packet: Fix kernel BUG in __skb_gso_segment Date: Thu, 22 Dec 2022 10:35:43 +0200 Message-Id: <20221222083545.1972489-1-tudor.ambarus@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 The series is intended for stable@vger.kernel.org # 5.4+ Syzkaller reported the following bug on linux-5.{4, 10, 15}.y: https://syzkaller.appspot.com/bug?id=ce5575575f074c33ff80d104f5baee26f22e95f5 The upstream commit that introduces this bug is: 1ed1d5921139 ("net: skip virtio_net_hdr_set_proto if protocol already set") Upstream fixes the bug with the following commits, one of which introduces new support: e9d3f80935b6 ("net/af_packet: make sure to pull mac header") dfed913e8b55 ("net/af_packet: add VLAN support for AF_PACKET SOCK_RAW GSO") The additional logic and risk backported seems manageable. The blammed commit introduces a kernel BUG in __skb_gso_segment for AF_PACKET SOCK_RAW GSO VLAN tagged packets. What happens is that virtio_net_hdr_set_proto() exists early as skb->protocol is already set to ETH_P_ALL. Then in packet_parse_headers() skb->protocol is set to ETH_P_8021AD, but neither the network header position is adjusted, nor the mac header is pulled. Thus when we get to validate the xmit skb and enter skb_mac_gso_segment(), skb->mac_len has value 14, but vlan_depth gets updated to 18 after skb_network_protocol() is called. This causes the BUG_ON from __skb_pull(skb, vlan_depth) to be hit, as the mac header has not been pulled yet. The fixes from upstream backported cleanly without conflicts. I updated the commit message of the first patch to describe the problem encountered, and added Cc, Fixes, Reported-by and Tested-by tags. For the second patch I just added Cc to stable indicating the versions to be fixed, and added my Tested and Signed-off-by tags. I tested the patches on linux-5.{4, 10, 15}.y. Eric Dumazet (1): net/af_packet: make sure to pull mac header Hangbin Liu (1): net/af_packet: add VLAN support for AF_PACKET SOCK_RAW GSO net/packet/af_packet.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) -- 2.34.1