2020-10-30 19:05:45

by Ben Widawsky

[permalink] [raw]
Subject: [PATCH 04/12] mm/mempolicy: allow preferred code to take a nodemask

From: Dave Hansen <[email protected]>

Create a helper function (mpol_new_preferred_many()) which is usable
both by the old, single-node MPOL_PREFERRED and the new
MPOL_PREFERRED_MANY.

Enforce the old single-node MPOL_PREFERRED behavior in the "new"
version of mpol_new_preferred() which calls mpol_new_preferred_many().

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Dave Hansen <[email protected]>
Signed-off-by: Ben Widawsky <[email protected]>
---
mm/mempolicy.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 21a6f80f91a9..b1b43e511d6f 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -203,17 +203,30 @@ static int mpol_new_interleave(struct mempolicy *pol, const nodemask_t *nodes)
return 0;
}

-static int mpol_new_preferred(struct mempolicy *pol, const nodemask_t *nodes)
+static int mpol_new_preferred_many(struct mempolicy *pol,
+ const nodemask_t *nodes)
{
if (!nodes)
pol->flags |= MPOL_F_LOCAL; /* local allocation */
else if (nodes_empty(*nodes))
return -EINVAL; /* no allowed nodes */
else
- pol->v.preferred_nodes = nodemask_of_node(first_node(*nodes));
+ pol->v.preferred_nodes = *nodes;
return 0;
}

+static int mpol_new_preferred(struct mempolicy *pol, const nodemask_t *nodes)
+{
+ if (nodes) {
+ /* MPOL_PREFERRED can only take a single node: */
+ nodemask_t tmp = nodemask_of_node(first_node(*nodes));
+
+ return mpol_new_preferred_many(pol, &tmp);
+ }
+
+ return mpol_new_preferred_many(pol, NULL);
+}
+
static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)
{
if (nodes_empty(*nodes))
--
2.29.2


2021-01-03 13:30:17

by kernel test robot

[permalink] [raw]
Subject: [mm/mempolicy] 5ef9c2a53c: Kernel_panic-not_syncing:stack-protector:Kernel_stack_is_corrupted_in:mpol_new_preferred


Greeting,

FYI, we noticed the following commit (built with gcc-9):

commit: 5ef9c2a53c14ed6f0aaa696a04c5d31381eff005 ("[PATCH 04/12] mm/mempolicy: allow preferred code to take a nodemask")
url: https://github.com/0day-ci/linux/commits/Ben-Widawsky/Introduced-multi-preference-mempolicy/20201031-222924
base: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git 5fc6b075e165f641fbc366b58b578055762d5f8c

in testcase: trinity
version: trinity-x86_64-4d2343bd-1_20201007
with following parameters:

runtime: 300s

test-description: Trinity is a linux system call fuzz tester.
test-url: http://codemonkey.org.uk/projects/trinity/


on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 8G

caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):


+------------------------------------------------------------------------------------------+------------+------------+
| | 006fd7781f | 5ef9c2a53c |
+------------------------------------------------------------------------------------------+------------+------------+
| Kernel_panic-not_syncing:stack-protector:Kernel_stack_is_corrupted_in:mpol_new_preferred | 0 | 10 |
+------------------------------------------------------------------------------------------+------------+------------+


If you fix the issue, kindly add following tag
Reported-by: kernel test robot <[email protected]>


[ 93.254954] audit: type=1326 audit(1609487580.227:15): auid=4294967295 uid=65534 gid=65534 ses=4294967295 subj==unconfined pid=1571 comm="trinity-c4" exe="/bin/trinity" sig=9 arch=c000003e syscall=8 compat=0 ip=0x7f3aee712597 code=0x0
[ 93.456390] audit: type=1326 audit(1609487580.429:16): auid=4294967295 uid=65534 gid=65534 ses=4294967295 subj==unconfined pid=1657 comm="trinity-c4" exe="/bin/trinity" sig=9 arch=c000003e syscall=8 compat=0 ip=0x7f3aee712597 code=0x0
[ 94.475141] [main] 92493 iterations. [F:71179 S:20820 HI:4127 STALLED:1]
[ 94.475153]
[ 100.659993] audit: type=1326 audit(1609487587.632:17): auid=4294967295 uid=65534 gid=65534 ses=4294967295 subj==unconfined pid=1740 comm="trinity-c0" exe="/bin/trinity" sig=9 arch=c000003e syscall=8 compat=0 ip=0x7f3aee712597 code=0x0
[ 101.703531] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: mpol_new_preferred+0x12f/0x140
[ 101.708513] CPU: 1 PID: 1678 Comm: trinity-c7 Not tainted 5.10.0-rc1-00280-g5ef9c2a53c14 #1
[ 101.712591] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
[ 101.716816] Call Trace:
[ 101.723732] dump_stack+0x57/0x6a
[ 101.726937] panic+0x102/0x2d2
[ 101.729938] ? mpol_new_preferred+0x12f/0x140
[ 101.733195] __stack_chk_fail+0x10/0x20
[ 101.736256] mpol_new_preferred+0x12f/0x140
[ 101.739874] do_set_mempolicy+0x68/0x140
[ 101.742937] kernel_set_mempolicy+0x7c/0xa0
[ 101.746151] do_syscall_64+0x33/0x40
[ 101.749013] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 101.752279] RIP: 0033:0x7f3aee71bf59
[ 101.755238] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 07 6f 0c 00 f7 d8 64 89 01 48
[ 101.766139] RSP: 002b:00007fff9ce9f068 EFLAGS: 00000246 ORIG_RAX: 00000000000000ee
[ 101.770126] RAX: ffffffffffffffda RBX: 00000000000000ee RCX: 00007f3aee71bf59
[ 101.773764] RDX: 0000000000000200 RSI: 00007f3aec7c4000 RDI: 0000000000000001
[ 101.777425] RBP: 00000000000000ee R08: 00000000ffffefff R09: 000000000000002f
[ 101.781357] R10: 0000000000000008 R11: 0000000000000246 R12: 0000000000000002
[ 101.785035] R13: 00007f3aed0c8058 R14: 00007f3aee6046c0 R15: 00007f3aed0c8000
[ 101.788723] Kernel Offset: 0x7200000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)

Kboot worker: lkp-worker31


To reproduce:

# build kernel
cd linux
cp config-5.10.0-rc1-00280-g5ef9c2a53c14 .config
make HOSTCC=gcc-9 CC=gcc-9 ARCH=x86_64 olddefconfig prepare modules_prepare bzImage

git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
bin/lkp qemu -k <bzImage> job-script # job-script is attached in this email



Thanks,
Oliver Sang


Attachments:
(No filename) (4.30 kB)
config-5.10.0-rc1-00280-g5ef9c2a53c14 (173.87 kB)
job-script (4.53 kB)
dmesg.xz (16.04 kB)
Download all attachments