[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <19237943-5a2d-4930-9aa5-6419819ff51c@lunn.ch>
Date: Fri, 11 Apr 2025 14:22:20 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Zilin Guan <zilin@....edu.cn>
Cc: wenjia@...ux.ibm.com, jaka@...ux.ibm.com, alibuda@...ux.alibaba.com,
tonylu@...ux.alibaba.com, guwen@...ux.alibaba.com,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, horms@...nel.org, linux-rdma@...r.kernel.org,
linux-s390@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, jianhao.xu@....edu.cn
Subject: Re: [RFC PATCH] net/smc: Consider using kfree_sensitive() to free
cpu_addr
On Fri, Apr 11, 2025 at 04:44:56AM +0000, Zilin Guan wrote:
> Hello,
>
> In smcr_buf_unuse() and smc_buf_unuse(), memzero_explicit() is used to
> clear cpu_addr when it is no longer in use, suggesting that cpu_addr
> may contain sensitive information.
>
> To ensure proper handling of this sensitive memory, I propose using
> kfree_sensitive()/kvfree_sensitive instead of kfree()/vfree() to free
> cpu_addr in both smcd_buf_free() and smc_buf_free(). This change aims
> to prevent potential sensitive data leaks.
There is another possible meaning:
memzero_explicit(conn->sndbuf_desc->cpu_addr, bufsize);
WRITE_ONCE(conn->sndbuf_desc->used, 0);
The WRITE_ONCE() probably tells the hardware the buffer is ready for
it. In order to ensure they memzero has completed and that the
compiler does not reorder the instructions you need a memory barrier:
static inline void memzero_explicit(void *s, size_t count)
{
memset(s, 0, count);
barrier_data(s);
}
So it could be using memzero_explicit() just for the barrier_data().
Please spend some time to analyze this code, look at the git history
etc, see if there are any clues as to why memzero_explicit is used, or
if there is any indication of sensitive information.
Andrew
Powered by blists - more mailing lists