linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Christoph Hellwig <hch@infradead.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Eric Biederman <ebiederm@xmission.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	Linux-MM <linux-mm@kvack.org>,
	kexec@lists.infradead.org
Subject: Re: [PATCH 3/4] mm: remove compat_sys_move_pages
Date: Sat, 26 Sep 2020 17:21:29 +0200	[thread overview]
Message-ID: <CAK8P3a15GEGL8AnxTYZxD_EeGb7__v=iy6rTfCTNq2jmsQe9fQ@mail.gmail.com> (raw)
In-Reply-To: <20200919053807.GK30063@infradead.org>

On Sat, Sep 19, 2020 at 7:38 AM Christoph Hellwig <hch@infradead.org> wrote:
>
> I'd just keep the native version inline and have the compat one in
> a helper, but that is just a minor detail.

Folded in this change:

diff --git a/mm/migrate.c b/mm/migrate.c
index e9dfbde5f12c..d3fa3f4bf653 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1835,18 +1835,14 @@ static void do_pages_stat_array(struct
mm_struct *mm, unsigned long nr_pages,
        mmap_read_unlock(mm);
 }

-static int put_pages_array(const void __user *chunk_pages[],
-                          const void __user * __user *pages,
-                          unsigned long chunk_nr)
+static int put_compat_pages_array(const void __user *chunk_pages[],
+                                 const void __user * __user *pages,
+                                 unsigned long chunk_nr)
 {
        compat_uptr_t __user *pages32 = (compat_uptr_t __user *)pages;
        compat_uptr_t p;
        int i;

-       if (!in_compat_syscall())
-               return copy_from_user(chunk_pages, pages,
-                                     chunk_nr * sizeof(*chunk_pages));
-
        for (i = 0; i < chunk_nr; i++) {
                if (get_user(p, pages32 + i))
                        return -EFAULT;
@@ -1875,8 +1871,15 @@ static int do_pages_stat(struct mm_struct *mm,
unsigned long nr_pages,
                if (chunk_nr > DO_PAGES_STAT_CHUNK_NR)
                        chunk_nr = DO_PAGES_STAT_CHUNK_NR;

-               if (put_pages_array(chunk_pages, pages, chunk_nr))
-                       break;
+               if (in_compat_syscall()) {
+                       if (put_compat_pages_array(chunk_pages, pages,
+                                                  chunk_nr))
+                               break;
+               } else {
+                       if (copy_from_user(chunk_pages, pages,
+                                     chunk_nr * sizeof(*chunk_pages)))
+                               break;
+               }

                do_pages_stat_array(mm, chunk_nr, chunk_pages, chunk_status);

It does make the separation cleaner but it's also more code, which is
why I had it in the combined function before.

      Arnd

  reply	other threads:[~2020-09-26 15:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-18 13:24 [PATCH 0/4] syscalls: remove compat_alloc_user_space callers Arnd Bergmann
2020-09-18 13:24 ` [PATCH 1/4] x86: add __X32_COND_SYSCALL() macro Arnd Bergmann
2020-09-19  5:35   ` Christoph Hellwig
2020-09-19 16:23     ` Andy Lutomirski
2020-09-19 17:14       ` hpa
2020-09-19 17:39         ` Andy Lutomirski
2020-09-19 17:45         ` Brian Gerst
2020-09-18 13:24 ` [PATCH 2/4] kexec: remove compat_sys_kexec_load syscall Arnd Bergmann
2020-09-19  5:37   ` Christoph Hellwig
2020-09-26 21:10     ` Arnd Bergmann
2020-09-18 13:24 ` [PATCH 3/4] mm: remove compat_sys_move_pages Arnd Bergmann
2020-09-19  5:38   ` Christoph Hellwig
2020-09-26 15:21     ` Arnd Bergmann [this message]
2020-09-18 13:24 ` [PATCH 4/4] mm: remove compat numa syscalls Arnd Bergmann
2020-09-19  5:41   ` Christoph Hellwig
2020-09-26 15:14     ` Arnd Bergmann

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='CAK8P3a15GEGL8AnxTYZxD_EeGb7__v=iy6rTfCTNq2jmsQe9fQ@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=hch@infradead.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).