Skip to content
This repository was archived by the owner on Jun 4, 2020. It is now read-only.

Commit e1f1dea

Browse files
XidianGeneralgregkh
authored andcommitted
net: caif: Fix a sleep-in-atomic bug in cfpkt_create_pfx
[ Upstream commit f146e872eb12ebbe92d8e583b2637e0741440db3 ] The kernel may sleep under a rcu read lock in cfpkt_create_pfx, and the function call path is: cfcnfg_linkup_rsp (acquire the lock by rcu_read_lock) cfctrl_linkdown_req cfpkt_create cfpkt_create_pfx alloc_skb(GFP_KERNEL) --> may sleep cfserl_receive (acquire the lock by rcu_read_lock) cfpkt_split cfpkt_create_pfx alloc_skb(GFP_KERNEL) --> may sleep There is "in_interrupt" in cfpkt_create_pfx to decide use "GFP_KERNEL" or "GFP_ATOMIC". In this situation, "GFP_KERNEL" is used because the function is called under a rcu read lock, instead in interrupt. To fix it, only "GFP_ATOMIC" is used in cfpkt_create_pfx. Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 721ee8d commit e1f1dea

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

net/caif/cfpkt_skbuff.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,7 @@ static struct cfpkt *cfpkt_create_pfx(u16 len, u16 pfx)
8181
{
8282
struct sk_buff *skb;
8383

84-
if (likely(in_interrupt()))
85-
skb = alloc_skb(len + pfx, GFP_ATOMIC);
86-
else
87-
skb = alloc_skb(len + pfx, GFP_KERNEL);
88-
84+
skb = alloc_skb(len + pfx, GFP_ATOMIC);
8985
if (unlikely(skb == NULL))
9086
return NULL;
9187

0 commit comments

Comments
 (0)