aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/backport-5.10/415-v6.0-mtd-core-check-partition-before-dereference.patch
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2022-10-04 12:04:37 +0200
committerRafał Miłecki <rafal@milecki.pl>2022-10-04 12:43:01 +0200
commit977f6f36a0121b213f9eee4a7deb7fdf073320e4 (patch)
tree0aabc8d1e52aef65b682bae5fa6943b15ca8ce8c /target/linux/generic/backport-5.10/415-v6.0-mtd-core-check-partition-before-dereference.patch
parent562894b39da381264a34ce31e9334c8a036fa139 (diff)
downloadupstream-977f6f36a0121b213f9eee4a7deb7fdf073320e4.tar.gz
upstream-977f6f36a0121b213f9eee4a7deb7fdf073320e4.tar.bz2
upstream-977f6f36a0121b213f9eee4a7deb7fdf073320e4.zip
kernel: fix possible mtd NULL pointer dereference
Fixes: cae4d089bc1d3 ("kernel: backport mtd dynamic partition patch") Signed-off-by: Rafał Miłecki <rafal@milecki.pl> (cherry picked from commit a5265497a4f6da158e95d6a450cb2cb6dc085cab)
Diffstat (limited to 'target/linux/generic/backport-5.10/415-v6.0-mtd-core-check-partition-before-dereference.patch')
-rw-r--r--target/linux/generic/backport-5.10/415-v6.0-mtd-core-check-partition-before-dereference.patch30
1 files changed, 30 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.10/415-v6.0-mtd-core-check-partition-before-dereference.patch b/target/linux/generic/backport-5.10/415-v6.0-mtd-core-check-partition-before-dereference.patch
new file mode 100644
index 0000000000..65789ddf2d
--- /dev/null
+++ b/target/linux/generic/backport-5.10/415-v6.0-mtd-core-check-partition-before-dereference.patch
@@ -0,0 +1,30 @@
+From 7ec4cdb321738d44ae5d405e7b6ac73dfbf99caa Mon Sep 17 00:00:00 2001
+From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
+Date: Mon, 25 Jul 2022 22:49:25 +0900
+Subject: [PATCH] mtd: core: check partition before dereference
+
+syzbot is reporting NULL pointer dereference at mtd_check_of_node() [1],
+for mtdram test device (CONFIG_MTD_MTDRAM) is not partition.
+
+Link: https://syzkaller.appspot.com/bug?extid=fe013f55a2814a9e8cfd [1]
+Reported-by: syzbot <syzbot+fe013f55a2814a9e8cfd@syzkaller.appspotmail.com>
+Reported-by: kernel test robot <oliver.sang@intel.com>
+Fixes: ad9b10d1eaada169 ("mtd: core: introduce of support for dynamic partitions")
+Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
+CC: stable@vger.kernel.org
+Signed-off-by: Richard Weinberger <richard@nod.at>
+---
+ drivers/mtd/mtdcore.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/mtd/mtdcore.c
++++ b/drivers/mtd/mtdcore.c
+@@ -574,6 +574,8 @@ static void mtd_check_of_node(struct mtd
+ return;
+
+ /* Check if a partitions node exist */
++ if (!mtd_is_partition(mtd))
++ return;
+ parent = mtd->parent;
+ parent_dn = dev_of_node(&parent->dev);
+ if (!parent_dn)