Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751271AbdFEEIc (ORCPT ); Mon, 5 Jun 2017 00:08:32 -0400 Received: from m12-12.163.com ([220.181.12.12]:47204 "EHLO m12-12.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751230AbdFEEIb (ORCPT ); Mon, 5 Jun 2017 00:08:31 -0400 From: Jia-Ju Bai To: dhowells@redhat.com Cc: linux-cachefs@redhat.com, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] cachefiles: Fix a sleep-in-atomic bug in cachefiles_printk_object Date: Mon, 5 Jun 2017 11:55:38 +0800 Message-Id: <1496634938-19315-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: DMCowAA3PByn1TRZCwVxIg--.33330S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7JF4UGF4fur43Kr43tF4ruFg_yoWDAFcE9F 97Ar18XF4fWryxKw47C3yvqFWYgw13Cwn0yFyrtw13Z3sxJrWrCFyDAr9rJFy3XF18uayU Jrn3ZFy5ur17WjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbCJm5UUUUU== X-Originating-IP: [166.111.70.19] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/xtbBRQrtelO-7aO8mAAAse Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 984 Lines: 32 The driver may sleep under a write spin lock, and the function call path is: cachefiles_mark_object_active (acquire the lock by write_lock) cachefiles_printk_object kmalloc(GFP_NOIO) --> may sleep cachefiles_mark_object_buried (acquire the lock by write_lock) cachefiles_printk_object kmalloc(GFP_NOIO) --> may sleep To fix it, "GFP_NOIO" is replaced with "GFP_ATOMIC". Signed-off-by: Jia-Ju Bai --- fs/cachefiles/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 41df8a2..d0f76e7 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -83,7 +83,7 @@ static noinline void cachefiles_printk_object(struct cachefiles_object *object, { u8 *keybuf; - keybuf = kmalloc(CACHEFILES_KEYBUF_SIZE, GFP_NOIO); + keybuf = kmalloc(CACHEFILES_KEYBUF_SIZE, GFP_ATOMIC); if (object) __cachefiles_printk_object(object, "", keybuf); if (xobject) -- 1.7.9.5