summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPeter Oskolkov <posk@google.com>2019-01-16 08:47:54 -0800
committerDaniel Borkmann <daniel@iogearbox.net>2019-01-18 00:27:47 +0100
commitf4924f24da8c7ef64195096817f3cde324091d97 (patch)
treec59e9d734170a6ff9c5640a9ada341bdf77ec515 /net
parentc61c27687a5abce11431e6de1adb6e36099b9859 (diff)
downloadlinux-f4924f24da8c7ef64195096817f3cde324091d97.tar.bz2
bpf: bpf_setsockopt: reset sock dst on SO_MARK changes
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(). Fixes: 8c4b4c7e9ff0 ("bpf: Add setsockopt helper function to bpf") 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> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/filter.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index d9076e609fca..d9ea51b47f35 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;