Skip to content

Commit 9e502ec

Browse files
Wang Haiksacilotto
authored andcommitted
inet_diag: Fix error path to cancel the meseage in inet_req_diag_fill()
BugLink: https://bugs.launchpad.net/bugs/1908561 [ Upstream commit e33de7c ] nlmsg_cancel() needs to be called in the error path of inet_req_diag_fill to cancel the message. Fixes: d545cac ("net: inet: diag: expose the socket mark to privileged processes.") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Wang Hai <wanghai38@huawei.com> Link: https://lore.kernel.org/r/20201116082018.16496-1-wanghai38@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Ian May <ian.may@canonical.com>
1 parent a805d50 commit 9e502ec

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/ipv4/inet_diag.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,10 @@ static int inet_req_diag_fill(struct sock *sk, struct sk_buff *skb,
388388
r->idiag_inode = 0;
389389

390390
if (net_admin && nla_put_u32(skb, INET_DIAG_MARK,
391-
inet_rsk(reqsk)->ir_mark))
391+
inet_rsk(reqsk)->ir_mark)) {
392+
nlmsg_cancel(skb, nlh);
392393
return -EMSGSIZE;
394+
}
393395

394396
nlmsg_end(skb, nlh);
395397
return 0;

0 commit comments

Comments
 (0)