From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA8CDC2BA2B for ; Sun, 12 Apr 2020 13:32:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9CADE206B8 for ; Sun, 12 Apr 2020 13:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586698336; bh=JA7VPU9jf4n2Bwa5p3gNG6ES6Ix1joKztihzudiR0qg=; h=From:To:Cc:Subject:Date:List-ID:From; b=2msJV4HaVv75nBdCJwVFBbh7TGrgOpbuSrTkx+21FEo3ddzMuFhJ0sEHuRibFQHxM /8SpdI9LIqA5SD8stRa+aZMS2Xf+rQRX97K+L5VYg2hZQNugGTv2mHsVoDQ/enZ81l fRXzf0QlQtKKdWXn+cIadZtIl5c8x6fo3dwe33Cc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726955AbgDLNcP (ORCPT ); Sun, 12 Apr 2020 09:32:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:60690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbgDLNcO (ORCPT ); Sun, 12 Apr 2020 09:32:14 -0400 Received: from C02YQ0RWLVCF.internal.digitalocean.com (c-73-203-53-74.hsd1.co.comcast.net [73.203.53.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D405320673; Sun, 12 Apr 2020 13:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586698335; bh=JA7VPU9jf4n2Bwa5p3gNG6ES6Ix1joKztihzudiR0qg=; h=From:To:Cc:Subject:Date:From; b=XF1NqN30of9Ro9crAXehwCEyTVIaGKVayHM5vy24q0HeFQlOK6FsYWWwnHdILSUwK d5VWUXOwG1ZzxvxWN+KUuiEt1bgN+GBQ44PaIKuqhDxP9G/8MRxS6yQq1n7aWj2M4W cz2lc+UN+HrpxnaAkucQvqimH9VMk4MoTYUN7nk4= From: David Ahern To: daniel@iogearbox.net, ast@kernel.org Cc: netdev@vger.kernel.org, David Ahern , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= Subject: [PATCH bpf] xdp: Reset prog in dev_change_xdp_fd when fd is negative Date: Sun, 12 Apr 2020 07:32:04 -0600 Message-Id: <20200412133204.43847-1-dsahern@kernel.org> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern The commit mentioned in the Fixes tag reuses the local prog variable when looking up an expected_fd. The variable is not reset when fd < 0 causing a detach with the expected_fd set to actually call dev_xdp_install for the existing program. The end result is that the detach does not happen. Fixes: 92234c8f15c8 ("xdp: Support specifying expected existing program when attaching XDP") Signed-off-by: David Ahern Cc: Toke Høiland-Jørgensen --- net/core/dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index df8097b8e286..522288177bbd 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8667,8 +8667,8 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack, const struct net_device_ops *ops = dev->netdev_ops; enum bpf_netdev_command query; u32 prog_id, expected_id = 0; - struct bpf_prog *prog = NULL; bpf_op_t bpf_op, bpf_chk; + struct bpf_prog *prog; bool offload; int err; @@ -8734,6 +8734,7 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack, } else { if (!prog_id) return 0; + prog = NULL; } err = dev_xdp_install(dev, bpf_op, extack, flags, prog); -- 2.20.1