[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191026142458.GJ23523@kadam>
Date: Sat, 26 Oct 2019 17:24:58 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: zhanglin <zhang.lin16@....com.cn>
Cc: davem@...emloft.net, ast@...nel.org, daniel@...earbox.net,
jakub.kicinski@...ronome.com, hawk@...nel.org,
john.fastabend@...il.com, mkubecek@...e.cz, jiri@...lanox.com,
pablo@...filter.org, f.fainelli@...il.com,
maxime.chevallier@...tlin.com, lirongqing@...du.com,
vivien.didelot@...il.com, linyunsheng@...wei.com,
natechancellor@...il.com, arnd@...db.de, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
xue.zhihong@....com.cn, wang.yi59@....com.cn,
jiang.xuexin@....com.cn
Subject: Re: [PATCH] net: Zeroing the structure ethtool_wolinfo in
ethtool_get_wol()
On Sat, Oct 26, 2019 at 03:54:16PM +0800, zhanglin wrote:
> memset() the structure ethtool_wolinfo that has padded bytes
> but the padded bytes have not been zeroed out.
>
> Signed-off-by: zhanglin <zhang.lin16@....com.cn>
> ---
> net/core/ethtool.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> index aeabc48..563a845 100644
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -1471,11 +1471,13 @@ static int ethtool_reset(struct net_device *dev, char __user *useraddr)
>
> static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
> {
> - struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
> + struct ethtool_wolinfo wol;
>
How did you detect that they weren't initialized? Is this a KASAN
thing?
Most of the time GCC will zero out the padding bytes when you have an
initializer like this, but sometimes it just makes the intialization a
series of assignments which leaves the holes uninitialized. I wish I
knew the rules so that I could check for it in Smatch. Or even better,
I wish that there were an option to always zero the holes in this
situation...
regards,
dan carpenter
Powered by blists - more mailing lists