Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3628597pxb; Mon, 24 Jan 2022 13:54:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJztv5fKcxHFK6DmS0bFxltO51hdqguHecXHv/yHT2eiIDvmOVwZr5rXVaVGCzN4LJaenZKc X-Received: by 2002:a17:90b:4f87:: with SMTP id qe7mr338207pjb.154.1643061270156; Mon, 24 Jan 2022 13:54:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061270; cv=none; d=google.com; s=arc-20160816; b=Nsnov6JGv7gw8HQYEE/68yrEfrQCJ7k6ZroPQsXWwCOCKvfj3re7SaDYXQ1RI/jfuE S8TxQ4zWgmT2BX7RLzLs4Aq1bmlRhVI43ZN5ejVBUFEzyjB5U6oPNd9AOirjtKF0uAkV b8c90UEO9OTMu5AlGJpjDPplOJxcW9wI6A8lgaK0x5v7nI0yjfoeN4lO8dTHA0tifYrM Kb3wKsC30Fv0/12eXgt84fGQn2acKzzNJDjGCgGDfu2qzRdMf9V4zvKFPrmUiIg3ZxnF myujQGNOA1wPFhgSoC1oT52EqDQIFc1/e5aeMoB9l065J8snaUWBSEX0o85gY+qAFe6m bBdg== 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=j4CwP2sAePKL18zPR4ds3yKpyYOoRYPNJeZmO5GQEQQ=; b=SFkJyhOcXh5i+eMksmMwMyhg8nmmpkfOh3Wn1TDmPb2BmOQXA3faIOUXS9ftihB4K0 y63dC3Hx2a5xIMc2HYAlCvUjxYsi5LHXnbGYRM3XwPddxKqbECIu3wjisr8ouk5z9rOH 5l3nbmeHxfI63acB+0VYRzIspdLYcGaElL9028LsqbpJEEVQ78q9Q856UA0DfcLgWlXs 5zJL4R+powArcA4bgOEpNPPnaPEYOnQXbrflEIj4ZVwnXAgsOqqSVBorQDw+eXowEd9q 8BdjfnZ9kfPkKajAK/ha73wj03676S1l/qrhvjEYdDZGZHA6imvtdycbXC7pWI4U934Q QvHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ft1zlP+J; 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 kb17si462470pjb.76.2022.01.24.13.54.16; Mon, 24 Jan 2022 13:54:30 -0800 (PST) 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=Ft1zlP+J; 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 S1457096AbiAXVky (ORCPT + 99 others); Mon, 24 Jan 2022 16:40:54 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:56160 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1445320AbiAXVCs (ORCPT ); Mon, 24 Jan 2022 16:02:48 -0500 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 ams.source.kernel.org (Postfix) with ESMTPS id 4C690B81057; Mon, 24 Jan 2022 21:02:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70613C340E5; Mon, 24 Jan 2022 21:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058165; bh=MMPMmtVSLrtuyr7cLejn7b26l10ZVjMuBWZcYg26WQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ft1zlP+JT9w94b5TJ+snE25Sy8phg8EBFwdWdLDsRCPfaKaoO7fZIgZXRLb3jt8kO 7p1YtwrTZK947uTrXGo7T+JET16eQ77X/lC7cJP/XF0CCcZ9XVfxhrOh7eQzl9DxgR s9pq5F4yfMq8VsxpYp6VCd2Ns4Xr7RISZfqfyYzI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jesper Dangaard Brouer , Nechama Kraus , Maciej Fijalkowski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.16 0201/1039] igc: AF_XDP zero-copy metadata adjust breaks SKBs on XDP_PASS Date: Mon, 24 Jan 2022 19:33:10 +0100 Message-Id: <20220124184132.088197008@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Jesper Dangaard Brouer [ Upstream commit 4fa8fcd3440101dbacf4fae91de69877ef751977 ] Driver already implicitly supports XDP metadata access in AF_XDP zero-copy mode, as xsk_buff_pool's xp_alloc() naturally set xdp_buff data_meta equal data. This works fine for XDP and AF_XDP, but if a BPF-prog adjust via bpf_xdp_adjust_meta() and choose to call XDP_PASS, then igc function igc_construct_skb_zc() will construct an invalid SKB packet. The function correctly include the xdp->data_meta area in the memcpy, but forgot to pull header to take metasize into account. Fixes: fc9df2a0b520 ("igc: Enable RX via AF_XDP zero-copy") Signed-off-by: Jesper Dangaard Brouer Tested-by: Nechama Kraus Acked-by: Maciej Fijalkowski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igc/igc_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index d28a80a009537..d83e665b3a4f2 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2448,8 +2448,10 @@ static struct sk_buff *igc_construct_skb_zc(struct igc_ring *ring, skb_reserve(skb, xdp->data_meta - xdp->data_hard_start); memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize); - if (metasize) + if (metasize) { skb_metadata_set(skb, metasize); + __skb_pull(skb, metasize); + } return skb; } -- 2.34.1