From: Jia-Ju Bai <baijiaju1990@163.com>
To: viro@zeniv.linux.org.uk, jack@suse.com, sagi@grimberg.me,
james.smart@broadcom.com
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, Jia-Ju Bai <baijiaju1990@163.com>
Subject: [PATCH] ext2/super: Fix a possible sleep-in-atomic bug in parse_options
Date: Sat, 7 Oct 2017 09:20:46 +0800 [thread overview]
Message-ID: <1507339246-13067-1-git-send-email-baijiaju1990@163.com> (raw)
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
next reply other threads:[~2017-10-07 1:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-07 1:20 Jia-Ju Bai [this message]
2017-10-07 1:37 ` [PATCH] ext2/super: Fix a possible sleep-in-atomic bug in parse_options 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1507339246-13067-1-git-send-email-baijiaju1990@163.com \
--to=baijiaju1990@163.com \
--cc=jack@suse.com \
--cc=james.smart@broadcom.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sagi@grimberg.me \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).