af_key: add __GFP_ZERO flag for compose_sadb_supported in function pfkey_register
Subsystems (3)
Sasha Levin
maintainerPATCH 1/2 af_key: add __GFP_ZERO flag for compose_sadb_supported in function pfkey_register
From: Haimin Zhang <[email protected]>
[ Upstream commit 9a564bccb78a76740ea9d75a259942df8143d02c ]
Add __GFP_ZERO flag for compose_sadb_supported in function pfkey_register to initialize the buffer of supp_skb to fix a kernel-info-leak issue.
1) Function pfkey_register calls compose_sadb_supported to request a sk_buff. 2) compose_sadb_supported calls alloc_sbk to allocate a sk_buff, but it doesn't zero it. 3) If auth_len is greater 0, then compose_sadb_supported treats the memory as a struct sadb_supported and begins to initialize. But it just initializes the field sadb_supported_len and field sadb_supported_exttype without field sadb_supported_reserved.
--- net/key/af_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/key/af_key.c +1 -1
@@ -1709,7 +1709,7 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sadxfrm_probe_algs (); - supp_skb =compose_sadb_supported (hdr,GFP_KERNEL ); + supp_skb =compose_sadb_supported (hdr,GFP_KERNEL | __GFP_ZERO);if (!supp_skb) {if (hdr->sadb_msg_satype !=SADB_SATYPE_UNSPEC ) pfk->registered &= ~(1 <<hdr->sadb_msg_satype);
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 2/2 net: ipv6: fix skb_over_panic in __ip6_append_data
From: Tadeusz Struk <[email protected]>
[ Upstream commit 5e34af4142ffe68f01c8a9acae83300f8911e20c ]
Syzbot found a kernel bug in the ipv6 stack:
The reproducer triggers it by sending a crafted message via sendmmsg() call, which triggers skb_over_panic, and crashes the kernel:
skbuff: skb_over_panic: text:ffffffff84647fb4 len:65575 put:65575 head:ffff888109ff0000 data:ffff888109ff0088 tail:0x100af end:0xfec0 dev:<NULL>
Update the check that prevents an invalid packet with MTU equal to the fregment header size to eat up all the space for payload.
The reproducer can be found here:
--- net/ipv6/ip6_output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ip6_output.c +2 -2
@@ -1321,8 +1321,8 @@ static int __ip6_append_data(struct sock *sk, sizeof(struct frag_hdr) : 0) + rt->rt6i_nfheader_len; -if (mtu < fragheaderlen || - ((mtu - fragheaderlen) & ~7 ) + fragheaderlen <sizeof (struct frag_hdr )) +if (mtu <= fragheaderlen || + ((mtu - fragheaderlen) & ~7 ) + fragheaderlen <=sizeof (struct frag_hdr )) goto emsgsize; maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen -
Signature · 1 line
2.34.1