lkml.org 
[lkml]   [2023]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next v3] net: ioctl: Use kernel memory on protocol ioctl callbacks
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.

--
pw-bot: cr

\
 
 \ /
  Last update: 2023-05-25 16:56    [W:0.140 / U:1.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site