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: <87lem0w1k3.fsf@nvidia.com>
Date:   Wed, 18 Jan 2023 11:54:23 +0100
From:   Petr Machata <petrm@...dia.com>
To:     Daniel Machon <daniel.machon@...rochip.com>
CC:     <netdev@...r.kernel.org>, <davem@...emloft.net>,
        <edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.com>,
        <lars.povlsen@...rochip.com>, <Steen.Hegelund@...rochip.com>,
        <UNGLinuxDriver@...rochip.com>, <joe@...ches.com>,
        <error27@...il.com>, <horatiu.vultur@...rochip.com>,
        <Julia.Lawall@...ia.fr>, <petrm@...dia.com>,
        <vladimir.oltean@....com>, <maxime.chevallier@...tlin.com>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next v2 3/6] net: dcb: add new rewrite table


Daniel Machon <daniel.machon@...rochip.com> writes:

> diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
> index cb5319c6afe6..54af3ee03491 100644
> --- a/net/dcb/dcbnl.c
> +++ b/net/dcb/dcbnl.c
> @@ -178,6 +178,7 @@ static const struct nla_policy dcbnl_featcfg_nest[DCB_FEATCFG_ATTR_MAX + 1] = {
>  };
>  
>  static LIST_HEAD(dcb_app_list);
> +static LIST_HEAD(dcb_rewr_list);
>  static DEFINE_SPINLOCK(dcb_lock);
>  
>  static enum ieee_attrs_app dcbnl_app_attr_type_get(u8 selector)
> @@ -1138,7 +1139,7 @@ static int dcbnl_app_table_setdel(struct nlattr *attr,
>  static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
>  {
>  	const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
> -	struct nlattr *ieee, *app;
> +	struct nlattr *ieee, *app, *rewr;
>  	struct dcb_app_type *itr;
>  	int dcbx;
>  	int err;
> @@ -1241,6 +1242,26 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
>  	spin_unlock_bh(&dcb_lock);
>  	nla_nest_end(skb, app);
>  
> +	rewr = nla_nest_start_noflag(skb, DCB_ATTR_DCB_REWR_TABLE);
> +	if (!rewr)
> +		return -EMSGSIZE;

This being new code, don't use _noflag please.

> +
> +	spin_lock_bh(&dcb_lock);
> +	list_for_each_entry(itr, &dcb_rewr_list, list) {
> +		if (itr->ifindex == netdev->ifindex) {
> +			enum ieee_attrs_app type =
> +				dcbnl_app_attr_type_get(itr->app.selector);
> +			err = nla_put(skb, type, sizeof(itr->app), &itr->app);
> +			if (err) {
> +				spin_unlock_bh(&dcb_lock);

This should cancel the nest started above.

I wonder if it would be cleaner in a separate function, so that there
can be a dedicated clean-up block to goto.

> +				return -EMSGSIZE;
> +			}
> +		}
> +	}
> +
> +	spin_unlock_bh(&dcb_lock);
> +	nla_nest_end(skb, rewr);
> +
>  	if (ops->dcbnl_getapptrust) {
>  		err = dcbnl_getapptrust(netdev, skb);
>  		if (err)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ