linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cachefiles: Fix a sleep-in-atomic bug in cachefiles_printk_object
@ 2017-06-05  3:55 Jia-Ju Bai
  0 siblings, 0 replies; only message in thread
From: Jia-Ju Bai @ 2017-06-05  3:55 UTC (permalink / raw)
  To: dhowells; +Cc: linux-cachefs, linux-kernel, Jia-Ju Bai

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 <baijiaju1990@163.com>
---
 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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-05  4:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05  3:55 [PATCH] cachefiles: Fix a sleep-in-atomic bug in cachefiles_printk_object Jia-Ju Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).