From: David Laight <David.Laight@ACULAB.COM>
To: 'Willem de Bruijn' <willemdebruijn.kernel@gmail.com>,
Breno Leitao <leitao@debian.org>
Cc: "axboe@kernel.dk" <axboe@kernel.dk>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"courmisch@gmail.com" <courmisch@gmail.com>,
"nhorman@tuxdriver.com" <nhorman@tuxdriver.com>,
"asml.silence@gmail.com" <asml.silence@gmail.com>,
"alex.aring@gmail.com" <alex.aring@gmail.com>,
"dccp@vger.kernel.org" <dccp@vger.kernel.org>,
"mptcp@lists.linux.dev" <mptcp@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"matthieu.baerts@tessares.net" <matthieu.baerts@tessares.net>,
"marcelo.leitner@gmail.com" <marcelo.leitner@gmail.com>,
"linux-wpan@vger.kernel.org" <linux-wpan@vger.kernel.org>,
"linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>,
"leit@fb.com" <leit@fb.com>,
"dsahern@kernel.org" <dsahern@kernel.org>
Subject: RE: [PATCH 1/1] net: ioctl: Use kernel memory on protocol ioctl callbacks
Date: Sat, 20 May 2023 12:48:21 +0000 [thread overview]
Message-ID: <00e1ca50c7824750b24039c16a9d8bc9@AcuMS.aculab.com> (raw)
In-Reply-To: <CAF=yD-L0MnbofufMB_SKu+8PZ+f_QdAGYoDe-jOavdkAjFrXXg@mail.gmail.com>
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)
next prev parent reply other threads:[~2023-05-20 12:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-19 13:58 [PATCH 0/1] net: ioctl: Use kernel buffer on proto ioctl callbacks Breno Leitao
2023-05-19 13:58 ` [PATCH 1/1] net: ioctl: Use kernel memory on protocol " Breno Leitao
2023-05-19 14:22 ` David Laight
2023-05-19 15:09 ` Willem de Bruijn
2023-05-19 15:39 ` Breno Leitao
2023-05-19 17:04 ` Willem de Bruijn
2023-05-20 12:48 ` David Laight [this message]
2023-05-20 13:02 ` David Laight
2023-05-20 3:50 ` David Ahern
2023-05-19 15:15 ` [PATCH 0/1] net: ioctl: Use kernel buffer on proto " Jakub Kicinski
2023-05-19 15:19 ` Breno Leitao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=00e1ca50c7824750b24039c16a9d8bc9@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=alex.aring@gmail.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=courmisch@gmail.com \
--cc=davem@davemloft.net \
--cc=dccp@vger.kernel.org \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=leit@fb.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=matthieu.baerts@tessares.net \
--cc=mptcp@lists.linux.dev \
--cc=nhorman@tuxdriver.com \
--cc=pabeni@redhat.com \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).