From: David Laight <David.Laight@ACULAB.COM>
To: 'Breno Leitao' <leitao@debian.org>,
"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>,
"willemdebruijn.kernel@gmail.com"
<willemdebruijn.kernel@gmail.com>,
"courmisch@gmail.com" <courmisch@gmail.com>,
"nhorman@tuxdriver.com" <nhorman@tuxdriver.com>
Cc: "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: Fri, 19 May 2023 14:22:08 +0000 [thread overview]
Message-ID: <f2d1a07b3e954db8ae40a2d739372e6c@AcuMS.aculab.com> (raw)
In-Reply-To: <20230519135821.922326-2-leitao@debian.org>
From: Breno Leitao
> Sent: 19 May 2023 14:58
>
> Most of the ioctls to net protocols operates directly on userspace
> argument (arg). Usually doing get_user()/put_user() directly in the
> ioctl callback. This is not flexible, because it is hard to reuse these
> functions without passing userspace buffers.
>
> Change the "struct proto" ioctls to avoid touching userspace memory and
> operate on kernel buffers, i.e., all protocol's ioctl callbacks is
> adapted to operate on a kernel memory other than on userspace (so, no
> more {put,get}_user() and friends being called in the ioctl callback).
>
> This changes the "struct proto" ioctl format in the following way:
>
> int (*ioctl)(struct sock *sk, int cmd,
> - unsigned long arg);
> + int *karg);
I think I'd add a karg_len field for the actual buffer length.
It will save embarrassment later on.
Do any of the ioctl functions return +ve values on success?
If not you can use the return value as the length for any
copy_to_user().
If all the current 'cmd' are 16bit, there is the option
of using 32bit IOR() etc commands to get automatic sizing.
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-19 14:22 UTC|newest]
Thread overview: 14+ 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 [this message]
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
2023-05-20 13:02 ` David Laight
2023-05-19 16:54 ` kernel test robot
2023-05-19 19:26 ` kernel test robot
2023-05-19 23:29 ` kernel test robot
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=f2d1a07b3e954db8ae40a2d739372e6c@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