linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext2/super: Fix a possible sleep-in-atomic bug in parse_options
@ 2017-10-07  1:20 Jia-Ju Bai
  2017-10-07  1:37 ` Linus Torvalds
  2017-10-08 22:20 ` Dave Chinner
  0 siblings, 2 replies; 7+ messages in thread
From: Jia-Ju Bai @ 2017-10-07  1:20 UTC (permalink / raw)
  To: viro, jack, sagi, james.smart
  Cc: linux-ext4, linux-fsdevel, linux-kernel, Jia-Ju Bai

The kernel may sleep under a spinlock, and the function call path is:
ext2_remount
  parse_options
    match_int
      match_number (lib/parser.c)
        kmalloc(GFP_KERNEL) --> may sleep

To fix it, GFP_KERNEL 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>
---
 lib/parser.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/parser.c b/lib/parser.c
index 3278958..bc6e2ce 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -133,7 +133,7 @@ static int match_number(substring_t *s, int *result, int base)
 	long val;
 	size_t len = s->to - s->from;
 
-	buf = kmalloc(len + 1, GFP_KERNEL);
+	buf = kmalloc(len + 1, GFP_ATOMIC);
 	if (!buf)
 		return -ENOMEM;
 	memcpy(buf, s->from, len);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-09 13:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-07  1:20 [PATCH] ext2/super: Fix a possible sleep-in-atomic bug in parse_options Jia-Ju Bai
2017-10-07  1:37 ` Linus Torvalds
2017-10-07  1:55   ` Jia-Ju Bai
2017-10-07  2:02   ` Al Viro
2017-10-07  2:28     ` Al Viro
2017-10-09 13:32     ` Jan Kara
2017-10-08 22:20 ` Dave Chinner

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).