aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic-2.6/patches-2.6.30/065-rootfs_split.patch
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2009-07-21 15:05:13 +0000
committerFelix Fietkau <nbd@openwrt.org>2009-07-21 15:05:13 +0000
commitdffad9690ff20a45084325ab89f77b14e1392096 (patch)
treeb08047d7f4b776d327c528db4531fbe363efd91f /target/linux/generic-2.6/patches-2.6.30/065-rootfs_split.patch
parent5df06062655dbf0585e2c90ca0cd8dc68f723c77 (diff)
downloadupstream-dffad9690ff20a45084325ab89f77b14e1392096.tar.gz
upstream-dffad9690ff20a45084325ab89f77b14e1392096.tar.bz2
upstream-dffad9690ff20a45084325ab89f77b14e1392096.zip
fix a >2 year old stack overflow in the mtd rootfs split patch which only caused issues on the orion platform on 2.6.30. also merge the squashfs4 fix into the rootfs split patch
SVN-Revision: 16944
Diffstat (limited to 'target/linux/generic-2.6/patches-2.6.30/065-rootfs_split.patch')
-rw-r--r--target/linux/generic-2.6/patches-2.6.30/065-rootfs_split.patch19
1 files changed, 9 insertions, 10 deletions
diff --git a/target/linux/generic-2.6/patches-2.6.30/065-rootfs_split.patch b/target/linux/generic-2.6/patches-2.6.30/065-rootfs_split.patch
index 0eca8990bc..824e3df10e 100644
--- a/target/linux/generic-2.6/patches-2.6.30/065-rootfs_split.patch
+++ b/target/linux/generic-2.6/patches-2.6.30/065-rootfs_split.patch
@@ -37,7 +37,7 @@
/*
* MTD methods which simply translate the effective address and pass through
-@@ -512,6 +514,156 @@ out_register:
+@@ -512,6 +514,155 @@ out_register:
return slave;
}
@@ -54,32 +54,31 @@
+
+static int split_squashfs(struct mtd_info *master, int offset, int *split_offset)
+{
-+ char buf[512];
-+ struct squashfs_super_block *sb = (struct squashfs_super_block *) buf;
++ struct squashfs_super_block sb;
+ int len, ret;
+
-+ ret = master->read(master, offset, sizeof(*sb), &len, buf);
-+ if (ret || (len != sizeof(*sb))) {
++ ret = master->read(master, offset, sizeof(sb), &len, (void *) &sb);
++ if (ret || (len != sizeof(sb))) {
+ printk(KERN_ALERT "split_squashfs: error occured while reading "
+ "from \"%s\"\n", master->name);
+ return -EINVAL;
+ }
+
-+ if (*((u32 *) buf) != SQUASHFS_MAGIC) {
++ if (SQUASHFS_MAGIC != le32_to_cpu(sb.s_magic) ) {
+ printk(KERN_ALERT "split_squashfs: no squashfs found in \"%s\"\n",
+ master->name);
+ *split_offset = 0;
+ return 0;
+ }
+
-+ if (sb->bytes_used <= 0) {
++ if (le64_to_cpu((sb.bytes_used)) <= 0) {
+ printk(KERN_ALERT "split_squashfs: squashfs is empty in \"%s\"\n",
+ master->name);
+ *split_offset = 0;
+ return 0;
+ }
+
-+ len = (u32) sb->bytes_used;
++ len = (u32) le64_to_cpu(sb.bytes_used);
+ len += (offset & 0x000fffff);
+ len += (master->erasesize - 1);
+ len &= ~(master->erasesize - 1);
@@ -194,7 +193,7 @@
/*
* This function, given a master MTD object and a partition table, creates
* and registers slave MTD objects which are bound to the master according to
-@@ -527,14 +679,29 @@ int add_mtd_partitions(struct mtd_info *
+@@ -527,14 +678,29 @@ int add_mtd_partitions(struct mtd_info *
{
struct mtd_part *slave;
uint64_t cur_offset = 0;
@@ -227,7 +226,7 @@
cur_offset = slave->offset + slave->mtd.size;
}
-@@ -542,6 +709,32 @@ int add_mtd_partitions(struct mtd_info *
+@@ -542,6 +708,32 @@ int add_mtd_partitions(struct mtd_info *
}
EXPORT_SYMBOL(add_mtd_partitions);