netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] xdp: Reset prog in dev_change_xdp_fd when fd is negative
@ 2020-04-12 13:32 David Ahern
  2020-04-12 18:11 ` Jakub Kicinski
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: David Ahern @ 2020-04-12 13:32 UTC (permalink / raw)
  To: daniel, ast; +Cc: netdev, David Ahern, Toke Høiland-Jørgensen

From: David Ahern <dsahern@gmail.com>

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 <dsahern@gmail.com>
Cc: Toke Høiland-Jørgensen <toke@redhat.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf] xdp: Reset prog in dev_change_xdp_fd when fd is negative
  2020-04-12 13:32 [PATCH bpf] xdp: Reset prog in dev_change_xdp_fd when fd is negative David Ahern
@ 2020-04-12 18:11 ` Jakub Kicinski
  2020-04-13 22:08 ` Alexei Starovoitov
  2020-04-14  7:17 ` Toke Høiland-Jørgensen
  2 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2020-04-12 18:11 UTC (permalink / raw)
  To: David Ahern
  Cc: daniel, ast, netdev, David Ahern, Toke Høiland-Jørgensen

On Sun, 12 Apr 2020 07:32:04 -0600 David Ahern wrote:
> From: David Ahern <dsahern@gmail.com>
> 
> 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 <dsahern@gmail.com>
> Cc: Toke Høiland-Jørgensen <toke@redhat.com>

Reviewed-by: Jakub Kicinski <kuba@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf] xdp: Reset prog in dev_change_xdp_fd when fd is negative
  2020-04-12 13:32 [PATCH bpf] xdp: Reset prog in dev_change_xdp_fd when fd is negative David Ahern
  2020-04-12 18:11 ` Jakub Kicinski
@ 2020-04-13 22:08 ` Alexei Starovoitov
  2020-04-14  7:17 ` Toke Høiland-Jørgensen
  2 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2020-04-13 22:08 UTC (permalink / raw)
  To: David Ahern
  Cc: daniel, ast, netdev, David Ahern, Toke Høiland-Jørgensen

On Sun, Apr 12, 2020 at 07:32:04AM -0600, David Ahern wrote:
> From: David Ahern <dsahern@gmail.com>
> 
> 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 <dsahern@gmail.com>
> Cc: Toke Høiland-Jørgensen <toke@redhat.com>

Argh. Thanks for the fix.

Toke, please review.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf] xdp: Reset prog in dev_change_xdp_fd when fd is negative
  2020-04-12 13:32 [PATCH bpf] xdp: Reset prog in dev_change_xdp_fd when fd is negative David Ahern
  2020-04-12 18:11 ` Jakub Kicinski
  2020-04-13 22:08 ` Alexei Starovoitov
@ 2020-04-14  7:17 ` Toke Høiland-Jørgensen
  2020-04-14 19:45   ` Daniel Borkmann
  2 siblings, 1 reply; 5+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-04-14  7:17 UTC (permalink / raw)
  To: David Ahern, daniel, ast; +Cc: netdev, David Ahern

David Ahern <dsahern@kernel.org> writes:

> From: David Ahern <dsahern@gmail.com>
>
> 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 <dsahern@gmail.com>
> Cc: Toke Høiland-Jørgensen <toke@redhat.com>

Ugh, my bad (obviously!). Thanks for the fix! I'll send an update to the
selftest to catch errors like this...

Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf] xdp: Reset prog in dev_change_xdp_fd when fd is negative
  2020-04-14  7:17 ` Toke Høiland-Jørgensen
@ 2020-04-14 19:45   ` Daniel Borkmann
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Borkmann @ 2020-04-14 19:45 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, David Ahern, ast; +Cc: netdev, David Ahern

On 4/14/20 9:17 AM, Toke Høiland-Jørgensen wrote:
> David Ahern <dsahern@kernel.org> writes:
> 
>> From: David Ahern <dsahern@gmail.com>
>>
>> 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 <dsahern@gmail.com>
>> Cc: Toke Høiland-Jørgensen <toke@redhat.com>
> 
> Ugh, my bad (obviously!). Thanks for the fix! I'll send an update to the
> selftest to catch errors like this...

+1

> Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-14 19:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12 13:32 [PATCH bpf] xdp: Reset prog in dev_change_xdp_fd when fd is negative David Ahern
2020-04-12 18:11 ` Jakub Kicinski
2020-04-13 22:08 ` Alexei Starovoitov
2020-04-14  7:17 ` Toke Høiland-Jørgensen
2020-04-14 19:45   ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).