Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1196773pxk; Fri, 18 Sep 2020 06:27:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHLQglsJAPWGMahGeAnA1PCP3cdMfZkZmenGTlKLA7WWTEMVcO7mBm2UK8JKxJgeMqFLzA X-Received: by 2002:aa7:d585:: with SMTP id r5mr38805428edq.278.1600435626909; Fri, 18 Sep 2020 06:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600435626; cv=none; d=google.com; s=arc-20160816; b=av7ip5dM+X7lNVCWdXxxhHEgryOS9XbmsOX/eYyI4n4o/IYVG/EC2XAyJLWE/NDED7 5seAJc/lktUoos6zl4P6+MMc/7tnwHDjHHJ7qjxiOowqH04Vg+s/NMGjYqwsryB+mmoQ 19MDCxBHGkLcm0P9iV9AnsvkR2QJ8zQjpWC02WS1zEZjiDHOWgcUcWVZu7Okkweq3j4D UdcZ9SShDAiypuuhncwASCYqb6UBM1VzP30v372ecC2EQpogXOxNR7EUE3tcZycYF/RT MPOJLuQ9fSbj12c1TIglZq8+QbgvMRT9+DVguPJ93o/FZbXmSpoSSiPYoTtgD16UQkJV +UWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5uJm0DuyHPRRdeW1QAd3JTDzMZhQSuWN9ZitkhiNp6Q=; b=KYeQ1e7QXINY3Zhu417AQ8jbT4WtQ934ejh31Ed5ZGmY7ftDRt1kkkBstOxMvk1mOh DoSKm06DYwQBCrXEjsQ213Nygo/U3/nBEtiUtHTPMmGDsiRDoEy7zxwYv4eLfx03XDhj aZR02SXLl+jmm+LP0BodXtxmRUVktTexra1kEDyrM9cocxurHWW8E6IflTsZ8qM51Npd DajYVLrjSbXU4vmnyf3immRY4euXUCIhzSmT8zRjQq+WG5XYnsbofub9b7/U1SuNyYQ/ U+VkqH+/SWWhzcnPDziLDmMa5TQGsaa/dqJjgvfSo8YMnGkMGu4jLLGyq4ILUFv9w2cb jclQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw12si2504999edb.20.2020.09.18.06.26.43; Fri, 18 Sep 2020 06:27:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726822AbgIRNZv (ORCPT + 99 others); Fri, 18 Sep 2020 09:25:51 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:36885 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726489AbgIRNZu (ORCPT ); Fri, 18 Sep 2020 09:25:50 -0400 Received: from threadripper.lan ([149.172.98.151]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MElhb-1kHqXN1DP1-00GKmP; Fri, 18 Sep 2020 15:24:54 +0200 From: Arnd Bergmann To: Christoph Hellwig , Alexander Viro , Eric Biederman , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, kexec@lists.infradead.org, Arnd Bergmann Subject: [PATCH 3/4] mm: remove compat_sys_move_pages Date: Fri, 18 Sep 2020 15:24:38 +0200 Message-Id: <20200918132439.1475479-4-arnd@arndb.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200918132439.1475479-1-arnd@arndb.de> References: <20200918132439.1475479-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:9HBh2SGDIfLC4kmRog36Y+2yXnwhwLlSN+68IM3LicqoJ2Cu8sf W0NpvqEO54w82dFe5AF83L/33zph8GAZnIMeRuUny2o26krprnWYWdeUfWh5lJwYll90U1+ 94mW4y6xZYIqPboRTyA1JP9wiAcGHjn2O1lMfESTnYgDMETmvLLbFnyep7nOLsiE1vA+16+ UBD2hsKIblvZJuQkVA0uA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:pa3xb1PHRU8=:t3VwuX9k+/JPY8JW/7f2Bm 9TEBunUl0/0tQn5GJTYXG1ZLByIZ2k3pypgna49HKnBOTQ84UFIkoj7eOQNXxA+mSoU6Wgdgz Gng4c3HjxN9xMBge8iEdalCuy8+F1sSPSZDcGhcA5oTwXBisBplyHv4VGzsBVeL3b6lFDKYXt 9RJS2f2x2YDDSLsya0HDpBJb+cNLsC8o7uXd+LxZNFVj2S80dKUsleNFHEJ9xCkesN0nygH6z U4osjyv6+lEkV7FxpBYQzbbnGw4qM8UjcVXpuSWL+clCnttOfabWHYqEHmU01JJADx0JUXaBz O0EegbbDEWnnFHxHGPWdMaMzuhXp+aFlPZIKwgu+/dGGLL2SVzGnW43s8Cmp5j3OmS8Hl612l BhcYs+D5jqLCoSHWNjlrmLEudIyaTr+VQy4t3ySjYCUQcq49PaQMI8TInC7/q1ot4DsWr3yse X49QjCkRPYDAwTCG81w42FhORJQ1sX98je2dfXd13OY1haT4dSgCZihCygUdwF/q1+at+EYxv 8QLUN20zo19eyu38eOZaCn6dwDTUroHN/pSpABUXJaXtUDgMFCyS+fMR8QFae3E+tUdAsEYMq p0Up8JbY3sZe82HhaLF0agHNw/9rWz1MKpGRNjftWpEzj9esF9KILJEyI1s1a+4ztE7swxOnM XCGuJZJlnXhD/jBQiwXMz2NrArbNjGk4xUpMevALl21m+G0Mwtn2STY7fAQaFJJljFNOajPCv tHjrM9lvbotq+8vozF2XfNAvwrPk6cL9AD0fwhjy/iYaLNeTYRdeyvLNKvtAy6YThdsTnuJjW erb86GUbd7wo2EUFLV+3HqNClhQ/qB0CYFZeSbAht/BeegyI+WGK9xqcqRF/tG9L41BjViu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The compat move_pages() implementation uses compat_alloc_user_space() for converting the pointer array. Moving the compat handling into the function itself is a bit simpler and lets us avoid the compat_alloc_user_space() call. Signed-off-by: Arnd Bergmann --- arch/arm64/include/asm/unistd32.h | 2 +- arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 2 +- arch/parisc/kernel/syscalls/syscall.tbl | 2 +- arch/powerpc/kernel/syscalls/syscall.tbl | 2 +- arch/s390/kernel/syscalls/syscall.tbl | 2 +- arch/sparc/kernel/syscalls/syscall.tbl | 2 +- arch/x86/entry/syscalls/syscall_32.tbl | 2 +- arch/x86/entry/syscalls/syscall_64.tbl | 2 +- include/linux/compat.h | 5 --- include/uapi/asm-generic/unistd.h | 2 +- kernel/sys_ni.c | 1 - mm/migrate.c | 45 +++++++++++------------ 13 files changed, 32 insertions(+), 39 deletions(-) diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index b6517df74037..af793775ba98 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -699,7 +699,7 @@ __SYSCALL(__NR_tee, sys_tee) #define __NR_vmsplice 343 __SYSCALL(__NR_vmsplice, compat_sys_vmsplice) #define __NR_move_pages 344 -__SYSCALL(__NR_move_pages, compat_sys_move_pages) +__SYSCALL(__NR_move_pages, sys_move_pages) #define __NR_getcpu 345 __SYSCALL(__NR_getcpu, sys_getcpu) #define __NR_epoll_pwait 346 diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl index ad157aab4c09..7fa1ca45e44c 100644 --- a/arch/mips/kernel/syscalls/syscall_n32.tbl +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl @@ -279,7 +279,7 @@ 268 n32 sync_file_range sys_sync_file_range 269 n32 tee sys_tee 270 n32 vmsplice compat_sys_vmsplice -271 n32 move_pages compat_sys_move_pages +271 n32 move_pages sys_move_pages 272 n32 set_robust_list compat_sys_set_robust_list 273 n32 get_robust_list compat_sys_get_robust_list 274 n32 kexec_load sys_kexec_load diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl index 57baf6c8008f..194c7fbeedf7 100644 --- a/arch/mips/kernel/syscalls/syscall_o32.tbl +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl @@ -319,7 +319,7 @@ 305 o32 sync_file_range sys_sync_file_range sys32_sync_file_range 306 o32 tee sys_tee 307 o32 vmsplice sys_vmsplice compat_sys_vmsplice -308 o32 move_pages sys_move_pages compat_sys_move_pages +308 o32 move_pages sys_move_pages 309 o32 set_robust_list sys_set_robust_list compat_sys_set_robust_list 310 o32 get_robust_list sys_get_robust_list compat_sys_get_robust_list 311 o32 kexec_load sys_kexec_load diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl index 778bf166d7bd..5c17edaffe70 100644 --- a/arch/parisc/kernel/syscalls/syscall.tbl +++ b/arch/parisc/kernel/syscalls/syscall.tbl @@ -331,7 +331,7 @@ 292 64 sync_file_range sys_sync_file_range 293 common tee sys_tee 294 common vmsplice sys_vmsplice compat_sys_vmsplice -295 common move_pages sys_move_pages compat_sys_move_pages +295 common move_pages sys_move_pages 296 common getcpu sys_getcpu 297 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait 298 common statfs64 sys_statfs64 compat_sys_statfs64 diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl index f128ba8b9a71..04fb42d7b377 100644 --- a/arch/powerpc/kernel/syscalls/syscall.tbl +++ b/arch/powerpc/kernel/syscalls/syscall.tbl @@ -389,7 +389,7 @@ 298 common faccessat sys_faccessat 299 common get_robust_list sys_get_robust_list compat_sys_get_robust_list 300 common set_robust_list sys_set_robust_list compat_sys_set_robust_list -301 common move_pages sys_move_pages compat_sys_move_pages +301 common move_pages sys_move_pages 302 common getcpu sys_getcpu 303 nospu epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait 304 32 utimensat sys_utimensat_time32 diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl index d45952058be2..3197965d45e9 100644 --- a/arch/s390/kernel/syscalls/syscall.tbl +++ b/arch/s390/kernel/syscalls/syscall.tbl @@ -317,7 +317,7 @@ 307 common sync_file_range sys_sync_file_range compat_sys_s390_sync_file_range 308 common tee sys_tee sys_tee 309 common vmsplice sys_vmsplice compat_sys_vmsplice -310 common move_pages sys_move_pages compat_sys_move_pages +310 common move_pages sys_move_pages 311 common getcpu sys_getcpu sys_getcpu 312 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait 313 common utimes sys_utimes sys_utimes_time32 diff --git a/arch/sparc/kernel/syscalls/syscall.tbl b/arch/sparc/kernel/syscalls/syscall.tbl index a46edcdd950d..e36ac364e61a 100644 --- a/arch/sparc/kernel/syscalls/syscall.tbl +++ b/arch/sparc/kernel/syscalls/syscall.tbl @@ -370,7 +370,7 @@ 304 common get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy 305 common set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy 306 common kexec_load sys_kexec_load sys_kexec_load -307 common move_pages sys_move_pages compat_sys_move_pages +307 common move_pages sys_move_pages 308 common getcpu sys_getcpu 309 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait 310 32 utimensat sys_utimensat_time32 diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index 7e4140b78aad..b3263b8b2eae 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -328,7 +328,7 @@ 314 i386 sync_file_range sys_ia32_sync_file_range 315 i386 tee sys_tee 316 i386 vmsplice sys_vmsplice compat_sys_vmsplice -317 i386 move_pages sys_move_pages compat_sys_move_pages +317 i386 move_pages sys_move_pages 318 i386 getcpu sys_getcpu 319 i386 epoll_pwait sys_epoll_pwait 320 i386 utimensat sys_utimensat_time32 diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl index 9986f5f08278..4a997a0cbf47 100644 --- a/arch/x86/entry/syscalls/syscall_64.tbl +++ b/arch/x86/entry/syscalls/syscall_64.tbl @@ -389,7 +389,7 @@ 530 x32 set_robust_list compat_sys_set_robust_list 531 x32 get_robust_list compat_sys_get_robust_list 532 x32 vmsplice compat_sys_vmsplice -533 x32 move_pages compat_sys_move_pages +533 x32 move_pages sys_move_pages 534 x32 preadv compat_sys_preadv64 535 x32 pwritev compat_sys_pwritev64 536 x32 rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo diff --git a/include/linux/compat.h b/include/linux/compat.h index a7a5a0ff59ef..db1d7ac2c9e0 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -763,11 +763,6 @@ asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask, asmlinkage long compat_sys_migrate_pages(compat_pid_t pid, compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes, const compat_ulong_t __user *new_nodes); -asmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages, - __u32 __user *pages, - const int __user *nodes, - int __user *status, - int flags); asmlinkage long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig, diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index 83f1fc7fd3d7..4da51702fb21 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -681,7 +681,7 @@ __SC_COMP(__NR_set_mempolicy, sys_set_mempolicy, compat_sys_set_mempolicy) #define __NR_migrate_pages 238 __SC_COMP(__NR_migrate_pages, sys_migrate_pages, compat_sys_migrate_pages) #define __NR_move_pages 239 -__SC_COMP(__NR_move_pages, sys_move_pages, compat_sys_move_pages) +__SYSCALL(__NR_move_pages, sys_move_pages) #endif #define __NR_rt_tgsigqueueinfo 240 diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index c925d1e1777e..783a24ceee88 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c @@ -290,7 +290,6 @@ COND_SYSCALL_COMPAT(set_mempolicy); COND_SYSCALL(migrate_pages); COND_SYSCALL_COMPAT(migrate_pages); COND_SYSCALL(move_pages); -COND_SYSCALL_COMPAT(move_pages); COND_SYSCALL(perf_event_open); COND_SYSCALL(accept4); diff --git a/mm/migrate.c b/mm/migrate.c index 34a842a8eb6a..e9dfbde5f12c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1835,6 +1835,27 @@ 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) +{ + 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; + chunk_pages[i] = compat_ptr(p); + } + + return 0; +} + /* * Determine the nodes of a user array of pages and store it in * a user array of status. @@ -1854,7 +1875,7 @@ 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 (copy_from_user(chunk_pages, pages, chunk_nr * sizeof(*chunk_pages))) + if (put_pages_array(chunk_pages, pages, chunk_nr)) break; do_pages_stat_array(mm, chunk_nr, chunk_pages, chunk_status); @@ -1943,28 +1964,6 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages, return kernel_move_pages(pid, nr_pages, pages, nodes, status, flags); } -#ifdef CONFIG_COMPAT -COMPAT_SYSCALL_DEFINE6(move_pages, pid_t, pid, compat_ulong_t, nr_pages, - compat_uptr_t __user *, pages32, - const int __user *, nodes, - int __user *, status, - int, flags) -{ - const void __user * __user *pages; - int i; - - pages = compat_alloc_user_space(nr_pages * sizeof(void *)); - for (i = 0; i < nr_pages; i++) { - compat_uptr_t p; - - if (get_user(p, pages32 + i) || - put_user(compat_ptr(p), pages + i)) - return -EFAULT; - } - return kernel_move_pages(pid, nr_pages, pages, nodes, status, flags); -} -#endif /* CONFIG_COMPAT */ - #ifdef CONFIG_NUMA_BALANCING /* * Returns true if this is a safe migration target node for misplaced NUMA -- 2.27.0