From: Wang Hai Date: Mon, 16 Nov 2020 08:20:18 +0000 (+0800) Subject: inet_diag: Fix error path to cancel the meseage in inet_req_diag_fill() X-Git-Tag: v5.4.80~152 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0e8b0213dc60371172da2ae61b37c1310dde4b8a;p=users%2Fdwmw2%2Flinux.git inet_diag: Fix error path to cancel the meseage in inet_req_diag_fill() [ Upstream commit e33de7c5317e2827b2ba6fd120a505e9eb727b05 ] 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.") Reported-by: Hulk Robot Signed-off-by: Wang Hai Link: https://lore.kernel.org/r/20201116082018.16496-1-wanghai38@huawei.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index 5b68bdaa8bff8..4f71aca156662 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -388,8 +388,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;