From patchwork Tue Mar 31 06:06:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maowenan X-Patchwork-Id: 1264535 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming-bpf@patchwork.ozlabs.org Delivered-To: patchwork-incoming-bpf@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=bpf-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48rzL70VjGz9sRN for ; Tue, 31 Mar 2020 17:04:14 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726060AbgCaGEM (ORCPT ); Tue, 31 Mar 2020 02:04:12 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12660 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725809AbgCaGEM (ORCPT ); Tue, 31 Mar 2020 02:04:12 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 128B67015BC6416B1C16; Tue, 31 Mar 2020 14:04:05 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Tue, 31 Mar 2020 14:04:01 +0800 From: Mao Wenan To: , , , , , , , , , , , , , CC: , , , Subject: [PATCH net v2] veth: xdp: use head instead of hard_start Date: Tue, 31 Mar 2020 14:06:41 +0800 Message-ID: <20200331060641.79999-1-maowenan@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org xdp.data_hard_start is equal to first address of struct xdp_frame, which is mentioned in convert_to_xdp_frame(). But the pointer hard_start in veth_xdp_rcv_one() is 32 bytes offset of frame, so it should use head instead of hard_start to set xdp.data_hard_start. Otherwise, if BPF program calls helper_function such as bpf_xdp_adjust_head, it will be confused for xdp_frame_end. Fixes: 9fc8d518d9d5 ("veth: Handle xdp_frames in xdp napi ring") Signed-off-by: Mao Wenan Reported-by: Mao Wenan Signed-off-by: Jesper Dangaard Brouer Acked-by: Toshiaki Makita --- v2: add fixes tag, as well as commit log. drivers/net/veth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index d4cbb9e8c63f..5ea550884bf8 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -506,7 +506,7 @@ static struct sk_buff *veth_xdp_rcv_one(struct veth_rq *rq, struct xdp_buff xdp; u32 act; - xdp.data_hard_start = hard_start; + xdp.data_hard_start = head; xdp.data = frame->data; xdp.data_end = frame->data + frame->len; xdp.data_meta = frame->data - frame->metasize;