From: Trond Myklebust <trondmy@primarydata.com>
To: "baijiaju1990@163.com" <baijiaju1990@163.com>,
"anna.schumaker@netapp.com" <anna.schumaker@netapp.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH] fs: nfs: Fix a sleep-in-atomic bug in nfs_access_add_cache
Date: Mon, 5 Jun 2017 11:48:37 +0000 [thread overview]
Message-ID: <1496663315.3433.1.camel@primarydata.com> (raw)
In-Reply-To: <1496649904-1855-1-git-send-email-baijiaju1990@163.com>
On Mon, 2017-06-05 at 16:05 +0800, Jia-Ju Bai wrote:
> The driver may sleep under a rcu read lock, and function call path
> is:
> nfs_permission (acquire the lock by rcu_read_lock)
> nfs_do_access
> nfs_access_add_cache
> kmalloc(GFP_KERNEL) --> may sleep
>
> To fix it, "GFP_KERNEL" is replaced with "GFP_ATOMIC".
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
> ---
> fs/nfs/dir.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 32ccd77..7a074db 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -2333,7 +2333,7 @@ static void nfs_access_add_rbtree(struct inode
> *inode, struct nfs_access_entry *
>
> void nfs_access_add_cache(struct inode *inode, struct
> nfs_access_entry *set)
> {
> - struct nfs_access_entry *cache = kmalloc(sizeof(*cache),
> GFP_KERNEL);
> + struct nfs_access_entry *cache = kmalloc(sizeof(*cache),
> GFP_ATOMIC);
> if (cache == NULL)
> return;
> RB_CLEAR_NODE(&cache->rb_node);
The RCU locked codepath will not ever hit nfs_access_add_rbtree(). It
returns with an error code of -ECHILD after the test of "may_block".
Cheers
Trond
--
Trond Myklebust
Linux NFS client maintainer, PrimaryData
trond.myklebust@primarydata.com
next prev parent reply other threads:[~2017-06-05 11:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-05 8:05 [PATCH] fs: nfs: Fix a sleep-in-atomic bug in nfs_access_add_cache Jia-Ju Bai
2017-06-05 11:48 ` Trond Myklebust [this message]
2017-06-05 12:36 ` Jia-Ju Bai
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=1496663315.3433.1.camel@primarydata.com \
--to=trondmy@primarydata.com \
--cc=anna.schumaker@netapp.com \
--cc=baijiaju1990@163.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
/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