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
| ||
|
Message-ID: <Y70KhcGV5twckdxj@pop-os.localdomain> Date: Mon, 9 Jan 2023 22:49:41 -0800 From: Cong Wang <xiyou.wangcong@...il.com> To: Guillaume Nault <gnault@...hat.com> Cc: netdev@...r.kernel.org, g.nault@...halink.fr, Cong Wang <cong.wang@...edance.com>, Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>, Jakub Sitnicki <jakub@...udflare.com>, Eric Dumazet <edumazet@...gle.com> Subject: Re: [Patch net 1/2] l2tp: convert l2tp_tunnel_list to idr On Sat, Jan 07, 2023 at 08:48:51PM +0100, Guillaume Nault wrote: > On Thu, Jan 05, 2023 at 11:13:38AM -0800, Cong Wang wrote: > > +int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, > > + u32 peer_tunnel_id, struct l2tp_tunnel_cfg *cfg, > > + struct l2tp_tunnel **tunnelp) > > { > > struct l2tp_tunnel *tunnel = NULL; > > int err; > > enum l2tp_encap_type encap = L2TP_ENCAPTYPE_UDP; > > + struct l2tp_net *pn = l2tp_pernet(net); > > > > if (cfg) > > encap = cfg->encap; > > > > + spin_lock_bh(&pn->l2tp_tunnel_idr_lock); > > + err = idr_alloc_u32(&pn->l2tp_tunnel_idr, NULL, &tunnel_id, tunnel_id, > > + GFP_ATOMIC); > > + if (err) { > > + spin_unlock_bh(&pn->l2tp_tunnel_idr_lock); > > + return err; > > + } > > + spin_unlock_bh(&pn->l2tp_tunnel_idr_lock); > > Why reserving the tunnel_id in l2tp_tunnel_create()? This function is > supposed to just allocate a structure and pre-initialise some fields. > The only cleanup required upon error after this call is to kfree() the > new structure. So I can't see any reason to guarantee the id will be > accepted by the future l2tp_tunnel_register() call. > > Looks like you could reserve the id at the beginning of > l2tp_tunnel_register() instead. That'd avoid changing the API and thus > the side effects on l2tp_{ppp,netlink}.c. Also we wouldn't need create > l2tp_tunnel_remove(). > The idr_replace() is guaranteed to succeed in terms of ID allocation. So either way could work, but I think you are right that the patch could be smaller if we do it in l2tp_tunnel_register(). Thanks.
Powered by blists - more mailing lists