Linux NFS development
 help / color / mirror / Atom feed
From: Yihao Wu <wuyihao@linux.alibaba.com>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: Bruce Fields <bfields@fieldses.org>, Neil Brown <neilb@suse.de>,
	Sasha Levin <sashal@kernel.org>,
	Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH v3] SUNRPC/cache: Fix unsafe traverse caused double-free in cache_purge
Date: Mon, 6 Apr 2020 02:31:41 +0800	[thread overview]
Message-ID: <25dcf75e-65b1-b6e8-1fe5-81a193ed4189@linux.alibaba.com> (raw)
In-Reply-To: <0308EB8A-A8B7-412C-8F93-A444DE47CB1D@oracle.com>

>> net/sunrpc/cache.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
>> index af0ddd28b081..b445874e8e2f 100644
>> --- a/net/sunrpc/cache.c
>> +++ b/net/sunrpc/cache.c
>> @@ -541,7 +541,9 @@ void cache_purge(struct cache_detail *detail)
>> 	dprintk("RPC: %d entries in %s cache\n", detail->entries, detail->name);
>> 	for (i = 0; i < detail->hash_size; i++) {
>> 		head = &detail->hash_table[i];
>> -		hlist_for_each_entry_safe(ch, tmp, head, cache_list) {
> 
> If review/testing shows you need to respin this patch, I note that "tmp" is
> now unused and should be removed. I've pulled v3 into my testing branch and
> made that minor change. Thanks!
> 
> 
>> +		while (!hlist_empty(head)) {
>> +			ch = hlist_entry(head->first, struct cache_head,
>> +					 cache_list);
>> 			sunrpc_begin_cache_remove_entry(ch, detail);
>> 			spin_unlock(&detail->hash_lock);
>> 			sunrpc_end_cache_remove_entry(ch, detail);
>> -- 
>> 2.20.1.2432.ga663e714
> 
> --
> Chuck Lever
> 
> 

Thanks a lot, Chuck!

If it needs further changes by me, I'll fix the unused 'tmp' along with them.

BTW, if you and Neil think it's proper to add Signed-off-by Neil too later,
please do, since the bug fix owes to Neil's idea :-)

Yihao Wu

  reply	other threads:[~2020-04-05 18:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-05 17:38 [PATCH v2] SUNRPC/cache: Fix unsafe traverse caused double-free in cache_purge Yihao Wu
2020-04-05 17:57 ` [PATCH v3] " Yihao Wu
2020-04-05 18:07   ` Chuck Lever
2020-04-05 18:31     ` Yihao Wu [this message]
2020-04-05 18:35       ` Chuck Lever
2020-04-06  0:03   ` NeilBrown

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=25dcf75e-65b1-b6e8-1fe5-81a193ed4189@linux.alibaba.com \
    --to=wuyihao@linux.alibaba.com \
    --cc=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=sashal@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