bluetooth: use GFP_ATOMIC in *_sock_create's sk_alloc
Subsystems (3)
PATCH 2/2 bluetooth: use GFP_ATOMIC in *_sock_create's sk_alloc
From: Frederik Deweerdt <[email protected]>
I think that the bluetooth-guard-bt_proto-with-rwlock.patch introduced the following BUG:
[ 43.232000] BUG: sleeping function called from invalid context at mm/slab.c:2903 [ 43.232000] in_atomic():1, irqs_disabled():0 [ 43.232000] [<c0104114>] show_trace_log_lvl+0x197/0x1ba [ 43.232000] [<c010415e>] show_trace+0x27/0x29 [ 43.232000] [<c010426e>] dump_stack+0x26/0x28 [ 43.232000] [<c011ad1c>] __might_sleep+0xa2/0xaa [ 43.232000] [<c0173085>] __kmalloc+0x9c/0xb3 [ 43.232000] [<c02f9295>] sk_alloc+0x1bc/0x1de [ 43.232000] [<c036d689>] hci_sock_create+0x42/0x8a [ 43.236000] [<c0366f40>] bt_sock_create+0xb5/0x154 [ 43.236000] [<c02f69dc>] __sock_create+0x131/0x356 [ 43.236000] [<c02f6c2f>] sock_create+0x2e/0x30 [ 43.236000] [<c02f6c88>] sys_socket+0x27/0x53 [ 43.240000] [<c02f7db5>] sys_socketcall+0xa9/0x277 [ 43.240000] [<c0103131>] sysenter_past_esp+0x56/0x8d [ 43.240000] [<b7f38410>] 0xb7f38410
This patch makes sk_alloc GFP_ATOMIC, because we are holding the bt_proto_rwlock, for the following functions:
- bnep_sock_create
- cmtp_sock_create
- hci_sock_create
- hidp_sock_create
- l2cap_sock_create
- rfcomm_sock_create
- sco_sock_create
Signed-off-by Frederik Deweerdt <[email protected]>
Cc Masatake YAMATO <[email protected]>
Cc Marcel Holtmann <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
net/bluetooth/bnep/sock.c | 2 +- net/bluetooth/cmtp/sock.c | 2 +- net/bluetooth/hci_sock.c | 2 +- net/bluetooth/hidp/sock.c | 2 +- net/bluetooth/l2cap.c | 2 +- net/bluetooth/rfcomm/sock.c | 2 +- net/bluetooth/sco.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-)
net/bluetooth/bnep/sock.c renamed from net/bluetooth/bnep/sock.c~bluetooth-use-gfp_atomic-in-_sock_creates-sk_alloc +1 -1
@@ -181,7 +181,7 @@ static int bnep_sock_create(struct sockeif (sock->type !=SOCK_RAW )return -ESOCKTNOSUPPORT ; - sk =sk_alloc (PF_BLUETOOTH ,GFP_KERNEL , &bnep_proto,1 ); + sk =sk_alloc (PF_BLUETOOTH ,GFP_ATOMIC , &bnep_proto,1 );if (!sk)return -ENOMEM ;
net/bluetooth/cmtp/sock.c renamed from net/bluetooth/cmtp/sock.c~bluetooth-use-gfp_atomic-in-_sock_creates-sk_alloc +1 -1
@@ -172,7 +172,7 @@ static int cmtp_sock_create(struct sockeif (sock->type !=SOCK_RAW )return -ESOCKTNOSUPPORT ; - sk =sk_alloc (PF_BLUETOOTH ,GFP_KERNEL , &cmtp_proto,1 ); + sk =sk_alloc (PF_BLUETOOTH ,GFP_ATOMIC , &cmtp_proto,1 );if (!sk)return -ENOMEM ;
net/bluetooth/hci_sock.c renamed from net/bluetooth/hci_sock.c~bluetooth-use-gfp_atomic-in-_sock_creates-sk_alloc +1 -1
@@ -618,7 +618,7 @@ static int hci_sock_create(struct socket sock->ops = &hci_sock_ops; - sk =sk_alloc (PF_BLUETOOTH ,GFP_KERNEL , &hci_sk_proto,1 ); + sk =sk_alloc (PF_BLUETOOTH ,GFP_ATOMIC , &hci_sk_proto,1 );if (!sk)return -ENOMEM ;
net/bluetooth/hidp/sock.c renamed from net/bluetooth/hidp/sock.c~bluetooth-use-gfp_atomic-in-_sock_creates-sk_alloc +1 -1
@@ -178,7 +178,7 @@ static int hidp_sock_create(struct sockeif (sock->type !=SOCK_RAW )return -ESOCKTNOSUPPORT ; - sk =sk_alloc (PF_BLUETOOTH ,GFP_KERNEL , &hidp_proto,1 ); + sk =sk_alloc (PF_BLUETOOTH ,GFP_ATOMIC , &hidp_proto,1 );if (!sk)return -ENOMEM ;
net/bluetooth/l2cap.c renamed from net/bluetooth/l2cap.c~bluetooth-use-gfp_atomic-in-_sock_creates-sk_alloc +1 -1
@@ -559,7 +559,7 @@ static int l2cap_sock_create(struct sock sock->ops = &l2cap_sock_ops; - sk =l2cap_sock_alloc (sock, protocol,GFP_KERNEL ); + sk =l2cap_sock_alloc (sock, protocol,GFP_ATOMIC );if (!sk)return -ENOMEM ;
net/bluetooth/rfcomm/sock.c renamed from net/bluetooth/rfcomm/sock.c~bluetooth-use-gfp_atomic-in-_sock_creates-sk_alloc +1 -1
@@ -336,7 +336,7 @@ static int rfcomm_sock_create(struct soc sock->ops = &rfcomm_sock_ops; -if (!(sk =rfcomm_sock_alloc (sock, protocol,GFP_KERNEL ))) +if (!(sk =rfcomm_sock_alloc (sock, protocol,GFP_ATOMIC )))return -ENOMEM ;rfcomm_sock_init (sk,NULL );
net/bluetooth/sco.c renamed from net/bluetooth/sco.c~bluetooth-use-gfp_atomic-in-_sock_creates-sk_alloc +1 -1
@@ -452,7 +452,7 @@ static int sco_sock_create(struct socket sock->ops = &sco_sock_ops; -if (!(sk =sco_sock_alloc (sock, protocol,GFP_KERNEL ))) +if (!(sk =sco_sock_alloc (sock, protocol,GFP_ATOMIC )))return -ENOMEM ;sco_sock_init (sk,NULL );
_