Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2600526ybb; Sun, 5 Apr 2020 11:34:58 -0700 (PDT) X-Google-Smtp-Source: APiQypIQtPMkIJf0YwDBwsogJ9ozeXejKbh9pz+8478rM5fdM385kdEqvrVHwdoKGwgZill5n7NL X-Received: by 2002:a4a:929b:: with SMTP id i27mr557101ooh.95.1586111698659; Sun, 05 Apr 2020 11:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586111698; cv=none; d=google.com; s=arc-20160816; b=rAUAg0NgApJvN2Qek76cxJ/bvogGwaSZPi0idBp/Tl5f6MJY7rt0j/D40Oitcwx7cp XyVLlvifbi2ctulbkz2pujET3rDQS8p+ZkuGAoIrFAvmHkJnl8vl3rrUfcm9YxDtmEh1 kH6tZvQ/vwqg3clcMY6e8YSETHpByMwwCRX+v25Sa+h6MYReoqF+KScjuL7ZTq2No2JV H6W0BKyV9Pdu0v6DQwYbojcpxJj/nLESGmutsFKZLcFwnCzNN2pOvl6zf8O/Pudx+Z8i FGN+VihpMzI0n1gIa8BUYbQhrVR+7zu5vMIfmPz9SmldybcpX44DZNuT4LhxTJAjAxIG oLbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=oobeNHWqUS98conuyFDBe8Gdq6oso+92OhmhzoMDv7M=; b=Vc7bLo4HrDoZjWHnT4qj5+QHTgyuBQuEaz2rxRXgAPaY1YTAXxaTGPghgQoHEWIcz8 b9nZnCXP82Vbu1qxWvhILQxinFVLlvZbk09PoJpCLDI9XKyGI8fxqQgBBEdux08J+mbp igOyFoGzk7Ynvb3MoZw3sSn95PTRAb6flf1brQjYvzYmjE0yiN2wI9YDg+PF8Ywb8oN3 Qr46JqVwBgo1xs08D+Rdwar4dKKE+p5K8dWYlllsFLWkDTk0hYwSY9yhEjcsRUreRZ8G hEYH9/9g4FYKf1SkeMCJretJ9EELqqatT/FCfpfuslsXx6JiAE0xDmcsJOTRv7qhTpZ6 bN4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m8si6305714oim.26.2020.04.05.11.34.28; Sun, 05 Apr 2020 11:34:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727254AbgDESbp (ORCPT + 99 others); Sun, 5 Apr 2020 14:31:45 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:8929 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726771AbgDESbp (ORCPT ); Sun, 5 Apr 2020 14:31:45 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07484;MF=wuyihao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0TugA-z5_1586111501; Received: from Macintosh.local(mailfrom:wuyihao@linux.alibaba.com fp:SMTPD_---0TugA-z5_1586111501) by smtp.aliyun-inc.com(127.0.0.1); Mon, 06 Apr 2020 02:31:42 +0800 Subject: Re: [PATCH v3] SUNRPC/cache: Fix unsafe traverse caused double-free in cache_purge To: Chuck Lever Cc: Bruce Fields , Neil Brown , Sasha Levin , Linux NFS Mailing List References: <4568a7cf87f110b8e59fda6f53fda34c550ab403.1586108200.git.wuyihao@linux.alibaba.com> <0308EB8A-A8B7-412C-8F93-A444DE47CB1D@oracle.com> From: Yihao Wu Message-ID: <25dcf75e-65b1-b6e8-1fe5-81a193ed4189@linux.alibaba.com> Date: Mon, 6 Apr 2020 02:31:41 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <0308EB8A-A8B7-412C-8F93-A444DE47CB1D@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org >> 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