[PATCH] fs/cachefiles: Fix a possible sleep-in-atomic bug in cachefiles_printk_object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The kernel may sleep under a write spinlock, and the function call path is:
cachefiles_mark_object_active (acquire the spinlock)
  cachefiles_printk_object
    kmalloc(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@xxxxxxx>
---
 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 3978b32..39e1504 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





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux