* [net v2] tipc: fix NULL deref in tipc_link_xmit()
@ 2021-01-08 7:13 Hoang Huu Le
2021-01-10 0:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Hoang Huu Le @ 2021-01-08 7:13 UTC (permalink / raw)
To: netdev, ying.xue; +Cc: maloy, jmaloy, Hoang Le
From: Hoang Le <hoang.h.le@dektech.com.au>
The buffer list can have zero skb as following path:
tipc_named_node_up()->tipc_node_xmit()->tipc_link_xmit(), so
we need to check the list before casting an &sk_buff.
Fault report:
[] tipc: Bulk publication failure
[] general protection fault, probably for non-canonical [#1] PREEMPT [...]
[] KASAN: null-ptr-deref in range [0x00000000000000c8-0x00000000000000cf]
[] CPU: 0 PID: 0 Comm: swapper/0 Kdump: loaded Not tainted 5.10.0-rc4+ #2
[] Hardware name: Bochs ..., BIOS Bochs 01/01/2011
[] RIP: 0010:tipc_link_xmit+0xc1/0x2180
[] Code: 24 b8 00 00 00 00 4d 39 ec 4c 0f 44 e8 e8 d7 0a 10 f9 48 [...]
[] RSP: 0018:ffffc90000006ea0 EFLAGS: 00010202
[] RAX: dffffc0000000000 RBX: ffff8880224da000 RCX: 1ffff11003d3cc0d
[] RDX: 0000000000000019 RSI: ffffffff886007b9 RDI: 00000000000000c8
[] RBP: ffffc90000007018 R08: 0000000000000001 R09: fffff52000000ded
[] R10: 0000000000000003 R11: fffff52000000dec R12: ffffc90000007148
[] R13: 0000000000000000 R14: 0000000000000000 R15: ffffc90000007018
[] FS: 0000000000000000(0000) GS:ffff888037400000(0000) knlGS:000[...]
[] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[] CR2: 00007fffd2db5000 CR3: 000000002b08f000 CR4: 00000000000006f0
Fixes: af9b028e270fd ("tipc: make media xmit call outside node spinlock context")
Acked-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
--
v2: add 'Fixes' tag
---
net/tipc/link.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 6ae2140eb4f7..a6a694b78927 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1030,7 +1030,6 @@ void tipc_link_reset(struct tipc_link *l)
int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,
struct sk_buff_head *xmitq)
{
- struct tipc_msg *hdr = buf_msg(skb_peek(list));
struct sk_buff_head *backlogq = &l->backlogq;
struct sk_buff_head *transmq = &l->transmq;
struct sk_buff *skb, *_skb;
@@ -1038,13 +1037,18 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,
u16 ack = l->rcv_nxt - 1;
u16 seqno = l->snd_nxt;
int pkt_cnt = skb_queue_len(list);
- int imp = msg_importance(hdr);
unsigned int mss = tipc_link_mss(l);
unsigned int cwin = l->window;
unsigned int mtu = l->mtu;
+ struct tipc_msg *hdr;
bool new_bundle;
int rc = 0;
+ int imp;
+
+ if (pkt_cnt <= 0)
+ return 0;
+ hdr = buf_msg(skb_peek(list));
if (unlikely(msg_size(hdr) > mtu)) {
pr_warn("Too large msg, purging xmit list %d %d %d %d %d!\n",
skb_queue_len(list), msg_user(hdr),
@@ -1053,6 +1057,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,
return -EMSGSIZE;
}
+ imp = msg_importance(hdr);
/* Allow oversubscription of one data msg per source at congestion */
if (unlikely(l->backlog[imp].len >= l->backlog[imp].limit)) {
if (imp == TIPC_SYSTEM_IMPORTANCE) {
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [net v2] tipc: fix NULL deref in tipc_link_xmit()
2021-01-08 7:13 [net v2] tipc: fix NULL deref in tipc_link_xmit() Hoang Huu Le
@ 2021-01-10 0:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-01-10 0:20 UTC (permalink / raw)
To: Hoang Huu Le; +Cc: netdev, ying.xue, maloy, jmaloy
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
On Fri, 8 Jan 2021 14:13:37 +0700 you wrote:
> From: Hoang Le <hoang.h.le@dektech.com.au>
>
> The buffer list can have zero skb as following path:
> tipc_named_node_up()->tipc_node_xmit()->tipc_link_xmit(), so
> we need to check the list before casting an &sk_buff.
>
> Fault report:
> [] tipc: Bulk publication failure
> [] general protection fault, probably for non-canonical [#1] PREEMPT [...]
> [] KASAN: null-ptr-deref in range [0x00000000000000c8-0x00000000000000cf]
> [] CPU: 0 PID: 0 Comm: swapper/0 Kdump: loaded Not tainted 5.10.0-rc4+ #2
> [] Hardware name: Bochs ..., BIOS Bochs 01/01/2011
> [] RIP: 0010:tipc_link_xmit+0xc1/0x2180
> [] Code: 24 b8 00 00 00 00 4d 39 ec 4c 0f 44 e8 e8 d7 0a 10 f9 48 [...]
> [] RSP: 0018:ffffc90000006ea0 EFLAGS: 00010202
> [] RAX: dffffc0000000000 RBX: ffff8880224da000 RCX: 1ffff11003d3cc0d
> [] RDX: 0000000000000019 RSI: ffffffff886007b9 RDI: 00000000000000c8
> [] RBP: ffffc90000007018 R08: 0000000000000001 R09: fffff52000000ded
> [] R10: 0000000000000003 R11: fffff52000000dec R12: ffffc90000007148
> [] R13: 0000000000000000 R14: 0000000000000000 R15: ffffc90000007018
> [] FS: 0000000000000000(0000) GS:ffff888037400000(0000) knlGS:000[...]
> [] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [] CR2: 00007fffd2db5000 CR3: 000000002b08f000 CR4: 00000000000006f0
>
> [...]
Here is the summary with links:
- [net,v2] tipc: fix NULL deref in tipc_link_xmit()
https://git.kernel.org/netdev/net/c/b77413446408
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-10 0:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 7:13 [net v2] tipc: fix NULL deref in tipc_link_xmit() Hoang Huu Le
2021-01-10 0:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).