Re: Re: [PATCH] SUNRPC: Convert from atomic_t to refcount_t on rpc_clnt->cl_count
From: Xiyu Yang <hidden>
Date: 2021-07-17 16:33:32
Also in:
linux-nfs, lkml
Sorry, I'm not sure why you need to bump a zero refcount in a normal situation. But maybe we can use refcount_inc_not_zero() API in rpc_free_auth() instead?
-----Original Messages----- From: "Trond Myklebust" <redacted> Sent Time: 2021-07-17 22:43:26 (Saturday) To: "tanxin.ctf@gmail.com" <redacted>, "xiyuyang19@fudan.edu.cn" <redacted>, "davem@davemloft.net" <davem@davemloft.net>, "chuck.lever@oracle.com" <redacted>, "linux-kernel@vger.kernel.org" <redacted>, "kolga@netapp.com" <redacted>, "kuba@kernel.org" <kuba@kernel.org>, "netdev@vger.kernel.org" <redacted>, "bfields@fieldses.org" <redacted>, "anna.schumaker@netapp.com" <redacted>, "linux-nfs@vger.kernel.org" <redacted> Cc: "yuanxzhang@fudan.edu.cn" <redacted> Subject: Re: [PATCH] SUNRPC: Convert from atomic_t to refcount_t on rpc_clnt->cl_count On Sat, 2021-07-17 at 18:18 +0800, Xiyu Yang wrote:quoted
refcount_t type and corresponding API can protect refcounters from accidental underflow and overflow and further use-after-free situations.Have you tested this patch? As far as I remember, the reason why we never converted is that refcount_inc() gets upset and WARNs when you bump a zero refcount, like we do very much on purpose in rpc_free_auth(). Is that no longer the case? -- Trond Myklebust Linux NFS client maintainer, Hammerspace trond.myklebust@hammerspace.com