]> git.baikalelectronics.ru Git - kernel.git/commit
net: caif: Fix a sleep-in-atomic bug in cfpkt_create_pfx
authorJia-Ju Bai <baijiaju1990@163.com>
Sat, 10 Jun 2017 08:49:39 +0000 (16:49 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 10 Jun 2017 22:19:45 +0000 (18:19 -0400)
commite44f0813a642bc77ae4273bdde689014538fa7f9
tree11df674fe1f70d91c86b2a63cfec66f8823ecfd1
parent3222a2a7c8af7c7b4b2e4c521417f44050adfc26
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>
net/caif/cfpkt_skbuff.c