Skip to contentSkip to conversation

inet_diag: Fix error path to cancel the meseage in inet_req_diag_fill()

PATCH Applied Wang Hai 2 participants 2 messages Nov 16, 2020 – Nov 18, 2020

Subsystems (2)
lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 inet_diag: Fix error path to cancel the meseage in inet_req_diag_fill()

nlmsg_cancel() needs to be called in the error path of inet_req_diag_fill to cancel the message.

Fixes d545caca827b ("net: inet: diag: expose the socket mark to privileged processes.")
---
 net/ipv4/inet_diag.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/inet_diag.c +3 -1
index 366a4507b5a3..93474b1bea4e 100644
@@ -479,8 +479,10 @@ static int inet_req_diag_fill(struct sock *sk, struct sk_buff *skb,
 	r->idiag_inode	= 0;
 
 	if (net_admin && nla_put_u32(skb, INET_DIAG_MARK,
-				     inet_rsk(reqsk)->ir_mark))
+				     inet_rsk(reqsk)->ir_mark)) {
+		nlmsg_cancel(skb, nlh);
 		return -EMSGSIZE;
+	}
 
 	nlmsg_end(skb, nlh);
 	return 0;
Signature · 1 line
2.17.1
#1 lore raw
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

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

Quoted 8 lines · On Mon, 16 Nov 2020 16:20:18 +0800 you wrote:

nlmsg_cancel() needs to be called in the error path of inet_req_diag_fill to cancel the message.

Fixes d545caca827b ("net: inet: diag: expose the socket mark to privileged processes.")

[...]

Here is the summary with links:
- [net] inet_diag: Fix error path to cancel the meseage in inet_req_diag_fill()

    https://git.kernel.org/netdev/net/c/e33de7c5317e

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