Message ID | 752f1ccf762223d109845365d07f55414058e5a3.1714484273.git.pabeni@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 080cbb890286cd794f1ee788bbc5463e2deb7c2b |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] tipc: fix UAF in error path | expand |
On Tue, Apr 30, 2024 at 3:53 PM Paolo Abeni <pabeni@redhat.com> wrote: > > Sam Page (sam4k) working with Trend Micro Zero Day Initiative reported > a UAF in the tipc_buf_append() error path: > > BUG: KASAN: slab-use-after-free in kfree_skb_list_reason+0x47e/0x4c0 > linux/net/core/skbuff.c:1183 > Read of size 8 at addr ffff88804d2a7c80 by task poc/8034 > > > In the critical scenario, either the relevant skb is freed or its > ownership is transferred into a frag_lists. In both cases, the cleanup > code must not free it again: we need to clear the skb reference earlier. > > Fixes: 1149557d64c9 ("tipc: eliminate unnecessary linearization of incoming buffers") > Cc: stable@vger.kernel.org > Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-23852 > Acked-by: Xin Long <lucien.xin@gmail.com> > Signed-off-by: Paolo Abeni <pabeni@redhat.com> > --- > net/tipc/msg.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > Reviewed-by: Eric Dumazet <edumazet@google.com>
Hello: This patch was applied to netdev/net.git (main) by Jakub Kicinski <kuba@kernel.org>: On Tue, 30 Apr 2024 15:53:37 +0200 you wrote: > Sam Page (sam4k) working with Trend Micro Zero Day Initiative reported > a UAF in the tipc_buf_append() error path: > > BUG: KASAN: slab-use-after-free in kfree_skb_list_reason+0x47e/0x4c0 > linux/net/core/skbuff.c:1183 > Read of size 8 at addr ffff88804d2a7c80 by task poc/8034 > > [...] Here is the summary with links: - [net] tipc: fix UAF in error path https://git.kernel.org/netdev/net/c/080cbb890286 You are awesome, thank you!
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 5c9fd4791c4b..9a6e9bcbf694 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c @@ -156,6 +156,11 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf) if (!head) goto err; + /* Either the input skb ownership is transferred to headskb + * or the input skb is freed, clear the reference to avoid + * bad access on error path. + */ + *buf = NULL; if (skb_try_coalesce(head, frag, &headstolen, &delta)) { kfree_skb_partial(frag, headstolen); } else { @@ -179,7 +184,6 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf) *headbuf = NULL; return 1; } - *buf = NULL; return 0; err: kfree_skb(*buf);