From: Sasha Levin Date: Mon, 20 Jun 2022 07:16:32 +0000 (-0400) Subject: Fixes for 5.4 X-Git-Tag: v5.4.200~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=105612d87f9f1c0111d917a12db45a1cee383902;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- diff --git a/queue-5.4/faddr2line-fix-overlapping-text-section-failures-the.patch b/queue-5.4/faddr2line-fix-overlapping-text-section-failures-the.patch new file mode 100644 index 00000000000..8acb1e842df --- /dev/null +++ b/queue-5.4/faddr2line-fix-overlapping-text-section-failures-the.patch @@ -0,0 +1,139 @@ +From b69d484fdd4a024897cea7ed6253b7a25a0f7c08 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 1 Jun 2022 17:42:22 -0700 +Subject: faddr2line: Fix overlapping text section failures, the sequel + +From: Josh Poimboeuf + +[ Upstream commit dcea997beed694cbd8705100ca1a6eb0d886de69 ] + +If a function lives in a section other than .text, but .text also exists +in the object, faddr2line may wrongly assume .text. This can result in +comically wrong output. For example: + + $ scripts/faddr2line vmlinux.o enter_from_user_mode+0x1c + enter_from_user_mode+0x1c/0x30: + find_next_bit at /home/jpoimboe/git/linux/./include/linux/find.h:40 + (inlined by) perf_clear_dirty_counters at /home/jpoimboe/git/linux/arch/x86/events/core.c:2504 + +Fix it by passing the section name to addr2line, unless the object file +is vmlinux, in which case the symbol table uses absolute addresses. + +Fixes: 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section failures") +Reported-by: Peter Zijlstra +Signed-off-by: Josh Poimboeuf +Link: https://lore.kernel.org/r/7d25bc1408bd3a750ac26e60d2f2815a5f4a8363.1654130536.git.jpoimboe@kernel.org +Signed-off-by: Sasha Levin +--- + scripts/faddr2line | 45 ++++++++++++++++++++++++++++++++++----------- + 1 file changed, 34 insertions(+), 11 deletions(-) + +diff --git a/scripts/faddr2line b/scripts/faddr2line +index 0e6268d59883..94ed98dd899f 100755 +--- a/scripts/faddr2line ++++ b/scripts/faddr2line +@@ -95,17 +95,25 @@ __faddr2line() { + local print_warnings=$4 + + local sym_name=${func_addr%+*} +- local offset=${func_addr#*+} +- offset=${offset%/*} ++ local func_offset=${func_addr#*+} ++ func_offset=${func_offset%/*} + local user_size= ++ local file_type ++ local is_vmlinux=0 + [[ $func_addr =~ "/" ]] && user_size=${func_addr#*/} + +- if [[ -z $sym_name ]] || [[ -z $offset ]] || [[ $sym_name = $func_addr ]]; then ++ if [[ -z $sym_name ]] || [[ -z $func_offset ]] || [[ $sym_name = $func_addr ]]; then + warn "bad func+offset $func_addr" + DONE=1 + return + fi + ++ # vmlinux uses absolute addresses in the section table rather than ++ # section offsets. ++ local file_type=$(${READELF} --file-header $objfile | ++ ${AWK} '$1 == "Type:" { print $2; exit }') ++ [[ $file_type = "EXEC" ]] && is_vmlinux=1 ++ + # Go through each of the object's symbols which match the func name. + # In rare cases there might be duplicates, in which case we print all + # matches. +@@ -114,9 +122,11 @@ __faddr2line() { + local sym_addr=0x${fields[1]} + local sym_elf_size=${fields[2]} + local sym_sec=${fields[6]} ++ local sec_size ++ local sec_name + + # Get the section size: +- local sec_size=$(${READELF} --section-headers --wide $objfile | ++ sec_size=$(${READELF} --section-headers --wide $objfile | + sed 's/\[ /\[/' | + ${AWK} -v sec=$sym_sec '$1 == "[" sec "]" { print "0x" $6; exit }') + +@@ -126,6 +136,17 @@ __faddr2line() { + return + fi + ++ # Get the section name: ++ sec_name=$(${READELF} --section-headers --wide $objfile | ++ sed 's/\[ /\[/' | ++ ${AWK} -v sec=$sym_sec '$1 == "[" sec "]" { print $2; exit }') ++ ++ if [[ -z $sec_name ]]; then ++ warn "bad section name: section: $sym_sec" ++ DONE=1 ++ return ++ fi ++ + # Calculate the symbol size. + # + # Unfortunately we can't use the ELF size, because kallsyms +@@ -174,10 +195,10 @@ __faddr2line() { + + sym_size=0x$(printf %x $sym_size) + +- # Calculate the section address from user-supplied offset: +- local addr=$(($sym_addr + $offset)) ++ # Calculate the address from user-supplied offset: ++ local addr=$(($sym_addr + $func_offset)) + if [[ -z $addr ]] || [[ $addr = 0 ]]; then +- warn "bad address: $sym_addr + $offset" ++ warn "bad address: $sym_addr + $func_offset" + DONE=1 + return + fi +@@ -191,9 +212,9 @@ __faddr2line() { + fi + + # Make sure the provided offset is within the symbol's range: +- if [[ $offset -gt $sym_size ]]; then ++ if [[ $func_offset -gt $sym_size ]]; then + [[ $print_warnings = 1 ]] && +- echo "skipping $sym_name address at $addr due to size mismatch ($offset > $sym_size)" ++ echo "skipping $sym_name address at $addr due to size mismatch ($func_offset > $sym_size)" + continue + fi + +@@ -202,11 +223,13 @@ __faddr2line() { + [[ $FIRST = 0 ]] && echo + FIRST=0 + +- echo "$sym_name+$offset/$sym_size:" ++ echo "$sym_name+$func_offset/$sym_size:" + + # Pass section address to addr2line and strip absolute paths + # from the output: +- local output=$(${ADDR2LINE} -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;") ++ local args="--functions --pretty-print --inlines --exe=$objfile" ++ [[ $is_vmlinux = 0 ]] && args="$args --section=$sec_name" ++ local output=$(${ADDR2LINE} $args $addr | sed "s; $dir_prefix\(\./\)*; ;") + [[ -z $output ]] && continue + + # Default output (non --list): +-- +2.35.1 + diff --git a/queue-5.4/i2c-designware-use-standard-optional-ref-clock-imple.patch b/queue-5.4/i2c-designware-use-standard-optional-ref-clock-imple.patch new file mode 100644 index 00000000000..087f1a5ff7b --- /dev/null +++ b/queue-5.4/i2c-designware-use-standard-optional-ref-clock-imple.patch @@ -0,0 +1,80 @@ +From 7930810fa17314193fba227677bdc4f29b8a4497 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 10 Jun 2022 10:42:33 +0300 +Subject: i2c: designware: Use standard optional ref clock implementation + +From: Serge Semin + +[ Upstream commit 27071b5cbca59d8e8f8750c199a6cbf8c9799963 ] + +Even though the DW I2C controller reference clock source is requested by +the method devm_clk_get() with non-optional clock requirement the way the +clock handler is used afterwards has a pure optional clock semantic +(though in some circumstances we can get a warning about the clock missing +printed in the system console). There is no point in reimplementing that +functionality seeing the kernel clock framework already supports the +optional interface from scratch. Thus let's convert the platform driver to +using it. + +Note by providing this commit we get to fix two problems. The first one +was introduced in commit c62ebb3d5f0d ("i2c: designware: Add support for +an interface clock"). It causes not having the interface clock (pclk) +enabled/disabled in case if the reference clock isn't provided. The second +problem was first introduced in commit b33af11de236 ("i2c: designware: Do +not require clock when SSCN and FFCN are provided"). Since that +modification the deferred probe procedure has been unsupported in case if +the interface clock isn't ready. + +Fixes: c62ebb3d5f0d ("i2c: designware: Add support for an interface clock") +Fixes: b33af11de236 ("i2c: designware: Do not require clock when SSCN and FFCN are provided") +Signed-off-by: Serge Semin +Reviewed-by: Andy Shevchenko +Acked-by: Jarkko Nikula +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-designware-common.c | 3 --- + drivers/i2c/busses/i2c-designware-platdrv.c | 13 +++++++++++-- + 2 files changed, 11 insertions(+), 5 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c +index 2de7452fcd6d..c9036675bd77 100644 +--- a/drivers/i2c/busses/i2c-designware-common.c ++++ b/drivers/i2c/busses/i2c-designware-common.c +@@ -253,9 +253,6 @@ int i2c_dw_prepare_clk(struct dw_i2c_dev *dev, bool prepare) + { + int ret; + +- if (IS_ERR(dev->clk)) +- return PTR_ERR(dev->clk); +- + if (prepare) { + /* Optional interface clock */ + ret = clk_prepare_enable(dev->pclk); +diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c +index 0c55c54372d7..75313c80f132 100644 +--- a/drivers/i2c/busses/i2c-designware-platdrv.c ++++ b/drivers/i2c/busses/i2c-designware-platdrv.c +@@ -349,8 +349,17 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) + goto exit_reset; + } + +- dev->clk = devm_clk_get(&pdev->dev, NULL); +- if (!i2c_dw_prepare_clk(dev, true)) { ++ dev->clk = devm_clk_get_optional(&pdev->dev, NULL); ++ if (IS_ERR(dev->clk)) { ++ ret = PTR_ERR(dev->clk); ++ goto exit_reset; ++ } ++ ++ ret = i2c_dw_prepare_clk(dev, true); ++ if (ret) ++ goto exit_reset; ++ ++ if (dev->clk) { + u64 clk_khz; + + dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; +-- +2.35.1 + diff --git a/queue-5.4/irqchip-gic-realview-fix-refcount-leak-in-realview_g.patch b/queue-5.4/irqchip-gic-realview-fix-refcount-leak-in-realview_g.patch new file mode 100644 index 00000000000..0e80a5f25b4 --- /dev/null +++ b/queue-5.4/irqchip-gic-realview-fix-refcount-leak-in-realview_g.patch @@ -0,0 +1,37 @@ +From a75c3b45febb3d56ca09d1b9062a8acb4abfa8b4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 1 Jun 2022 12:09:25 +0400 +Subject: irqchip/gic/realview: Fix refcount leak in realview_gic_of_init + +From: Miaoqian Lin + +[ Upstream commit f4b98e314888cc51486421bcf6d52852452ea48b ] + +of_find_matching_node_and_match() returns a node pointer with refcount +incremented, we should use of_node_put() on it when not need anymore. +Add missing of_node_put() to avoid refcount leak. + +Fixes: 82b0a434b436 ("irqchip/gic/realview: Support more RealView DCC variants") +Signed-off-by: Miaoqian Lin +Signed-off-by: Marc Zyngier +Link: https://lore.kernel.org/r/20220601080930.31005-2-linmq006@gmail.com +Signed-off-by: Sasha Levin +--- + drivers/irqchip/irq-gic-realview.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/irqchip/irq-gic-realview.c b/drivers/irqchip/irq-gic-realview.c +index b4c1924f0255..38fab02ffe9d 100644 +--- a/drivers/irqchip/irq-gic-realview.c ++++ b/drivers/irqchip/irq-gic-realview.c +@@ -57,6 +57,7 @@ realview_gic_of_init(struct device_node *node, struct device_node *parent) + + /* The PB11MPCore GIC needs to be configured in the syscon */ + map = syscon_node_to_regmap(np); ++ of_node_put(np); + if (!IS_ERR(map)) { + /* new irq mode with no DCC */ + regmap_write(map, REALVIEW_SYS_LOCK_OFFSET, +-- +2.35.1 + diff --git a/queue-5.4/irqchip-gic-v3-fix-error-handling-in-gic_populate_pp.patch b/queue-5.4/irqchip-gic-v3-fix-error-handling-in-gic_populate_pp.patch new file mode 100644 index 00000000000..a2dd6551153 --- /dev/null +++ b/queue-5.4/irqchip-gic-v3-fix-error-handling-in-gic_populate_pp.patch @@ -0,0 +1,39 @@ +From 63b3f6d065e46aeda401abf80d933432a69fb455 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 1 Jun 2022 12:09:28 +0400 +Subject: irqchip/gic-v3: Fix error handling in gic_populate_ppi_partitions + +From: Miaoqian Lin + +[ Upstream commit ec8401a429ffee34ccf38cebf3443f8d5ae6cb0d ] + +of_get_child_by_name() returns a node pointer with refcount +incremented, we should use of_node_put() on it when not need anymore. +When kcalloc fails, it missing of_node_put() and results in refcount +leak. Fix this by goto out_put_node label. + +Fixes: 52085d3f2028 ("irqchip/gic-v3: Dynamically allocate PPI partition descriptors") +Signed-off-by: Miaoqian Lin +Signed-off-by: Marc Zyngier +Link: https://lore.kernel.org/r/20220601080930.31005-5-linmq006@gmail.com +Signed-off-by: Sasha Levin +--- + drivers/irqchip/irq-gic-v3.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c +index f589ca2480a1..8ce4a2925e92 100644 +--- a/drivers/irqchip/irq-gic-v3.c ++++ b/drivers/irqchip/irq-gic-v3.c +@@ -1616,7 +1616,7 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node) + + gic_data.ppi_descs = kcalloc(gic_data.ppi_nr, sizeof(*gic_data.ppi_descs), GFP_KERNEL); + if (!gic_data.ppi_descs) +- return; ++ goto out_put_node; + + nr_parts = of_get_child_count(parts_node); + +-- +2.35.1 + diff --git a/queue-5.4/irqchip-gic-v3-fix-refcount-leak-in-gic_populate_ppi.patch b/queue-5.4/irqchip-gic-v3-fix-refcount-leak-in-gic_populate_ppi.patch new file mode 100644 index 00000000000..03ba6110dd0 --- /dev/null +++ b/queue-5.4/irqchip-gic-v3-fix-refcount-leak-in-gic_populate_ppi.patch @@ -0,0 +1,46 @@ +From 145b9ec31cfbed08034fad2b5666b56b3931fd5d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 1 Jun 2022 12:09:29 +0400 +Subject: irqchip/gic-v3: Fix refcount leak in gic_populate_ppi_partitions + +From: Miaoqian Lin + +[ Upstream commit fa1ad9d4cc47ca2470cd904ad4519f05d7e43a2b ] + +of_find_node_by_phandle() returns a node pointer with refcount +incremented, we should use of_node_put() on it when not need anymore. +Add missing of_node_put() to avoid refcount leak. + +Fixes: e3825ba1af3a ("irqchip/gic-v3: Add support for partitioned PPIs") +Signed-off-by: Miaoqian Lin +Signed-off-by: Marc Zyngier +Link: https://lore.kernel.org/r/20220601080930.31005-6-linmq006@gmail.com +Signed-off-by: Sasha Levin +--- + drivers/irqchip/irq-gic-v3.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c +index 8ce4a2925e92..77a130c03223 100644 +--- a/drivers/irqchip/irq-gic-v3.c ++++ b/drivers/irqchip/irq-gic-v3.c +@@ -1657,12 +1657,15 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node) + continue; + + cpu = of_cpu_node_to_id(cpu_node); +- if (WARN_ON(cpu < 0)) ++ if (WARN_ON(cpu < 0)) { ++ of_node_put(cpu_node); + continue; ++ } + + pr_cont("%pOF[%d] ", cpu_node, cpu); + + cpumask_set_cpu(cpu, &part->mask); ++ of_node_put(cpu_node); + } + + pr_cont("}\n"); +-- +2.35.1 + diff --git a/queue-5.4/series b/queue-5.4/series index ab8ff702492..e2aa374feaf 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -213,3 +213,8 @@ mlxsw-spectrum_cnt-reorder-counter-pools.patch net-bgmac-fix-an-erroneous-kfree-in-bgmac_remove.patch arm64-ftrace-fix-branch-range-checks.patch certs-blacklist_hashes.c-fix-const-confusion-in-cert.patch +faddr2line-fix-overlapping-text-section-failures-the.patch +irqchip-gic-realview-fix-refcount-leak-in-realview_g.patch +irqchip-gic-v3-fix-error-handling-in-gic_populate_pp.patch +irqchip-gic-v3-fix-refcount-leak-in-gic_populate_ppi.patch +i2c-designware-use-standard-optional-ref-clock-imple.patch