lkml.org 
[lkml]   [2017]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] block/drbd: Fix a sleep-in-atomic bug in drbd_bcast_event
Date
The driver may sleep under a RCU lock, and the function call path is:
drbd_sync_handshake (acquire the RCU lock)
drbd_asb_recover_1p
drbd_khelper
drbd_bcast_event
genlmsg_new(GFP_NOIO) --> may sleep

To fix it, GFP_NOIO is replaced with GFP_ATOMIC.
This bug is found by my static analysis tool and my code review.


Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
---
drivers/block/drbd/drbd_nl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index a12f77e..713c965 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -4537,7 +4537,7 @@ void drbd_bcast_event(struct drbd_device *device, const struct sib_info *sib)
int err = -ENOMEM;

seq = atomic_inc_return(&drbd_genl_seq);
- msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
+ msg = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
if (!msg)
goto failed;

--
1.7.9.5

\
 
 \ /
  Last update: 2017-10-04 03:31    [W:0.061 / U:2.528 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site