unrestrict process_madvise() for current process
Subsystems (6)
cover unrestrict process_madvise() for current process
The process_madvise() call was introduced in commit ecb8ac8b1f14 ("mm/madvise: introduce process_madvise() syscall: an external memory hinting API") as a means of performing madvise() operations on another process.
However, as it provides the means by which to perform multiple madvise() operations in a batch via an iovec, it is useful to utilise the same interface for performing operations on the current process rather than a remote one.
Using this interface targeting the current process is cumbersome - a pidfd needs to be setup for the current pid, and we are limited to only a subset of madvise() operations, a limitation sensible for manipulating remote processes but not meaningful when manipulating the current one.
Commit 22af8caff7d1 ("mm/madvise: process_madvise() drop capability check if same mm") removed the need for a caller invoking process_madvise() on its own pidfd to possess the CAP_SYS_NICE capability, however this leaves the restrictions on operation in place and the cumbersome need for a 'self pidfd'.
This patch series eliminates both limitations:
1. The restriction on permitted operations is removed when operating on the current process.
2. A new flag is introduced - PR_MADV_SELF - which eliminates the need for a pidfd - if this flag is set, the pidfd argument is ignored and the operation is simply applied to the current process.
Therefore a user can simply invoke:
process_madvise(0, iovec, n, MADV_..., PR_MADV_SELF);
And perform any madvise() operation they like on the n ranges specified by the iovec parameter.
This series also introduces a series of self-tests for this feature asserting that the flag functions as expected.
Lorenzo Stoakes (2):
mm/madvise: introduce PR_MADV_SELF flag to process_madvise() selftests/mm: add test for process_madvise PR_MADV_SELF flag use
include/uapi/asm-generic/mman-common.h | 2 + mm/madvise.c | 58 +++++++--- tools/testing/selftests/mm/.gitignore | 1 + tools/testing/selftests/mm/Makefile | 1 + tools/testing/selftests/mm/process_madvise.c | 115 +++++++++++++++++++ 5 files changed, 161 insertions(+), 16 deletions(-) create mode 100644 tools/testing/selftests/mm/process_madvise.c
--
2.46.0
PATCH 1/2 mm/madvise: introduce PR_MADV_SELF flag to process_madvise()
process_madvise() was conceived as a useful means for performing a vector of madvise() operations on a remote process's address space.
However it's useful to be able to do so on the current process also. It is currently rather clunky to do this (requiring a pidfd to be opened for the current process) and introduces unnecessary overhead in incrementing reference counts for the task and mm.
Avoid all of this by providing a PR_MADV_SELF flag, which causes process_madvise() to simply ignore the pidfd parameter and instead apply the operation to the current process.
Since we are operating on our own process, no restrictions need be applied on behaviors we can perform, so do not limit these in that case.
Also extend the case of a user specifying the current process via pidfd to not be restricted on behaviors which can be performed.
--- include/uapi/asm-generic/mman-common.h | 2 + mm/madvise.c | 58 +++++++++++++++++++------- 2 files changed, 44 insertions(+), 16 deletions(-)
include/uapi/asm-generic/mman-common.h +2 -0
@@ -87,4 +87,6 @@#define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ PKEY_DISABLE_WRITE) +#define PR_MADV_SELF (1<<0)/* process_madvise() flag - apply to self */ +#endif /* __ASM_GENERIC_MMAN_COMMON_H */
mm/madvise.c +42 -16
102 lines not on this page · raw message
Signature · 1 line
2.46.0
PATCH 2/2 selftests/mm: add test for process_madvise PR_MADV_SELF flag use
In reply to Lorenzo StoakesAdd a new process_madvise() selftest, and add a test for the newly introduced PR_MADV_SELF flag.
Assert that we can perform a vector operation of an operation that would not be permitted on a remote mm (MADV_DONTNEED in this instance) on ones in our own mm and that the operation is correctly peformed.
--- tools/testing/selftests/mm/.gitignore | 1 + tools/testing/selftests/mm/Makefile | 1 + tools/testing/selftests/mm/process_madvise.c | 115 +++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 tools/testing/selftests/mm/process_madvise.c
tools/testing/selftests/mm/.gitignore +1 -0
@@ -51,3 +51,4 @@ hugetlb_madv_vs_map mseal_test seal_elf droppable +process_madvise
tools/testing/selftests/mm/Makefile +1 -0
@@ -79,6 +79,7 @@ TEST_GEN_FILES += hugetlb_fault_after_madv TEST_GEN_FILES += hugetlb_madv_vs_map TEST_GEN_FILES += hugetlb_dio TEST_GEN_FILES += droppable +TEST_GEN_FILES += process_madvise ifneq ($(ARCH),arm64) TEST_GEN_FILES += soft-dirty
tools/testing/selftests/mm/process_madvise.c new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.46.0
Re: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise()
In reply to Lorenzo StoakesOn Mon, Sep 23, 2024 at 05:03:56PM GMT, Lorenzo Stoakes wrote:
[...]
Quoted 30 lines
SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec
__user*, vec,mm/madvise.c +10
-2size_t, vlen, int, behavior, unsigned int, flags) {@@ -1486,10 +1509,9 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,struct iov_iter iter;struct task_struct *task;struct mm_struct *mm; -size_t total_len;unsigned int f_flags; -if (flags !=0 ) { +if (flags & ~PR_MADV_SELF ) { ret = -EINVAL ; goto out; }@@ -1498,13 +1520,26 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,if (ret <0 ) goto out; +/* +* Perform an madvise operation on the current process. No restrictions +* need be applied, nor do we need to pin the task or mm_struct. +*/ +if (flags &PR_MADV_SELF ) { + ret =vector_madvise (current->mm, &iter, behavior); + goto free_iov; + } + task =pidfd_get_task (pidfd, &f_flags);if (IS_ERR (task)) {
mm/madvise.c SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, · line 1542
Quoted 10 lines
mm/madvise.c +5
-1ret =PTR_ERR (task); goto free_iov; } -if (!process_madvise_behavior_valid (behavior)) { +/* +* We need only perform this check if we are attempting to manipulate a +* remote process's address space. +*/ +if (mm != current->mm && !process_madvise_remote_valid (behavior)) {
Move the above check after mm is initialized i.e. mm = mm_access().
Shakeel
Re: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise()
Quoted 45 lines · Shakeel Butt
On Mon, Sep 23, 2024 at 05:03:56PM GMT, Lorenzo Stoakes wrote:
[...]Quoted 30 lines
SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec
__user*, vec,(quoted diff) +10
-2size_t, vlen, int, behavior, unsigned int, flags) {@@ -1486,10 +1509,9 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, struct iov_iter iter; struct task_struct *task; struct mm_struct *mm; - size_t total_len; unsigned int f_flags; - if (flags != 0) { + if (flags & ~PR_MADV_SELF) { ret = -EINVAL; goto out; }@@ -1498,13 +1520,26 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, if (ret < 0) goto out; + /* + * Perform an madvise operation on the current process. No restrictions + * need be applied, nor do we need to pin the task or mm_struct. + */ + if (flags & PR_MADV_SELF) { + ret = vector_madvise(current->mm, &iter, behavior); + goto free_iov; + } + task = pidfd_get_task(pidfd, &f_flags); if (IS_ERR(task)) {Review SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, · line 1542
Quoted 10 lines
(quoted diff) +5
-1ret = PTR_ERR(task); goto free_iov; } - if (!process_madvise_behavior_valid(behavior)) { + /* + * We need only perform this check if we are attempting to manipulate a + * remote process's address space. + */ + if (mm != current->mm && !process_madvise_remote_valid(behavior)) {Move the above check after mm is initialized i.e. mm =
mm_access().
Quoted 1 line
Shakeel
Ugh, sorry silly one there! Reflexively put that check in the original position.
Enclose a quick fix-patch for it, will fix on any respin also.
----8<----
From dc09e0edf1cf71a89cc4cfc3ec73fdae3c2ab86c Mon Sep 17 00:00:00 2001
From: Lorenzo Stoakes <[email protected]>
Date: Mon, 23 Sep 2024 20:33:07 +0100
Subject: [PATCH] mm/madvise: retrieve mm before checking
--- mm/madvise.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
mm/madvise.c +8 -8
@@ -1535,20 +1535,20 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, goto free_iov; } +/* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */ + mm =mm_access (task,PTRACE_MODE_READ_FSCREDS ); +if (IS_ERR_OR_NULL (mm)) { + ret =IS_ERR (mm) ?PTR_ERR (mm) : -ESRCH ; + goto release_task; + } +/* * We need only perform this check if we are attempting to manipulate a * remote process's address space. */ if (mm != current->mm && !process_madvise_remote_valid (behavior)) { ret = -EINVAL ; - goto release_task; - } - -/* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */ - mm =mm_access (task,PTRACE_MODE_READ_FSCREDS ); -if (IS_ERR_OR_NULL (mm)) { - ret =IS_ERR (mm) ?PTR_ERR (mm) : -ESRCH ; - goto release_task; + goto release_mm; }/*
--
2.46.0
kernel test robot
build botRe: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise()
In reply to Lorenzo Stoakeskernel test robot noticed the following build warnings:
Hi Lorenzo,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on arnd-asm-generic/master soc/for-next linus/master v6.11 next-20240923] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Stoakes/mm-madvise-introduce-PR_MADV_SELF-flag-to-process_madvise/20240924-000845 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/077be0d59cb1047870a84c87c62e7b027af1c75d.1727106751.git.lorenzo.stoakes%40oracle.com patch subject: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise() config: arm-aspeed_g4_defconfig (https://download.01.org/0day-ci/archive/20240924/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 8663a75fa2f31299ab8d1d90288d9df92aadee88) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240924/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from mm/madvise.c:9:
In file included from include/linux/mman.h:5:
In file included from include/linux/mm.h:2198:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from mm/madvise.c:21:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
>> mm/madvise.c:1542:6: warning: variable 'mm' is uninitialized when used here [-Wuninitialized]
1542 | if (mm != current->mm && !process_madvise_remote_valid(behavior)) {
| ^~
mm/madvise.c:1511:22: note: initialize the variable 'mm' to silence this warning
1511 | struct mm_struct *mm;
| ^
| = NULL4 warnings generated.
vim +/mm +1542 mm/madvise.c
1502
1503 SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
1504 size_t, vlen, int, behavior, unsigned int, flags)
1505 {
1506 ssize_t ret;
1507 struct iovec iovstack[UIO_FASTIOV];
1508 struct iovec *iov = iovstack;
1509 struct iov_iter iter;
1510 struct task_struct *task;
1511 struct mm_struct *mm;
1512 unsigned int f_flags;
1513
1514 if (flags & ~PR_MADV_SELF) {
1515 ret = -EINVAL;
1516 goto out;
1517 }
1518
1519 ret = import_iovec(ITER_DEST, vec, vlen, ARRAY_SIZE(iovstack), &iov, &iter);
1520 if (ret < 0)
1521 goto out;
1522
1523 /*
1524 * Perform an madvise operation on the current process. No restrictions
1525 * need be applied, nor do we need to pin the task or mm_struct.
1526 */
1527 if (flags & PR_MADV_SELF) {
1528 ret = vector_madvise(current->mm, &iter, behavior);
1529 goto free_iov;
1530 }
1531
1532 task = pidfd_get_task(pidfd, &f_flags);
1533 if (IS_ERR(task)) {
1534 ret = PTR_ERR(task);
1535 goto free_iov;
1536 }
1537
1538 /*
1539 * We need only perform this check if we are attempting to manipulate a
1540 * remote process's address space.
1541 */
> 1542 if (mm != current->mm && !process_madvise_remote_valid(behavior)) {Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise()
In reply to Lorenzo Stoakeskernel test robot noticed the following build errors:
Hi Lorenzo,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on arnd-asm-generic/master soc/for-next linus/master v6.11 next-20240923] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Stoakes/mm-madvise-introduce-PR_MADV_SELF-flag-to-process_madvise/20240924-000845 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/077be0d59cb1047870a84c87c62e7b027af1c75d.1727106751.git.lorenzo.stoakes%40oracle.com patch subject: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise() config: parisc-allnoconfig (https://download.01.org/0day-ci/archive/20240924/[email protected]/config) compiler: hppa-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240924/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
mm/madvise.c: In function '__do_sys_process_madvise':
>> mm/madvise.c:1514:22: error: 'PR_MADV_SELF' undeclared (first use in this function)
1514 | if (flags & ~PR_MADV_SELF) {
| ^~~~~~~~~~~~ mm/madvise.c:1514:22: note: each undeclared identifier is reported only once for each function it appears in
vim +/PR_MADV_SELF +1514 mm/madvise.c
1502
1503 SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
1504 size_t, vlen, int, behavior, unsigned int, flags)
1505 {
1506 ssize_t ret;
1507 struct iovec iovstack[UIO_FASTIOV];
1508 struct iovec *iov = iovstack;
1509 struct iov_iter iter;
1510 struct task_struct *task;
1511 struct mm_struct *mm;
1512 unsigned int f_flags;
1513
> 1514 if (flags & ~PR_MADV_SELF) {Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Arnd Bergmann
maintainerRe: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise()
In reply to Lorenzo Stoakesmm/madvise.c SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, · line 1543
Quoted 8 lines · Lorenzo Stoakes
On Mon, Sep 23, 2024 at 11:56:06AM GMT, Shakeel Butt wrote:
mm/madvise.c +6
-0+/* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */ + mm =mm_access (task,PTRACE_MODE_READ_FSCREDS ); +if (IS_ERR_OR_NULL (mm)) { + ret =IS_ERR (mm) ?PTR_ERR (mm) : -ESRCH ; + goto release_task; + }
Any chance we can fix mm_access() to not be able to return a NULL pointer and an error pointer? IS_ERR_OR_NULL() is usually an indication of a confusing API, and this is clearly one of them, given that only one of the callers actually wants the NULL value instead of -ESRCH.
Arnd
kernel test robot
build botRe: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise()
In reply to Lorenzo Stoakeskernel test robot noticed the following build errors:
Hi Lorenzo,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on soc/for-next linus/master v6.11 next-20240923] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Stoakes/mm-madvise-introduce-PR_MADV_SELF-flag-to-process_madvise/20240924-000845 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/077be0d59cb1047870a84c87c62e7b027af1c75d.1727106751.git.lorenzo.stoakes%40oracle.com patch subject: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise() config: mips-ip32_defconfig (https://download.01.org/0day-ci/archive/20240924/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 8663a75fa2f31299ab8d1d90288d9df92aadee88) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240924/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from mm/madvise.c:9:
In file included from include/linux/mman.h:5:
In file included from include/linux/mm.h:2198:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from mm/madvise.c:21:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
>> mm/madvise.c:1514:15: error: use of undeclared identifier 'PR_MADV_SELF'
1514 | if (flags & ~PR_MADV_SELF) {
| ^
mm/madvise.c:1527:14: error: use of undeclared identifier 'PR_MADV_SELF'
1527 | if (flags & PR_MADV_SELF) {
| ^3 warnings and 2 errors generated.
vim +/PR_MADV_SELF +1514 mm/madvise.c
1502
1503 SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
1504 size_t, vlen, int, behavior, unsigned int, flags)
1505 {
1506 ssize_t ret;
1507 struct iovec iovstack[UIO_FASTIOV];
1508 struct iovec *iov = iovstack;
1509 struct iov_iter iter;
1510 struct task_struct *task;
1511 struct mm_struct *mm;
1512 unsigned int f_flags;
1513
> 1514 if (flags & ~PR_MADV_SELF) {Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise()
In reply to Arnd BergmannQuoted 16 lines · Arnd Bergmann
mm/madvise.c SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, · line 1543
Quoted 8 lines · Lorenzo Stoakes
On Mon, Sep 23, 2024 at 11:56:06AM GMT, Shakeel Butt wrote:
mm/madvise.c +6
-0+/* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */ + mm =mm_access (task,PTRACE_MODE_READ_FSCREDS ); +if (IS_ERR_OR_NULL (mm)) { + ret =IS_ERR (mm) ?PTR_ERR (mm) : -ESRCH ; + goto release_task; + }Any chance we can fix
mm_access()to not be able to return a NULL pointer and an error pointer?IS_ERR_OR_NULL()is usually an indication of a confusing API, and this is clearly one of them, given that only one of the callers actually wants the NULL value instead of-ESRCH.
Quoted 1 line
Arnd
Agreed, this should be fixed. I think it'd be a bit out of the scope of this series so will send something separately for this.
Re: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise()
In reply to kernel test robotQuoted 41 lines · kernel test robot
Hi Lorenzo,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on soc/for-next linus/master v6.11 next-20240923] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Stoakes/mm-madvise-introduce-PR_MADV_SELF-flag-to-process_madvise/20240924-000845 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/077be0d59cb1047870a84c87c62e7b027af1c75d.1727106751.git.lorenzo.stoakes%40oracle.com patch subject: [PATCH 1/2] mm/madvise: introduce PR_MADV_SELF flag to process_madvise() config: mips-ip32_defconfig (https://download.01.org/0day-ci/archive/20240924/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 8663a75fa2f31299ab8d1d90288d9df92aadee88) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240924/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
In file included from
mm/madvise.c:9:
In file included frominclude/linux/mman.h:5:In file included from include/linux/mm.h:2198: include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~ In file included from mm/madvise.c:21: include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages); | ~~~~~~~~~~~ ^ ~~~ include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 49 | NR_ZONE_LRU_BASE + lru, nr_pages); | ~~~~~~~~~~~~~~~~ ^ ~~~
Quoted 7 lines
Quoted 1 line
Quoted 1 line
mm/madvise.c:1514:15: error: use of undeclared identifier 'PR_MADV_SELF'1514 | if (flags & ~PR_MADV_SELF) { | ^ mm/madvise.c:1527:14: error: use of undeclared identifier 'PR_MADV_SELF' 1527 | if (flags & PR_MADV_SELF) { | ^3 warnings and 2 errors generated.
OK looks like mman-common.h is insufficient for some arches, will fix up and send out a v2.
Quoted 21 lines
vim +/PR_MADV_SELF +1514
mm/madvise.c1502
1503 SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec__user*, vec,
1504size_t, vlen, int, behavior, unsigned int, flags)
1505 {
1506ssize_tret;
1507 struct iovec iovstack[UIO_FASTIOV];
1508 struct iovec *iov = iovstack;
1509 structiov_iteriter;
1510 structtask_struct*task;
1511 structmm_struct*mm;
1512 unsigned intf_flags;
1513Quoted 1 line
1514 if (flags & ~PR_MADV_SELF) {
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki