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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241006152527.55776-1-kuniyu@amazon.com>
Date: Sun, 6 Oct 2024 08:25:27 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <edumazet@...gle.com>
CC: <davem@...emloft.net>, <kuba@...nel.org>, <kuni1840@...il.com>,
	<kuniyu@...zon.com>, <netdev@...r.kernel.org>, <pabeni@...hat.com>
Subject: Re: [PATCH v2 net 1/6] rtnetlink: Add bulk registration helpers for rtnetlink message handlers.

From: Eric Dumazet <edumazet@...gle.com>
Date: Sat, 5 Oct 2024 10:25:20 +0200
> On Sat, Oct 5, 2024 at 12:24 AM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
> >
> > Before commit addf9b90de22 ("net: rtnetlink: use rcu to free rtnl message
> > handlers"), once rtnl_msg_handlers[protocol] was allocated, the following
> > rtnl_register_module() for the same protocol never failed.
> >
> > However, after the commit, rtnl_msg_handler[protocol][msgtype] needs to
> > be allocated in each rtnl_register_module(), so each call could fail.
> >
> > Many callers of rtnl_register_module() do not handle the returned error,
> > and we need to add many error handlings.
> >
> > To handle that easily, let's add wrapper functions for bulk registration
> > of rtnetlink message handlers.
> >
> > Signed-off-by: Kuniyuki Iwashima <kuniyu@...zon.com>
> > ---
> >  include/net/rtnetlink.h | 19 +++++++++++++++++++
> >  net/core/rtnetlink.c    | 30 ++++++++++++++++++++++++++++++
> >  2 files changed, 49 insertions(+)
> >
> > diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
> > index b45d57b5968a..b6b91898dc13 100644
> > --- a/include/net/rtnetlink.h
> > +++ b/include/net/rtnetlink.h
> > @@ -29,6 +29,14 @@ static inline enum rtnl_kinds rtnl_msgtype_kind(int msgtype)
> >         return msgtype & RTNL_KIND_MASK;
> >  }
> >
> > +struct rtnl_msg_handler {
> 
> Since we add a structure, we could stick here a
> 
>             struct module *owner;

Will add it and remove _module version in v3.

Thanks!


> 
> > +       int protocol;
> > +       int msgtype;
> > +       rtnl_doit_func doit;
> > +       rtnl_dumpit_func dumpit;
> > +       int flags;
> > +};
> > +
> >  void rtnl_register(int protocol, int msgtype,
> >                    rtnl_doit_func, rtnl_dumpit_func, unsigned int flags);
> >  int rtnl_register_module(struct module *owner, int protocol, int msgtype,
> > @@ -36,6 +44,17 @@ int rtnl_register_module(struct module *owner, int protocol, int msgtype,
> >  int rtnl_unregister(int protocol, int msgtype);
> >  void rtnl_unregister_all(int protocol);
> >
> > +int __rtnl_register_many(struct module *owner,
> > +                        struct rtnl_msg_handler *handlers, int n);
> > +void __rtnl_unregister_many(struct rtnl_msg_handler *handlers, int n);
> > +
> > +#define rtnl_register_many(handlers)                                           \
> > +       __rtnl_register_many(NULL, handlers, ARRAY_SIZE(handlers))
> > +#define rtnl_register_module_many(handlers)                                    \
> > +       __rtnl_register_many(THIS_MODULE, handlers, ARRAY_SIZE(handlers))
> 
> 
> This would allow a simpler api, no need for rtnl_register_module_many()

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ