]>
Commit | Line | Data |
---|---|---|
d3e91060 SL |
1 | From 368349e58c2cc6c4d2372800863f61d724175b2f Mon Sep 17 00:00:00 2001 |
2 | From: Daniel Santos <daniel.santos@pobox.com> | |
3 | Date: Fri, 19 Oct 2018 03:30:20 -0500 | |
4 | Subject: jffs2: Fix use of uninitialized delayed_work, lockdep breakage | |
5 | ||
6 | [ Upstream commit a788c5272769ddbcdbab297cf386413eeac04463 ] | |
7 | ||
8 | jffs2_sync_fs makes the assumption that if CONFIG_JFFS2_FS_WRITEBUFFER | |
9 | is defined then a write buffer is available and has been initialized. | |
10 | However, this does is not the case when the mtd device has no | |
11 | out-of-band buffer: | |
12 | ||
13 | int jffs2_nand_flash_setup(struct jffs2_sb_info *c) | |
14 | { | |
15 | if (!c->mtd->oobsize) | |
16 | return 0; | |
17 | ... | |
18 | ||
19 | The resulting call to cancel_delayed_work_sync passing a uninitialized | |
20 | (but zeroed) delayed_work struct forces lockdep to become disabled. | |
21 | ||
22 | [ 90.050639] overlayfs: upper fs does not support tmpfile. | |
23 | [ 90.652264] INFO: trying to register non-static key. | |
24 | [ 90.662171] the code is fine but needs lockdep annotation. | |
25 | [ 90.673090] turning off the locking correctness validator. | |
26 | [ 90.684021] CPU: 0 PID: 1762 Comm: mount_root Not tainted 4.14.63 #0 | |
27 | [ 90.696672] Stack : 00000000 00000000 80d8f6a2 00000038 805f0000 80444600 8fe364f4 805dfbe7 | |
28 | [ 90.713349] 80563a30 000006e2 8068370c 00000001 00000000 00000001 8e2fdc48 ffffffff | |
29 | [ 90.730020] 00000000 00000000 80d90000 00000000 00000106 00000000 6465746e 312e3420 | |
30 | [ 90.746690] 6b636f6c 03bf0000 f8000000 20676e69 00000000 80000000 00000000 8e2c2a90 | |
31 | [ 90.763362] 80d90000 00000001 00000000 8e2c2a90 00000003 80260dc0 08052098 80680000 | |
32 | [ 90.780033] ... | |
33 | [ 90.784902] Call Trace: | |
34 | [ 90.789793] [<8000f0d8>] show_stack+0xb8/0x148 | |
35 | [ 90.798659] [<8005a000>] register_lock_class+0x270/0x55c | |
36 | [ 90.809247] [<8005cb64>] __lock_acquire+0x13c/0xf7c | |
37 | [ 90.818964] [<8005e314>] lock_acquire+0x194/0x1dc | |
38 | [ 90.828345] [<8003f27c>] flush_work+0x200/0x24c | |
39 | [ 90.837374] [<80041dfc>] __cancel_work_timer+0x158/0x210 | |
40 | [ 90.847958] [<801a8770>] jffs2_sync_fs+0x20/0x54 | |
41 | [ 90.857173] [<80125cf4>] iterate_supers+0xf4/0x120 | |
42 | [ 90.866729] [<80158fc4>] sys_sync+0x44/0x9c | |
43 | [ 90.875067] [<80014424>] syscall_common+0x34/0x58 | |
44 | ||
45 | Signed-off-by: Daniel Santos <daniel.santos@pobox.com> | |
46 | Reviewed-by: Hou Tao <houtao1@huawei.com> | |
47 | Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> | |
48 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
49 | --- | |
50 | fs/jffs2/super.c | 3 ++- | |
51 | 1 file changed, 2 insertions(+), 1 deletion(-) | |
52 | ||
53 | diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c | |
54 | index 1544f530ccd0..023e7f32ee1b 100644 | |
55 | --- a/fs/jffs2/super.c | |
56 | +++ b/fs/jffs2/super.c | |
57 | @@ -101,7 +101,8 @@ static int jffs2_sync_fs(struct super_block *sb, int wait) | |
58 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); | |
59 | ||
60 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | |
61 | - cancel_delayed_work_sync(&c->wbuf_dwork); | |
62 | + if (jffs2_is_writebuffered(c)) | |
63 | + cancel_delayed_work_sync(&c->wbuf_dwork); | |
64 | #endif | |
65 | ||
66 | mutex_lock(&c->alloc_sem); | |
67 | -- | |
68 | 2.19.1 | |
69 |