From 9e45351250f95f878c534fabe6d6ebccd13dae8f Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Tue, 22 May 2018 14:59:31 +0800 Subject: [PATCH] update kernel 4.9 patch --- ...-improve-handling-TRX-partition-size.patch | 65 ------------------- ...-generic-parsing-of-linux-part-probe.patch | 8 +-- .../400-mtd-add-rootfs-split-support.patch | 6 +- ...for-different-partition-parser-types.patch | 2 +- ...arsers-for-rootfs-and-firmware-split.patch | 6 +- .../404-mtd-add-more-helper-functions.patch | 4 +- .../411-mtd-partial_eraseblock_write.patch | 2 +- .../479-mtd-spi-nor-add-eon-en25qh32.patch | 10 +++ ...ng-with-source-address-failed-policy.patch | 22 +++++-- 9 files changed, 39 insertions(+), 86 deletions(-) delete mode 100644 target/linux/generic/pending-4.9/142-mtd-bcm47xxpart-improve-handling-TRX-partition-size.patch create mode 100644 target/linux/generic/pending-4.9/479-mtd-spi-nor-add-eon-en25qh32.patch diff --git a/target/linux/generic/pending-4.9/142-mtd-bcm47xxpart-improve-handling-TRX-partition-size.patch b/target/linux/generic/pending-4.9/142-mtd-bcm47xxpart-improve-handling-TRX-partition-size.patch deleted file mode 100644 index 60c8ecbdc..000000000 --- a/target/linux/generic/pending-4.9/142-mtd-bcm47xxpart-improve-handling-TRX-partition-size.patch +++ /dev/null @@ -1,65 +0,0 @@ -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Subject: [PATCH] mtd: bcm47xxpart: improve handling TRX partition size -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -When bcm47xxpart finds a TRX partition (container) it's supposed to jump -to the end of it and keep looking for more partitions. TRX and its -subpartitions are handled be a separated parser. - -The problem with old code was relying on the length specified in a TRX -header. That isn't reliable as TRX is commonly modified to have checksum -cover only non-changing subpartitions. Otherwise modifying e.g. a rootfs -would result in CRC32 mismatch and bootloader refusing to boot a -firmware. - -Fix it by trying better to figure out a real TRX size. We can securely -assume that TRX has to cover all subpartitions and the last one is at -least of a block size in size. Then compare it with a length field. - -This makes code more optimal & reliable thanks to skipping data that -shouldn't be parsed. - -Signed-off-by: Rafał Miłecki ---- - ---- a/drivers/mtd/bcm47xxpart.c -+++ b/drivers/mtd/bcm47xxpart.c -@@ -186,6 +186,8 @@ static int bcm47xxpart_parse(struct mtd_ - /* TRX */ - if (buf[0x000 / 4] == TRX_MAGIC) { - struct trx_header *trx; -+ uint32_t last_subpart; -+ uint32_t trx_size; - - if (trx_num >= ARRAY_SIZE(trx_parts)) - pr_warn("No enough space to store another TRX found at 0x%X\n", -@@ -195,11 +197,23 @@ static int bcm47xxpart_parse(struct mtd_ - bcm47xxpart_add_part(&parts[curr_part++], "firmware", - offset, 0); - -- /* Jump to the end of TRX */ -+ /* -+ * Try to find TRX size. The "length" field isn't fully -+ * reliable as it could be decreased to make CRC32 cover -+ * only part of TRX data. It's commonly used as checksum -+ * can't cover e.g. ever-changing rootfs partition. -+ * Use offsets as helpers for assuming min TRX size. -+ */ - trx = (struct trx_header *)buf; -- offset = roundup(offset + trx->length, blocksize); -- /* Next loop iteration will increase the offset */ -- offset -= blocksize; -+ last_subpart = max3(trx->offset[0], trx->offset[1], -+ trx->offset[2]); -+ trx_size = max(trx->length, last_subpart + blocksize); -+ -+ /* -+ * Skip the TRX data. Decrease offset by block size as -+ * the next loop iteration will increase it. -+ */ -+ offset += roundup(trx_size, blocksize) - blocksize; - continue; - } - diff --git a/target/linux/generic/pending-4.9/161-mtd-part-add-generic-parsing-of-linux-part-probe.patch b/target/linux/generic/pending-4.9/161-mtd-part-add-generic-parsing-of-linux-part-probe.patch index 5f0fa3a41..e2a0e4887 100644 --- a/target/linux/generic/pending-4.9/161-mtd-part-add-generic-parsing-of-linux-part-probe.patch +++ b/target/linux/generic/pending-4.9/161-mtd-part-add-generic-parsing-of-linux-part-probe.patch @@ -114,7 +114,7 @@ Signed-off-by: Hauke Mehrtens #include #include -@@ -856,6 +857,42 @@ void deregister_mtd_parser(struct mtd_pa +@@ -843,6 +844,42 @@ void deregister_mtd_parser(struct mtd_pa EXPORT_SYMBOL_GPL(deregister_mtd_parser); /* @@ -157,8 +157,8 @@ Signed-off-by: Hauke Mehrtens * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you * are changing this array! */ -@@ -999,6 +1036,13 @@ int parse_mtd_partitions(struct mtd_info - { +@@ -983,6 +1020,13 @@ int parse_mtd_partitions(struct mtd_info + struct mtd_partitions pparts = { }; struct mtd_part_parser *parser; int ret, err = 0; + const char *const *types_of = NULL; @@ -171,7 +171,7 @@ Signed-off-by: Hauke Mehrtens if (!types) types = default_mtd_part_types; -@@ -1035,6 +1079,7 @@ int parse_mtd_partitions(struct mtd_info +@@ -1023,6 +1067,7 @@ int parse_mtd_partitions(struct mtd_info if (ret < 0 && !err) err = ret; } diff --git a/target/linux/generic/pending-4.9/400-mtd-add-rootfs-split-support.patch b/target/linux/generic/pending-4.9/400-mtd-add-rootfs-split-support.patch index ef7a6df3e..10be7a16a 100644 --- a/target/linux/generic/pending-4.9/400-mtd-add-rootfs-split-support.patch +++ b/target/linux/generic/pending-4.9/400-mtd-add-rootfs-split-support.patch @@ -60,7 +60,7 @@ Signed-off-by: Felix Fietkau /* * Given a pointer to the MTD object in the mtd_part structure, we can retrieve * the pointer to that structure. -@@ -679,6 +683,7 @@ int mtd_add_partition(struct mtd_info *p +@@ -666,6 +670,7 @@ int mtd_add_partition(struct mtd_info *p mutex_unlock(&mtd_partitions_mutex); add_mtd_device(&new->mtd); @@ -68,7 +68,7 @@ Signed-off-by: Felix Fietkau mtd_add_partition_attrs(new); -@@ -757,6 +762,35 @@ int mtd_del_partition(struct mtd_info *m +@@ -744,6 +749,35 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); @@ -104,7 +104,7 @@ Signed-off-by: Felix Fietkau /* * 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 -@@ -788,6 +822,7 @@ int add_mtd_partitions(struct mtd_info * +@@ -775,6 +809,7 @@ int add_mtd_partitions(struct mtd_info * mutex_unlock(&mtd_partitions_mutex); add_mtd_device(&slave->mtd); diff --git a/target/linux/generic/pending-4.9/401-mtd-add-support-for-different-partition-parser-types.patch b/target/linux/generic/pending-4.9/401-mtd-add-support-for-different-partition-parser-types.patch index 54cfcb0c3..63affd7ee 100644 --- a/target/linux/generic/pending-4.9/401-mtd-add-support-for-different-partition-parser-types.patch +++ b/target/linux/generic/pending-4.9/401-mtd-add-support-for-different-partition-parser-types.patch @@ -9,7 +9,7 @@ Signed-off-by: Gabor Juhos --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -1134,6 +1134,62 @@ void mtd_part_parser_cleanup(struct mtd_ +@@ -1122,6 +1122,62 @@ void mtd_part_parser_cleanup(struct mtd_ } } diff --git a/target/linux/generic/pending-4.9/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch b/target/linux/generic/pending-4.9/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch index 9b406d468..10d855148 100644 --- a/target/linux/generic/pending-4.9/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch +++ b/target/linux/generic/pending-4.9/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch @@ -10,7 +10,7 @@ Signed-off-by: Gabor Juhos --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -762,6 +762,36 @@ int mtd_del_partition(struct mtd_info *m +@@ -749,6 +749,36 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); @@ -47,7 +47,7 @@ Signed-off-by: Gabor Juhos #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME #else -@@ -770,6 +800,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition); +@@ -757,6 +787,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition); static void split_firmware(struct mtd_info *master, struct mtd_part *part) { @@ -55,7 +55,7 @@ Signed-off-by: Gabor Juhos } void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, -@@ -784,6 +815,12 @@ static void mtd_partition_split(struct m +@@ -771,6 +802,12 @@ static void mtd_partition_split(struct m if (rootfs_found) return; diff --git a/target/linux/generic/pending-4.9/404-mtd-add-more-helper-functions.patch b/target/linux/generic/pending-4.9/404-mtd-add-more-helper-functions.patch index a08f46c31..076ec314b 100644 --- a/target/linux/generic/pending-4.9/404-mtd-add-more-helper-functions.patch +++ b/target/linux/generic/pending-4.9/404-mtd-add-more-helper-functions.patch @@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -792,6 +792,17 @@ run_parsers_by_type(struct mtd_part *sla +@@ -779,6 +779,17 @@ run_parsers_by_type(struct mtd_part *sla return nr_parts; } @@ -29,7 +29,7 @@ Signed-off-by: Gabor Juhos #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME #else -@@ -1244,6 +1255,24 @@ int mtd_is_partition(const struct mtd_in +@@ -1232,6 +1243,24 @@ int mtd_is_partition(const struct mtd_in } EXPORT_SYMBOL_GPL(mtd_is_partition); diff --git a/target/linux/generic/pending-4.9/411-mtd-partial_eraseblock_write.patch b/target/linux/generic/pending-4.9/411-mtd-partial_eraseblock_write.patch index 9a585214e..e925983b3 100644 --- a/target/linux/generic/pending-4.9/411-mtd-partial_eraseblock_write.patch +++ b/target/linux/generic/pending-4.9/411-mtd-partial_eraseblock_write.patch @@ -107,7 +107,7 @@ Signed-off-by: Felix Fietkau if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN) instr->fail_addr -= part->offset; -@@ -591,19 +660,22 @@ static struct mtd_part *allocate_partiti +@@ -578,19 +647,22 @@ static struct mtd_part *allocate_partiti remainder = do_div(tmp, wr_alignment); if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) { /* Doesn't start on a boundary of major erase size */ diff --git a/target/linux/generic/pending-4.9/479-mtd-spi-nor-add-eon-en25qh32.patch b/target/linux/generic/pending-4.9/479-mtd-spi-nor-add-eon-en25qh32.patch new file mode 100644 index 000000000..9e9e091a2 --- /dev/null +++ b/target/linux/generic/pending-4.9/479-mtd-spi-nor-add-eon-en25qh32.patch @@ -0,0 +1,10 @@ +--- a/drivers/mtd/spi-nor/spi-nor.c ++++ b/drivers/mtd/spi-nor/spi-nor.c +@@ -1007,6 +1007,7 @@ + { "en25p64", INFO(0x1c2017, 0, 64 * 1024, 128, 0) }, + { "en25q64", INFO(0x1c3017, 0, 64 * 1024, 128, SECT_4K) }, + { "en25q128", INFO(0x1c3018, 0, 64 * 1024, 256, SECT_4K) }, ++ { "en25qh32", INFO(0x1c7016, 0, 64 * 1024, 64, 0) }, + { "en25qh128", INFO(0x1c7018, 0, 64 * 1024, 256, 0) }, + { "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 512, 0) }, + { "en25s64", INFO(0x1c3817, 0, 64 * 1024, 128, SECT_4K) }, diff --git a/target/linux/generic/pending-4.9/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch b/target/linux/generic/pending-4.9/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch index ad3a15705..2cebf55a4 100644 --- a/target/linux/generic/pending-4.9/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch +++ b/target/linux/generic/pending-4.9/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch @@ -171,7 +171,7 @@ Signed-off-by: Jonas Gorski /* * Allocate a dst for local (unicast / anycast) address. */ -@@ -2848,7 +2881,8 @@ static int rtm_to_fib6_config(struct sk_ +@@ -2850,7 +2883,8 @@ static int rtm_to_fib6_config(struct sk_ if (rtm->rtm_type == RTN_UNREACHABLE || rtm->rtm_type == RTN_BLACKHOLE || rtm->rtm_type == RTN_PROHIBIT || @@ -181,7 +181,7 @@ Signed-off-by: Jonas Gorski cfg->fc_flags |= RTF_REJECT; if (rtm->rtm_type == RTN_LOCAL) -@@ -3220,6 +3254,9 @@ static int rt6_fill_node(struct net *net +@@ -3222,6 +3256,9 @@ static int rt6_fill_node(struct net *net case -EACCES: rtm->rtm_type = RTN_PROHIBIT; break; @@ -191,7 +191,7 @@ Signed-off-by: Jonas Gorski case -EAGAIN: rtm->rtm_type = RTN_THROW; break; -@@ -3496,6 +3533,8 @@ static int ip6_route_dev_notify(struct n +@@ -3498,6 +3535,8 @@ static int ip6_route_dev_notify(struct n #ifdef CONFIG_IPV6_MULTIPLE_TABLES net->ipv6.ip6_prohibit_entry->dst.dev = dev; net->ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(dev); @@ -200,7 +200,15 @@ Signed-off-by: Jonas Gorski net->ipv6.ip6_blk_hole_entry->dst.dev = dev; net->ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(dev); #endif -@@ -3722,6 +3761,17 @@ static int __net_init ip6_route_net_init +@@ -3509,6 +3548,7 @@ static int ip6_route_dev_notify(struct n + in6_dev_put(net->ipv6.ip6_null_entry->rt6i_idev); + #ifdef CONFIG_IPV6_MULTIPLE_TABLES + in6_dev_put(net->ipv6.ip6_prohibit_entry->rt6i_idev); ++ in6_dev_put(net->ipv6.ip6_policy_failed_entry->rt6i_idev); + in6_dev_put(net->ipv6.ip6_blk_hole_entry->rt6i_idev); + #endif + } +@@ -3724,6 +3764,17 @@ static int __net_init ip6_route_net_init net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops; dst_init_metrics(&net->ipv6.ip6_blk_hole_entry->dst, ip6_template_metrics, true); @@ -218,7 +226,7 @@ Signed-off-by: Jonas Gorski #endif net->ipv6.sysctl.flush_delay = 0; -@@ -3740,6 +3790,8 @@ out: +@@ -3742,6 +3793,8 @@ out: return ret; #ifdef CONFIG_IPV6_MULTIPLE_TABLES @@ -227,7 +235,7 @@ Signed-off-by: Jonas Gorski out_ip6_prohibit_entry: kfree(net->ipv6.ip6_prohibit_entry); out_ip6_null_entry: -@@ -3757,6 +3809,7 @@ static void __net_exit ip6_route_net_exi +@@ -3759,6 +3812,7 @@ static void __net_exit ip6_route_net_exi #ifdef CONFIG_IPV6_MULTIPLE_TABLES kfree(net->ipv6.ip6_prohibit_entry); kfree(net->ipv6.ip6_blk_hole_entry); @@ -235,7 +243,7 @@ Signed-off-by: Jonas Gorski #endif dst_entries_destroy(&net->ipv6.ip6_dst_ops); } -@@ -3830,6 +3883,9 @@ void __init ip6_route_init_special_entri +@@ -3832,6 +3886,9 @@ void __init ip6_route_init_special_entri init_net.ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); init_net.ipv6.ip6_blk_hole_entry->dst.dev = init_net.loopback_dev; init_net.ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);