From: David Ahern <dsahern@kernel.org>
To: dccp@vger.kernel.org
Subject: Re: [PATCH net-next v3] net: ioctl: Use kernel memory on protocol ioctl callbacks
Date: Thu, 25 May 2023 15:03:02 +0000 [thread overview]
Message-ID: <83d90ef3-67ba-737e-02fb-dbfb7cc8d2de@kernel.org> (raw)
In-Reply-To: <20230525125503.400797-1-leitao@debian.org>
On 5/25/23 8:54 AM, Simon Horman wrote:
> On Thu, May 25, 2023 at 04:19:32PM +0200, Eric Dumazet wrote:
>> On Thu, May 25, 2023 at 2:55 PM Breno Leitao <leitao@debian.org> wrote:
>>>
>>> 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).
>>>
>>
>> diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h
>>> index 862f1719b523..93705d99f862 100644
>>> --- a/include/net/phonet/phonet.h
>>> +++ b/include/net/phonet/phonet.h
>>> @@ -109,4 +109,23 @@ void phonet_sysctl_exit(void);
>>> int isi_register(void);
>>> void isi_unregister(void);
>>>
>>> +#ifdef CONFIG_PHONET
>>> +int phonet_sk_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
>>> +
>>> +static inline bool phonet_is_sk(struct sock *sk)
>>> +{
>>> + return sk->sk_family = PF_PHONET && sk->sk_protocol = PN_PROTO_PHONET;
>>> +}
>>> +#else
>>> +static inline bool phonet_is_sk(struct sock *sk)
>>> +{
>>> + return 0;
>>> +}
>>> +
>>> +static inline int phonet_sk_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
>>> +{
>>> + return 1;
>>> +}
>>> +#endif
>>> +
>>>
>>
>> PHONET can be built as a module, so I guess the compiler would
>> complain if "CONFIG_PHONET=m" ???
>
> Yes, indeed it does.
>
phonet_sk_ioctl is simple enough to make an inline in which case this
should go in include//linux/phonet.h.
next prev parent reply other threads:[~2023-05-25 15:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 12:54 [PATCH net-next v3] net: ioctl: Use kernel memory on protocol ioctl callbacks Breno Leitao
2023-05-25 14:19 ` Eric Dumazet
2023-05-25 14:54 ` Simon Horman
2023-05-25 15:03 ` David Ahern [this message]
2023-05-25 15:05 ` Willem de Bruijn
2023-05-25 15:34 ` David Ahern
2023-05-25 16:06 ` Willem de Bruijn
2023-05-26 8:49 ` Breno Leitao
2023-05-26 9:08 ` Breno Leitao
2023-05-26 14:09 ` Willem de Bruijn
2023-05-28 18:05 ` kernel test robot
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=83d90ef3-67ba-737e-02fb-dbfb7cc8d2de@kernel.org \
--to=dsahern@kernel.org \
--cc=dccp@vger.kernel.org \
/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