netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Breno Leitao <leitao@debian.org>,
	dsahern@kernel.org, willemdebruijn.kernel@gmail.com,
	Remi Denis-Courmont <courmisch@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Alexander Aring <alex.aring@gmail.com>,
	Stefan Schmidt <stefan@datenfreihafen.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Matthieu Baerts <matthieu.baerts@tessares.net>,
	Mat Martineau <martineau@kernel.org>,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Xin Long <lucien.xin@gmail.com>,
	leit@fb.com, axboe@kernel.dk, asml.silence@gmail.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	dccp@vger.kernel.org, linux-wpan@vger.kernel.org,
	mptcp@lists.linux.dev, linux-sctp@vger.kernel.org
Subject: Re: [PATCH net-next v3] net: ioctl: Use kernel memory on protocol ioctl callbacks
Date: Thu, 25 May 2023 16:54:27 +0200	[thread overview]
Message-ID: <ZG92ox2BWE3rS1xR@corigine.com> (raw)
In-Reply-To: <CANn89i+neca0ApNxRdZCiTMkwy-5=0mnOMM=9Z3u78VPNw4_fg@mail.gmail.com>

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


  reply	other threads:[~2023-05-25 14:54 UTC|newest]

Thread overview: 12+ 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 [this message]
2023-05-25 15:03     ` David Ahern
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  9:08       ` Breno Leitao
2023-05-26 14:09         ` Willem de Bruijn
2023-05-26  8:49   ` Breno Leitao
2023-05-26  1:15 ` kernel test robot
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=ZG92ox2BWE3rS1xR@corigine.com \
    --to=simon.horman@corigine.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=lucien.xin@gmail.com \
    --cc=marcelo.leitner@gmail.com \
    --cc=martineau@kernel.org \
    --cc=matthieu.baerts@tessares.net \
    --cc=miquel.raynal@bootlin.com \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stefan@datenfreihafen.org \
    --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).