[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20171009140827.jlr5hwsrofn7x4ld@rck.sh>
Date: Mon, 9 Oct 2017 16:08:27 +0200
From: Roland Kammerer <roland.kammerer@...bit.com>
To: Jia-Ju Bai <baijiaju1990@....com>
Cc: philipp.reisner@...bit.com, lars.ellenberg@...bit.com,
linux-kernel@...r.kernel.org, drbd-dev@...ts.linbit.com
Subject: Re: [Drbd-dev] [PATCH] block/drbd: Fix a sleep-in-atomic bug in
drbd_bcast_event
On Wed, Oct 04, 2017 at 09:33:18AM +0800, Jia-Ju Bai wrote:
> 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@....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;
Hi Jia-Ju,
thanks for reporting that. I fixed that by narrowing the scope of the
rcu_lock in drbd_sync_handshake() while keeping the code down the rabbit
hole untouched. This has the benefit that it fixes all your 3 cases.
As usual, we will send that upstream soon.
Thanks, rck
Powered by blists - more mailing lists