Vlastimil Babka
0c5e357fa8
mm: /proc/pid/smaps_rollup: fix NULL pointer deref in smaps_pte_range()
...
commit fa76da461bb0be13c8339d984dcf179151167c8f upstream.
Leonardo reports an apparent regression in 4.19-rc7:
BUG: unable to handle kernel NULL pointer dereference at 00000000000000f0
PGD 0 P4D 0
Oops: 0000 [#1 ] PREEMPT SMP PTI
CPU: 3 PID: 6032 Comm: python Not tainted 4.19.0-041900rc7-lowlatency #201810071631
Hardware name: LENOVO 80UG/Toronto 4A2, BIOS 0XCN45WW 08/09/2018
RIP: 0010:smaps_pte_range+0x32d/0x540
Code: 80 00 00 00 00 74 a9 48 89 de 41 f6 40 52 40 0f 85 04 02 00 00 49 2b 30 48 c1 ee 0c 49 03 b0 98 00 00 00 49 8b 80 a0 00 00 00 <48> 8b b8 f0 00 00 00 e8 b7 ef ec ff 48 85 c0 0f 84 71 ff ff ff a8
RSP: 0018:ffffb0cbc484fb88 EFLAGS: 00010202
RAX: 0000000000000000 RBX: 0000560ddb9e9000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000560ddb9e9 RDI: 0000000000000001
RBP: ffffb0cbc484fbc0 R08: ffff94a5a227a578 R09: ffff94a5a227a578
R10: 0000000000000000 R11: 0000560ddbbe7000 R12: ffffe903098ba728
R13: ffffb0cbc484fc78 R14: ffffb0cbc484fcf8 R15: ffff94a5a2e9cf48
FS: 00007f6dfb683740(0000) GS:ffff94a5aaf80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000000000f0 CR3: 000000011c118001 CR4: 00000000003606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
__walk_page_range+0x3c2/0x6f0
walk_page_vma+0x42/0x60
smap_gather_stats+0x79/0xe0
? gather_pte_stats+0x320/0x320
? gather_hugetlb_stats+0x70/0x70
show_smaps_rollup+0xcd/0x1c0
seq_read+0x157/0x400
__vfs_read+0x3a/0x180
? security_file_permission+0x93/0xc0
? security_file_permission+0x93/0xc0
vfs_read+0x8f/0x140
ksys_read+0x55/0xc0
__x64_sys_read+0x1a/0x20
do_syscall_64+0x5a/0x110
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Decoded code matched to local compilation+disassembly points to
smaps_pte_entry():
} else if (unlikely(IS_ENABLED(CONFIG_SHMEM) && mss->check_shmem_swap
&& pte_none(*pte))) {
page = find_get_entry(vma->vm_file->f_mapping,
linear_page_index(vma, addr));
Here, vma->vm_file is NULL. mss->check_shmem_swap should be false in that
case, however for smaps_rollup, smap_gather_stats() can set the flag true
for one vma and leave it true for subsequent vma's where it should be
false.
To fix, reset the check_shmem_swap flag to false. There's also related
bug which sets mss->swap to shmem_swapped, which in the context of
smaps_rollup overwrites any value accumulated from previous vma's. Fix
that as well.
Note that the report suggests a regression between 4.17.19 and 4.19-rc7,
which makes the 4.19 series ending with commit 258f669e7e88 ("mm:
/proc/pid/smaps_rollup: convert to single value seq_file") suspicious.
But the mss was reused for rollup since 493b0e9d945f ("mm: add
/proc/pid/smaps_rollup") so let's play it safe with the stable backport.
Link: http://lkml.kernel.org/r/555fbd1f-4ac9-0b58-dcd4-5dc4380ff7ca@suse.cz
Link: https://bugzilla.kernel.org/show_bug.cgi?id=201377
Fixes: 493b0e9d945f ("mm: add /proc/pid/smaps_rollup")
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Reported-by: Leonardo Soares Müller <leozinho29_eu@hotmail.com>
Tested-by: Leonardo Soares Müller <leozinho29_eu@hotmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Daniel Colascione <dancol@google.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-13 11:15:08 -08:00
..
2018-09-09 19:55:55 +02:00
2017-11-02 11:10:55 +01:00
2018-05-30 07:51:47 +02:00
2018-07-08 15:30:51 +02:00
2018-09-19 22:43:48 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-11-04 14:52:45 +01:00
2018-11-10 07:48:34 -08:00
2018-08-24 13:09:07 +02:00
2018-11-04 14:52:43 +01:00
2017-11-24 08:37:05 +01:00
2018-09-26 08:38:10 +02:00
2017-11-02 11:10:55 +01:00
2018-08-03 07:50:32 +02:00
2017-07-15 12:00:42 -07:00
2018-07-17 11:39:26 +02:00
2017-11-02 11:10:55 +01:00
2018-06-21 04:02:42 +09:00
2017-07-11 06:09:21 -04:00
2017-11-02 11:10:55 +01:00
2017-09-07 11:59:42 -07:00
2018-07-11 16:29:22 +02:00
2018-11-13 11:15:06 -08:00
2018-11-13 11:15:01 -08:00
2018-11-04 14:52:47 +01:00
2018-09-05 09:26:29 +02:00
2018-09-05 09:26:38 +02:00
2018-11-13 11:15:05 -08:00
2018-09-15 09:45:26 +02:00
2018-09-15 09:45:27 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-04-19 08:56:21 +02:00
2018-10-03 17:00:57 -07:00
2018-11-13 11:15:05 -08:00
2018-11-13 11:14:45 -08:00
2018-08-09 12:16:39 +02:00
2018-02-16 20:22:59 +01:00
2018-02-03 17:39:08 +01:00
2017-11-02 11:10:55 +01:00
2018-03-28 18:24:43 +02:00
2018-09-26 08:38:09 +02:00
2018-02-03 17:39:08 +01:00
2018-11-10 07:48:33 -08:00
2018-05-30 07:51:47 +02:00
2017-11-02 11:10:55 +01:00
2018-11-10 07:48:34 -08:00
2017-11-02 11:10:55 +01:00
2018-11-04 14:52:41 +01:00
2017-11-02 11:10:55 +01:00
2018-06-26 08:06:33 +08:00
2018-11-10 07:48:33 -08:00
2018-11-13 11:15:08 -08:00
2018-09-26 08:38:05 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-09-09 19:56:02 +02:00
2017-09-06 17:27:26 -07:00
2018-09-15 09:45:27 +02:00
2017-11-02 11:10:55 +01:00
2018-09-05 09:26:32 +02:00
2018-09-05 09:26:41 +02:00
2017-11-02 11:10:55 +01:00
2017-07-06 03:31:46 -04:00
2018-10-13 09:27:29 +02:00
2018-07-03 11:25:03 +02:00
2018-05-30 07:51:47 +02:00
2018-11-10 07:48:34 -08:00
2018-06-05 11:41:54 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-09-04 19:05:15 -04:00
2017-09-14 18:13:32 -07:00
2018-09-26 08:38:09 +02:00
2017-11-02 11:10:55 +01:00
2018-06-26 08:06:33 +08:00
2017-10-03 17:54:25 -07:00
2018-08-03 07:50:42 +02:00
2017-11-30 08:40:45 +00:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-04-26 11:02:14 +02:00
2018-10-18 09:16:25 +02:00
2018-03-08 22:41:06 -08:00
2017-11-02 11:10:55 +01:00
2017-07-03 21:13:25 -07:00
2017-09-08 18:26:49 -07:00
2018-03-03 10:24:21 +01:00
2017-12-17 15:07:59 +01:00
2017-11-02 11:10:55 +01:00
2017-08-28 00:50:23 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-05-16 10:10:25 +02:00
2018-07-17 11:39:27 +02:00
2017-09-13 09:11:44 -07:00
2018-11-10 07:48:33 -08:00
2018-10-03 17:00:53 -07:00
2017-07-12 16:26:00 -07:00
2017-07-06 07:02:29 -04:00
2018-10-03 17:00:53 -07:00
2017-11-02 11:10:55 +01:00
2018-02-22 15:42:25 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-04-19 08:56:19 +02:00
2018-10-20 09:48:52 +02:00
2017-11-02 11:10:55 +01:00
2017-09-05 12:53:12 +02:00
2018-02-16 20:23:05 +01:00
2017-11-02 11:10:55 +01:00
2018-11-10 07:48:33 -08:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-02-22 15:42:28 +01:00
2017-11-02 11:10:55 +01:00
2017-09-04 19:05:15 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-05-30 07:51:47 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-08-06 16:20:49 +02:00
2017-11-02 11:10:55 +01:00
2018-10-10 08:54:27 +02:00