Skip to content

Commit 844c6fd

Browse files
Zhihao Chengrichardweinberger
authored andcommitted
ubi: Revert "ubi: wl: Close down wear-leveling before nand is suspended"
Commit 5580cda ("ubi: wl: Close down wear-leveling before nand is suspended") added a reboot notification in UBI layer to shutdown the wear-leveling subsystem, which imported an UAF problem[1]. Besides that, the method also brings other potential UAF problems, for example: reboot kworker ubi_wl_reboot_notifier ubi_wl_close ubi_fastmap_close kfree(ubi->fm) update_fastmap_work_fn ubi_update_fastmap old_fm = ubi->fm if (old_fm && old_fm->e[i]) // UAF! Actually, the problem fixed by commit 5580cda ("ubi: wl: Close down wear-leveling before nand is suspended") has been solved by commit 8cba323 ("mtd: rawnand: protect access to rawnand devices while in suspend"), which was discussed in [2]. So we can revert the commit 5580cda ("ubi: wl: Close down wear-leveling before nand is suspended") directly. [1] https://lore.kernel.org/linux-mtd/[email protected]/ [2] https://lore.kernel.org/all/[email protected]/ Fixes: 5580cda ("ubi: wl: Close down wear-leveling before nand is suspended") Reported-by: Dennis Lam <[email protected]> Closes: https://lore.kernel.org/linux-mtd/[email protected]/ Signed-off-by: Zhihao Cheng <[email protected]> Acked-by: Mårten Lindahl <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent 404de7a commit 844c6fd

File tree

2 files changed

+0
-23
lines changed

2 files changed

+0
-23
lines changed

drivers/mtd/ubi/ubi.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@ struct ubi_debug_info {
549549
* @peb_buf: a buffer of PEB size used for different purposes
550550
* @buf_mutex: protects @peb_buf
551551
* @ckvol_mutex: serializes static volume checking when opening
552-
* @wl_reboot_notifier: close all wear-leveling work before reboot
553552
*
554553
* @dbg: debugging information for this UBI device
555554
*/
@@ -652,7 +651,6 @@ struct ubi_device {
652651
void *peb_buf;
653652
struct mutex buf_mutex;
654653
struct mutex ckvol_mutex;
655-
struct notifier_block wl_reboot_notifier;
656654

657655
struct ubi_debug_info dbg;
658656
};

drivers/mtd/ubi/wl.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
#include <linux/crc32.h>
9090
#include <linux/freezer.h>
9191
#include <linux/kthread.h>
92-
#include <linux/reboot.h>
9392
#include "ubi.h"
9493
#include "wl.h"
9594

@@ -128,8 +127,6 @@ static int self_check_in_wl_tree(const struct ubi_device *ubi,
128127
struct ubi_wl_entry *e, struct rb_root *root);
129128
static int self_check_in_pq(const struct ubi_device *ubi,
130129
struct ubi_wl_entry *e);
131-
static int ubi_wl_reboot_notifier(struct notifier_block *n,
132-
unsigned long state, void *cmd);
133130

134131
/**
135132
* wl_tree_add - add a wear-leveling entry to a WL RB-tree.
@@ -1953,13 +1950,6 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
19531950
if (!ubi->ro_mode && !ubi->fm_disabled)
19541951
ubi_ensure_anchor_pebs(ubi);
19551952
#endif
1956-
1957-
if (!ubi->wl_reboot_notifier.notifier_call) {
1958-
ubi->wl_reboot_notifier.notifier_call = ubi_wl_reboot_notifier;
1959-
ubi->wl_reboot_notifier.priority = 1; /* Higher than MTD */
1960-
register_reboot_notifier(&ubi->wl_reboot_notifier);
1961-
}
1962-
19631953
return 0;
19641954

19651955
out_free:
@@ -2005,17 +1995,6 @@ void ubi_wl_close(struct ubi_device *ubi)
20051995
kfree(ubi->lookuptbl);
20061996
}
20071997

2008-
static int ubi_wl_reboot_notifier(struct notifier_block *n,
2009-
unsigned long state, void *cmd)
2010-
{
2011-
struct ubi_device *ubi;
2012-
2013-
ubi = container_of(n, struct ubi_device, wl_reboot_notifier);
2014-
ubi_wl_close(ubi);
2015-
2016-
return NOTIFY_DONE;
2017-
}
2018-
20191998
/**
20201999
* self_check_ec - make sure that the erase counter of a PEB is correct.
20212000
* @ubi: UBI device description object

0 commit comments

Comments
 (0)