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: <00e1ca50c7824750b24039c16a9d8bc9@AcuMS.aculab.com>
Date:   Sat, 20 May 2023 12:48:21 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Willem de Bruijn' <willemdebruijn.kernel@...il.com>,
        Breno Leitao <leitao@...ian.org>
CC:     "axboe@...nel.dk" <axboe@...nel.dk>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "edumazet@...gle.com" <edumazet@...gle.com>,
        "kuba@...nel.org" <kuba@...nel.org>,
        "pabeni@...hat.com" <pabeni@...hat.com>,
        "courmisch@...il.com" <courmisch@...il.com>,
        "nhorman@...driver.com" <nhorman@...driver.com>,
        "asml.silence@...il.com" <asml.silence@...il.com>,
        "alex.aring@...il.com" <alex.aring@...il.com>,
        "dccp@...r.kernel.org" <dccp@...r.kernel.org>,
        "mptcp@...ts.linux.dev" <mptcp@...ts.linux.dev>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "matthieu.baerts@...sares.net" <matthieu.baerts@...sares.net>,
        "marcelo.leitner@...il.com" <marcelo.leitner@...il.com>,
        "linux-wpan@...r.kernel.org" <linux-wpan@...r.kernel.org>,
        "linux-sctp@...r.kernel.org" <linux-sctp@...r.kernel.org>,
        "leit@...com" <leit@...com>,
        "dsahern@...nel.org" <dsahern@...nel.org>
Subject: RE: [PATCH 1/1] net: ioctl: Use kernel memory on protocol ioctl
 callbacks

From: Willem de Bruijn
> Sent: 19 May 2023 18:05
...
> > Should I stack allocate all the 4 structures sock_skprot_ioctl and pass
> > them to sock_skproto_ioctl_inout() together with the size? (using the
> > original name to avoid confusion - will rename in V2)
> >
> > I mean, writing something as:
> >
> > int sock_skprot_ioctl(struct sock *sk, unsigned int cmd
> >                      void __user *arg`
> > {
> >         struct sioc_vif_req sioc_vif_req_arg;
> >         struct sioc_sg_req sioc_sg_req_arg;
> >         struct sioc_mif_req6 sioc_mif_req6_arg;
> >         struct sioc_sg_req6 sioc_sg_req6_arg;
> >
> >         ..
> >
> >         if (!strcmp(sk->sk_prot->name, "RAW6")) {
> >         switch (cmd) {
> >                case SIOCGETMIFCNT_IN6:
> >                        return sock_skproto_ioctl_inout(sk, cmd,
> >                                arg, &sioc_mif_req6_arg, sizeof(sioc_mif_req6_arg);
> >                case SIOCGETSGCNT_IN6:
> >                        return sock_skproto_ioctl_inout(sk, cmd,
> >                                arg, &sioc_sg_req6_arg, sizeof(sioc_sg_req6_arg));
> >                }
> >        }
> >        ...
> > }
> 
> Slight preference for using braces in the individual case statements
> and defining the variables in that block scope. See for instance
> do_tcp_setsockopt.

Beware of stack bloat especially under KASAN (etc).
It might be better to use a union.
Then the switch statement only need determine the required length.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ