]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/fs-file.c-initialize-init_files.resize_wait.patch
8df52dc847833761a8d4b772c23407d61430d1cc
[thirdparty/kernel/stable-queue.git] / queue-4.19 / fs-file.c-initialize-init_files.resize_wait.patch
1 From e807d131939378fb4235a78b11c3cb8b7523728f Mon Sep 17 00:00:00 2001
2 From: Shuriyc Chu <sureeju@gmail.com>
3 Date: Tue, 5 Mar 2019 15:41:56 -0800
4 Subject: fs/file.c: initialize init_files.resize_wait
5
6 [ Upstream commit 5704a06810682683355624923547b41540e2801a ]
7
8 (Taken from https://bugzilla.kernel.org/show_bug.cgi?id=200647)
9
10 'get_unused_fd_flags' in kthread cause kernel crash. It works fine on
11 4.1, but causes crash after get 64 fds. It also cause crash on
12 ubuntu1404/1604/1804, centos7.5, and the crash messages are almost the
13 same.
14
15 The crash message on centos7.5 shows below:
16
17 start fd 61
18 start fd 62
19 start fd 63
20 BUG: unable to handle kernel NULL pointer dereference at (null)
21 IP: __wake_up_common+0x2e/0x90
22 PGD 0
23 Oops: 0000 [#1] SMP
24 Modules linked in: test(OE) xt_CHECKSUM iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter devlink sunrpc kvm_intel kvm irqbypass crc32_pclmul ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper cryptd sg ppdev pcspkr virtio_balloon parport_pc parport i2c_piix4 joydev ip_tables xfs libcrc32c sr_mod cdrom sd_mod crc_t10dif crct10dif_generic ata_generic pata_acpi virtio_scsi virtio_console virtio_net cirrus drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm crct10dif_pclmul crct10dif_common crc32c_intel drm ata_piix serio_raw libata virtio_pci virtio_ring i2c_core
25 virtio floppy dm_mirror dm_region_hash dm_log dm_mod
26 CPU: 2 PID: 1820 Comm: test_fd Kdump: loaded Tainted: G OE ------------ 3.10.0-862.3.3.el7.x86_64 #1
27 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.10.2-0-g5f4c7b1-prebuilt.qemu-project.org 04/01/2014
28 task: ffff8e92b9431fa0 ti: ffff8e94247a0000 task.ti: ffff8e94247a0000
29 RIP: 0010:__wake_up_common+0x2e/0x90
30 RSP: 0018:ffff8e94247a2d18 EFLAGS: 00010086
31 RAX: 0000000000000000 RBX: ffffffff9d09daa0 RCX: 0000000000000000
32 RDX: 0000000000000000 RSI: 0000000000000003 RDI: ffffffff9d09daa0
33 RBP: ffff8e94247a2d50 R08: 0000000000000000 R09: ffff8e92b95dfda8
34 R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff9d09daa8
35 R13: 0000000000000003 R14: 0000000000000000 R15: 0000000000000003
36 FS: 0000000000000000(0000) GS:ffff8e9434e80000(0000) knlGS:0000000000000000
37 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
38 CR2: 0000000000000000 CR3: 000000017c686000 CR4: 00000000000207e0
39 Call Trace:
40 __wake_up+0x39/0x50
41 expand_files+0x131/0x250
42 __alloc_fd+0x47/0x170
43 get_unused_fd_flags+0x30/0x40
44 test_fd+0x12a/0x1c0 [test]
45 kthread+0xd1/0xe0
46 ret_from_fork_nospec_begin+0x21/0x21
47 Code: 66 90 55 48 89 e5 41 57 41 89 f7 41 56 41 89 ce 41 55 41 54 49 89 fc 49 83 c4 08 53 48 83 ec 10 48 8b 47 08 89 55 cc 4c 89 45 d0 <48> 8b 08 49 39 c4 48 8d 78 e8 4c 8d 69 e8 75 08 eb 3b 4c 89 ef
48 RIP __wake_up_common+0x2e/0x90
49 RSP <ffff8e94247a2d18>
50 CR2: 0000000000000000
51
52 This issue exists since CentOS 7.5 3.10.0-862 and CentOS 7.4
53 (3.10.0-693.21.1 ) is ok. Root cause: the item 'resize_wait' is not
54 initialized before being used.
55
56 Reported-by: Richard Zhang <zhang.zijian@h3c.com>
57 Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
58 Cc: Al Viro <viro@zeniv.linux.org.uk>
59 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
60 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
61 Signed-off-by: Sasha Levin <sashal@kernel.org>
62 ---
63 fs/file.c | 1 +
64 1 file changed, 1 insertion(+)
65
66 diff --git a/fs/file.c b/fs/file.c
67 index 7ffd6e9d103d..780d29e58847 100644
68 --- a/fs/file.c
69 +++ b/fs/file.c
70 @@ -457,6 +457,7 @@ struct files_struct init_files = {
71 .full_fds_bits = init_files.full_fds_bits_init,
72 },
73 .file_lock = __SPIN_LOCK_UNLOCKED(init_files.file_lock),
74 + .resize_wait = __WAIT_QUEUE_HEAD_INITIALIZER(init_files.resize_wait),
75 };
76
77 static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start)
78 --
79 2.19.1
80