From: Jeff Layton <jlayton@redhat.com>
To: Jia-Ju Bai <baijiaju1990@163.com>,
dhowells@redhat.com, viro@zeniv.linux.org.uk,
bfields@fieldses.org
Cc: linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs/afs/flock and fs/locks: Fix possible sleep-in-atomic bugs in posix_lock_file
Date: Sat, 07 Oct 2017 06:36:57 -0400 [thread overview]
Message-ID: <1507372617.26934.0.camel@redhat.com> (raw)
In-Reply-To: <1507370104-21751-1-git-send-email-baijiaju1990@163.com>
On Sat, 2017-10-07 at 17:55 +0800, Jia-Ju Bai wrote:
> The kernel may sleep under a spinlock, and the function call paths are:
> afs_do_unlk (acquire the spinlock)
> posix_lock_file
> posix_lock_inode (fs/locks.c)
> locks_get_lock_context
> kmem_cache_alloc(GFP_KERNEL) --> may sleep
>
> afs_do_setlk (acquire the spinlock)
> posix_lock_file
> posix_lock_inode (fs/locks.c)
> locks_get_lock_context
> kmem_cache_alloc(GFP_KERNEL) --> may sleep
>
> To fix them, GFP_KERNEL is replaced with GFP_ATOMIC.
> These bugs are found by my static analysis tool and my code review.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
> ---
> fs/locks.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index 1bd71c4..975cc62 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -222,7 +222,7 @@ struct file_lock_list_struct {
> if (likely(ctx) || type == F_UNLCK)
> goto out;
>
> - ctx = kmem_cache_alloc(flctx_cache, GFP_KERNEL);
> + ctx = kmem_cache_alloc(flctx_cache, GFP_ATOMIC);
> if (!ctx)
> goto out;
>
NAK
This needs to be fixed in the AFS code. It should not be calling these
functions with a spinlock held.
--
Jeff Layton <jlayton@redhat.com>
next prev parent reply other threads:[~2017-10-07 10:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-07 9:55 [PATCH] fs/afs/flock and fs/locks: Fix possible sleep-in-atomic bugs in posix_lock_file Jia-Ju Bai
2017-10-07 10:36 ` Jeff Layton [this message]
2017-10-08 1:07 ` J. Bruce Fields
2017-10-11 9:47 ` David Howells
2017-10-11 13:45 ` J. Bruce Fields
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=1507372617.26934.0.camel@redhat.com \
--to=jlayton@redhat.com \
--cc=baijiaju1990@163.com \
--cc=bfields@fieldses.org \
--cc=dhowells@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.