Message ID | 20190116164754.104170-1-posk@google.com |
---|---|
State | Accepted |
Delegated to: | BPF Maintainers |
Headers | show |
Series | [bpf-next] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes | expand |
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>
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>
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
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
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!
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;
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(-) --