lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241023185850.GC402847@kernel.org>
Date: Wed, 23 Oct 2024 19:58:50 +0100
From: Simon Horman <horms@...nel.org>
To: Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	David Ahern <dsahern@...nel.org>,
	Kuniyuki Iwashima <kuni1840@...il.com>, netdev@...r.kernel.org,
	kernel test robot <lkp@...el.com>
Subject: Re: [PATCH v1 net-next 01/12] rtnetlink: Make per-netns RTNL
 dereference helpers to macro.

On Mon, Oct 21, 2024 at 11:32:28AM -0700, Kuniyuki Iwashima wrote:
> When CONFIG_DEBUG_NET_SMALL_RTNL is off, rtnl_net_dereference() is the
> static inline wrapper of rtnl_dereference() returning a plain (void *)
> pointer to make sure net is always evaluated as requested in [0].
> 
> But, it makes sparse complain [1] when the pointer has __rcu annotation:
> 
>   net/ipv4/devinet.c:674:47: sparse: warning: incorrect type in argument 2 (different address spaces)
>   net/ipv4/devinet.c:674:47: sparse:    expected void *p
>   net/ipv4/devinet.c:674:47: sparse:    got struct in_ifaddr [noderef] __rcu *
> 
> Also, if we evaluate net as (void *) in a macro, then the compiler
> in turn fails to build due to -Werror=unused-value.
> 
>   #define rtnl_net_dereference(net, p)                  \
>         ({                                              \
>                 (void *)net;                            \
>                 rtnl_dereference(p);                    \
>         })
> 
>   net/ipv4/devinet.c: In function ‘inet_rtm_deladdr’:
>   ./include/linux/rtnetlink.h:154:17: error: statement with no effect [-Werror=unused-value]
>     154 |                 (void *)net;                            \
>   net/ipv4/devinet.c:674:21: note: in expansion of macro ‘rtnl_net_dereference’
>     674 |              (ifa = rtnl_net_dereference(net, *ifap)) != NULL;
>         |                     ^~~~~~~~~~~~~~~~~~~~
> 
> Let's go back to the original simplest macro.
> 
> Note that checkpatch complains about this approach, but it's one-shot and
> less noisy than the other two.
> 
>   WARNING: Argument 'net' is not used in function-like macro
>   #76: FILE: include/linux/rtnetlink.h:142:
>   +#define rtnl_net_dereference(net, p)			\
>   +	rtnl_dereference(p)
> 
> Fixes: 844e5e7e656d ("rtnetlink: Add assertion helpers for per-netns RTNL.")
> Link: https://lore.kernel.org/netdev/20241004132145.7fd208e9@kernel.org/ [0]
> Reported-by: kernel test robot <lkp@...el.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202410200325.SaEJmyZS-lkp@intel.com/ [1]
> Signed-off-by: Kuniyuki Iwashima <kuniyu@...zon.com>

Thanks,

I was able to reproduce the build problem as described.

Reviewed-by: Simon Horman <horms@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ