All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: sock: fix in-kernel mark setting
@ 2021-05-31 21:00 Alexander Aring
  2021-06-01 22:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Aring @ 2021-05-31 21:00 UTC (permalink / raw)
  To: netdev; +Cc: marcelo.leitner, davem, kuba

This patch fixes the in-kernel mark setting by doing an additional
sk_dst_reset() which was introduced by commit 50254256f382 ("sock: Reset
dst when changing sk_mark via setsockopt"). The code is now shared to
avoid any further suprises when changing the socket mark value.

Fixes: 84d1c617402e ("net: sock: add sock_set_mark")
Reported-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 net/core/sock.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 958614ea16ed..946888afef88 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -815,10 +815,18 @@ void sock_set_rcvbuf(struct sock *sk, int val)
 }
 EXPORT_SYMBOL(sock_set_rcvbuf);
 
+static void __sock_set_mark(struct sock *sk, u32 val)
+{
+	if (val != sk->sk_mark) {
+		sk->sk_mark = val;
+		sk_dst_reset(sk);
+	}
+}
+
 void sock_set_mark(struct sock *sk, u32 val)
 {
 	lock_sock(sk);
-	sk->sk_mark = val;
+	__sock_set_mark(sk, val);
 	release_sock(sk);
 }
 EXPORT_SYMBOL(sock_set_mark);
@@ -1126,10 +1134,10 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
 	case SO_MARK:
 		if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) {
 			ret = -EPERM;
-		} else if (val != sk->sk_mark) {
-			sk->sk_mark = val;
-			sk_dst_reset(sk);
+			break;
 		}
+
+		__sock_set_mark(sk, val);
 		break;
 
 	case SO_RXQ_OVFL:
-- 
2.26.3


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

* Re: [PATCH net] net: sock: fix in-kernel mark setting
  2021-05-31 21:00 [PATCH net] net: sock: fix in-kernel mark setting Alexander Aring
@ 2021-06-01 22:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-01 22:30 UTC (permalink / raw)
  To: Alexander Aring; +Cc: netdev, marcelo.leitner, davem, kuba

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Mon, 31 May 2021 17:00:30 -0400 you wrote:
> This patch fixes the in-kernel mark setting by doing an additional
> sk_dst_reset() which was introduced by commit 50254256f382 ("sock: Reset
> dst when changing sk_mark via setsockopt"). The code is now shared to
> avoid any further suprises when changing the socket mark value.
> 
> Fixes: 84d1c617402e ("net: sock: add sock_set_mark")
> Reported-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> Signed-off-by: Alexander Aring <aahringo@redhat.com>
> 
> [...]

Here is the summary with links:
  - [net] net: sock: fix in-kernel mark setting
    https://git.kernel.org/netdev/net/c/dd9082f4a9f9

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-06-01 22:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-31 21:00 [PATCH net] net: sock: fix in-kernel mark setting Alexander Aring
2021-06-01 22:30 ` patchwork-bot+netdevbpf

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.