diff options
author | Jia-Ju Bai <baijiaju1990@163.com> | 2017-06-10 04:49:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-10 18:19:45 -0400 |
commit | f146e872eb12ebbe92d8e583b2637e0741440db3 (patch) | |
tree | 11df674fe1f70d91c86b2a63cfec66f8823ecfd1 | |
parent | 5aa32f53ab93175442dffbd95a231d0798cab4d1 (diff) |
net: caif: Fix a sleep-in-atomic bug in cfpkt_create_pfx
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>
-rw-r--r-- | net/caif/cfpkt_skbuff.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/net/caif/cfpkt_skbuff.c b/net/caif/cfpkt_skbuff.c index 59ce1fcc220c..71b6ab240dea 100644 --- a/net/caif/cfpkt_skbuff.c +++ b/net/caif/cfpkt_skbuff.c | |||
@@ -81,11 +81,7 @@ static struct cfpkt *cfpkt_create_pfx(u16 len, u16 pfx) | |||
81 | { | 81 | { |
82 | struct sk_buff *skb; | 82 | struct sk_buff *skb; |
83 | 83 | ||
84 | if (likely(in_interrupt())) | 84 | skb = alloc_skb(len + pfx, GFP_ATOMIC); |
85 | skb = alloc_skb(len + pfx, GFP_ATOMIC); | ||
86 | else | ||
87 | skb = alloc_skb(len + pfx, GFP_KERNEL); | ||
88 | |||
89 | if (unlikely(skb == NULL)) | 85 | if (unlikely(skb == NULL)) |
90 | return NULL; | 86 | return NULL; |
91 | 87 | ||