netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: David Laight <David.Laight@aculab.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v4 2/4] net: socket: rework SIOC?IFMAP ioctls
Date: Tue, 24 Nov 2020 20:05:46 +0100	[thread overview]
Message-ID: <CAK8P3a08F1Xk2Vz69CUN=sJcBkqZvcrkd06qrmG3SMR8VhBN4A@mail.gmail.com> (raw)
In-Reply-To: <e86a5d8a3aed44139010dac219dfcf08@AcuMS.aculab.com>

On Tue, Nov 24, 2020 at 5:13 PM David Laight <David.Laight@aculab.com> wrote:
>
> From: Arnd Bergmann
> > Sent: 24 November 2020 15:18
> >
> > SIOCGIFMAP and SIOCSIFMAP currently require compat_alloc_user_space()
> > and copy_in_user() for compat mode.
> >
> > Move the compat handling into the location where the structures are
> > actually used, to avoid using those interfaces and get a clearer
> > implementation.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> > changes in v3:
> >  - complete rewrite
> ...
> >  include/linux/compat.h | 18 ++++++------
> >  net/core/dev_ioctl.c   | 64 +++++++++++++++++++++++++++++++++---------
> >  net/socket.c           | 39 ++-----------------------
> >  3 files changed, 62 insertions(+), 59 deletions(-)
> >
> > diff --git a/include/linux/compat.h b/include/linux/compat.h
> > index 08dbd34bb7a5..47496c5eb5eb 100644
> > --- a/include/linux/compat.h
> > +++ b/include/linux/compat.h
> > @@ -96,6 +96,15 @@ struct compat_iovec {
> >       compat_size_t   iov_len;
> >  };
> >
> > +struct compat_ifmap {
> > +     compat_ulong_t mem_start;
> > +     compat_ulong_t mem_end;
> > +     unsigned short base_addr;
> > +     unsigned char irq;
> > +     unsigned char dma;
> > +     unsigned char port;
> > +};
>
> Isn't the only difference the number of pad bytes at the end?

No, the main difference is in the first two fields, which are
'unsigned long' and therefore different. The three-byte padding
is in fact the same on all architectures (including x86) that
have a compat mode, though it might be different on
m68k and arm-oabi, which have slightly special struct
alignment rules.

It could be done with two assignments and a memcpy, but
I like the individual assignments better here.

      Arnd

  reply	other threads:[~2020-11-24 19:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24 15:18 [PATCH net-next v4 0/4] remove compat_alloc_user_space() Arnd Bergmann
2020-11-24 15:18 ` [PATCH v4 1/4] ethtool: improve compat ioctl handling Arnd Bergmann
2020-11-24 16:19   ` David Laight
2020-11-24 19:42     ` Arnd Bergmann
2020-11-24 15:18 ` [PATCH v4 2/4] net: socket: rework SIOC?IFMAP ioctls Arnd Bergmann
2020-11-24 16:13   ` David Laight
2020-11-24 19:05     ` Arnd Bergmann [this message]
2020-11-24 22:12       ` David Laight
2020-11-24 15:18 ` [PATCH v4 3/4] net: socket: simplify dev_ifconf handling Arnd Bergmann
2020-11-24 20:52   ` Jakub Kicinski
2020-11-24 15:18 ` [PATCH v4 4/4] net: socket: rework compat_ifreq_ioctl() Arnd Bergmann
2021-01-27 18:19 ` [PATCH net-next v4 0/4] remove compat_alloc_user_space() Christoph Hellwig

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='CAK8P3a08F1Xk2Vz69CUN=sJcBkqZvcrkd06qrmG3SMR8VhBN4A@mail.gmail.com' \
    --to=arnd@kernel.org \
    --cc=David.Laight@aculab.com \
    --cc=arnd@arndb.de \
    --cc=netdev@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;
as well as URLs for NNTP newsgroup(s).