All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes
@ 2019-01-16 16:47 Peter Oskolkov
  2019-01-16 18:09 ` Martin Lau
  2019-01-17 15:50 ` Daniel Borkmann
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Oskolkov @ 2019-01-16 16:47 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, netdev
  Cc: Peter Oskolkov, Peter Oskolkov, Maciej Żenczykowski

In sock_setsockopt() (net/core/sock.h), when SO_MARK option is used
to change sk_mark, sk_dst_reset(sk) is called. The same should be done
in bpf_setsockopt.

Reported-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Peter Oskolkov <posk@google.com>
---
 net/core/filter.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 2b3b436ef545..0c1bc6ccfd7f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4132,7 +4132,10 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, bpf_sock,
 			sk->sk_rcvlowat = val ? : 1;
 			break;
 		case SO_MARK:
-			sk->sk_mark = val;
+			if (sk->sk_mark != val) {
+				sk->sk_mark = val;
+				sk_dst_reset(sk);
+			}
 			break;
 		default:
 			ret = -EINVAL;
-- 


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

* Re: [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes
  2019-01-16 16:47 [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes Peter Oskolkov
@ 2019-01-16 18:09 ` Martin Lau
  2019-01-17  0:35   ` Maciej Żenczykowski
  2019-01-17 15:50 ` Daniel Borkmann
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Lau @ 2019-01-16 18:09 UTC (permalink / raw)
  Cc: Alexei Starovoitov, Daniel Borkmann, netdev, Peter Oskolkov,
	Maciej Żenczykowski

On Wed, Jan 16, 2019 at 08:47:54AM -0800, Peter Oskolkov wrote:
> In sock_setsockopt() (net/core/sock.h), when SO_MARK option is used
> to change sk_mark, sk_dst_reset(sk) is called. The same should be done
> in bpf_setsockopt.
> 
> Reported-by: Maciej Żenczykowski <maze@google.com>
> Signed-off-by: Peter Oskolkov <posk@google.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>

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

* Re: [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes
  2019-01-16 18:09 ` Martin Lau
@ 2019-01-17  0:35   ` Maciej Żenczykowski
  0 siblings, 0 replies; 6+ messages in thread
From: Maciej Żenczykowski @ 2019-01-17  0:35 UTC (permalink / raw)
  To: Martin Lau; +Cc: Alexei Starovoitov, Daniel Borkmann, netdev, Peter Oskolkov

On Wed, Jan 16, 2019 at 10:09 AM Martin Lau <kafai@fb.com> wrote:
> > In sock_setsockopt() (net/core/sock.h), when SO_MARK option is used
> > to change sk_mark, sk_dst_reset(sk) is called. The same should be done
> > in bpf_setsockopt.
> >
> > Reported-by: Maciej Żenczykowski <maze@google.com>
> > Signed-off-by: Peter Oskolkov <posk@google.com>
> Acked-by: Martin KaFai Lau <kafai@fb.com>
Reviewed-by: Maciej Żenczykowski <maze@google.com>

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

* Re: [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes
  2019-01-16 16:47 [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes Peter Oskolkov
  2019-01-16 18:09 ` Martin Lau
@ 2019-01-17 15:50 ` Daniel Borkmann
  2019-01-17 16:36   ` Peter Oskolkov
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel Borkmann @ 2019-01-17 15:50 UTC (permalink / raw)
  To: Peter Oskolkov, Alexei Starovoitov, netdev
  Cc: Peter Oskolkov, Maciej Żenczykowski

On 01/16/2019 05:47 PM, Peter Oskolkov wrote:
> In sock_setsockopt() (net/core/sock.h), when SO_MARK option is used
> to change sk_mark, sk_dst_reset(sk) is called. The same should be done
> in bpf_setsockopt.
> 
> Reported-by: Maciej Żenczykowski <maze@google.com>
> Signed-off-by: Peter Oskolkov <posk@google.com>

Given this is a fix, I'm inclined to apply to bpf tree. Objections?

Thanks,
Daniel

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

* Re: [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes
  2019-01-17 15:50 ` Daniel Borkmann
@ 2019-01-17 16:36   ` Peter Oskolkov
  2019-01-17 23:34     ` Daniel Borkmann
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Oskolkov @ 2019-01-17 16:36 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Alexei Starovoitov, netdev, Peter Oskolkov, Maciej Żenczykowski

On Thu, Jan 17, 2019 at 7:50 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 01/16/2019 05:47 PM, Peter Oskolkov wrote:
> > In sock_setsockopt() (net/core/sock.h), when SO_MARK option is used
> > to change sk_mark, sk_dst_reset(sk) is called. The same should be done
> > in bpf_setsockopt.
> >
> > Reported-by: Maciej Żenczykowski <maze@google.com>
> > Signed-off-by: Peter Oskolkov <posk@google.com>
>
> Given this is a fix, I'm inclined to apply to bpf tree. Objections?

Up to the maintainer... :)

>
> Thanks,
> Daniel

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

* Re: [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes
  2019-01-17 16:36   ` Peter Oskolkov
@ 2019-01-17 23:34     ` Daniel Borkmann
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Borkmann @ 2019-01-17 23:34 UTC (permalink / raw)
  To: Peter Oskolkov
  Cc: Alexei Starovoitov, netdev, Peter Oskolkov, Maciej Żenczykowski

On 01/17/2019 05:36 PM, Peter Oskolkov wrote:
> On Thu, Jan 17, 2019 at 7:50 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>>
>> On 01/16/2019 05:47 PM, Peter Oskolkov wrote:
>>> In sock_setsockopt() (net/core/sock.h), when SO_MARK option is used
>>> to change sk_mark, sk_dst_reset(sk) is called. The same should be done
>>> in bpf_setsockopt.
>>>
>>> Reported-by: Maciej Żenczykowski <maze@google.com>
>>> Signed-off-by: Peter Oskolkov <posk@google.com>
>>
>> Given this is a fix, I'm inclined to apply to bpf tree. Objections?
> 
> Up to the maintainer... :)

Applied to bpf, thanks!

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

end of thread, other threads:[~2019-01-17 23:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16 16:47 [PATCH bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes Peter Oskolkov
2019-01-16 18:09 ` Martin Lau
2019-01-17  0:35   ` Maciej Żenczykowski
2019-01-17 15:50 ` Daniel Borkmann
2019-01-17 16:36   ` Peter Oskolkov
2019-01-17 23:34     ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.