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] [day] [month] [year] [list]
Message-ID: <20211125163747.im7tnfziatyllixb@kgollan-pc>
Date:   Thu, 25 Nov 2021 18:37:48 +0200
From:   Lahav Schlesinger <lschlesinger@...venets.com>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     netdev@...r.kernel.org, dsahern@...il.com
Subject: Re: [PATCH net-next v2] rtnetlink: Support fine-grained netdevice
 bulk deletion

On Thu, Nov 25, 2021 at 08:06:38AM -0800, Jakub Kicinski wrote:
> CAUTION: External E-Mail - Use caution with links and attachments
>
>
> On Thu, 25 Nov 2021 14:47:13 +0200 Lahav Schlesinger wrote:
> > +static int rtnl_list_dellink(struct net *net, void *ifindex_list, int size)
>
> s/ifindex_list/ifindices/ ? it's not really a list
>
> Can we make it an int pointer so we don't have to cast it later?
>
> > +{
> > +     const int num_devices = size / sizeof(int);
> > +     struct net_device **dev_list;
> > +     LIST_HEAD(list_kill);
> > +     int i, ret;
> > +
> > +     if (size < 0 || size % sizeof(int))
>
> Does core reject size == 0? It won't be valid either.
>
> > +             return -EINVAL;
> > +
> > +     dev_list = kmalloc_array(num_devices, sizeof(*dev_list), GFP_KERNEL);
> > +     if (!dev_list)
> > +             return -ENOMEM;
> > +
> > +     for (i = 0; i < num_devices; i++) {
> > +             const struct rtnl_link_ops *ops;
> > +             struct net_device *dev;
> > +
> > +             ret = -ENODEV;
> > +             dev = __dev_get_by_index(net, ((int *)ifindex_list)[i]);
> > +             if (!dev)
> > +                     goto out_free;
> > +
> > +             ret = -EOPNOTSUPP;
> > +             ops = dev->rtnl_link_ops;
> > +             if (!ops || !ops->dellink)
> > +                     goto out_free;
> > +
> > +             dev_list[i] = dev;
> > +     }
> > +
> > +     for (i = 0; i < num_devices; i++) {
> > +             const struct rtnl_link_ops *ops;
> > +             struct net_device *dev;
>
> the temp variables are unnecessary here, the whole thing comfortably
> fits on a line:
>
>                 dev->rtnl_link_ops->dellink(dev_list[i], &list_kill);
>
> > +             dev = dev_list[i];
> > +             ops = dev->rtnl_link_ops;
> > +             ops->dellink(dev, &list_kill);
> > +     }
> > +
> > +     unregister_netdevice_many(&list_kill);
> > +
> > +     ret = 0;
> > +
> > +out_free:
> > +     kfree(dev_list);
> > +     return ret;
> > +}

Thanks for the feedback Jakub, I'll send a V3 with your proposed
changes.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ