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]
Date:   Mon, 26 Sep 2022 10:37:46 +0200
From:   Nicolas Dichtel <nicolas.dichtel@...nd.com>
To:     Hangbin Liu <liuhangbin@...il.com>, netdev@...r.kernel.org
Cc:     "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Ido Schimmel <idosch@...dia.com>,
        Petr Machata <petrm@...dia.com>,
        Florent Fourcot <florent.fourcot@...irst.fr>,
        Nikolay Aleksandrov <razor@...ckwall.org>,
        Guillaume Nault <gnault@...hat.com>
Subject: Re: [PATCHv2 net-next] rtnetlink: Honour NLM_F_ECHO flag in
 rtnl_{new, set, del}link


Le 26/09/2022 à 09:12, Hangbin Liu a écrit :
> Netlink messages are used for communicating between user and kernel space.
> When user space configures the kernel with netlink messages, it can set the
> NLM_F_ECHO flag to request the kernel to send the applied configuration back
> to the caller. This allows user space to retrieve configuration information
> that are filled by the kernel (either because these parameters can only be
> set by the kernel or because user space let the kernel choose a default
> value).
> 
> The kernel has support this feature in some places like RTM_{NEW, DEL}ADDR,
> RTM_{NEW, DEL}ROUTE. This patch handles NLM_F_ECHO flag and send link info
> back after rtnl_{new, set, del}link.
> 
> Suggested-by: Guillaume Nault <gnault@...hat.com>
> Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
> ---
> v2:
> 1) rename rtnl_echo_link_info() to rtnl_link_notify().
> 2) remove IFLA_LINK_NETNSID and IFLA_EXT_MASK, which do not fit here.
> 3) Add NLM_F_ECHO in rtnl_dellink. But we can't re-use the rtnl_link_notify()
>    helper as we need to get the link info before rtnl_delete_link().
> ---
>  net/core/rtnetlink.c | 66 ++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 58 insertions(+), 8 deletions(-)
> 
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 74864dc46a7e..0897cb6cc931 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -2645,13 +2645,41 @@ static int do_set_proto_down(struct net_device *dev,
>  	return 0;
>  }
>  
> +static void rtnl_link_notify(struct net_device *dev, u32 pid,
> +			     struct nlmsghdr *nlh)
> +{
> +	struct sk_buff *skb;
> +	int err = -ENOBUFS;
> +
> +	skb = nlmsg_new(if_nlmsg_size(dev, 0), GFP_KERNEL);
> +	if (!skb)
> +		goto errout;
> +
> +	err = rtnl_fill_ifinfo(skb, dev, dev_net(dev), RTM_NEWLINK, pid,
> +			       nlh->nlmsg_seq, 0, 0, 0, 0, NULL, 0, 0,
> +			       GFP_KERNEL);
> +	if (err < 0) {
> +		/* -EMSGSIZE implies BUG in if_nlmsg_size */
> +		WARN_ON(err == -EMSGSIZE);
> +		kfree_skb(skb);
> +		goto errout;
> +	}
> +
> +	rtnl_notify(skb, dev_net(dev), pid, RTM_NEWLINK, nlh, GFP_KERNEL);
The fourth argument is the group, not the command. It should be RTNLGRP_LINK
here. But it would be better to pass 0 to avoid multicasting a new / duplicate
notification. Calling functions already multicast one.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ