5.10.4-rc1 review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 471/717 NFS/pNFS: Fix a typo in ff_layout_resend_pnfs_read()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 52104f274e2d7f134d34bab11cada8913d4544e2 ]
Don't bump the index twice.
--- fs/nfs/flexfilelayout/flexfilelayout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/flexfilelayout/flexfilelayout.c +1 -1
@@ -1056,7 +1056,7 @@ static void ff_layout_resend_pnfs_read(struct nfs_pgio_header *hdr)u32 idx = hdr->pgio_mirror_idx +1 ;u32 new_idx =0 ; -if (ff_layout_choose_any_ds_for_read (hdr->lseg, idx +1 , &new_idx)) +if (ff_layout_choose_any_ds_for_read (hdr->lseg, idx, &new_idx))ff_layout_send_layouterror (hdr->lseg);else pnfs_error_mark_layout_for_return (hdr->inode, hdr->lseg);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 473/717 devlink: use _BITUL() macro instead of BIT() in the UAPI header
In reply to Greg Kroah-HartmanFrom: Tobias Klauser <[email protected]>
[ Upstream commit 75f4d4544db9fa34e1f04174f27d9f8a387be37d ]
The BIT() macro is not available for the UAPI headers. Moreover, it can be defined differently in user space headers. Thus, replace its usage with the _BITUL() macro which is already used in other macro definitions in <linux/devlink.h>.
--- include/uapi/linux/devlink.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/devlink.h +1 -1
@@ -322,7 +322,7 @@ enum devlink_reload_limit {DEVLINK_RELOAD_LIMIT_MAX = __DEVLINK_RELOAD_LIMIT_MAX -1 }; -#define DEVLINK_RELOAD_LIMITS_VALID_MASK (BIT(__DEVLINK_RELOAD_LIMIT_MAX) - 1) +#define DEVLINK_RELOAD_LIMITS_VALID_MASK (_BITUL(__DEVLINK_RELOAD_LIMIT_MAX) - 1)enum devlink_attr {/* don't change the order or add anything between, this is ABI! */
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 449/717 mm: memcg/slab: fix return of child memcg objcg for root memcg
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
[ Upstream commit 2f7659a314736b32b66273dbf91c19874a052fde ]
Consider the following memcg hierarchy.
root
/ \
A BIf we failed to get the reference on objcg of memcg A, the get_obj_cgroup_from_current can return the wrong objcg for the root memcg.
--- mm/memcontrol.c | 1 + 1 file changed, 1 insertion(+)
mm/memcontrol.c +1 -0
@@ -2987,6 +2987,7 @@ __always_inline struct obj_cgroup *get_obj_cgroup_from_current(void) objcg =rcu_dereference (memcg->objcg);if (objcg &&obj_cgroup_tryget (objcg))break ; + objcg =NULL ; }rcu_read_unlock ();
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 490/717 virtio_net: Fix error code in probe()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 411ea23a76526e6efed0b601abb603d3c981b333 ]
Set a negative error code intead of returning success if the MTU has been changed to something invalid.
--- drivers/net/virtio_net.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/virtio_net.c +1 -0
@@ -3072,6 +3072,7 @@ static int virtnet_probe(struct virtio_device *vdev)dev_err (&vdev->dev,"device MTU appears to have changed it is now %d < %d" , mtu, dev->min_mtu); + err = -EINVAL ; goto free; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 484/717 tools build: Add missing libcap to test-all.bin target
In reply to Greg Kroah-HartmanFrom: Jiri Olsa <[email protected]>
[ Upstream commit 09d59c2f3465fb01e65a0c96698697b026ea8e79 ]
We're missing -lcap in test-all.bin target, so in case it's the only library missing (if more are missing test-all.bin fails anyway), we will falsely claim that we detected it and fail build, like:
$ make ... Auto-detecting system features: ... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... libbfd: [ on ] ... libbfd-buildid: [ on ] ... libcap: [ on ] ... libelf: [ on ] ... libnuma: [ on ] ... numa_num_possible_cpus: [ on ] ... libperl: [ on ] ... libpython: [ on ] ... libcrypto: [ on ] ... libunwind: [ on ] ... libdw-dwarf-unwind: [ on ] ... zlib: [ on ] ... lzma: [ on ] ... get_cpuid: [ on ] ... bpf: [ on ] ... libaio: [ on ] ... libzstd: [ on ] ... disassembler-four-args: [ on ]
...
CC builtin-ftrace.o
In file included from builtin-ftrace.c:29:
util/cap.h:11:10: fatal error: sys/capability.h: No such file or directory
11 | #include <sys/capability.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
--- tools/build/feature/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/feature/Makefile +1 -1
@@ -90,7 +90,7 @@ __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$( ############################### $(OUTPUT)test-all.bin: - $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -I/usr/include/slang -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma -lzstd + $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -I/usr/include/slang -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma -lzstd -lcap $(OUTPUT)test-hello.bin: $(BUILD)
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 488/717 vdpa/mlx5: Use write memory barrier after updating CQ index
In reply to Greg Kroah-HartmanFrom: Eli Cohen <[email protected]>
[ Upstream commit 83ef73b27eb2363f44faf9c3ee28a3fe752cfd15 ]
Make sure to put dma write memory barrier after updating CQ consumer index so the hardware knows that there are available CQE slots in the queue.
Failure to do this can cause the update of the RX doorbell record to get updated before the CQ consumer index resulting in CQ overrun.
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +5 -0
@@ -464,6 +464,11 @@ static int mlx5_vdpa_poll_one(struct mlx5_vdpa_cq *vcq)static void mlx5_vdpa_handle_completions (struct mlx5_vdpa_virtqueue *mvq,int num) {mlx5_cq_set_ci (&mvq->cq.mcq); + +/* make sure CQ cosumer update is visible to the hardware before updating +* RX doorbell record. +*/ +dma_wmb ();rx_post (&mvq->vqqp, num);if (mvq->event_cb.callback) mvq->event_cb.callback (mvq->event_cb.private);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 491/717 virtio_ring: Fix two use after free bugs
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e152d8af4220a05c9797591609151d404866beaa ]
The "vq" struct is added to the "vdev->vqs" list prematurely. If we encounter an error later in the function then the "vq" is freed, but since it is still on the list that could lead to a use after free bug.
--- drivers/virtio/virtio_ring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/virtio/virtio_ring.c +2 -2
@@ -1608,7 +1608,6 @@ static struct virtqueue *vring_create_virtqueue_packed( vq->num_added =0 ; vq->packed_ring = true; vq->use_dma_api =vring_use_dma_api (vdev); -list_add_tail (&vq->vq.list, &vdev->vqs);#ifdef DEBUG vq->in_use = false; vq->last_add_time_valid = false;
@@ -1669,6 +1668,7 @@ static struct virtqueue *vring_create_virtqueue_packed(cpu_to_le16 (vq->packed.event_flags_shadow); } +list_add_tail (&vq->vq.list, &vdev->vqs);return &vq->vq; err_desc_extra:
@@ -2085,7 +2085,6 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, vq->last_used_idx =0 ; vq->num_added =0 ; vq->use_dma_api =vring_use_dma_api (vdev); -list_add_tail (&vq->vq.list, &vdev->vqs);#ifdef DEBUG vq->in_use = false; vq->last_add_time_valid = false;
@@ -2127,6 +2126,7 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,memset (vq->split.desc_state,0 , vring.num *sizeof (struct vring_desc_state_split )); +list_add_tail (&vq->vq.list, &vdev->vqs);return &vq->vq; }EXPORT_SYMBOL_GPL (__vring_new_virtqueue);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 494/717 clk: bcm: dvp: Add MODULE_DEVICE_TABLE()
In reply to Greg Kroah-HartmanFrom: Nicolas Saenz Julienne <[email protected]>
[ Upstream commit be439cc4c404f646a8ba090fa786d53c10926b12 ]
Add MODULE_DEVICE_TABLE() so as to be able to use the driver as a module. More precisely, for the driver to be loaded automatically at boot.
--- drivers/clk/bcm/clk-bcm2711-dvp.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/bcm/clk-bcm2711-dvp.c +1 -0
@@ -108,6 +108,7 @@ static const struct of_device_id clk_dvp_dt_ids[] = { { .compatible = "brcm,brcm2711-dvp", }, {/* sentinel */ } }; +MODULE_DEVICE_TABLE (of, clk_dvp_dt_ids);static struct platform_driver clk_dvp_driver = { .probe = clk_dvp_probe,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 476/717 watchdog: qcom: Avoid context switch in restart handler
In reply to Greg Kroah-HartmanFrom: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 7948fab26bcc468aa2a76462f441291b5fb0d5c7 ]
The use of msleep() in the restart handler will cause scheduler to induce a context switch which is not desirable. This generates below warning on SDX55 when WDT is the only available restart source:
[ 39.800188] reboot: Restarting system [ 39.804115] ------------[ cut here ]------------ [ 39.807855] WARNING: CPU: 0 PID: 678 at kernel/rcu/tree_plugin.h:297 rcu_note_context_switch+0x190/0x764 [ 39.812538] Modules linked in: [ 39.821954] CPU: 0 PID: 678 Comm: reboot Not tainted 5.10.0-rc1-00063-g33a9990d1d66-dirty #47 [ 39.824854] Hardware name: Generic DT based system [ 39.833470] [<c0310fbc>] (unwind_backtrace) from [<c030c544>] (show_stack+0x10/0x14) [ 39.838154] [<c030c544>] (show_stack) from [<c0c218f0>] (dump_stack+0x8c/0xa0) [ 39.846049] [<c0c218f0>] (dump_stack) from [<c0322f80>] (__warn+0xd8/0xf0) [ 39.853058] [<c0322f80>] (__warn) from [<c0c1dc08>] (warn_slowpath_fmt+0x64/0xc8) [ 39.859925] [<c0c1dc08>] (warn_slowpath_fmt) from [<c038b6f4>] (rcu_note_context_switch+0x190/0x764) [ 39.867503] [<c038b6f4>] (rcu_note_context_switch) from [<c0c2aa3c>] (__schedule+0x84/0x640) [ 39.876685] [<c0c2aa3c>] (__schedule) from [<c0c2b050>] (schedule+0x58/0x10c) [ 39.885095] [<c0c2b050>] (schedule) from [<c0c2eed0>] (schedule_timeout+0x1e8/0x3d4) [ 39.892135] [<c0c2eed0>] (schedule_timeout) from [<c039ad40>] (msleep+0x2c/0x38) [ 39.899947] [<c039ad40>] (msleep) from [<c0a59d0c>] (qcom_wdt_restart+0xc4/0xcc) [ 39.907319] [<c0a59d0c>] (qcom_wdt_restart) from [<c0a58290>] (watchdog_restart_notifier+0x18/0x28) [ 39.914715] [<c0a58290>] (watchdog_restart_notifier) from [<c03468e0>] (atomic_notifier_call_chain+0x60/0x84) [ 39.923487] [<c03468e0>] (atomic_notifier_call_chain) from [<c030ae64>] (machine_restart+0x78/0x7c) [ 39.933551] [<c030ae64>] (machine_restart) from [<c0348048>] (__do_sys_reboot+0xdc/0x1e0) [ 39.942397] [<c0348048>] (__do_sys_reboot) from [<c0300060>] (ret_fast_syscall+0x0/0x54) [ 39.950721] Exception stack(0xc3e0bfa8 to 0xc3e0bff0) [ 39.958855] bfa0: 0001221c bed2fe24 fee1dead 28121969 01234567 00000000 [ 39.963832] bfc0: 0001221c bed2fe24 00000003 00000058 000225e0 00000000 00000000 00000000 [ 39.971985] bfe0: b6e62560 bed2fc84 00010fd8 b6e62580 [ 39.980124] ---[ end trace 3f578288bad866e4 ]---
Hence, replace msleep() with mdelay() to fix this issue.
--- drivers/watchdog/qcom-wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/qcom-wdt.c +1 -1
@@ -148,7 +148,7 @@ static int qcom_wdt_restart(struct watchdog_device *wdd, unsigned long action,*/ wmb (); -msleep (150 ); +mdelay (150 );return 0 ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 492/717 vhost scsi: fix error return code in vhost_scsi_set_endpoint()
In reply to Greg Kroah-HartmanFrom: Zhang Changzhong <[email protected]>
[ Upstream commit 2e1139d613c7fb0956e82f72a8281c0a475ad4f8 ]
Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.
--- drivers/vhost/scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/vhost/scsi.c +2 -1
@@ -1643,7 +1643,8 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,if (!vhost_vq_is_setup (vq))continue ; -if (vhost_scsi_setup_vq_cmds (vq, vq->num)) + ret =vhost_scsi_setup_vq_cmds (vq, vq->num); +if (ret) goto destroy_vq_cmds; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 496/717 clk: at91: sam9x60: remove atmel,osc-bypass support
In reply to Greg Kroah-HartmanFrom: Alexandre Belloni <[email protected]>
[ Upstream commit 01324f9e88b5cfc1f4c26eef66bdcb52596c9af8 ]
The sam9x60 doesn't have the MOSCXTBY bit to enable the crystal oscillator bypass.
--- drivers/clk/at91/sam9x60.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/clk/at91/sam9x60.c +1 -5
@@ -174,7 +174,6 @@ static void __init sam9x60_pmc_setup(struct device_node *np)struct regmap *regmap;struct clk_hw *hw;int i; -bool bypass; i =of_property_match_string (np,"clock-names" ,"td_slck" );if (i <0 )
@@ -209,10 +208,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)if (IS_ERR (hw)) goto err_free; - bypass =of_property_read_bool (np,"atmel,osc-bypass" ); - - hw =at91_clk_register_main_osc (regmap,"main_osc" , mainxtal_name, - bypass); + hw =at91_clk_register_main_osc (regmap,"main_osc" , mainxtal_name,0 );if (IS_ERR (hw)) goto err_free; main_osc_hw = hw;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 498/717 clk: sunxi-ng: Make sure divider tables have sentinel
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 48f68de00c1405351fa0e7bc44bca067c49cd0a3 ]
Two clock divider tables are missing sentinel at the end. Effect of that is that clock framework reads past the last entry. Fix that with adding sentinel at the end.
Issue was discovered with KASan.
--- drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 1 + drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 1 + 2 files changed, 2 insertions(+)
drivers/clk/sunxi-ng/ccu-sun50i-a64.c +1 -0
@@ -389,6 +389,7 @@ static struct clk_div_table ths_div_table[] = { { .val = 1, .div = 2 }, { .val = 2, .div = 4 }, { .val = 3, .div = 6 }, + { /* Sentinel */ }, };static const char *const ths_parents[] = {"osc24M" };static struct ccu_div ths_clk = {
drivers/clk/sunxi-ng/ccu-sun8i-h3.c +1 -0
@@ -322,6 +322,7 @@ static struct clk_div_table ths_div_table[] = { { .val = 1, .div = 2 }, { .val = 2, .div = 4 }, { .val = 3, .div = 6 }, + { /* Sentinel */ }, }; static SUNXI_CCU_DIV_TABLE_WITH_GATE(ths_clk, "ths", "osc24M", 0x074, 0, 2, ths_div_table, BIT(31), 0);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 499/717 clk: vc5: Use "idt,voltage-microvolt" instead of "idt,voltage-microvolts"
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 4b003f5fcadfa2d0e087e907b0c65d023f6e29fb ]
Commit 45c940184b501fc6 ("dt-bindings: clk: versaclock5: convert to yaml") accidentally changed "idt,voltage-microvolts" to "idt,voltage-microvolt" in the DT bindings, while the driver still used the former.
Update the driver to match the bindings, as Documentation/devicetree/bindings/property-units.txt actually recommends using "microvolt".
--- drivers/clk/clk-versaclock5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/clk-versaclock5.c +2 -2
@@ -739,8 +739,8 @@ static int vc5_update_power(struct device_node *np_output, {u32 value; -if (!of_property_read_u32 (np_output, -"idt,voltage-microvolts" , &value)) { +if (!of_property_read_u32 (np_output,"idt,voltage-microvolt" , + &value)) { clk_out->clk_output_cfg0_mask |=VC5_CLK_OUTPUT_CFG0_PWR_MASK ;switch (value) {case 1800000 :
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 456/717 hugetlb: fix an error code in hugetlb_reserve_pages()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 7fc2513aa237e2ce239ab54d7b04d1d79b317110 ]
Preserve the error code from region_add() instead of returning success.
--- mm/hugetlb.c | 1 + 1 file changed, 1 insertion(+)
mm/hugetlb.c +1 -0
@@ -5115,6 +5115,7 @@ int hugetlb_reserve_pages(struct inode *inode,if (unlikely (add <0 )) {hugetlb_acct_memory (h, -gbl_reserve); + ret = add; goto out_put_pages; }else if (unlikely (chg > add)) {/*
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 501/717 powerpc/boot: Fix build of dts/fsl
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
[ Upstream commit b36f835b636908e4122f2e17310b1dbc380a3b19 ]
The lkp robot reported that some configs fail to build, for example mpc85xx_smp_defconfig, with:
cc1: fatal error: opening output file arch/powerpc/boot/dts/fsl/.mpc8540ads.dtb.dts.tmp: No such file or directory
This bisects to:
cc8a51ca6f05 ("kbuild: always create directories of targets")
Although that commit claims to be about in-tree builds, it somehow breaks out-of-tree builds. But presumably it's just exposing a latent bug in our Makefiles.
We can fix it by adding to targets for dts/fsl in the same way that we do for dts.
--- arch/powerpc/boot/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/boot/Makefile +2 -0
@@ -368,6 +368,8 @@ initrd-y := $(filter-out $(image-y), $(initrd-y)) targets += $(image-y) $(initrd-y) targets += $(foreach x, dtbImage uImage cuImage simpleImage treeImage, \ $(patsubst $(x).%, dts/%.dtb, $(filter $(x).%, $(image-y)))) +targets += $(foreach x, dtbImage uImage cuImage simpleImage treeImage, \ + $(patsubst $(x).%, dts/fsl/%.dtb, $(filter $(x).%, $(image-y)))) $(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 502/717 powerpc/smp: Add __init to init_big_cores()
In reply to Greg Kroah-HartmanFrom: Cédric Le Goater <[email protected]>
[ Upstream commit 9014eab6a38c60fd185bc92ed60f46cf99a462ab ]
It fixes this link warning:
WARNING: modpost: vmlinux.o(.text.unlikely+0x2d98): Section mismatch in reference from the function init_big_cores.isra.0() to the function .init.text:init_thread_group_cache_map() The function init_big_cores.isra.0() references
the function __init init_thread_group_cache_map().
This is often because init_big_cores.isra.0 lacks a __init
annotation or the annotation of init_thread_group_cache_map is wrong.
--- arch/powerpc/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/smp.c +1 -1
@@ -919,7 +919,7 @@ static struct sched_domain_topology_level powerpc_topology[] = { { NULL, }, }; -static int init_big_cores (void ) +static int __init init_big_cores (void ) {int cpu;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 466/717 net: bcmgenet: Fix a resource leak in an error handling path in the probe functin
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 4375ada01963d1ebf733d60d1bb6e5db401e1ac6 ]
If the 'register_netdev()' call fails, we must undo a previous 'bcmgenet_mii_init()' call.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +3 -1
@@ -4069,8 +4069,10 @@ static int bcmgenet_probe(struct platform_device *pdev)clk_disable_unprepare (priv->clk); err =register_netdev (dev); -if (err) +if (err) { +bcmgenet_mii_exit (dev); goto err; + }return err;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 495/717 clk: at91: sama7g5: fix compilation error
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 91274497c79170aaadc491d4ffe4de35495a060d ]
pmc_data_allocate() has been changed. pmc_data_free() was removed. Adapt the code taking this into consideration. With this the programmable clocks were also saved in sama7g5_pmc so that they could be later referenced.
--- drivers/clk/at91/sama7g5.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clk/at91/sama7g5.c +4 -2
@@ -838,7 +838,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np) sama7g5_pmc =pmc_data_allocate (PMC_I2S1_MUX +1 ,nck (sama7g5_systemck),nck (sama7g5_periphck), -nck (sama7g5_gck)); +nck (sama7g5_gck),8 );if (!sama7g5_pmc)return ;
@@ -980,6 +980,8 @@ static void __init sama7g5_pmc_setup(struct device_node *np) sama7g5_prog_mux_table);if (IS_ERR (hw)) goto err_free; + + sama7g5_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (sama7g5_systemck); i++) {
@@ -1052,7 +1054,7 @@ err_free:kfree (alloc_mem); } -pmc_data_free (sama7g5_pmc); +kfree (sama7g5_pmc); }/* Some clks are used for a clocksource */
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 497/717 clk: s2mps11: Fix a resource leak in error handling paths in the probe function
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit d2d94fc567624f96187e8b52083795620f93e69f ]
Some resource should be released in the error handling path of the probe function, as already done in the remove function.
The remove function was fixed in commit bf416bd45738 ("clk: s2mps11: Add missing of_node_put and of_clk_del_provider")
--- drivers/clk/clk-s2mps11.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/clk-s2mps11.c +1 -0
@@ -195,6 +195,7 @@ static int s2mps11_clk_probe(struct platform_device *pdev)return ret; err_reg: +of_node_put (s2mps11_clks[0 ].clk_np);while (--i >=0 )clkdev_drop (s2mps11_clks[i].lookup);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 504/717 ARM: 9036/1: uncompress: Fix dbgadtb size parameter name
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 1ecec38547d415054fdb63a231234f44396b6d06 ]
The dbgadtb macro is passed the size of the appended DTB, not the end address.
--- arch/arm/boot/compressed/head.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/compressed/head.S +2 -2
@@ -116,7 +116,7 @@ /* * Debug print of the final appended DTB location */ - .macro dbgadtb, begin, end + .macro dbgadtb, begin, size #ifdef DEBUG kputc #'D' kputc #'T'
@@ -129,7 +129,7 @@ kputc #'(' kputc #'0' kputc #'x' - kphex \end, 8 /* End of appended DTB */ + kphex \size, 8 /* Size of appended DTB */ kputc #')' kputc #'\n' #endif
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 506/717 io_uring: fix racy IOPOLL flush overflow
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ Upstream commit 634578f800652035debba3098d8ab0d21af7c7a5 ]
It's not safe to call io_cqring_overflow_flush() for IOPOLL mode without hodling uring_lock, because it does synchronisation differently. Make sure we have it.
As for io_ring_exit_work(), we don't even need it there because io_ring_ctx_wait_and_kill() already set force flag making all overflowed requests to be dropped.
--- fs/io_uring.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/io_uring.c +6 -4
@@ -8369,8 +8369,6 @@ static void io_ring_exit_work(struct work_struct *work)* as nobody else will be looking for them. */ do { -if (ctx->rings) -io_cqring_overflow_flush (ctx, true,NULL ,NULL );io_iopoll_try_reap_events (ctx); }while (!wait_for_completion_timeout (&ctx->ref_comp,HZ /20 ));io_ring_ctx_free (ctx);
@@ -8380,6 +8378,8 @@ static void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx) {mutex_lock (&ctx->uring_lock);percpu_ref_kill (&ctx->refs); +if (ctx->rings) +io_cqring_overflow_flush (ctx, true,NULL ,NULL );mutex_unlock (&ctx->uring_lock);io_kill_timeouts (ctx,NULL );
@@ -8389,8 +8389,6 @@ static void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)io_wq_cancel_all (ctx->io_wq);/* if we failed setting up the ctx, we might not have any rings */ -if (ctx->rings) -io_cqring_overflow_flush (ctx, true,NULL ,NULL );io_iopoll_try_reap_events (ctx);idr_for_each (&ctx->personality_idr, io_remove_personalities, ctx);
@@ -8654,7 +8652,9 @@ static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx, }io_cancel_defer_files (ctx, task, files); +io_ring_submit_lock (ctx, (ctx->flags &IORING_SETUP_IOPOLL ));io_cqring_overflow_flush (ctx, true, task, files); +io_ring_submit_unlock (ctx, (ctx->flags &IORING_SETUP_IOPOLL ));while (__io_uring_cancel_task_requests (ctx, task, files)) {io_run_task_work ();
@@ -8956,8 +8956,10 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,*/ ret =0 ;if (ctx->flags &IORING_SETUP_SQPOLL ) { +io_ring_submit_lock (ctx, (ctx->flags &IORING_SETUP_IOPOLL ));if (!list_empty_careful (&ctx->cq_overflow_list))io_cqring_overflow_flush (ctx, false,NULL ,NULL ); +io_ring_submit_unlock (ctx, (ctx->flags &IORING_SETUP_IOPOLL ));if (flags &IORING_ENTER_SQ_WAKEUP )wake_up (&ctx->sq_data->wait);if (flags &IORING_ENTER_SQ_WAIT )
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 478/717 clk: ti: Fix memleak in ti_fapll_synth_setup
In reply to Greg Kroah-HartmanFrom: Zhang Qilong <[email protected]>
[ Upstream commit 8c6239f6e95f583bb763d0228e02d4dd0fb3d492 ]
If clk_register fails, we should goto free branch
before function returns to prevent memleak.
--- drivers/clk/ti/fapll.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/clk/ti/fapll.c +9 -2
@@ -498,6 +498,7 @@ static struct clk * __init ti_fapll_synth_setup(struct fapll_data *fd, {struct clk_init_data *init;struct fapll_synth *synth; +struct clk *clk =ERR_PTR (-ENOMEM ); init =kzalloc (sizeof (*init),GFP_KERNEL );if (!init)
@@ -520,13 +521,19 @@ static struct clk * __init ti_fapll_synth_setup(struct fapll_data *fd, synth->hw.init = init; synth->clk_pll = pll_clk; -return clk_register (NULL , &synth->hw); + clk =clk_register (NULL , &synth->hw); +if (IS_ERR (clk)) { +pr_err ("failed to register clock\n" ); + goto free; + } + +return clk; free:kfree (synth);kfree (init); -return ERR_PTR (-ENOMEM ); +return clk; }static void __init ti_fapll_setup (struct device_node *node)
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 503/717 ARM: 9044/1: vfp: use undef hook for VFP support detection
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit 3cce9d44321e460e7c88cdec4e4537a6e9ad7c0d ]
Commit f77ac2e378be9dd6 ("ARM: 9030/1: entry: omit FP emulation for UND exceptions taken in kernel mode") failed to take into account that there is in fact a case where we relied on this code path: during boot, the VFP detection code issues a read of FPSID, which will trigger an undef exception on cores that lack VFP support.
So let's reinstate this logic using an undef hook which is registered only for the duration of the initcall to vpf_init(), and which sets VFP_arch to a non-zero value - as before - if no VFP support is present.
--- arch/arm/vfp/entry.S | 17 ----------------- arch/arm/vfp/vfpmodule.c | 25 ++++++++++++++++++++----- 2 files changed, 20 insertions(+), 22 deletions(-)
arch/arm/vfp/entry.S +0 -17
@@ -37,20 +37,3 @@ ENDPROC(vfp_null_entry) .align 2 .LCvfp: .word vfp_vector - -@ This code is called if the VFP does not exist. It needs to flag the -@ failure to the VFP initialisation code. - - __INIT -ENTRY(vfp_testing_entry) - dec_preempt_count_ti r10, r4 - ldr r0, VFP_arch_address - str r0, [r0] @ set to non-zero value - ret r9 @ we have handled the fault -ENDPROC(vfp_testing_entry) - - .align 2 -VFP_arch_address: - .word VFP_arch - - __FINIT
arch/arm/vfp/vfpmodule.c +20 -5
@@ -32,7 +32,6 @@/* * Our undef handlers (in entry.S) */ -asmlinkage void vfp_testing_entry(void); asmlinkage void vfp_support_entry(void); asmlinkage void vfp_null_entry(void);
@@ -43,7 +42,7 @@ asmlinkage void (*vfp_vector)(void) = vfp_null_entry;* Used in startup: set to non-zero if VFP checks fail * After startup, holds VFP architecture */ -unsigned int VFP_arch; +static unsigned int __initdata VFP_arch;/* * The pointer to the vfpstate structure of the thread which currently
@@ -437,7 +436,7 @@ static void vfp_enable(void *unused)* present on all CPUs within a SMP complex. Needs to be called prior to * vfp_init(). */ -void vfp_disable (void ) +void __init vfp_disable (void ) {if (VFP_arch) {pr_debug ("%s: should be called prior to vfp_init\n" , __func__);
@@ -707,7 +706,7 @@ static int __init vfp_kmode_exception_hook_init(void)register_undef_hook (&vfp_kmode_exception_hook[i]);return 0 ; } -core_initcall (vfp_kmode_exception_hook_init); +subsys_initcall (vfp_kmode_exception_hook_init);/* * Kernel-side NEON support functions
@@ -753,6 +752,21 @@ EXPORT_SYMBOL(kernel_neon_end);#endif /* CONFIG_KERNEL_MODE_NEON */ +static int __init vfp_detect (struct pt_regs *regs,unsigned int instr) +{ + VFP_arch =UINT_MAX ;/* mark as not present */ + regs->ARM_pc +=4 ; +return 0 ; +} + +static struct undef_hook vfp_detect_hook__initdata = { + .instr_mask =0x0c000e00 , + .instr_val =0x0c000a00 , + .cpsr_mask =MODE_MASK , + .cpsr_val =SVC_MODE , + .fn = vfp_detect, +}; +/* * VFP support code initialisation. */
@@ -773,10 +787,11 @@ static int __init vfp_init(void)* The handler is already setup to just log calls, so * we just need to read the VFPSID register. */ - vfp_vector = vfp_testing_entry; +register_undef_hook (&vfp_detect_hook);barrier (); vfpsid =fmrx (FPSID );barrier (); +unregister_undef_hook (&vfp_detect_hook); vfp_vector = vfp_null_entry;pr_info ("VFP support v0.3: " );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 463/717 i40e, xsk: clear the status bits for the next_to_use descriptor
In reply to Greg Kroah-HartmanFrom: Björn Töpel <[email protected]>
[ Upstream commit 64050b5b8706d304ba647591b06e1eddc55e8bd9 ]
On the Rx side, the next_to_use index points to the next item in the HW ring to be refilled/allocated, and next_to_clean points to the next item to potentially be processed.
When the HW Rx ring is fully refilled, i.e. no packets has been processed, the next_to_use will be next_to_clean - 1. When the ring is fully processed next_to_clean will be equal to next_to_use. The latter case is where a bug is triggered.
If the next_to_use bits are not cleared, and the "fully processed" state is entered, a stale descriptor can be processed.
The skb-path correctly clear the status bit for the next_to_use descriptor, but the AF_XDP zero-copy path did not do that.
This change adds the status bits clearing of the next_to_use descriptor.
--- drivers/net/ethernet/intel/i40e/i40e_xsk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_xsk.c +4 -1
@@ -219,8 +219,11 @@ bool i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 count) }while (count); no_buffers: -if (rx_ring->next_to_use != ntu) +if (rx_ring->next_to_use != ntu) { +/* clear the status bits for the next_to_use descriptor */ + rx_desc->wb.qword1.status_error_len =0 ;i40e_release_rx_desc (rx_ring, ntu); + }return ok; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 483/717 io_uring: cancel only requests of current task
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ Upstream commit df9923f96717d0aebb0a73adbcf6285fa79e38cb ]
io_uring_cancel_files() cancels all request that match files regardless of task. There is no real need in that, cancel only requests of the specified task. That also handles SQPOLL case as it already changes task to it.
--- fs/io_uring.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-)
fs/io_uring.c +5 -18
@@ -8421,14 +8421,6 @@ static int io_uring_release(struct inode *inode, struct file *file)return 0 ; } -static bool io_wq_files_match (struct io_wq_work *work,void *data) -{ -struct files_struct *files = data; - -return !files || ((work->flags &IO_WQ_WORK_FILES ) && - work->identity->files == files); -} -/* * Returns true if 'preq' is the link parent of 'req' */
@@ -8566,21 +8558,20 @@ static void io_cancel_defer_files(struct io_ring_ctx *ctx,* Returns true if we found and killed one or more files pinning requests */ static bool io_uring_cancel_files (struct io_ring_ctx *ctx, +struct task_struct *task,struct files_struct *files) {if (list_empty_careful (&ctx->inflight_list))return false; -/* cancel all at once, should be faster than doing it one by one*/ -io_wq_cancel_cb (ctx->io_wq, io_wq_files_match, files, true); -while (!list_empty_careful (&ctx->inflight_list)) {struct io_kiocb *cancel_req =NULL , *req;DEFINE_WAIT (wait);spin_lock_irq (&ctx->inflight_lock);list_for_each_entry (req, &ctx->inflight_list, inflight_entry) { -if (files && (req->work.flags &IO_WQ_WORK_FILES ) && +if (req->task == task && + (req->work.flags &IO_WQ_WORK_FILES ) && req->work.identity->files != files)continue ;/* req is being completed, ignore */
@@ -8623,7 +8614,7 @@ static bool __io_uring_cancel_task_requests(struct io_ring_ctx *ctx, {bool ret; - ret =io_uring_cancel_files (ctx, files); + ret =io_uring_cancel_files (ctx, task, files);if (!files) {enum io_wq_cancel cret;
@@ -8662,11 +8653,7 @@ static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx,io_sq_thread_park (ctx->sq_data); } -if (files) -io_cancel_defer_files (ctx,NULL , files); -else -io_cancel_defer_files (ctx, task,NULL ); - +io_cancel_defer_files (ctx, task, files);io_cqring_overflow_flush (ctx, true, task, files);while (__io_uring_cancel_task_requests (ctx, task, files)) {
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 507/717 io_uring: cancel reqs shouldnt kill overflow list
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ Upstream commit cda286f0715c82f8117e166afd42cca068876dde ]
io_uring_cancel_task_requests() doesn't imply that the ring is going away, it may continue to work well after that. The problem is that it sets ->cq_overflow_flushed effectively disabling the CQ overflow feature
Split setting cq_overflow_flushed from flush, and do the first one only on exit. It's ok in terms of cancellations because there is a io_uring->in_idle check in __io_cqring_fill_event().
It also fixes a race with setting ->cq_overflow_flushed in io_uring_cancel_task_requests, whuch's is not atomic and a part of a bitmask with other flags. Though, the only other flag that's not set during init is drain_next, so it's not as bad for sane architectures.
--- fs/io_uring.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/io_uring.c +2 -4
@@ -1641,10 +1641,6 @@ static bool io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force,spin_lock_irqsave (&ctx->completion_lock, flags); -/* if force is set, the ring is going away. always drop after that */ -if (force) - ctx->cq_overflow_flushed =1 ; - cqe =NULL ;list_for_each_entry_safe (req, tmp, &ctx->cq_overflow_list, compl.list) {if (tsk && req->task != tsk)
@@ -8378,6 +8374,8 @@ static void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx) {mutex_lock (&ctx->uring_lock);percpu_ref_kill (&ctx->refs); +/* if force is set, the ring is going away. always drop after that */ + ctx->cq_overflow_flushed =1 ;if (ctx->rings)io_cqring_overflow_flush (ctx, true,NULL ,NULL );mutex_unlock (&ctx->uring_lock);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 481/717 pwm: imx27: Fix overflow for bigger periods
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 1ce65396e6b2386b4fd54f87beff0647a772e1cd ]
The second parameter of do_div is an u32 and NSEC_PER_SEC * prescale overflows this for bigger periods. Assuming the usual pwm input clk rate of 66 MHz this happens starting at requested period > 606060 ns.
Splitting the division into two operations doesn't loose any precision. It doesn't need to be feared that c / NSEC_PER_SEC doesn't fit into the unsigned long variable "duty_cycles" because in this case the assignment above to period_cycles would already have been overflowing as period >= duty_cycle and then the calculation is moot anyhow.
--- drivers/pwm/pwm-imx27.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pwm/pwm-imx27.c +2 -1
@@ -235,8 +235,9 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm, period_cycles /= prescale; c = clkrate * state->duty_cycle; -do_div (c,NSEC_PER_SEC * prescale); +do_div (c,NSEC_PER_SEC ); duty_cycles = c; + duty_cycles /= prescale;/* * according to imx pwm RM, the real period value should be PERIOD
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 522/717 media: sunxi-cir: ensure IR is handled when it is continuous
In reply to Greg Kroah-HartmanFrom: Sean Young <[email protected]>
commit 3f56df4c8ffeb120ed41906d3aae71799b7e726a upstream.
If a user holds a button down on a remote, then no ir idle interrupt will be generated until the user releases the button, depending on how quickly the remote repeats. No IR is processed until that point, which means that holding down a button may not do anything.
This also resolves an issue on a Cubieboard 1 where the IR receiver is picking up ambient infrared as IR and spews out endless
"rc rc0: IR event FIFO is full!" messages unless you choose to live in the dark.
--- drivers/media/rc/sunxi-cir.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/rc/sunxi-cir.c +2 -0
@@ -137,6 +137,8 @@ static irqreturn_t sunxi_ir_irq(int irqn }else if (status ®_RXSTA_RPE ) {ir_raw_event_set_idle (ir->rc, true);ir_raw_event_handle (ir->rc); + }else { +ir_raw_event_handle (ir->rc); }spin_unlock (&ir->ir_lock);
Greg Kroah-Hartman
maintainerPATCH 509/717 proc mountinfo: make splice available again
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
[ Upstream commit 14e3e989f6a5d9646b6cf60690499cc8bdc11f7d ]
Since commit 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops") we've required that file operation structures explicitly enable splice support, rather than falling back to the default handlers.
Most /proc files use the indirect 'struct proc_ops' to describe their file operations, and were fixed up to support splice earlier in commits 40be821d627c..b24c30c67863, but the mountinfo files interact with the VFS directly using their own 'struct file_operations' and got missed as a result.
This adds the necessary support for splice to work for /proc/*/mountinfo and friends.
--- fs/proc_namespace.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/proc_namespace.c +6 -3
@@ -320,7 +320,8 @@ static int mountstats_open(struct inodeconst struct file_operations proc_mounts_operations = { .open = mounts_open, - .read = seq_read, + .read_iter = seq_read_iter, + .splice_read = generic_file_splice_read, .llseek = seq_lseek, .release = mounts_release, .poll = mounts_poll,
@@ -328,7 +329,8 @@ const struct file_operations proc_mountsconst struct file_operations proc_mountinfo_operations = { .open = mountinfo_open, - .read = seq_read, + .read_iter = seq_read_iter, + .splice_read = generic_file_splice_read, .llseek = seq_lseek, .release = mounts_release, .poll = mounts_poll,
@@ -336,7 +338,8 @@ const struct file_operations proc_mounticonst struct file_operations proc_mountstats_operations = { .open = mountstats_open, - .read = seq_read, + .read_iter = seq_read_iter, + .splice_read = generic_file_splice_read, .llseek = seq_lseek, .release = mounts_release, };
Greg Kroah-Hartman
maintainerPATCH 520/717 io_uring: fix double io_uring free
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
commit 9faadcc8abe4b83d0263216dc3a6321d5bbd616b upstream.
Once we created a file for current context during setup, we should not call io_ring_ctx_wait_and_kill() directly as it'll be done by fput(file)
--- fs/io_uring.c | 71 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 32 deletions(-)
fs/io_uring.c +39 -32
@@ -9195,55 +9195,52 @@ static int io_allocate_scq_urings(structreturn 0 ; } +static int io_uring_install_fd (struct io_ring_ctx *ctx,struct file *file) +{ +int ret, fd; + + fd =get_unused_fd_flags (O_RDWR |O_CLOEXEC ); +if (fd <0 ) +return fd; + + ret =io_uring_add_task_file (ctx, file); +if (ret) { +put_unused_fd (fd); +return ret; + } +fd_install (fd, file); +return fd; +} +/* * Allocate an anonymous fd, this is what constitutes the application * visible backing of an io_uring instance. The application mmaps this * fd to gain access to the SQ/CQ ring details. If UNIX sockets are enabled, * we have to tie this fd to a socket for file garbage collection purposes. */ -static int io_uring_get_fd (struct io_ring_ctx *ctx) +static struct file *io_uring_get_file (struct io_ring_ctx *ctx) {struct file *file; +#if defined(CONFIG_UNIX )int ret; -int fd; -#if defined(CONFIG_UNIX ) ret =sock_create_kern (&init_net,PF_UNIX ,SOCK_RAW ,IPPROTO_IP , &ctx->ring_sock);if (ret) -return ret; +return ERR_PTR (ret);#endif - ret =get_unused_fd_flags (O_RDWR |O_CLOEXEC ); -if (ret <0 ) - goto err; - fd = ret; - file =anon_inode_getfile ("[io_uring]" , &io_uring_fops, ctx,O_RDWR |O_CLOEXEC ); -if (IS_ERR (file)) { -put_unused_fd (fd); - ret =PTR_ERR (file); - goto err; - } -#if defined(CONFIG_UNIX ) - ctx->ring_sock->file = file; -#endif - ret =io_uring_add_task_file (ctx, file); -if (ret) { -fput (file); -put_unused_fd (fd); - goto err; +if (IS_ERR (file)) { +sock_release (ctx->ring_sock); + ctx->ring_sock =NULL ; + }else { + ctx->ring_sock->file = file; } -fd_install (fd, file); -return fd; -err: -#if defined(CONFIG_UNIX ) -sock_release (ctx->ring_sock); - ctx->ring_sock =NULL ;#endif -return ret; +return file; } static int io_uring_create(unsigned entries, struct io_uring_params *p,
@@ -9251,6 +9248,7 @@ static int io_uring_create(unsigned entr {struct user_struct *user =NULL ;struct io_ring_ctx *ctx; +struct file *file;bool limit_mem;int ret;
@@ -9397,13 +9395,22 @@ static int io_uring_create(unsigned entr goto err; } + file =io_uring_get_file (ctx); +if (IS_ERR (file)) { + ret =PTR_ERR (file); + goto err; + } +/* * Install ring fd as the very last thing, so we don't risk someone * having closed it before we finish setup */ - ret =io_uring_get_fd (ctx); -if (ret <0 ) - goto err; + ret =io_uring_install_fd (ctx, file); +if (ret <0 ) { +/* fput will clean it up */ +fput (file); +return ret; + }trace_io_uring_create (ret, ctx, p->sq_entries, p->cq_entries, p->flags);return ret;
Greg Kroah-Hartman
maintainerPATCH 523/717 media: netup_unidvb: Dont leak SPI master in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit e297ddf296de35037fa97f4302782def196d350a upstream.
If the call to spi_register_master() fails on probe of the NetUP Universal DVB driver, the spi_master struct is erroneously not freed.
Likewise, if spi_new_device() fails, the spi_controller struct is not unregistered. Plug the leaks.
While at it, fix an ordering issue in netup_spi_release() wherein spi_unregister_master() is called after fiddling with the IRQ control register. The correct order is to call spi_unregister_master() *before* this teardown step because bus accesses may still be ongoing until that function returns.
--- drivers/media/pci/netup_unidvb/netup_unidvb_spi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/pci/netup_unidvb/netup_unidvb_spi.c +3 -2
@@ -175,7 +175,7 @@ int netup_spi_init(struct netup_unidvb_dstruct spi_master *master;struct netup_spi *nspi; - master =spi_alloc_master (&ndev->pci_dev->dev, + master =devm_spi_alloc_master (&ndev->pci_dev->dev,sizeof (struct netup_spi ));if (!master) { dev_err(&ndev->pci_dev->dev,
@@ -208,6 +208,7 @@ int netup_spi_init(struct netup_unidvb_d ndev->pci_slot, ndev->pci_func);if (!spi_new_device (master, &netup_spi_board)) { +spi_unregister_master (master); ndev->spi =NULL ;dev_err (&ndev->pci_dev->dev,"%s(): unable to create SPI device\n" , __func__);
@@ -226,13 +227,13 @@ void netup_spi_release(struct netup_unidif (!spi)return ; +spi_unregister_master (spi->master);spin_lock_irqsave (&spi->lock, flags); reg =readw (&spi->regs->control_stat);writew (reg |NETUP_SPI_CTRL_IRQ , &spi->regs->control_stat); reg =readw (&spi->regs->control_stat);writew (reg & ~NETUP_SPI_CTRL_IMASK , &spi->regs->control_stat);spin_unlock_irqrestore (&spi->lock, flags); -spi_unregister_master (spi->master); ndev->spi =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 525/717 media: ipu3-cio2: Return actual subdev format
In reply to Greg Kroah-HartmanFrom: Sakari Ailus <[email protected]>
commit 8160e86702e0807bd36d40f82648f9f9820b9d5a upstream.
Return actual subdev format on ipu3-cio2 subdev pads. The earlier implementation was based on an infinite recursion that exhausted the stack.
--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +3 -21
@@ -1233,29 +1233,11 @@ static int cio2_subdev_get_fmt(struct v4 struct v4l2_subdev_format *fmt) { struct cio2_queue *q = container_of(sd, struct cio2_queue, subdev); -struct v4l2_subdev_format format; -int ret; -if (fmt->which ==V4L2_SUBDEV_FORMAT_TRY ) { +if (fmt->which ==V4L2_SUBDEV_FORMAT_TRY ) fmt->format = *v4l2_subdev_get_try_format (sd, cfg, fmt->pad); -return 0 ; - } - -if (fmt->pad ==CIO2_PAD_SINK ) { - format.which =V4L2_SUBDEV_FORMAT_ACTIVE ; - ret =v4l2_subdev_call (sd, pad, get_fmt,NULL , - &format); - -if (ret) -return ret; -/* update colorspace etc */ - q->subdev_fmt.colorspace = format.format.colorspace; - q->subdev_fmt.ycbcr_enc = format.format.ycbcr_enc; - q->subdev_fmt.quantization = format.format.quantization; - q->subdev_fmt.xfer_func = format.format.xfer_func; - } - - fmt->format = q->subdev_fmt; +else + fmt->format = q->subdev_fmt;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 528/717 media: ipu3-cio2: Make the field on subdev format V4L2_FIELD_NONE
In reply to Greg Kroah-HartmanFrom: Sakari Ailus <[email protected]>
commit 219a8b9c04e54872f9a4d566633fb42f08bcbe2a upstream.
The ipu3-cio2 doesn't make use of the field and this is reflected in V4L2 buffers as well as the try format. Do this in active format, too.
--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +1 -0
@@ -1286,6 +1286,7 @@ static int cio2_subdev_set_fmt(struct v4 fmt->format.width =min_t (u32, fmt->format.width,CIO2_IMAGE_MAX_WIDTH ); fmt->format.height =min_t (u32, fmt->format.height,CIO2_IMAGE_MAX_LENGTH ); + fmt->format.field =V4L2_FIELD_NONE ;mutex_lock (&q->subdev_lock); *mbus = fmt->format;
Greg Kroah-Hartman
maintainerPATCH 533/717 Revert "ACPI / resources: Use AE_CTRL_TERMINATE to terminate resources walks"
In reply to Greg Kroah-HartmanFrom: Daniel Scally <[email protected]>
commit 12fc4dad94dfac25599f31257aac181c691ca96f upstream.
This reverts commit 8a66790b7850a6669129af078768a1d42076a0ef.
Switching this function to AE_CTRL_TERMINATE broke the documented behaviour of acpi_dev_get_resources() - AE_CTRL_TERMINATE does not, in fact, terminate the resource walk because acpi_walk_resource_buffer() ignores it (specifically converting it to AE_OK), referring to that value as "an OK termination by the user function". This means that acpi_dev_get_resources() does not abort processing when the preproc function returns a negative value.
--- drivers/acpi/resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/resource.c +1 -1
@@ -541,7 +541,7 @@ static acpi_status acpi_dev_process_reso ret = c->preproc (ares, c->preproc_data);if (ret <0 ) { c->error = ret; -return AE_CTRL_TERMINATE ; +return AE_ABORT_METHOD ; }else if (ret >0 ) {return AE_OK ; }
Greg Kroah-Hartman
maintainerPATCH 527/717 media: ipu3-cio2: Validate mbus format in setting subdev format
In reply to Greg Kroah-HartmanFrom: Sakari Ailus <[email protected]>
commit a86cf9b29e8b12811cf53c4970eefe0c1d290476 upstream.
Validate media bus code, width and height when setting the subdev format.
This effectively reworks how setting subdev format is implemented in the driver.
--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +20 -9
@@ -1258,6 +1258,9 @@ static int cio2_subdev_set_fmt(struct v4 struct v4l2_subdev_format *fmt) { struct cio2_queue *q = container_of(sd, struct cio2_queue, subdev); +struct v4l2_mbus_framefmt *mbus; +u32 mbus_code = fmt->format.code; +unsigned int i;/* * Only allow setting sink pad format;
@@ -1266,18 +1269,26 @@ static int cio2_subdev_set_fmt(struct v4if (fmt->pad ==CIO2_PAD_SOURCE )return cio2_subdev_get_fmt (sd, cfg, fmt); -mutex_lock (&q->subdev_lock); +if (fmt->which ==V4L2_SUBDEV_FORMAT_TRY ) + mbus =v4l2_subdev_get_try_format (sd, cfg, fmt->pad); +else + mbus = &q->subdev_fmt; + + fmt->format.code = formats[0 ].mbus_code; -if (fmt->which ==V4L2_SUBDEV_FORMAT_TRY ) { - *v4l2_subdev_get_try_format (sd, cfg, fmt->pad) = fmt->format; - }else { -/* It's the sink, allow changing frame size */ - q->subdev_fmt.width = fmt->format.width; - q->subdev_fmt.height = fmt->format.height; - q->subdev_fmt.code = fmt->format.code; - fmt->format = q->subdev_fmt; +for (i =0 ; i <ARRAY_SIZE (formats); i++) { +if (formats[i].mbus_code == fmt->format.code) { + fmt->format.code = mbus_code; +break ; + } } + fmt->format.width =min_t (u32, fmt->format.width,CIO2_IMAGE_MAX_WIDTH ); + fmt->format.height =min_t (u32, fmt->format.height, +CIO2_IMAGE_MAX_LENGTH ); + +mutex_lock (&q->subdev_lock); + *mbus = fmt->format;mutex_unlock (&q->subdev_lock);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 529/717 Input: cyapa_gen6 - fix out-of-bounds stack access
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit f051ae4f6c732c231046945b36234e977f8467c6 upstream.
gcc -Warray-bounds warns about a serious bug incyapa_pip_retrieve_data_structure:
drivers/input/mouse/cyapa_gen6.c: In function 'cyapa_pip_retrieve_data_structure.constprop':include/linux/unaligned/access_ok.h:40:17: warning: array subscript -1 is outside array bounds of 'struct retrieve_data_struct_cmd[1]' [-Warray-bounds]
40 | *((__le16 *)p) = cpu_to_le16(val);drivers/input/mouse/cyapa_gen6.c:569:13: note: while referencing 'cmd'
569 | } __packed cmd;
| ^~~
Apparently the '-2' was added to the pointer instead of the value, writing garbage into the stack next to this variable.
--- drivers/input/mouse/cyapa_gen6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/cyapa_gen6.c +1 -1
@@ -573,7 +573,7 @@ static int cyapa_pip_retrieve_data_strucmemset (&cmd,0 ,sizeof (cmd));put_unaligned_le16 (PIP_OUTPUT_REPORT_ADDR , &cmd.head.addr); -put_unaligned_le16 (sizeof (cmd), &cmd.head.length -2 ); +put_unaligned_le16 (sizeof (cmd) -2 , &cmd.head.length); cmd.head.report_id =PIP_APP_CMD_REPORT_ID ; cmd.head.cmd_code =PIP_RETRIEVE_DATA_STRUCTURE ;put_unaligned_le16 (read_offset, &cmd.read_offset);
Greg Kroah-Hartman
maintainerPATCH 531/717 ACPI: NFIT: Fix input validation of bus-family
In reply to Greg Kroah-HartmanFrom: Dan Williams <[email protected]>
commit 9a7e3d7f056831a6193d6d737fb7a26dfdceb04b upstream.
Dan reports that smatch thinks userspace can craft an out-of-bound bus family number. However, nd_cmd_clear_to_send() blocks all non-zero values of bus-family since only the kernel can initiate these commands. However, in the speculation path, family is a user controlled array index value so mask it for speculation safety. Also, since the nd_cmd_clear_to_send() safety is non-obvious and possibly may change in the future include input validation as if userspace could get past the nd_cmd_clear_to_send() gatekeeper.
--- drivers/acpi/nfit/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/acpi/nfit/core.c +5 -1
@@ -5,6 +5,7 @@#include <linux/list_sort.h> #include <linux/libnvdimm.h> #include <linux/module.h> +#include <linux/nospec.h> #include <linux/mutex.h> #include <linux/ndctl.h> #include <linux/sysfs.h>
@@ -478,8 +479,11 @@ int acpi_nfit_ctl(struct nvdimm_bus_desc cmd_mask = nd_desc->cmd_mask;if (cmd ==ND_CMD_CALL && call_pkg->nd_family) { family = call_pkg->nd_family; -if (!test_bit (family, &nd_desc->bus_family_mask)) +if (family >NVDIMM_BUS_FAMILY_MAX || + !test_bit (family, &nd_desc->bus_family_mask))return -EINVAL ; + family =array_index_nospec (family, +NVDIMM_BUS_FAMILY_MAX +1 ); dsm_mask = acpi_desc->family_dsm_mask[family]; guid =to_nfit_bus_uuid (family); }else {
Greg Kroah-Hartman
maintainerPATCH 513/717 vfio/pci: Move dummy_resources_list init in vfio_pci_probe()
In reply to Greg Kroah-HartmanFrom: Eric Auger <[email protected]>
commit 16b8fe4caf499ae8e12d2ab1b1324497e36a7b83 upstream.
In case an error occurs in vfio_pci_enable() before the call to vfio_pci_probe_mmaps(), vfio_pci_disable() will try to iterate on an uninitialized list and cause a kernel panic.
Lets move to the initialization to vfio_pci_probe() to fix the issue.
--- drivers/vfio/pci/vfio_pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/vfio/pci/vfio_pci.c +1 -2
@@ -161,8 +161,6 @@ static void vfio_pci_probe_mmaps(structint i;struct vfio_pci_dummy_resource *dummy_res; -INIT_LIST_HEAD (&vdev->dummy_resources_list); -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) {int bar = i +PCI_STD_RESOURCES ;
@@ -1966,6 +1964,7 @@ static int vfio_pci_probe(struct pci_devmutex_init (&vdev->igate);spin_lock_init (&vdev->irqlock);mutex_init (&vdev->ioeventfds_lock); +INIT_LIST_HEAD (&vdev->dummy_resources_list);INIT_LIST_HEAD (&vdev->ioeventfds_list);mutex_init (&vdev->vma_lock);INIT_LIST_HEAD (&vdev->vma_list);
Greg Kroah-Hartman
maintainerPATCH 514/717 vfio/pci/nvlink2: Do not attempt NPU2 setup on POWER8NVL NPU
In reply to Greg Kroah-HartmanFrom: Alexey Kardashevskiy <[email protected]>
commit d22f9a6c92de96304c81792942ae7c306f08ac77 upstream.
We execute certain NPU2 setup code (such as mapping an LPID to a device in NPU2) unconditionally if an Nvlink bridge is detected. However this cannot succeed on POWER8NVL machines as the init helpers return an error other than ENODEV which means the device is there is and setup failed so vfio_pci_enable() fails and pass through is not possible.
This changes the two NPU2 related init helpers to return -ENODEV if there is no "memory-region" device tree property as this is the distinction between NPU and NPU2.
Tested on
- POWER9 pvr=004e1201, Ubuntu 19.04 host, Ubuntu 18.04 vm, NVIDIA GV100 10de:1db1 driver 418.39
- POWER8 pvr=004c0100, RHEL 7.6 host, Ubuntu 16.10 vm, NVIDIA P100 10de:15f9 driver 396.47
--- drivers/vfio/pci/vfio_pci_nvlink2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/vfio/pci/vfio_pci_nvlink2.c +5 -2
@@ -231,7 +231,7 @@ int vfio_pci_nvdia_v100_nvlink2_init(strreturn -EINVAL ;if (of_property_read_u32 (npu_node,"memory-region" , &mem_phandle)) -return -EINVAL ; +return -ENODEV ; mem_node =of_find_node_by_phandle (mem_phandle);if (!mem_node)
@@ -393,7 +393,7 @@ int vfio_pci_ibm_npu2_init(struct vfio_pint ret;struct vfio_pci_npu2_data *data;struct device_node *nvlink_dn; -u32 nvlink_index =0 ; +u32 nvlink_index =0 , mem_phandle =0 ;struct pci_dev *npdev = vdev->pdev;struct device_node *npu_node =pci_device_to_OF_node (npdev);struct pci_controller *hose =pci_bus_to_host (npdev->bus);
@@ -408,6 +408,9 @@ int vfio_pci_ibm_npu2_init(struct vfio_pif (!pnv_pci_get_gpu_dev (vdev->pdev))return -ENODEV ; +if (of_property_read_u32 (npu_node,"memory-region" , &mem_phandle)) +return -ENODEV ; +/* * NPU2 normally has 8 ATSD registers (for concurrency) and 6 links * so we can allocate one register per link, using nvlink index as
Greg Kroah-Hartman
maintainerPATCH 516/717 io_uring: fix io_wqe->work_list corruption
In reply to Greg Kroah-HartmanFrom: Xiaoguang Wang <[email protected]>
commit 0020ef04e48571a88d4f482ad08f71052c5c5a08 upstream.
For the first time a req punted to io-wq, we'll initialize io_wq_work's list to be NULL, then insert req to io_wqe->work_list. If this req is not inserted into tail of io_wqe->work_list, this req's io_wq_work list will point to another req's io_wq_work. For splitted bio case, this req maybe inserted to io_wqe->work_list repeatedly, once we insert it to tail of io_wqe->work_list for the second time, now io_wq_work->list->next will be invalid pointer, which then result in many strang error, panic, kernel soft-lockup, rcu stall, etc.
In my vm, kernel doest not have commit cc29e1bf0d63f7 ("block: disable iopoll for split bio"), below fio job can reproduce this bug steadily:
[global]
name=iouring-sqpoll-iopoll-1
ioengine=io_uring
iodepth=128
numjobs=1
thread
rw=randread
direct=1
registerfiles=1
hipri=1
bs=4m
size=100M
runtime=120time_basedgroup_reporting
randrepeat=0
[device]
directory=/home/feiman.wxg/mntpoint/ # an ext4 mount point
If we have commit cc29e1bf0d63f7 ("block: disable iopoll for split bio"), there will no splitted bio case for polled io, but I think we still to need to fix this list corruption, it also should maybe go to stable branchs.
To fix this corruption, if a req is inserted into tail of io_wqe->work_list, initialize req->io_wq_work->list->next to bu NULL.
--- fs/io-wq.h | 1 + 1 file changed, 1 insertion(+)
fs/io-wq.h +1 -0
@@ -59,6 +59,7 @@ static inline void wq_list_add_tail(stru list->last->next = node; list->last = node; } + node->next =NULL ; } static inline void wq_list_cut(struct io_wq_work_list *list,
Greg Kroah-Hartman
maintainerPATCH 540/717 ALSA: hda/realtek - Add supported for more Lenovo ALC285 Headset Button
In reply to Greg Kroah-HartmanFrom: Kailang Yang <[email protected]>
commit 607184cb1635eaee239fe3fb9648a8b82a5232d7 upstream.
Add supported for more Lenovo ALC285 Headset Button.
--- sound/pci/hda/patch_realtek.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/pci/hda/patch_realtek.c +4 -0
@@ -8577,6 +8577,10 @@ static const struct snd_hda_pin_quirk al {0x12, 0x90a60130}, {0x19, 0x03a11020}, {0x21, 0x0321101f}), + SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK, + {0x14, 0x90170110}, + {0x19, 0x04a11040}, + {0x21, 0x04211020}), SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE, {0x12, 0x90a60130}, {0x14, 0x90170110},
Greg Kroah-Hartman
maintainerPATCH 542/717 ALSA/hda: apply jack fixup for the Acer Veriton N4640G/N6640G/N2510G
In reply to Greg Kroah-HartmanFrom: Chris Chiu <[email protected]>
commit 13be30f156fda725b168ac89fc91f78651575307 upstream.
This Acer Veriton N4640G/N6640G/N2510G desktops have 2 headphone jacks(front and rear), and a separate Mic In jack.
The rear headphone jack is actually a line out jack but always silent while playing audio. The front 'Mic In' also fails the jack sensing. Apply the ALC269_FIXUP_LIFEBOOK to have all audio jacks to work as expected.
--- sound/pci/hda/patch_realtek.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/patch_realtek.c +3 -0
@@ -7805,11 +7805,14 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1025 ,0x0762 ,"Acer Aspire E1-472" ,ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572 ),SND_PCI_QUIRK (0x1025 ,0x0775 ,"Acer Aspire E1-572" ,ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572 ),SND_PCI_QUIRK (0x1025 ,0x079b ,"Acer Aspire V5-573G" ,ALC282_FIXUP_ASPIRE_V5_PINS ), +SND_PCI_QUIRK (0x1025 ,0x101c ,"Acer Veriton N2510G" ,ALC269_FIXUP_LIFEBOOK ),SND_PCI_QUIRK (0x1025 ,0x102b ,"Acer Aspire C24-860" ,ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1025 ,0x1065 ,"Acer Aspire C20-820" ,ALC269VC_FIXUP_ACER_HEADSET_MIC ),SND_PCI_QUIRK (0x1025 ,0x106d ,"Acer Cloudbook 14" ,ALC283_FIXUP_CHROME_BOOK ),SND_PCI_QUIRK (0x1025 ,0x1099 ,"Acer Aspire E5-523G" ,ALC255_FIXUP_ACER_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1025 ,0x110e ,"Acer Aspire ES1-432" ,ALC255_FIXUP_ACER_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0x1025 ,0x1166 ,"Acer Veriton N4640G" ,ALC269_FIXUP_LIFEBOOK ), +SND_PCI_QUIRK (0x1025 ,0x1167 ,"Acer Veriton N6640G" ,ALC269_FIXUP_LIFEBOOK ),SND_PCI_QUIRK (0x1025 ,0x1246 ,"Acer Predator Helios 500" ,ALC299_FIXUP_PREDATOR_SPK ),SND_PCI_QUIRK (0x1025 ,0x1247 ,"Acer vCopperbox" ,ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS ), SND_PCI_QUIRK(0x1025, 0x1248, "Acer Veriton N4660G", ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE),
Greg Kroah-Hartman
maintainerPATCH 512/717 io_uring: always let io_iopoll_complete() complete polled io
In reply to Greg Kroah-HartmanFrom: Xiaoguang Wang <[email protected]>
commit dad1b1242fd5717af18ae4ac9d12b9f65849e13a upstream.
Abaci Fuzz reported a double-free or invalid-free BUG in io_commit_cqring():
[ 95.504842] BUG: KASAN: double-free or invalid-free in io_commit_cqring+0x3ec/0x8e0 [ 95.505921] [ 95.506225] CPU: 0 PID: 4037 Comm: io_wqe_worker-0 Tainted: G B W 5.10.0-rc5+ #1 [ 95.507434] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 [ 95.508248] Call Trace: [ 95.508683] dump_stack+0x107/0x163 [ 95.509323] ? io_commit_cqring+0x3ec/0x8e0 [ 95.509982] print_address_description.constprop.0+0x3e/0x60 [ 95.510814] ? vprintk_func+0x98/0x140 [ 95.511399] ? io_commit_cqring+0x3ec/0x8e0 [ 95.512036] ? io_commit_cqring+0x3ec/0x8e0 [ 95.512733] kasan_report_invalid_free+0x51/0x80 [ 95.513431] ? io_commit_cqring+0x3ec/0x8e0 [ 95.514047] __kasan_slab_free+0x141/0x160 [ 95.514699] kfree+0xd1/0x390 [ 95.515182] io_commit_cqring+0x3ec/0x8e0 [ 95.515799] __io_req_complete.part.0+0x64/0x90 [ 95.516483] io_wq_submit_work+0x1fa/0x260 [ 95.517117] io_worker_handle_work+0xeac/0x1c00 [ 95.517828] io_wqe_worker+0xc94/0x11a0 [ 95.518438] ? io_worker_handle_work+0x1c00/0x1c00 [ 95.519151] ? __kthread_parkme+0x11d/0x1d0 [ 95.519806] ? io_worker_handle_work+0x1c00/0x1c00 [ 95.520512] ? io_worker_handle_work+0x1c00/0x1c00 [ 95.521211] kthread+0x396/0x470 [ 95.521727] ? _raw_spin_unlock_irq+0x24/0x30 [ 95.522380] ? kthread_mod_delayed_work+0x180/0x180 [ 95.523108] ret_from_fork+0x22/0x30 [ 95.523684] [ 95.523985] Allocated by task 4035: [ 95.524543] kasan_save_stack+0x1b/0x40 [ 95.525136] __kasan_kmalloc.constprop.0+0xc2/0xd0 [ 95.525882] kmem_cache_alloc_trace+0x17b/0x310 [ 95.533930] io_queue_sqe+0x225/0xcb0 [ 95.534505] io_submit_sqes+0x1768/0x25f0 [ 95.535164] __x64_sys_io_uring_enter+0x89e/0xd10 [ 95.535900] do_syscall_64+0x33/0x40 [ 95.536465] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 95.537199] [ 95.537505] Freed by task 4035: [ 95.538003] kasan_save_stack+0x1b/0x40 [ 95.538599] kasan_set_track+0x1c/0x30 [ 95.539177] kasan_set_free_info+0x1b/0x30 [ 95.539798] __kasan_slab_free+0x112/0x160 [ 95.540427] kfree+0xd1/0x390 [ 95.540910] io_commit_cqring+0x3ec/0x8e0 [ 95.541516] io_iopoll_complete+0x914/0x1390 [ 95.542150] io_do_iopoll+0x580/0x700 [ 95.542724] io_iopoll_try_reap_events.part.0+0x108/0x200 [ 95.543512] io_ring_ctx_wait_and_kill+0x118/0x340 [ 95.544206] io_uring_release+0x43/0x50 [ 95.544791] __fput+0x28d/0x940 [ 95.545291] task_work_run+0xea/0x1b0 [ 95.545873] do_exit+0xb6a/0x2c60 [ 95.546400] do_group_exit+0x12a/0x320 [ 95.546967] __x64_sys_exit_group+0x3f/0x50 [ 95.547605] do_syscall_64+0x33/0x40 [ 95.548155] entry_SYSCALL_64_after_hwframe+0x44/0xa9
The reason is that once we got a non EAGAIN error in io_wq_submit_work(), we'll complete req by calling io_req_complete(), which will hold completion_lock to call io_commit_cqring(), but for polled io, io_iopoll_complete() won't hold completion_lock to call io_commit_cqring(), then there maybe concurrent access to ctx->defer_list, double free may happen.
To fix this bug, we always let io_iopoll_complete() complete polled io.
--- fs/io_uring.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
fs/io_uring.c +13 -2
@@ -6083,8 +6083,19 @@ static struct io_wq_work *io_wq_submit_w }if (ret) { -req_set_fail_links (req); -io_req_complete (req, ret); +/* +* io_iopoll_complete() does not hold completion_lock to complete +* polled io, so here for polled io, just mark it done and still let +* io_iopoll_complete() complete it. +*/ +if (req->ctx->flags &IORING_SETUP_IOPOLL ) { +struct kiocb *kiocb = &req->rw.kiocb; + +kiocb_done (kiocb, ret,NULL ); + }else { +req_set_fail_links (req); +io_req_complete (req, ret); + } }return io_steal_work (req);
Greg Kroah-Hartman
maintainerPATCH 517/717 io_uring: fix 0-iov read buffer select
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
commit dd20166236953c8cd14f4c668bf972af32f0c6be upstream.
Doing vectored buf-select read with 0 iovec passed is meaningless and utterly broken, forbid it.
--- fs/io_uring.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/io_uring.c +1 -3
@@ -3048,9 +3048,7 @@ static ssize_t io_iov_buffer_select(stru iov[0 ].iov_len = kbuf->len;return 0 ; } -if (!req->rw.len) -return 0 ; -else if (req->rw.len >1 ) +if (req->rw.len !=1 )return -EINVAL ;#ifdef CONFIG_COMPAT
Greg Kroah-Hartman
maintainerPATCH 556/717 s390/dasd: prevent inconsistent LCU device data
In reply to Greg Kroah-HartmanFrom: Stefan Haberland <[email protected]>
commit a29ea01653493b94ea12bb2b89d1564a265081b6 upstream.
Prevent _lcu_update from adding a device to a pavgroup if the LCU still requires an update. The data is not reliable any longer and in parallel devices might have been moved on the lists already.
This might lead to list corruptions or invalid PAV grouping. Only add devices to a pavgroup if the LCU is up to date. Additional steps are taken by the scheduled lcu update.
--- drivers/s390/block/dasd_alias.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/s390/block/dasd_alias.c +9 -0
@@ -511,6 +511,14 @@ static int _lcu_update(struct dasd_devicreturn rc;spin_lock_irqsave (&lcu->lock, flags); +/* +* there is another update needed skip the remaining handling +* the data might already be outdated +* but especially do not add the device to an LCU with pending +* update +*/ +if (lcu->flags &NEED_UAC_UPDATE ) + goto out; lcu->pav =NO_PAV ;for (i =0 ; i <MAX_DEVICES_PER_LCU ; ++i) {switch (lcu->uac->unit[i].ua_type) {
@@ -529,6 +537,7 @@ static int _lcu_update(struct dasd_devic alias_list) {_add_device_to_lcu (lcu, device, refdev); } +out:spin_unlock_irqrestore (&lcu->lock, flags);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 551/717 s390/smp: perform initial CPU reset also for SMT siblings
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit b5e438ebd7e808d1d2435159ac4742e01a94b8da upstream.
Not resetting the SMT siblings might leave them in unpredictable state. One of the observed problems was that the CPU timer wasn't reset and therefore large system time values where accounted during CPU bringup.
--- arch/s390/kernel/smp.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
arch/s390/kernel/smp.c +3 -15
@@ -896,24 +896,12 @@ static void __no_sanitize_address smp_st/* Upping and downing of CPUs */ int __cpu_up (unsigned int cpu,struct task_struct *tidle) { -struct pcpu *pcpu; -int base, i, rc; +struct pcpu *pcpu = pcpu_devices + cpu; +int rc; - pcpu = pcpu_devices + cpu;if (pcpu->state !=CPU_STATE_CONFIGURED )return -EIO ; - base =smp_get_base_cpu (cpu); -for (i =0 ; i <= smp_cpu_mtid; i++) { -if (base + i < nr_cpu_ids) -if (cpu_online (base + i)) -break ; - } -/* -* If this is the first CPU of the core to get online -* do an initial CPU reset. -*/ -if (i > smp_cpu_mtid && -pcpu_sigp_retry (pcpu_devices + base,SIGP_INITIAL_CPU_RESET ,0 ) != +if (pcpu_sigp_retry (pcpu,SIGP_INITIAL_CPU_RESET ,0 ) !=SIGP_CC_ORDER_CODE_ACCEPTED )return -EIO ;
Greg Kroah-Hartman
maintainerPATCH 552/717 s390/kexec_file: fix diag308 subcode when loading crash kernel
In reply to Greg Kroah-HartmanFrom: Philipp Rudo <[email protected]>
commit 613775d62ec60202f98d2c5f520e6e9ba6dd4ac4 upstream.
diag308 subcode 0 performes a clear reset which inlcudes the reset of all registers in the system. While this is the preferred behavior when loading a normal kernel via kexec it prevents the crash kernel to store the register values in the dump. To prevent this use subcode 1 when loading a crash kernel instead.
--- arch/s390/purgatory/head.S | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/s390/purgatory/head.S +5 -4
@@ -62,14 +62,15 @@ jh 10b .endm -.macro START_NEXT_KERNEL base +.macro START_NEXT_KERNEL base subcode lg %r4,kernel_entry-\base(%r13) lg %r5,load_psw_mask-\base(%r13) ogr %r4,%r5 stg %r4,0(%r0) xgr %r0,%r0 - diag %r0,%r0,0x308 + lghi %r1,\subcode + diag %r0,%r1,0x308 .endm .text
@@ -123,7 +124,7 @@ ENTRY(purgatory_start) je .start_crash_kernel /* start normal kernel */ - START_NEXT_KERNEL .base_crash + START_NEXT_KERNEL .base_crash 0 .return_old_kernel: lmg %r6,%r15,gprregs-.base_crash(%r13)
@@ -227,7 +228,7 @@ ENTRY(purgatory_start) MEMCPY %r9,%r10,%r11 /* start crash kernel */ - START_NEXT_KERNEL .base_dst + START_NEXT_KERNEL .base_dst 1 load_psw_mask:
Greg Kroah-Hartman
maintainerPATCH 553/717 s390/idle: add missing mt_cycles calculation
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit e259b3fafa7de362b04ecd86e7fa9a9e9273e5fb upstream.
During removal of the critical section cleanup the calculation of mt_cycles during idle was removed. This causes invalid accounting on systems with SMT enabled.
--- arch/s390/kernel/entry.S | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
arch/s390/kernel/entry.S +25 -9
@@ -112,7 +112,7 @@ _LPP_OFFSET = __LC_LPP .macro SWITCH_ASYNC savearea,timer tmhh %r8,0x0001 # interrupting from user ? - jnz 2f + jnz 4f #if IS_ENABLED(CONFIG_KVM) lgr %r14,%r9 larl %r13,.Lsie_gmap
@@ -125,9 +125,25 @@ _LPP_OFFSET = __LC_LPP #endif 0: larl %r13,.Lpsw_idle_exit cgr %r13,%r9 - jne 1f + jne 3f - mvc __CLOCK_IDLE_EXIT(8,%r2), __LC_INT_CLOCK + larl %r1,smp_cpu_mtid + llgf %r1,0(%r1) + ltgr %r1,%r1 + jz 2f # no SMT, skip mt_cycles calculation + .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+80(%r15) + larl %r3,mt_cycles + ag %r3,__LC_PERCPU_OFFSET + la %r4,__SF_EMPTY+16(%r15) +1: lg %r0,0(%r3) + slg %r0,0(%r4) + alg %r0,64(%r4) + stg %r0,0(%r3) + la %r3,8(%r3) + la %r4,8(%r4) + brct %r1,1b + +2: mvc __CLOCK_IDLE_EXIT(8,%r2), __LC_INT_CLOCK mvc __TIMER_IDLE_EXIT(8,%r2), __LC_ASYNC_ENTER_TIMER # account system time going idle ni __LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT
@@ -146,17 +162,17 @@ _LPP_OFFSET = __LC_LPP mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2) nihh %r8,0xfcfd # clear wait state and irq bits -1: lg %r14,__LC_ASYNC_STACK # are we already on the target stack? +3: lg %r14,__LC_ASYNC_STACK # are we already on the target stack? slgr %r14,%r15 srag %r14,%r14,STACK_SHIFT - jnz 3f + jnz 5f CHECK_STACK \savearea aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) - j 4f -2: UPDATE_VTIME %r14,%r15,\timer + j 6f +4: UPDATE_VTIME %r14,%r15,\timer BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP -3: lg %r15,__LC_ASYNC_STACK # load async stack -4: la %r11,STACK_FRAME_OVERHEAD(%r15) +5: lg %r15,__LC_ASYNC_STACK # load async stack +6: la %r11,STACK_FRAME_OVERHEAD(%r15) .endm .macro UPDATE_VTIME w1,w2,enter_timer
Greg Kroah-Hartman
maintainerPATCH 554/717 s390/idle: fix accounting with machine checks
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit 454efcf82ea17d7efeb86ebaa20775a21ec87d27 upstream.
When a machine check interrupt is triggered during idle, the code is using the async timer/clock for idle time calculation. It should use the machine check enter timer/clock which is passed to the macro.
--- arch/s390/kernel/entry.S | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/s390/kernel/entry.S +6 -6
@@ -110,7 +110,7 @@ _LPP_OFFSET = __LC_LPP #endif .endm - .macro SWITCH_ASYNC savearea,timer + .macro SWITCH_ASYNC savearea,timer,clock tmhh %r8,0x0001 # interrupting from user ? jnz 4f #if IS_ENABLED(CONFIG_KVM)
@@ -143,8 +143,8 @@ _LPP_OFFSET = __LC_LPP la %r4,8(%r4) brct %r1,1b -2: mvc __CLOCK_IDLE_EXIT(8,%r2), __LC_INT_CLOCK - mvc __TIMER_IDLE_EXIT(8,%r2), __LC_ASYNC_ENTER_TIMER +2: mvc __CLOCK_IDLE_EXIT(8,%r2), \clock + mvc __TIMER_IDLE_EXIT(8,%r2), \timer # account system time going idle ni __LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT
@@ -761,7 +761,7 @@ ENTRY(io_int_handler) stmg %r8,%r15,__LC_SAVE_AREA_ASYNC lg %r12,__LC_CURRENT lmg %r8,%r9,__LC_IO_OLD_PSW - SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER + SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER,__LC_INT_CLOCK stmg %r0,%r7,__PT_R0(%r11) # clear user controlled registers to prevent speculative use xgr %r0,%r0
@@ -961,7 +961,7 @@ ENTRY(ext_int_handler) stmg %r8,%r15,__LC_SAVE_AREA_ASYNC lg %r12,__LC_CURRENT lmg %r8,%r9,__LC_EXT_OLD_PSW - SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER + SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER,__LC_INT_CLOCK stmg %r0,%r7,__PT_R0(%r11) # clear user controlled registers to prevent speculative use xgr %r0,%r0
@@ -1183,7 +1183,7 @@ ENTRY(mcck_int_handler) TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID jno .Lmcck_panic 4: ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off - SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER + SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER,__LC_MCCK_CLOCK .Lmcck_skip: lghi %r14,__LC_GPREGS_SAVE_AREA+64 stmg %r0,%r7,__PT_R0(%r11)
Greg Kroah-Hartman
maintainerPATCH 557/717 s390/dasd: fix list corruption of pavgroup group list
In reply to Greg Kroah-HartmanFrom: Stefan Haberland <[email protected]>
commit 0ede91f83aa335da1c3ec68eb0f9e228f269f6d8 upstream.
dasd_alias_add_device() moves devices to the active_devices list in case of a scheduled LCU update regardless if they have previously been in a pavgroup or not.
Example: device A and B are in the same pavgroup.
Device A has already been in a pavgroup and the private->pavgroup pointer is set and points to a valid pavgroup. While going through dasd_add_device it is moved from the pavgroup to the active_devices list.
In parallel device B might be removed from the same pavgroup in remove_device_from_lcu() which in turn checks if the group is empty and deletes it accordingly because device A has already been removed from there.
When now device A enters remove_device_from_lcu() it is tried to remove it from the pavgroup again because the pavgroup pointer is still set and again the empty group will be cleaned up which leads to a list corruption.
Fix by setting private->pavgroup to NULL in dasd_add_device.
If the device has been the last device on the pavgroup an empty pavgroup remains but this will be cleaned up by the scheduled lcu_update which iterates over all existing pavgroups.
--- drivers/s390/block/dasd_alias.c | 1 + 1 file changed, 1 insertion(+)
drivers/s390/block/dasd_alias.c +1 -0
@@ -642,6 +642,7 @@ int dasd_alias_add_device(struct dasd_de }if (lcu->flags &UPDATE_PENDING ) {list_move (&device->alias_list, &lcu->active_devices); + private->pavgroup =NULL ;_schedule_lcu_update (lcu, device); }spin_unlock_irqrestore (&lcu->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 561/717 ASoC: AMD Renoir - add DMI table to avoid the ACP mic probe (broken BIOS)
In reply to Greg Kroah-HartmanFrom: Jaroslav Kysela <[email protected]>
commit 718c406e1ffaca4eac987b957bbb36ce1090797a upstream.
Users reported that some Lenovo AMD platforms do not have ACP microphone, but the BIOS advertises it via ACPI.
This patch create a simple DMI table, where those machines with the broken BIOS can be added. The DMI description for Lenovo IdeaPad 5 and IdeaPad Flex 5 devices are added there.
Also describe the dmic_acpi_check kernel module parameter in a more understandable way.
--- sound/soc/amd/renoir/rn-pci-acp3x.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
sound/soc/amd/renoir/rn-pci-acp3x.c +23 -5
@@ -6,6 +6,7 @@#include <linux/pci.h> #include <linux/acpi.h> +#include <linux/dmi.h> #include <linux/module.h> #include <linux/io.h> #include <linux/delay.h>
@@ -20,14 +21,13 @@ module_param(acp_power_gating, int, 0644MODULE_PARM_DESC (acp_power_gating,"Enable acp power gating" );/** -* dmic_acpi_check = -1 - Checks ACPI method to know DMIC hardware status runtime -* = 0 - Skips the DMIC device creation and returns probe failure -* = 1 - Assumes that platform has DMIC support and skips ACPI -* method check +* dmic_acpi_check = -1 - Use ACPI/DMI method to detect the DMIC hardware presence at runtime +* = 0 - Skip the DMIC device creation and return probe failure +* = 1 - Force DMIC support */ static int dmic_acpi_check =ACP_DMIC_AUTO ;module_param (dmic_acpi_check, bint,0644 ); -MODULE_PARM_DESC (dmic_acpi_check,"checks Dmic hardware runtime" ); +MODULE_PARM_DESC (dmic_acpi_check,"Digital microphone presence (-1=auto, 0=none, 1=force)" );struct acp_dev_data {void __iomem *acp_base;
@@ -163,6 +163,17 @@ static int rn_acp_deinit(void __iomem *areturn 0 ; } +static const struct dmi_system_id rn_acp_quirk_table[] = { + { +/* Lenovo IdeaPad Flex 5 14ARE05, IdeaPad 5 15ARE05 */ + .matches = { +DMI_EXACT_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), +DMI_EXACT_MATCH (DMI_BOARD_NAME ,"LNVNB161216" ), + } + }, + {} +}; +static int snd_rn_acp_probe (struct pci_dev *pci,const struct pci_device_id *pci_id) {
@@ -172,6 +183,7 @@ static int snd_rn_acp_probe(struct pci_dacpi_handle handle;acpi_integer dmic_status;#endif +const struct dmi_system_id *dmi_id;unsigned int irqflags;int ret, index;u32 addr;
@@ -232,6 +244,12 @@ static int snd_rn_acp_probe(struct pci_d goto de_init; }#endif + dmi_id =dmi_first_match (rn_acp_quirk_table); +if (dmi_id && !dmi_id->driver_data) { +dev_info (&pci->dev,"ACPI settings override using DMI (ACP mic is not present)" ); + ret = -ENODEV ; + goto de_init; + } } adata->res = devm_kzalloc(&pci->dev,
Greg Kroah-Hartman
maintainerPATCH 555/717 s390/dasd: fix hanging device offline processing
In reply to Greg Kroah-HartmanFrom: Stefan Haberland <[email protected]>
commit 658a337a606f48b7ebe451591f7681d383fa115e upstream.
For an LCU update a read unit address configuration IO is required. This is started using sleep_on(), which has early exit paths in case the device is not usable for IO. For example when it is in offline processing.
In those cases the LCU update should fail and not be retried. Therefore lcu_update_work checks if EOPNOTSUPP is returned or not.
Commit 41995342b40c ("s390/dasd: fix endless loop after read unit address configuration") accidentally removed the EOPNOTSUPP return code from read_unit_address_configuration(), which in turn might lead to an endless loop of the LCU update in offline processing.
Fix by returning EOPNOTSUPP again if the device is not able to perform the request.
--- drivers/s390/block/dasd_alias.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/s390/block/dasd_alias.c +9 -1
@@ -462,11 +462,19 @@ static int read_unit_address_configuratispin_unlock_irqrestore (&lcu->lock, flags); rc =dasd_sleep_on (cqr); -if (rc && !suborder_not_supported (cqr)) { +if (!rc) + goto out; + +if (suborder_not_supported (cqr)) { +/* suborder not supported or device unusable for IO */ + rc = -EOPNOTSUPP ; + }else { +/* IO failed but should be retried */ spin_lock_irqsave (&lcu->lock, flags); lcu->flags |=NEED_UAC_UPDATE ;spin_unlock_irqrestore (&lcu->lock, flags); } +out:dasd_sfree_request (cqr, cqr->memdev);return rc; }
Greg Kroah-Hartman
maintainerPATCH 559/717 binder: add flag to clear buffer on txn complete
In reply to Greg Kroah-HartmanFrom: Todd Kjos <[email protected]>
commit 0f966cba95c78029f491b433ea95ff38f414a761 upstream.
Add a per-transaction flag to indicate that the buffer must be cleared when the transaction is complete to prevent copies of sensitive data from being preserved in memory.
--- drivers/android/binder.c | 1 drivers/android/binder_alloc.c | 48 ++++++++++++++++++++++++++++++++++++ drivers/android/binder_alloc.h | 4 ++- include/uapi/linux/android/binder.h | 1 4 files changed, 53 insertions(+), 1 deletion(-)
drivers/android/binder.c +1 -0
@@ -3146,6 +3146,7 @@ static void binder_transaction(struct bi t->buffer->debug_id = t->debug_id; t->buffer->transaction = t; t->buffer->target_node = target_node; + t->buffer->clear_on_free = !!(t->flags &TF_CLEAR_BUF );trace_binder_transaction_alloc_buf (t->buffer); if (binder_alloc_copy_user_to_buffer(
drivers/android/binder_alloc.c +48 -0
72 lines not on this page · raw message
drivers/android/binder_alloc.h +3 -1
@@ -23,6 +23,7 @@ struct binder_transaction;* @entry: entry alloc->buffers * @rb_node: node for allocated_buffers/free_buffers rb trees * @free: %true if buffer is free +* @clear_on_free: %true if buffer must be zeroed after use * @allow_user_free: %true if user is allowed to free buffer * @async_transaction: %true if buffer is in use for an async txn * @debug_id: unique ID for debugging
@@ -41,9 +42,10 @@ struct binder_buffer {struct rb_node rb_node;/* free entry by size or allocated entry */ /* by address */ unsigned free:1; + unsigned clear_on_free:1; unsigned allow_user_free:1; unsigned async_transaction:1; - unsigned debug_id:29; + unsigned debug_id:28;struct binder_transaction *transaction;
include/uapi/linux/android/binder.h +1 -0
@@ -248,6 +248,7 @@ enum transaction_flags {TF_ROOT_OBJECT =0x04 ,/* contents are the component's root object */ TF_STATUS_CODE =0x08 ,/* contents are a 32-bit status code */ TF_ACCEPT_FDS =0x10 ,/* allow replies with file descriptors */ + TF_CLEAR_BUF = 0x20, /* clear buffer on txn complete */ }; struct binder_transaction_data {
Greg Kroah-Hartman
maintainerPATCH 565/717 z3fold: stricter locking and more careful reclaim
In reply to Greg Kroah-HartmanFrom: Vitaly Wool <[email protected]>
commit dcf5aedb24f899d537e21c18ea552c780598d352 upstream.
Use temporary slots in reclaim function to avoid possible race when freeing those.
While at it, make sure we check CLAIMED flag under page lock in the reclaim function to make sure we are not racing with z3fold_alloc().
--- mm/z3fold.c | 143 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 85 insertions(+), 58 deletions(-)
mm/z3fold.c +85 -58
@@ -182,6 +182,13 @@ enum z3fold_page_flags { };/* +* handle flags, go under HANDLE_FLAG_MASK +*/ +enum z3fold_handle_flags { +HANDLES_NOFREE =0 , +}; + +/* * Forward declarations */ static struct z3fold_header *__z3fold_alloc (struct z3fold_pool *,size_t ,bool );
@@ -311,6 +318,12 @@ static inline void free_handle(unsigned slots =handle_to_slots (handle);write_lock (&slots->lock); *(unsigned long *)handle =0 ; + +if (test_bit (HANDLES_NOFREE , &slots->pool)) { +write_unlock (&slots->lock); +return ;/* simple case, nothing else to do */ + } +if (zhdr->slots != slots) zhdr->foreign_handles--;
@@ -621,6 +634,28 @@ static inline void add_to_unbuddied(stru } } +static inline enum buddy get_free_buddy (struct z3fold_header *zhdr,int chunks) +{ +enum buddy bud =HEADLESS ; + +if (zhdr->middle_chunks) { +if (!zhdr->first_chunks && + chunks <= zhdr->start_middle -ZHDR_CHUNKS ) + bud =FIRST ; +else if (!zhdr->last_chunks) + bud =LAST ; + }else { +if (!zhdr->first_chunks) + bud =FIRST ; +else if (!zhdr->last_chunks) + bud =LAST ; +else + bud =MIDDLE ; + } + +return bud; +} +static inline void *mchunk_memmove (struct z3fold_header *zhdr,unsigned short dst_chunk) {
@@ -682,18 +717,7 @@ static struct z3fold_header *compact_sinif (WARN_ON (new_zhdr == zhdr)) goto out_fail; -if (new_zhdr->first_chunks ==0 ) { -if (new_zhdr->middle_chunks !=0 && - chunks >= new_zhdr->start_middle) { - new_bud =LAST ; - }else { - new_bud =FIRST ; - } - }else if (new_zhdr->last_chunks ==0 ) { - new_bud =LAST ; - }else if (new_zhdr->middle_chunks ==0 ) { - new_bud =MIDDLE ; - } + new_bud =get_free_buddy (new_zhdr, chunks); q = new_zhdr;switch (new_bud) {case FIRST :
@@ -815,9 +839,8 @@ static void do_compact_page(struct z3folreturn ; } -if (unlikely (PageIsolated (page) || -test_bit (PAGE_CLAIMED , &page->private) || -test_bit (PAGE_STALE , &page->private))) { +if (test_bit (PAGE_STALE , &page->private) || +test_and_set_bit (PAGE_CLAIMED , &page->private)) {z3fold_page_unlock (zhdr);return ; }
@@ -826,13 +849,16 @@ static void do_compact_page(struct z3fol zhdr->mapped_count == 0 && compact_single_buddy(zhdr)) {if (kref_put (&zhdr->refcount, release_z3fold_page_locked))atomic64_dec (&pool->pages_nr); -else +else { +clear_bit (PAGE_CLAIMED , &page->private);z3fold_page_unlock (zhdr); + }return ; }z3fold_compact_page (zhdr);add_to_unbuddied (pool, zhdr); +clear_bit (PAGE_CLAIMED , &page->private);z3fold_page_unlock (zhdr); }
@@ -1080,17 +1106,8 @@ static int z3fold_alloc(struct z3fold_po retry: zhdr =__z3fold_alloc (pool, size, can_sleep);if (zhdr) { -if (zhdr->first_chunks ==0 ) { -if (zhdr->middle_chunks !=0 && - chunks >= zhdr->start_middle) - bud =LAST ; -else - bud =FIRST ; - }else if (zhdr->last_chunks ==0 ) - bud =LAST ; -else if (zhdr->middle_chunks ==0 ) - bud =MIDDLE ; -else { + bud =get_free_buddy (zhdr, chunks); +if (bud ==HEADLESS ) {if (kref_put (&zhdr->refcount, release_z3fold_page_locked))atomic64_dec (&pool->pages_nr);
@@ -1236,7 +1253,6 @@ static void z3fold_free(struct z3fold_popr_err ("%s: unknown bud %d\n" , __func__, bud);WARN_ON (1 );put_z3fold_header (zhdr); -clear_bit (PAGE_CLAIMED , &page->private);return ; }
@@ -1251,8 +1267,7 @@ static void z3fold_free(struct z3fold_poz3fold_page_unlock (zhdr);return ; } -if (unlikely (PageIsolated (page)) || -test_and_set_bit (NEEDS_COMPACTING , &page->private)) { +if (test_and_set_bit (NEEDS_COMPACTING , &page->private)) {put_z3fold_header (zhdr);clear_bit (PAGE_CLAIMED , &page->private);return ;
@@ -1316,6 +1331,10 @@ static int z3fold_reclaim_page(struct z3struct page *page =NULL ;struct list_head *pos;unsigned long first_handle =0 , middle_handle =0 , last_handle =0 ; + struct z3fold_buddy_slots slots __attribute__((aligned(SLOTS_ALIGN))); + +rwlock_init (&slots.lock); + slots.pool = (unsigned long )pool | (1 <<HANDLES_NOFREE );spin_lock (&pool->lock);if (!pool->ops || !pool->ops->evict || retries ==0 ) {
@@ -1330,35 +1349,36 @@ static int z3fold_reclaim_page(struct z3list_for_each_prev (pos, &pool->lru) { page = list_entry(pos, struct page, lru); -/* this bit could have been set by free, in which case -* we pass over to the next page in the pool. -*/ -if (test_and_set_bit (PAGE_CLAIMED , &page->private)) { - page =NULL ; -continue ; - } - -if (unlikely (PageIsolated (page))) { -clear_bit (PAGE_CLAIMED , &page->private); - page =NULL ; -continue ; - } zhdr =page_address (page);if (test_bit (PAGE_HEADLESS , &page->private))break ; +if (kref_get_unless_zero (&zhdr->refcount) ==0 ) { + zhdr =NULL ; +break ; + }if (!z3fold_page_trylock (zhdr)) { -clear_bit (PAGE_CLAIMED , &page->private); +if (kref_put (&zhdr->refcount, + release_z3fold_page)) +atomic64_dec (&pool->pages_nr); zhdr =NULL ;continue ;/* can't evict at this point */ } -if (zhdr->foreign_handles) { -clear_bit (PAGE_CLAIMED , &page->private); -z3fold_page_unlock (zhdr); + +/* test_and_set_bit is of course atomic, but we still +* need to do it under page lock, otherwise checking +* that bit in __z3fold_alloc wouldn't make sense +*/ +if (zhdr->foreign_handles || +test_and_set_bit (PAGE_CLAIMED , &page->private)) { +if (kref_put (&zhdr->refcount, + release_z3fold_page)) +atomic64_dec (&pool->pages_nr); +else +z3fold_page_unlock (zhdr); zhdr =NULL ;continue ;/* can't evict such page */ } -kref_get (&zhdr->refcount);list_del_init (&zhdr->buddy); zhdr->cpu =-1 ;break ;
@@ -1380,12 +1400,16 @@ static int z3fold_reclaim_page(struct z3 first_handle =0 ; last_handle =0 ; middle_handle =0 ; +memset (slots.slot,0 ,sizeof (slots.slot));if (zhdr->first_chunks) - first_handle =encode_handle (zhdr,FIRST ); + first_handle =__encode_handle (zhdr, &slots, +FIRST );if (zhdr->middle_chunks) - middle_handle =encode_handle (zhdr,MIDDLE ); + middle_handle =__encode_handle (zhdr, &slots, +MIDDLE );if (zhdr->last_chunks) - last_handle =encode_handle (zhdr,LAST ); + last_handle =__encode_handle (zhdr, &slots, +LAST );/* * it's safe to unlock here because we hold a * reference to this page
@@ -1400,19 +1424,16 @@ static int z3fold_reclaim_page(struct z3 ret = pool->ops->evict (pool, middle_handle);if (ret) goto next; -free_handle (middle_handle, zhdr); }if (first_handle) { ret = pool->ops->evict (pool, first_handle);if (ret) goto next; -free_handle (first_handle, zhdr); }if (last_handle) { ret = pool->ops->evict (pool, last_handle);if (ret) goto next; -free_handle (last_handle, zhdr); } next:if (test_bit (PAGE_HEADLESS , &page->private)) {
@@ -1426,9 +1447,11 @@ next:spin_unlock (&pool->lock);clear_bit (PAGE_CLAIMED , &page->private); }else { +struct z3fold_buddy_slots *slots = zhdr->slots;z3fold_page_lock (zhdr);if (kref_put (&zhdr->refcount, release_z3fold_page_locked)) { +kmem_cache_free (pool->c_handle, slots);atomic64_dec (&pool->pages_nr);return 0 ; }
@@ -1544,8 +1567,7 @@ static bool z3fold_page_isolate(struct pVM_BUG_ON_PAGE (!PageMovable (page), page);VM_BUG_ON_PAGE (PageIsolated (page), page); -if (test_bit (PAGE_HEADLESS , &page->private) || -test_bit (PAGE_CLAIMED , &page->private)) +if (test_bit (PAGE_HEADLESS , &page->private))return false; zhdr =page_address (page);
@@ -1557,6 +1579,8 @@ static bool z3fold_page_isolate(struct pif (zhdr->mapped_count !=0 || zhdr->foreign_handles !=0 ) goto out; +if (test_and_set_bit (PAGE_CLAIMED , &page->private)) + goto out; pool =zhdr_to_pool (zhdr);spin_lock (&pool->lock);if (!list_empty (&zhdr->buddy))
@@ -1583,16 +1607,17 @@ static int z3fold_page_migrate(struct adVM_BUG_ON_PAGE (!PageMovable (page), page);VM_BUG_ON_PAGE (!PageIsolated (page), page); +VM_BUG_ON_PAGE (!test_bit (PAGE_CLAIMED , &page->private), page);VM_BUG_ON_PAGE (!PageLocked (newpage), newpage); zhdr =page_address (page); pool =zhdr_to_pool (zhdr); -if (!z3fold_page_trylock (zhdr)) { +if (!z3fold_page_trylock (zhdr))return -EAGAIN ; - }if (zhdr->mapped_count !=0 || zhdr->foreign_handles !=0 ) {z3fold_page_unlock (zhdr); +clear_bit (PAGE_CLAIMED , &page->private);return -EBUSY ; }if (work_pending (&zhdr->work)) {
@@ -1634,6 +1659,7 @@ static int z3fold_page_migrate(struct adqueue_work_on (new_zhdr->cpu, pool->compact_wq, &new_zhdr->work);page_mapcount_reset (page); +clear_bit (PAGE_CLAIMED , &page->private);put_page (page);return 0 ; }
@@ -1657,6 +1683,7 @@ static void z3fold_page_putback(struct pspin_lock (&pool->lock);list_add (&page->lru, &pool->lru);spin_unlock (&pool->lock); +clear_bit (PAGE_CLAIMED , &page->private);z3fold_page_unlock (zhdr); }
Greg Kroah-Hartman
maintainerPATCH 570/717 cpufreq: intel_pstate: Use most recent guaranteed performance values
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit e40ad84c26b4deeee46666492ec66b9a534b8e59 upstream.
When turbo has been disabled by the BIOS, but HWP_CAP.GUARANTEED is changed later, user space may want to take advantage of this increased guaranteed performance.
HWP_CAP.GUARANTEED is not a static value. It can be adjusted by an out-of-band agent or during an Intel Speed Select performance level change. The HWP_CAP.MAX is still the maximum achievable performance with turbo disabled by the BIOS, so HWP_CAP.GUARANTEED can still change as long as it remains less than or equal to HWP_CAP.MAX.
When HWP_CAP.GUARANTEED is changed, the sysfs base_frequency attribute shows the most recent guaranteed frequency value. This attribute can be used by user space software to update the scaling min/max limits of the CPU.
Currently, the ->setpolicy() callback already uses the latest HWP_CAP values when setting HWP_REQ, but the ->verify() callback will restrict the user settings to the to old guaranteed performance value which prevents user space from making use of the extra CPU capacity theoretically available to it after increasing HWP_CAP.GUARANTEED.
To address this, read HWP_CAP in intel_pstate_verify_cpu_policy() to obtain the maximum P-state that can be used and use that to confine the policy max limit instead of using the cached and possibly stale pstate.max_freq value for this purpose.
For consistency, update intel_pstate_update_perf_limits() to use the maximum available P-state returned by intel_pstate_get_hwp_max() to compute the maximum frequency instead of using the return value of intel_pstate_get_max_freq() which, again, may be stale.
This issue is a side-effect of fixing the scaling frequency limits in commit eacc9c5a927e ("cpufreq: intel_pstate: Fix intel_pstate_get_hwp_max() for turbo disabled") which corrected the setting of the reduced scaling frequency values, but caused stale HWP_CAP.GUARANTEED to be used in the case at hand.
--- drivers/cpufreq/intel_pstate.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/cpufreq/intel_pstate.c +13 -3
@@ -2207,9 +2207,9 @@ static void intel_pstate_update_perf_limunsigned int policy_min, unsigned int policy_max) { - int max_freq = intel_pstate_get_max_freq(cpu); int32_t max_policy_perf, min_policy_perf;int max_state, turbo_max; +int max_freq;/* * HWP needs some special consideration, because on BDX the
@@ -2223,6 +2223,7 @@ static void intel_pstate_update_perf_lim cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; turbo_max = cpu->pstate.turbo_pstate; } + max_freq = max_state * cpu->pstate.scaling; max_policy_perf = max_state * policy_max / max_freq;if (policy_max == policy_min) {
@@ -2325,9 +2326,18 @@ static void intel_pstate_adjust_policy_mstatic void intel_pstate_verify_cpu_policy (struct cpudata *cpu,struct cpufreq_policy_data *policy) { +int max_freq; +update_turbo_state (); -cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, -intel_pstate_get_max_freq (cpu)); +if (hwp_active) { +int max_state, turbo_max; + +intel_pstate_get_hwp_max (cpu->cpu, &turbo_max, &max_state); + max_freq = max_state * cpu->pstate.scaling; + }else { + max_freq =intel_pstate_get_max_freq (cpu); + } +cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, max_freq);intel_pstate_adjust_policy_max (cpu, policy); }
Greg Kroah-Hartman
maintainerPATCH 572/717 crypto: arm/aes-ce - work around Cortex-A57/A72 silion errata
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit f3456b9fd269c6d0c973b136c5449d46b2510f4b upstream.
ARM Cortex-A57 and Cortex-A72 cores running in 32-bit mode are affected by silicon errata #1742098 and #1655431, respectively, where the second instruction of a AES instruction pair may execute twice if an interrupt is taken right after the first instruction consumes an input register of which a single 32-bit lane has been updated the last time it was modified.
This is not such a rare occurrence as it may seem: in counter mode, only the least significant 32-bit word is incremented in the absence of a carry, which makes our counter mode implementation susceptible to these errata.
So let's shuffle the counter assignments around a bit so that the most recent updates when the AES instruction pair executes are 128-bit wide.
[0] ARM-EPM-049219 v23 Cortex-A57 MPCore Software Developers Errata Notice
[1] ARM-EPM-012079 v11.0 Cortex-A72 MPCore Software Developers Errata Notice
--- arch/arm/crypto/aes-ce-core.S | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
arch/arm/crypto/aes-ce-core.S +22 -10
@@ -386,20 +386,32 @@ ENTRY(ce_aes_ctr_encrypt) .Lctrloop4x: subs r4, r4, #4 bmi .Lctr1x - add r6, r6, #1 + + /* + * NOTE: the sequence below has been carefully tweaked to avoid + * a silicon erratum that exists in Cortex-A57 (#1742098) and + * Cortex-A72 (#1655431) cores, where AESE/AESMC instruction pairs + * may produce an incorrect result if they take their input from a + * register of which a single 32-bit lane has been updated the last + * time it was modified. To work around this, the lanes of registers + * q0-q3 below are not manipulated individually, and the different + * counter values are prepared by successive manipulations of q7. + */ + add ip, r6, #1 vmov q0, q7 + rev ip, ip + add lr, r6, #2 + vmov s31, ip @ set lane 3 of q1 via q7 + add ip, r6, #3 + rev lr, lr vmov q1, q7 - rev ip, r6 - add r6, r6, #1 + vmov s31, lr @ set lane 3 of q2 via q7 + rev ip, ip vmov q2, q7 - vmov s7, ip - rev ip, r6 - add r6, r6, #1 + vmov s31, ip @ set lane 3 of q3 via q7 + add r6, r6, #4 vmov q3, q7 - vmov s11, ip - rev ip, r6 - add r6, r6, #1 - vmov s15, ip + vld1.8 {q4-q5}, [r1]! vld1.8 {q6}, [r1]! vld1.8 {q15}, [r1]!
Greg Kroah-Hartman
maintainerPATCH 544/717 ALSA: hda/realtek: Apply jack fixup for Quanta NL3
In reply to Greg Kroah-HartmanFrom: Chris Chiu <[email protected]>
commit 6ca653e3f73a1af0f30dbf9c2c79d2897074989f upstream.
The Quanta NL3 laptop has both a headphone output jack and a headset jack, on the right edge of the chassis.
The pin information suggests that both of these are at the Front. The PulseAudio is confused to differentiate them so one of the jack can neither get the jack sense working nor the audio output.
The ALC269_FIXUP_LIFEBOOK chained with ALC269_FIXUP_QUANTA_MUTE can help to differentiate 2 jacks and get the 'Auto-Mute Mode' working correctly.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -8021,6 +8021,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1458 ,0xfa53 ,"Gigabyte BXBT-2807" ,ALC283_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1462 ,0xb120 ,"MSI Cubi MS-B120" ,ALC283_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1462 ,0xb171 ,"Cubi N 8GL (MS-B171)" ,ALC283_FIXUP_HEADSET_MIC ), +SND_PCI_QUIRK (0x152d ,0x1082 ,"Quanta NL3" ,ALC269_FIXUP_LIFEBOOK ),SND_PCI_QUIRK (0x1558 ,0x1323 ,"Clevo N130ZU" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0x1325 ,"System76 Darter Pro (darp5)" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ), SND_PCI_QUIRK(0x1558, 0x1401, "Clevo L140[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
Greg Kroah-Hartman
maintainerPATCH 569/717 powerpc/perf: Exclude kernel samples while counting events in user space.
In reply to Greg Kroah-HartmanFrom: Athira Rajeev <[email protected]>
commit aa8e21c053d72b6639ea5a7f1d3a1d0209534c94 upstream.
Perf event attritube supports exclude_kernel flag to avoid sampling/profiling in supervisor state (kernel). Based on this event attr flag, Monitor Mode Control Register bit is set to freeze on supervisor state. But sometimes (due to hardware limitation), Sampled Instruction Address Register (SIAR) locks on to kernel address even when freeze on supervisor is set. Patch here adds a check to drop those samples.
--- arch/powerpc/perf/core-book3s.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/powerpc/perf/core-book3s.c +10 -0
@@ -2125,6 +2125,16 @@ static void record_and_restart(struct peperf_event_update_userpage (event);/* +* Due to hardware limitation, sometimes SIAR could sample a kernel +* address even when freeze on supervisor state (kernel) is set in +* MMCR2. Check attr.exclude_kernel and address to drop the sample in +* these cases. +*/ +if (event->attr.exclude_kernel && record) +if (is_kernel_addr (mfspr (SPRN_SIAR ))) + record =0 ; + +/* * Finally record data if requested. */ if (record) {
Greg Kroah-Hartman
maintainerPATCH 573/717 m68k: Fix WARNING splat in pmac_zilog driver
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
commit a7b5458ce73b235be027cf2658c39b19b7e58cf2 upstream.
Don't add platform resources that won't be used. This avoids a recently-added warning from the driver core, that can show up on a multi-platform kernel when !MACH_IS_MAC.
------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at drivers/base/platform.c:224 platform_get_irq_optional+0x8e/0xce
0 is an invalid IRQ number
Modules linked in:
CPU: 0 PID: 0 Comm: swapper Not tainted 5.9.0-multi #1
Stack from 004b3f04:
004b3f04 00462c2f 00462c2f 004b3f20 0002e128 004754db 004b6ad4 004b3f4c
0002e19c 004754f7 000000e0 00285ba0 00000009 00000000 004b3f44 ffffffff
004754db 004b3f64 004b3f74 00285ba0 004754f7 000000e0 00000009 004754db
004fdf0c 005269e2 004fdf0c 00000000 004b3f88 00285cae 004b6964 00000000
004fdf0c 004b3fac 0051cc68 004b6964 00000000 004b6964 00000200 00000000
0051cc3e 0023c18a 004b3fc0 0051cd8a 004fdf0c 00000002 0052b43c 004b3fc8
Call Trace: [<0002e128>] __warn+0xa6/0xd6
[<0002e19c>] warn_slowpath_fmt+0x44/0x76
[<00285ba0>] platform_get_irq_optional+0x8e/0xce
[<00285ba0>] platform_get_irq_optional+0x8e/0xce
[<00285cae>] platform_get_irq+0x12/0x4c
[<0051cc68>] pmz_init_port+0x2a/0xa6
[<0051cc3e>] pmz_init_port+0x0/0xa6
[<0023c18a>] strlen+0x0/0x22
[<0051cd8a>] pmz_probe+0x34/0x88
[<0051cde6>] pmz_console_init+0x8/0x28
[<00511776>] console_init+0x1e/0x28
[<0005a3bc>] printk+0x0/0x16
[<0050a8a6>] start_kernel+0x368/0x4ce
[<005094f8>] _sinittext+0x4f8/0xc48
random: get_random_bytes called from print_oops_end_marker+0x56/0x80 with crng_init=0
---[ end trace 392d8e82eed68d6c ]---Commit a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invalid"), which introduced the WARNING, suggests that testing for irq == 0 is undesirable. Instead of that comparison, just test for resource existence.
--- arch/m68k/mac/config.c | 17 +++++++++-------- drivers/tty/serial/pmac_zilog.c | 14 +++++++++----- 2 files changed, 18 insertions(+), 13 deletions(-)
arch/m68k/mac/config.c +9 -8
@@ -777,16 +777,12 @@ static struct resource scc_b_rsrcs[] = {struct platform_device scc_a_pdev = { .name ="scc" , .id =0 , - .num_resources =ARRAY_SIZE (scc_a_rsrcs), - .resource = scc_a_rsrcs, };EXPORT_SYMBOL (scc_a_pdev);struct platform_device scc_b_pdev = { .name ="scc" , .id =1 , - .num_resources =ARRAY_SIZE (scc_b_rsrcs), - .resource = scc_b_rsrcs, };EXPORT_SYMBOL (scc_b_pdev);
@@ -813,10 +809,15 @@ static void __init mac_identify(void)/* Set up serial port resources for the console initcall. */ - scc_a_rsrcs[0 ].start = (resource_size_t ) mac_bi_data.sccbase +2 ; - scc_a_rsrcs[0 ].end = scc_a_rsrcs[0 ].start; - scc_b_rsrcs[0 ].start = (resource_size_t ) mac_bi_data.sccbase; - scc_b_rsrcs[0 ].end = scc_b_rsrcs[0 ].start; + scc_a_rsrcs[0 ].start = (resource_size_t )mac_bi_data.sccbase +2 ; + scc_a_rsrcs[0 ].end = scc_a_rsrcs[0 ].start; + scc_a_pdev.num_resources =ARRAY_SIZE (scc_a_rsrcs); + scc_a_pdev.resource = scc_a_rsrcs; + + scc_b_rsrcs[0 ].start = (resource_size_t )mac_bi_data.sccbase; + scc_b_rsrcs[0 ].end = scc_b_rsrcs[0 ].start; + scc_b_pdev.num_resources =ARRAY_SIZE (scc_b_rsrcs); + scc_b_pdev.resource = scc_b_rsrcs;switch (macintosh_config->scc_type) {case MAC_SCC_PSC :
drivers/tty/serial/pmac_zilog.c +9 -5
@@ -1693,22 +1693,26 @@ static int __init pmz_probe(void)#else +/* On PCI PowerMacs, pmz_probe() does an explicit search of the OpenFirmware +* tree to obtain the device_nodes needed to start the console before the +* macio driver. On Macs without OpenFirmware, global platform_devices take +* the place of those device_nodes. +*/ extern struct platform_device scc_a_pdev, scc_b_pdev;static int __init pmz_init_port (struct uart_pmac_port *uap) { -struct resource *r_ports; -int irq; +struct resource *r_ports, *r_irq; r_ports =platform_get_resource (uap->pdev,IORESOURCE_MEM ,0 ); - irq =platform_get_irq (uap->pdev,0 ); -if (!r_ports || irq <=0 ) + r_irq =platform_get_resource (uap->pdev,IORESOURCE_IRQ ,0 ); +if (!r_ports || !r_irq)return -ENODEV ; uap->port.mapbase = r_ports->start; uap->port.membase = (unsigned char __iomem *) r_ports->start; uap->port.iotype =UPIO_MEM ; - uap->port.irq = irq; + uap->port.irq = r_irq->start; uap->port.uartclk =ZS_CLOCK ; uap->port.fifosize =1 ; uap->port.ops = &pmz_pops;
Greg Kroah-Hartman
maintainerPATCH 585/717 USB: serial: keyspan_pda: fix tx-unthrottle use-after-free
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 49fbb8e37a961396a5b6c82937c70df91de45e9d upstream.
The driver's transmit-unthrottle work was never flushed on disconnect, something which could lead to the driver port data being freed while the unthrottle work is still scheduled.
Fix this by cancelling the unthrottle work when shutting down the port.
--- drivers/usb/serial/keyspan_pda.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/serial/keyspan_pda.c +4 -0
@@ -647,8 +647,12 @@ error: }static void keyspan_pda_close (struct usb_serial_port *port) { +struct keyspan_pda_private *priv =usb_get_serial_port_data (port); +usb_kill_urb (port->write_urb);usb_kill_urb (port->interrupt_in_urb); + +cancel_work_sync (&priv->unthrottle_work); }
Greg Kroah-Hartman
maintainerPATCH 545/717 ALSA: hda/realtek: Remove dummy lineout on Acer TravelMate P648/P658
In reply to Greg Kroah-HartmanFrom: Chris Chiu <[email protected]>
commit 34cdf405aa5de827b8bef79a6c82c39120b3729b upstream.
Acer TravelMate laptops P648/P658 series with codec ALC282 only have one physical jack for headset but there's a confusing lineout pin on NID 0x1b reported. Audio applications hence misunderstand that there are a speaker and a lineout, and take the lineout as the default audio output.
Add a new quirk to remove the useless lineout and enable the pin 0x18 for jack sensing and headset microphone.
--- sound/pci/hda/patch_realtek.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
sound/pci/hda/patch_realtek.c +27 -0
@@ -6369,6 +6369,7 @@ enum {ALC287_FIXUP_HP_GPIO_LED ,ALC256_FIXUP_HP_HEADSET_MIC ,ALC236_FIXUP_DELL_AIO_HEADSET_MIC , + ALC282_FIXUP_ACER_DISABLE_LINEOUT, }; static const struct hda_fixup alc269_fixups[] = {
@@ -7792,6 +7793,16 @@ static const struct hda_fixup alc269_fix .chained = true, .chain_id =ALC255_FIXUP_DELL1_MIC_NO_PRESENCE }, + [ALC282_FIXUP_ACER_DISABLE_LINEOUT] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x1b ,0x411111f0 }, + {0x18 ,0x01a1913c },/* use as headset mic, without its own jack detect */ + { }, + }, + .chained = true, + .chain_id =ALC269_FIXUP_HEADSET_MODE + }, };static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -8569,6 +8580,22 @@ static const struct snd_hda_pin_quirk al {0x12, 0x90a60140}, {0x19, 0x04a11030}, {0x21, 0x04211020}), + SND_HDA_PIN_QUIRK(0x10ec0282, 0x1025, "Acer", ALC282_FIXUP_ACER_DISABLE_LINEOUT, + ALC282_STANDARD_PINS, + {0x12, 0x90a609c0}, + {0x18, 0x03a11830}, + {0x19, 0x04a19831}, + {0x1a, 0x0481303f}, + {0x1b, 0x04211020}, + {0x21, 0x0321101f}), + SND_HDA_PIN_QUIRK(0x10ec0282, 0x1025, "Acer", ALC282_FIXUP_ACER_DISABLE_LINEOUT, + ALC282_STANDARD_PINS, + {0x12, 0x90a60940}, + {0x18, 0x03a11830}, + {0x19, 0x04a19831}, + {0x1a, 0x0481303f}, + {0x1b, 0x04211020}, + {0x21, 0x0321101f}), SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, ALC282_STANDARD_PINS, {0x12, 0x90a60130},
Greg Kroah-Hartman
maintainerPATCH 548/717 ALSA: usb-audio: Disable sample read check if firmware doesnt give back
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 9df28edce7c6ab38050235f6f8b43dd7ccd01b6d upstream.
Some buggy firmware don't give the current sample rate but leaves zero. Handle this case more gracefully without warning but just skip the current rate verification from the next time.
--- sound/usb/clock.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/usb/clock.c +6 -0
@@ -531,6 +531,12 @@ static int set_sample_rate_v1(struct snd } crate = data[0 ] | (data[1 ] <<8 ) | (data[2 ] <<16 ); +if (!crate) { +dev_info (&dev->dev,"failed to read current rate; disabling the check\n" ); + chip->sample_rate_read_error =3 ;/* three strikes, see above */ +return 0 ; + } +if (crate != rate) {dev_warn (&dev->dev,"current rate %d is different from the runtime rate %d\n" , crate, rate);// runtime->rate = crate;
Greg Kroah-Hartman
maintainerPATCH 563/717 staging: comedi: mf6x4: Fix AI end-of-conversion detection
In reply to Greg Kroah-HartmanFrom: Ian Abbott <[email protected]>
commit 56c90457ebfe9422496aac6ef3d3f0f0ea8b2ec2 upstream.
I have had reports from two different people that attempts to read the analog input channels of the MF624 board fail with an ETIMEDOUT error.
After triggering the conversion, the code calls comedi_timeout() with mf6x4_ai_eoc() as the callback function to check if the conversion is complete. The callback returns 0 if complete or -EBUSY if not yet complete. comedi_timeout() returns -ETIMEDOUT if it has not completed within a timeout period which is propagated as an error to the user application.
The existing code considers the conversion to be complete when the EOLC bit is high. However, according to the user manuals for the MF624 and MF634 boards, this test is incorrect because EOLC is an active low signal that goes high when the conversion is triggered, and goes low when the conversion is complete. Fix the problem by inverting the test of the EOLC bit state.
--- drivers/staging/comedi/drivers/mf6x4.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/comedi/drivers/mf6x4.c +2 -1
@@ -112,8 +112,9 @@ static int mf6x4_ai_eoc(struct comedi_destruct mf6x4_private *devpriv = dev->private;unsigned int status; +/* EOLC goes low at end of conversion. */ status =ioread32 (devpriv->gpioc_reg); -if (status &MF6X4_GPIOC_EOLC ) +if ((status &MF6X4_GPIOC_EOLC ) ==0 )return 0 ;return -EBUSY ; }
Greg Kroah-Hartman
maintainerPATCH 566/717 perf/x86/intel: Add event constraint for CYCLE_ACTIVITY.STALLS_MEM_ANY
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
commit 306e3e91edf1c6739a55312edd110d298ff498dd upstream.
The event CYCLE_ACTIVITY.STALLS_MEM_ANY (0x14a3) should be available on all 8 GP counters on ICL, but it's only scheduled on the first four counters due to the current ICL constraint table.
Add a line for the CYCLE_ACTIVITY.STALLS_MEM_ANY event in the ICL constraint table.
Correct the comments for the CYCLE_ACTIVITY.CYCLES_MEM_ANY event.
--- arch/x86/events/intel/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/events/intel/core.c +2 -1
@@ -257,7 +257,8 @@ static struct event_constraint intel_iclINTEL_EVENT_CONSTRAINT_RANGE (0x48 ,0x54 ,0xf ),INTEL_EVENT_CONSTRAINT_RANGE (0x60 ,0x8b ,0xf ),INTEL_UEVENT_CONSTRAINT (0x04a3 ,0xff ),/* CYCLE_ACTIVITY.STALLS_TOTAL */ -INTEL_UEVENT_CONSTRAINT (0x10a3 ,0xff ),/* CYCLE_ACTIVITY.STALLS_MEM_ANY */ +INTEL_UEVENT_CONSTRAINT (0x10a3 ,0xff ),/* CYCLE_ACTIVITY.CYCLES_MEM_ANY */ +INTEL_UEVENT_CONSTRAINT (0x14a3 ,0xff ),/* CYCLE_ACTIVITY.STALLS_MEM_ANY */ INTEL_EVENT_CONSTRAINT (0xa3 ,0xf ),/* CYCLE_ACTIVITY.* */ INTEL_EVENT_CONSTRAINT_RANGE (0xa8 ,0xb0 ,0xf ), INTEL_EVENT_CONSTRAINT_RANGE(0xb7, 0xbd, 0xf),
Greg Kroah-Hartman
maintainerPATCH 567/717 perf/x86/intel: Fix rtm_abort_event encoding on Ice Lake
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
commit 46b72e1bf4fc571da0c29c6fb3e5b2a2107a4c26 upstream.
According to the event list from icelake_core_v1.09.json, the encoding of the RTM_RETIRED.ABORTED event on Ice Lake should be,
"EventCode": "0xc9",
"UMask": "0x04",
"EventName": "RTM_RETIRED.ABORTED",Correct the wrong encoding.
--- arch/x86/events/intel/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/core.c +1 -1
@@ -5465,7 +5465,7 @@ __init int intel_pmu_init(void) mem_attr = icl_events_attrs; td_attr = icl_td_events_attrs; tsx_attr = icl_tsx_events_attrs; - x86_pmu.rtm_abort_event = X86_CONFIG(.event=0xca, .umask=0x02); + x86_pmu.rtm_abort_event = X86_CONFIG(.event=0xc9, .umask=0x04); x86_pmu.lbr_pt_coexist = true;intel_pmu_pebs_data_source_skl (pmem); x86_pmu.update_topdown_event = icl_update_topdown_event;
Greg Kroah-Hartman
maintainerPATCH 568/717 perf/x86/intel/lbr: Fix the return type of get_lbr_cycles()
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
commit f8129cd958b395575e5543ce25a8434874b04d3a upstream.
The cycle count of a timed LBR is always 1 in perf record -D.
The cycle count is stored in the first 16 bits of the IA32_LBR_x_INFO register, but the get_lbr_cycles() return Boolean type.
Use u16 to replace the Boolean type.
--- arch/x86/events/intel/lbr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/lbr.c +1 -1
@@ -919,7 +919,7 @@ static __always_inline bool get_lbr_predreturn !(info &LBR_INFO_MISPRED ); } -static __always_inline bool get_lbr_cycles(u64 info) +static __always_inline u16 get_lbr_cycles(u64 info) {if (static_cpu_has (X86_FEATURE_ARCH_LBR ) && !(x86_pmu.lbr_timed_lbr && info &LBR_INFO_CYC_CNT_VALID ))
Greg Kroah-Hartman
maintainerPATCH 591/717 ext4: fix a memory leak of ext4_free_data
In reply to Greg Kroah-HartmanFrom: Chunguang Xu <[email protected]>
commit cca415537244f6102cbb09b5b90db6ae2c953bdd upstream.
When freeing metadata, we will create an ext4_free_data and insert it into the pending free list. After the current transaction is committed, the object will be freed.
ext4_mb_free_metadata() will check whether the area to be freed overlaps with the pending free list. If true, return directly. At this time, ext4_free_data is leaked. Fortunately, the probability of this problem is small, since it only occurs if the file system is corrupted such that a block is claimed by more one inode and those inodes are deleted within a single jbd2 transaction.
--- fs/ext4/mballoc.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/mballoc.c +1 -0
@@ -5126,6 +5126,7 @@ ext4_mb_free_metadata(handle_t *handle,ext4_group_first_block_no (sb, group) +EXT4_C2B (sbi, cluster), "Block already on to-be-freed list"); +kmem_cache_free (ext4_free_data_cachep, new_entry);return 0 ; } }
Greg Kroah-Hartman
maintainerPATCH 575/717 EDAC/i10nm: Use readl() to access MMIO registers
In reply to Greg Kroah-HartmanFrom: Qiuxu Zhuo <[email protected]>
commit 83ff51c4e3fecf6b8587ce4d46f6eac59f5d7c5a upstream.
Instead of raw access, use readl() to access MMIO registers of memory controller to avoid possible compiler re-ordering.
--- drivers/edac/i10nm_base.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/edac/i10nm_base.c +7 -4
@@ -6,6 +6,7 @@*/ #include <linux/kernel.h> +#include <linux/io.h> #include <asm/cpu_device_id.h> #include <asm/intel-family.h> #include <asm/mce.h>
@@ -19,14 +20,16 @@ #define i10nm_printk(level, fmt, arg...) \ edac_printk(level, "i10nm", fmt, ##arg) -#define I10NM_GET_SCK_BAR (d, reg) \ +#define I10NM_GET_SCK_BAR (d, reg) \ pci_read_config_dword((d)->uracu, 0xd0, &(reg))#define I10NM_GET_IMC_BAR (d, i, reg) \ pci_read_config_dword((d)->uracu, 0xd8 + (i) * 4, &(reg))#define I10NM_GET_DIMMMTR (m, i, j) \ - (*(u32 *)((m)->mbase + 0x2080c + (i) * 0x4000 + (j) * 4)) + readl((m)->mbase + 0x2080c + (i) * 0x4000 + (j) * 4)#define I10NM_GET_MCDDRTCFG (m, i, j) \ - (*(u32 *)((m)->mbase + 0x20970 + (i) * 0x4000 + (j) * 4)) + readl((m)->mbase + 0x20970 + (i) * 0x4000 + (j) * 4) +#define I10NM_GET_MCMTR (m, i) \ + readl((m)->mbase + 0x20ef8 + (i) * 0x4000)#define I10NM_GET_SCK_MMIO_BASE (reg) (GET_BITFIELD(reg, 0, 28) << 23)#define I10NM_GET_IMC_MMIO_OFFSET (reg) (GET_BITFIELD(reg, 0, 10) << 12)
@@ -148,7 +151,7 @@ static bool i10nm_check_ecc(struct skx_i {u32 mcmtr; - mcmtr = *(u32 *)(imc->mbase +0x20ef8 + chan *0x4000 ); + mcmtr =I10NM_GET_MCMTR (imc, chan);edac_dbg (1 ,"ch%d mcmtr reg %x\n" , chan, mcmtr);return !!GET_BITFIELD (mcmtr,2 ,2 );
Greg Kroah-Hartman
maintainerPATCH 560/717 ASoC: cx2072x: Fix doubly definitions of Playback and Capture streams
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 0d024a8bec084205fdd9fa17479ba91f45f85db3 upstream.
The cx2072x codec driver defines multiple DAIs with the same stream name "Playback" and "Capture". Although the current code works more or less as is as the secondary streams are never used, it still leads the error message like:
debugfs: File 'Playback' in directory 'dapm' already present!
debugfs: File 'Capture' in directory 'dapm' already present!
Fix it by renaming the secondary streams to unique names.
--- sound/soc/codecs/cx2072x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/cx2072x.c +2 -2
@@ -1579,7 +1579,7 @@ static struct snd_soc_dai_driver soc_cod .id = CX2072X_DAI_DSP, .probe = cx2072x_dsp_dai_probe, .playback = { - .stream_name = "Playback", + .stream_name = "DSP Playback", .channels_min = 2, .channels_max = 2, .rates = CX2072X_RATES_DSP,
@@ -1591,7 +1591,7 @@ static struct snd_soc_dai_driver soc_cod .name = "cx2072x-aec", .id = 3, .capture = { - .stream_name = "Capture", + .stream_name = "AEC Capture", .channels_min = 2, .channels_max = 2, .rates = CX2072X_RATES_DSP,
Greg Kroah-Hartman
maintainerPATCH 586/717 USB: serial: keyspan_pda: fix write unthrottling
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 320f9028c7873c3c7710e8e93e5c979f4c857490 upstream.
The driver did not update its view of the available device buffer space until write() was called in task context. This meant that write_room() would return 0 even after the device had sent a write-unthrottle notification, something which could lead to blocked writers not being woken up (e.g. when using OPOST).
Note that we must also request an unthrottle notification is case a write() request fills the device buffer exactly.
--- drivers/usb/serial/keyspan_pda.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
drivers/usb/serial/keyspan_pda.c +20 -9
@@ -40,6 +40,8 @@#define DRIVER_AUTHOR "Brian Warner <[email protected]>"#define DRIVER_DESC "USB Keyspan PDA Converter driver" +#define KEYSPAN_TX_THRESHOLD 16 +struct keyspan_pda_private {int tx_room;int tx_throttled;
@@ -110,7 +112,7 @@ static void keyspan_pda_request_unthrott7 ,/* request_unthrottle */ USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , -16 ,/* value: threshold */ +KEYSPAN_TX_THRESHOLD ,0 ,/* index */ NULL , 0,
@@ -129,6 +131,8 @@ static void keyspan_pda_rx_interrupt(strint retval;int status = urb->status;struct keyspan_pda_private *priv; +unsigned long flags; + priv =usb_get_serial_port_data (port);switch (status) {
@@ -171,7 +175,10 @@ static void keyspan_pda_rx_interrupt(strcase 1 :/* modemline change */ break ;case 2 :/* tx unthrottle interrupt */ +spin_lock_irqsave (&port->lock, flags); priv->tx_throttled =0 ; + priv->tx_room =max (priv->tx_room,KEYSPAN_TX_THRESHOLD ); +spin_unlock_irqrestore (&port->lock, flags);/* queue up a wakeup at scheduler time */ usb_serial_port_softint (port);break ;
@@ -505,7 +512,8 @@ static int keyspan_pda_write(struct tty_ goto exit; } } -if (count > priv->tx_room) { + +if (count >= priv->tx_room) {/* we're about to completely fill the Tx buffer, so we'll be throttled afterwards. */ count = priv->tx_room;
@@ -560,14 +568,17 @@ static void keyspan_pda_write_bulk_callbstatic int keyspan_pda_write_room (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data; -struct keyspan_pda_private *priv; - priv =usb_get_serial_port_data (port); -/* used by n_tty.c for processing of tabs and such. Giving it our -conservative guess is probably good enough, but needs testing by -running a console through the device. */ -return priv->tx_room; -} +struct keyspan_pda_private *priv =usb_get_serial_port_data (port); +unsigned long flags; +int room =0 ; + +spin_lock_irqsave (&port->lock, flags); +if (test_bit (0 , &port->write_urbs_free) && !priv->tx_throttled) + room = priv->tx_room; +spin_unlock_irqrestore (&port->lock, flags); +return room; +}static int keyspan_pda_chars_in_buffer (struct tty_struct *tty) {
Greg Kroah-Hartman
maintainerPATCH 587/717 btrfs: do not shorten unpin len for caching block groups
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 9076dbd5ee837c3882fc42891c14cecd0354a849 upstream.
While fixing up our ->last_byte_to_unpin locking I noticed that we will shorten len based on ->last_byte_to_unpin if we're caching when we're adding back the free space. This is correct for the free space, as we cannot unpin more than ->last_byte_to_unpin, however we use len to adjust the ->bytes_pinned counters and such, which need to track the actual pinned usage. This could result in WARN_ON(space_info->bytes_pinned) triggering at unmount time.
Fix this by using a local variable for the amount to add to free space cache, and leave len untouched in this case.
--- fs/btrfs/extent-tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/extent-tree.c +4 -4
@@ -2816,10 +2816,10 @@ static int unpin_extent_range(struct btr len = cache->start + cache->length - start; len =min (len, end +1 - start); -if (start < cache->last_byte_to_unpin) { - len =min (len, cache->last_byte_to_unpin - start); -if (return_free_space) -btrfs_add_free_space (cache, start, len); +if (start < cache->last_byte_to_unpin && return_free_space) { +u64 add_len =min (len, cache->last_byte_to_unpin - start); + +btrfs_add_free_space (cache, start, add_len); } start += len;
Greg Kroah-Hartman
maintainerPATCH 588/717 btrfs: update last_byte_to_unpin in switch_commit_roots
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 27d56e62e4748c2135650c260024e9904b8c1a0a upstream.
While writing an explanation for the need of the commit_root_sem for btrfs_prepare_extent_commit, I realized we have a slight hole that could result in leaked space if we have to do the old style caching. Consider the following scenario
commit root
+----+----+----+----+----+----+----+ |\\\\| |\\\\|\\\\| |\\\\|\\\\| +----+----+----+----+----+----+----+ 0 1 2 3 4 5 6 7
new commit root
+----+----+----+----+----+----+----+ | | | |\\\\| | |\\\\| +----+----+----+----+----+----+----+ 0 1 2 3 4 5 6 7
Prior to this patch, we run btrfs_prepare_extent_commit, which updates the last_byte_to_unpin, and then we subsequently run switch_commit_roots. In this example lets assume that caching_ctl->progress == 1 at btrfs_prepare_extent_commit() time, which means that cache->last_byte_to_unpin == 1. Then we go and do the switch_commit_roots(), but in the meantime the caching thread has made some more progress, because we drop the commit_root_sem and re-acquired it. Now caching_ctl->progress == 3. We swap out the commit root and carry on to unpin.
The race can happen like:
1) The caching thread was running using the old commit root when it
found the extent for [2, 3);
2) Then it released the commit_root_sem because it was in the last
item of a leaf and the semaphore was contended, and set ->progress
to 3 (value of 'last'), as the last extent item in the current leaf
was for the extent for range [2, 3); 3) Next time it gets the commit_root_sem, will start using the new commit root and search for a key with offset 3, so it never finds the hole for [2, 3).
So the caching thread never saw [2, 3) as free space in any of the commit roots, and by the time finish_extent_commit() was called for the range [0, 3), ->last_byte_to_unpin was 1, so it only returned the subrange [0, 1) to the free space cache, skipping [2, 3).
In the unpin code we have last_byte_to_unpin == 1, so we unpin [0,1), but do not unpin [2,3). However because caching_ctl->progress == 3 we do not see the newly freed section of [2,3), and thus do not add it to our free space cache. This results in us missing a chunk of free space in memory (on disk too, unless we have a power failure before writing the free space cache to disk).
Fix this by making sure the ->last_byte_to_unpin is set at the same time that we swap the commit roots, this ensures that we will always be consistent.
--- fs/btrfs/ctree.h | 1 - fs/btrfs/extent-tree.c | 25 ------------------------- fs/btrfs/transaction.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 28 deletions(-)
fs/btrfs/ctree.h +0 -1
@@ -2593,7 +2593,6 @@ int btrfs_free_reserved_extent(struct bt u64 start, u64 len, int delalloc);int btrfs_pin_reserved_extent (struct btrfs_trans_handle *trans,u64 start,u64 len); -void btrfs_prepare_extent_commit (struct btrfs_fs_info *fs_info);int btrfs_finish_extent_commit (struct btrfs_trans_handle *trans);int btrfs_inc_extent_ref (struct btrfs_trans_handle *trans,struct btrfs_ref *generic_ref);
fs/btrfs/extent-tree.c +0 -25
@@ -2730,31 +2730,6 @@ btrfs_inc_block_group_reservations(strucatomic_inc (&bg->reservations); } -void btrfs_prepare_extent_commit (struct btrfs_fs_info *fs_info) -{ -struct btrfs_caching_control *next; -struct btrfs_caching_control *caching_ctl; -struct btrfs_block_group *cache; - -down_write (&fs_info->commit_root_sem); - -list_for_each_entry_safe (caching_ctl, next, - &fs_info->caching_block_groups, list) { - cache = caching_ctl->block_group; -if (btrfs_block_group_done (cache)) { - cache->last_byte_to_unpin = (u64)-1 ; -list_del_init (&caching_ctl->list); -btrfs_put_caching_control (caching_ctl); - }else { - cache->last_byte_to_unpin = caching_ctl->progress; - } - } - -up_write (&fs_info->commit_root_sem); - -btrfs_update_global_block_rsv (fs_info); -} -/* * Returns the free cluster for the given space info and sets empty_cluster to * what it should be based on the mount options.
fs/btrfs/transaction.c +40 -2
60 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 596/717 arm64: dts: marvell: keep SMMU disabled by default for Armada 7040 and 8040
In reply to Greg Kroah-HartmanFrom: Tomasz Nowicki <[email protected]>
commit f43cadef2df260101497a6aace05e24201f00202 upstream.
FW has to configure devices' StreamIDs so that SMMU is able to lookup context and do proper translation later on. For Armada 7040 & 8040 and publicly available FW, most of the devices are configured properly, but some like ap_sdhci0, PCIe, NIC still remain unassigned which results in SMMU faults about unmatched StreamID (assuming ARM_SMMU_DISABLE_BYPASS_BY_DEFAUL=y).
Since there is dependency on custom FW let SMMU be disabled by default. People who still willing to use SMMU need to enable manually and use ARM_SMMU_DISABLE_BYPASS_BY_DEFAUL=n (or via kernel command line) with extra caution.
--- arch/arm64/boot/dts/marvell/armada-7040.dtsi | 4 ---- arch/arm64/boot/dts/marvell/armada-8040.dtsi | 4 ---- 2 files changed, 8 deletions(-)
arch/arm64/boot/dts/marvell/armada-7040.dtsi +0 -4
@@ -15,10 +15,6 @@ "marvell,armada-ap806"; }; -&smmu { - status = "okay"; -}; - &cp0_pcie0 { iommu-map = <0x0 &smmu 0x480 0x20>,
arch/arm64/boot/dts/marvell/armada-8040.dtsi +0 -4
@@ -15,10 +15,6 @@ "marvell,armada-ap806"; }; -&smmu { - status = "okay"; -}; - &cp0_pcie0 { iommu-map = <0x0 &smmu 0x480 0x20>,
Greg Kroah-Hartman
maintainerPATCH 592/717 ext4: fix deadlock with fs freezing and EA inodes
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 46e294efc355c48d1dd4d58501aa56dac461792a upstream.
Xattr code using inodes with large xattr data can end up dropping last inode reference (and thus deleting the inode) from places like ext4_xattr_set_entry(). That function is called with transaction started and so ext4_evict_inode() can deadlock against fs freezing like:
CPU1 CPU2
removexattr() freeze_super()
vfs_removexattr()
ext4_xattr_set()
handle = ext4_journal_start()
...
ext4_xattr_set_entry()
iput(old_ea_inode)
ext4_evict_inode(old_ea_inode)
sb->s_writers.frozen = SB_FREEZE_FS;
sb_wait_write(sb, SB_FREEZE_FS);
ext4_freeze()
jbd2_journal_lock_updates()
-> blocks waiting for all
handles to stop
sb_start_intwrite()
-> blocks as sb is already in SB_FREEZE_FS stateGenerally it is advisable to delete inodes from a separate transaction as it can consume quite some credits however in this case it would be quite clumsy and furthermore the credits for inode deletion are quite limited and already accounted for. So just tweak ext4_evict_inode() to avoid freeze protection if we have transaction already started and thus it is not really needed anyway.
--- fs/ext4/inode.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
fs/ext4/inode.c +15 -6
@@ -175,6 +175,7 @@ void ext4_evict_inode(struct inode *inod*/ int extra_credits =6 ;struct ext4_xattr_inode_array *ea_inode_array =NULL ; +bool freeze_protected = false;trace_ext4_evict_inode (inode);
@@ -232,9 +233,14 @@ void ext4_evict_inode(struct inode *inod/* * Protect us against freezing - iput() caller didn't have to have any -* protection against it -*/ -sb_start_intwrite (inode->i_sb); +* protection against it. When we are in a running transaction though, +* we are already protected against freezing and we cannot grab further +* protection due to lock ordering constraints. +*/ +if (!ext4_journal_current_handle ()) { +sb_start_intwrite (inode->i_sb); + freeze_protected = true; + }if (!IS_NOQUOTA (inode)) extra_credits +=EXT4_MAXQUOTAS_DEL_BLOCKS (inode->i_sb);
@@ -253,7 +259,8 @@ void ext4_evict_inode(struct inode *inod* cleaned up. */ ext4_orphan_del (NULL , inode); -sb_end_intwrite (inode->i_sb); +if (freeze_protected) +sb_end_intwrite (inode->i_sb); goto no_delete; }
@@ -294,7 +301,8 @@ void ext4_evict_inode(struct inode *inod stop_handle:ext4_journal_stop (handle);ext4_orphan_del (NULL , inode); -sb_end_intwrite (inode->i_sb); +if (freeze_protected) +sb_end_intwrite (inode->i_sb);ext4_xattr_inode_array_free (ea_inode_array); goto no_delete; }
@@ -323,7 +331,8 @@ stop_handle:else ext4_free_inode (handle, inode);ext4_journal_stop (handle); -sb_end_intwrite (inode->i_sb); +if (freeze_protected) +sb_end_intwrite (inode->i_sb);ext4_xattr_inode_array_free (ea_inode_array);return ; no_delete:
Greg Kroah-Hartman
maintainerPATCH 601/717 iommu/arm-smmu-qcom: Read back stream mappings
In reply to Greg Kroah-HartmanFrom: Bjorn Andersson <[email protected]>
commit 07a7f2caaa5a2619934491bab3c47b261c554fb0 upstream.
The Qualcomm boot loader configures stream mapping for the peripherals that it accesses and in particular it sets up the stream mapping for the display controller to be allowed to scan out a splash screen or EFI framebuffer.
Read back the stream mappings during initialization and make the arm-smmu driver maintain the streams in bypass mode.
--- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +23 -0
@@ -23,6 +23,28 @@ static const struct of_device_id qcom_sm { } }; +static int qcom_smmu_cfg_probe (struct arm_smmu_device *smmu) +{ +u32 smr; +int i; + +for (i =0 ; i < smmu->num_mapping_groups; i++) { + smr =arm_smmu_gr0_read (smmu,ARM_SMMU_GR0_SMR (i)); + +if (FIELD_GET (ARM_SMMU_SMR_VALID , smr)) { + smmu->smrs[i].id =FIELD_GET (ARM_SMMU_SMR_ID , smr); + smmu->smrs[i].mask =FIELD_GET (ARM_SMMU_SMR_MASK , smr); + smmu->smrs[i].valid = true; + + smmu->s2crs[i].type =S2CR_TYPE_BYPASS ; + smmu->s2crs[i].privcfg =S2CR_PRIVCFG_DEFAULT ; + smmu->s2crs[i].cbndx =0xff ; + } + } + +return 0 ; +} +static int qcom_smmu_def_domain_type (struct device *dev) { const struct of_device_id *match =
@@ -61,6 +83,7 @@ static int qcom_smmu500_reset(struct arm }static const struct arm_smmu_impl qcom_smmu_impl = { + .cfg_probe = qcom_smmu_cfg_probe, .def_domain_type = qcom_smmu_def_domain_type, .reset = qcom_smmu500_reset, };
Greg Kroah-Hartman
maintainerPATCH 576/717 EDAC/amd64: Fix PCI component registration
In reply to Greg Kroah-HartmanFrom: Borislav Petkov <[email protected]>
commit 706657b1febf446a9ba37dc51b89f46604f57ee9 upstream.
In order to setup its PCI component, the driver needs any node private instance in order to get a reference to the PCI device and hand that into edac_pci_create_generic_ctl(). For convenience, it uses the 0th memory controller descriptor under the assumption that if any, the 0th will be always present.
However, this assumption goes wrong when the 0th node doesn't have memory and the driver doesn't initialize an instance for it:
EDAC amd64: F17h detected (node 0).
...
EDAC amd64: Node 0: No DIMMs detected.
But looking up node instances is not really needed - all one needs is the pointer to the proper device which gets discovered during instance init.
So stash that pointer into a variable and use it when setting up the EDAC PCI component.
Clear that variable when the driver needs to unwind due to some instances failing init to avoid any registration imbalance.
--- drivers/edac/amd64_edac.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/edac/amd64_edac.c +14 -12
@@ -18,6 +18,9 @@ static struct amd64_family_type *fam_typ/* Per-node stuff */ static struct ecc_settings **ecc_stngs; +/* Device for the PCI component */ +static struct device *pci_ctl_dev; +/* * Valid scrub rates for the K8 hardware memory scrubber. We map the scrubbing * bandwidth to a valid bit pattern. The 'set' operation finds the 'matching-
@@ -2683,6 +2686,9 @@ reserve_mc_sibling_devs(struct amd64_pvtreturn -ENODEV ; } +if (!pci_ctl_dev) + pci_ctl_dev = &pvt->F0->dev; +edac_dbg (1 ,"F0: %s\n" ,pci_name (pvt->F0));edac_dbg (1 ,"F3: %s\n" ,pci_name (pvt->F3));edac_dbg (1 ,"F6: %s\n" ,pci_name (pvt->F6));
@@ -2707,6 +2713,9 @@ reserve_mc_sibling_devs(struct amd64_pvtreturn -ENODEV ; } +if (!pci_ctl_dev) + pci_ctl_dev = &pvt->F2->dev; +edac_dbg (1 ,"F1: %s\n" ,pci_name (pvt->F1));edac_dbg (1 ,"F2: %s\n" ,pci_name (pvt->F2));edac_dbg (1 ,"F3: %s\n" ,pci_name (pvt->F3));
@@ -3623,21 +3632,10 @@ static void remove_one_instance(unsignedstatic void setup_pci_device (void ) { -struct mem_ctl_info *mci; -struct amd64_pvt *pvt; -if (pci_ctl)return ; - mci =edac_mc_find (0 ); -if (!mci) -return ; - - pvt = mci->pvt_info; -if (pvt->umc) - pci_ctl =edac_pci_create_generic_ctl (&pvt->F0->dev,EDAC_MOD_STR ); -else - pci_ctl =edac_pci_create_generic_ctl (&pvt->F2->dev,EDAC_MOD_STR ); + pci_ctl =edac_pci_create_generic_ctl (pci_ctl_dev,EDAC_MOD_STR );if (!pci_ctl) {pr_warn ("%s(): Unable to create PCI control\n" , __func__);pr_warn ("%s(): PCI error report via EDAC not set\n" , __func__);
@@ -3716,6 +3714,8 @@ static int __init amd64_edac_init(void)return 0 ; err_pci: + pci_ctl_dev =NULL ; +msrs_free (msrs); msrs =NULL ;
@@ -3745,6 +3745,8 @@ static void __exit amd64_edac_exit(void)kfree (ecc_stngs); ecc_stngs =NULL ; + pci_ctl_dev =NULL ; +msrs_free (msrs); msrs =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 593/717 ext4: dont remount read-only with errors=continue on reboot
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit b08070eca9e247f60ab39d79b2c25d274750441f upstream.
ext4_handle_error() with errors=continue mount option can accidentally remount the filesystem read-only when the system is rebooting. Fix that.
--- fs/ext4/super.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
fs/ext4/super.c +6 -8
@@ -666,19 +666,17 @@ static bool system_going_down(void)static void ext4_handle_error (struct super_block *sb) { +journal_t *journal =EXT4_SB (sb)->s_journal; +if (test_opt (sb,WARN_ON_ERROR ))WARN_ON_ONCE (1 ); -if (sb_rdonly (sb)) +if (sb_rdonly (sb) ||test_opt (sb,ERRORS_CONT ))return ; -if (!test_opt (sb,ERRORS_CONT )) { -journal_t *journal =EXT4_SB (sb)->s_journal; - -ext4_set_mount_flag (sb,EXT4_MF_FS_ABORTED ); -if (journal) -jbd2_journal_abort (journal, -EIO ); - } +ext4_set_mount_flag (sb,EXT4_MF_FS_ABORTED ); +if (journal) +jbd2_journal_abort (journal, -EIO );/* * We force ERRORS_RO behavior when system is rebooting. Otherwise we * could panic during 'reboot -f' as the underlying device got already
Greg Kroah-Hartman
maintainerPATCH 577/717 cpuset: fix race between hotplug work and later CPU offline
In reply to Greg Kroah-HartmanFrom: Daniel Jordan <[email protected]>
commit 406100f3da08066c00105165db8520bbc7694a36 upstream.
One of our machines keeled over trying to rebuild the scheduler domains. Mainline produces the same splat:
BUG: unable to handle page fault for address: 0000607f820054db CPU: 2 PID: 149 Comm: kworker/1:1 Not tainted 5.10.0-rc1-master+ #6 Workqueue: events cpuset_hotplug_workfn RIP: build_sched_domains Call Trace: partition_sched_domains_locked rebuild_sched_domains_locked cpuset_hotplug_workfn
It happens with cgroup2 and exclusive cpusets only. This reproducer triggers it on an 8-cpu vm and works most effectively with no preexisting child cgroups:
cd $UNIFIED_ROOT
mkdir cg1
echo 4-7 > cg1/cpuset.cpus
echo root > cg1/cpuset.cpus.partition
# with smt/control reading 'on', echo off > /sys/devices/system/cpu/smt/control
RIP maps to
sd->shared = *per_cpu_ptr(sdd->sds, sd_id);
from sd_init(). sd_id is calculated earlier in the same function:
cpumask_and(sched_domain_span(sd), cpu_map, tl->mask(cpu)); sd_id = cpumask_first(sched_domain_span(sd));
tl->mask(cpu), which reads cpu_sibling_map on x86, returns an empty mask and so cpumask_first() returns >= nr_cpu_ids, which leads to the bogus value from per_cpu_ptr() above.
The problem is a race between cpuset_hotplug_workfn() and a later offline of CPU N. cpuset_hotplug_workfn() updates the effective masks when N is still online, the offline clears N from cpu_sibling_map, and then the worker uses the stale effective masks that still have N to generate the scheduling domains, leading the worker to read N's empty cpu_sibling_map in sd_init().
rebuild_sched_domains_locked() prevented the race during the cgroup2 cpuset series up until the Fixes commit changed its check. Make the check more robust so that it can detect an offline CPU in any exclusive cpuset's effective mask, not just the top one.
--- kernel/cgroup/cpuset.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)
kernel/cgroup/cpuset.c +28 -5
@@ -983,25 +983,48 @@ partition_and_rebuild_sched_domains(int*/ static void rebuild_sched_domains_locked (void ) { +struct cgroup_subsys_state *pos_css;struct sched_domain_attr *attr;cpumask_var_t *doms; +struct cpuset *cs;int ndoms;lockdep_assert_cpus_held ();percpu_rwsem_assert_held (&cpuset_rwsem);/* -* We have raced with CPU hotplug. Don't do anything to avoid +* If we have raced with CPU hotplug, return early to avoid * passing doms with offlined cpu to partition_sched_domains(). -* Anyways, hotplug work item will rebuild sched domains. +* Anyways, cpuset_hotplug_workfn() will rebuild sched domains. +* +* With no CPUs in any subpartitions, top_cpuset's effective CPUs +* should be the same as the active CPUs, so checking only top_cpuset +* is enough to detect racing CPU offlines. */ if (!top_cpuset.nr_subparts_cpus && !cpumask_equal (top_cpuset.effective_cpus, cpu_active_mask))return ; -if (top_cpuset.nr_subparts_cpus && - !cpumask_subset (top_cpuset.effective_cpus, cpu_active_mask)) -return ; +/* +* With subpartition CPUs, however, the effective CPUs of a partition +* root should be only a subset of the active CPUs. Since a CPU in any +* partition root could be offlined, all must be checked. +*/ +if (top_cpuset.nr_subparts_cpus) { +rcu_read_lock (); +cpuset_for_each_descendant_pre (cs, pos_css, &top_cpuset) { +if (!is_partition_root (cs)) { + pos_css =css_rightmost_descendant (pos_css); +continue ; + } +if (!cpumask_subset (cs->effective_cpus, + cpu_active_mask)) { +rcu_read_unlock (); +return ; + } + } +rcu_read_unlock (); + }/* Generate domain masks and attrs */ ndoms =generate_sched_domains (&doms, &attr);
Greg Kroah-Hartman
maintainerPATCH 606/717 xprtrdma: Fix XDRBUF_SPARSE_PAGES support
In reply to Greg Kroah-HartmanFrom: Chuck Lever <[email protected]>
commit 15261b9126cd5bb2ad8521da49d8f5c042d904c7 upstream.
Olga K. observed that rpcrdma_marsh_req() allocates sparse pages only when it has determined that a Reply chunk is necessary. There are plenty of cases where no Reply chunk is needed, but the XDRBUF_SPARSE_PAGES flag is set. The result would be a crash in rpcrdma_inline_fixup() when it tries to copy parts of the received Reply into a missing page.
To avoid crashing, handle sparse page allocation up front.
Until XATTR support was added, this issue did not appear often because the only SPARSE_PAGES consumer always expected a reply large enough to always require a Reply chunk.
--- net/sunrpc/xprtrdma/rpc_rdma.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-)
net/sunrpc/xprtrdma/rpc_rdma.c +31 -9
@@ -179,6 +179,31 @@ rpcrdma_nonpayload_inline(const struct r r_xprt->rx_ep->re_max_inline_recv; } +/* ACL likes to be lazy in allocating pages. For TCP, these +* pages can be allocated during receive processing. Not true +* for RDMA, which must always provision receive buffers +* up front. +*/ +static noinline int +rpcrdma_alloc_sparse_pages (struct xdr_buf *buf) +{ +struct page **ppages; +int len; + + len = buf->page_len; + ppages = buf->pages + (buf->page_base >>PAGE_SHIFT ); +while (len >0 ) { +if (!*ppages) + *ppages =alloc_page (GFP_NOWAIT | __GFP_NOWARN); +if (!*ppages) +return -ENOBUFS ; + ppages++; + len -=PAGE_SIZE ; + } + +return 0 ; +} +/* Split @vec on page boundaries into SGEs. FMR registers pages, not * a byte range. Other modes coalesce these SGEs into a single MR * when they can.
@@ -233,15 +258,6 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt ppages = xdrbuf->pages + (xdrbuf->page_base >>PAGE_SHIFT ); page_base =offset_in_page (xdrbuf->page_base);while (len) { -/* ACL likes to be lazy in allocating pages - ACLs -* are small by default but can get huge. -*/ -if (unlikely (xdrbuf->flags &XDRBUF_SPARSE_PAGES )) { -if (!*ppages) - *ppages =alloc_page (GFP_NOWAIT | __GFP_NOWARN); -if (!*ppages) -return -ENOBUFS ; - } seg->mr_page = *ppages; seg->mr_offset = (char *)page_base; seg->mr_len =min_t (u32,PAGE_SIZE - page_base, len);
@@ -867,6 +883,12 @@ rpcrdma_marshal_req(struct rpcrdma_xprt__be32 *p;int ret; +if (unlikely (rqst->rq_rcv_buf.flags &XDRBUF_SPARSE_PAGES )) { + ret =rpcrdma_alloc_sparse_pages (&rqst->rq_rcv_buf); +if (ret) +return ret; + } +rpcrdma_set_xdrlen (&req->rl_hdrbuf,0 );xdr_init_encode (xdr, &req->rl_hdrbuf,rdmab_data (req->rl_rdmabuf), rqst);
Greg Kroah-Hartman
maintainerPATCH 583/717 USB: serial: keyspan_pda: fix stalled writes
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit c01d2c58698f710c9e13ba3e2d296328606f74fd upstream.
Make sure to clear the write-busy flag also in case no new data was submitted due to lack of device buffer space so that writing is resumed once space again becomes available.
--- drivers/usb/serial/keyspan_pda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/keyspan_pda.c +1 -1
@@ -548,7 +548,7 @@ static int keyspan_pda_write(struct tty_ rc = count; exit: -if (rc <0 ) +if (rc <=0 )set_bit (0 , &port->write_urbs_free);return rc; }
Greg Kroah-Hartman
maintainerPATCH 599/717 KVM: SVM: Remove the call to sev_platform_status() during setup
In reply to Greg Kroah-HartmanFrom: Tom Lendacky <[email protected]>
commit 9d4747d02376aeb8de38afa25430de79129c5799 upstream.
When both KVM support and the CCP driver are built into the kernel instead of as modules, KVM initialization can happen before CCP initialization. As a result, sev_platform_status() will return a failure when it is called from sev_hardware_setup(), when this isn't really an error condition.
Since sev_platform_status() doesn't need to be called at this time anyway, remove the invocation from sev_hardware_setup().
Message-Id: <618380488358b56af558f2682203786f09a49483.1607620209.git.thomas.lendacky@amd.com>
--- arch/x86/kvm/svm/sev.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
arch/x86/kvm/svm/sev.c +1 -21
@@ -1127,9 +1127,6 @@ void sev_vm_destroy(struct kvm *kvm)int __init sev_hardware_setup (void ) { -struct sev_user_data_status *status; -int rc; -/* Maximum number of encrypted guests supported simultaneously */ max_sev_asid =cpuid_ecx (0x8000001F );
@@ -1148,26 +1145,9 @@ int __init sev_hardware_setup(void)if (!sev_reclaim_asid_bitmap)return 1 ; - status =kmalloc (sizeof (*status),GFP_KERNEL ); -if (!status) -return 1 ; - -/* -* Check SEV platform status. -* -* PLATFORM_STATUS can be called in any state, if we failed to query -* the PLATFORM status then either PSP firmware does not support SEV -* feature or SEV firmware is dead. -*/ - rc =sev_platform_status (status,NULL ); -if (rc) - goto err; -pr_info ("SEV supported\n" ); -err: -kfree (status); -return rc; +return 0 ; }void sev_hardware_teardown (void )
Greg Kroah-Hartman
maintainerPATCH 604/717 ARM: dts: at91: sama5d2: fix CAN message ram offset and size
In reply to Greg Kroah-HartmanFrom: Nicolas Ferre <[email protected]>
commit 85b8350ae99d1300eb6dc072459246c2649a8e50 upstream.
CAN0 and CAN1 instances share the same message ram configured at 0x210000 on sama5d2 Linux systems.
According to current configuration of CAN0, we need 0x1c00 bytes so that the CAN1 don't overlap its message ram:
64 x RX FIFO0 elements => 64 x 72 bytes
32 x TXE (TX Event FIFO) elements => 32 x 8 bytes
32 x TXB (TX Buffer) elements => 32 x 72 bytes
So a total of 7168 bytes (0x1C00).
Fix offset to match this needed size.
Make the CAN0 message ram ioremap match exactly this size so that is easily understandable. Adapt CAN1 size accordingly.
--- arch/arm/boot/dts/sama5d2.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/sama5d2.dtsi +3 -3
@@ -725,7 +725,7 @@ can0: can@f8054000 { compatible = "bosch,m_can"; - reg = <0xf8054000 0x4000>, <0x210000 0x4000>; + reg = <0xf8054000 0x4000>, <0x210000 0x1c00>; reg-names = "m_can", "message_ram"; interrupts = <56 IRQ_TYPE_LEVEL_HIGH 7>, <64 IRQ_TYPE_LEVEL_HIGH 7>;
@@ -1131,7 +1131,7 @@ can1: can@fc050000 { compatible = "bosch,m_can"; - reg = <0xfc050000 0x4000>, <0x210000 0x4000>; + reg = <0xfc050000 0x4000>, <0x210000 0x3800>; reg-names = "m_can", "message_ram"; interrupts = <57 IRQ_TYPE_LEVEL_HIGH 7>, <65 IRQ_TYPE_LEVEL_HIGH 7>;
@@ -1141,7 +1141,7 @@ assigned-clocks = <&pmc PMC_TYPE_GCK 57>; assigned-clock-parents = <&pmc PMC_TYPE_CORE PMC_UTMI>; assigned-clock-rates = <40000000>; - bosch,mram-cfg = <0x1100 0 0 64 0 0 32 32>; + bosch,mram-cfg = <0x1c00 0 0 64 0 0 32 32>; status = "disabled"; };
Greg Kroah-Hartman
maintainerPATCH 578/717 dyndbg: fix use before null check
In reply to Greg Kroah-HartmanFrom: Jim Cromie <[email protected]>
commit 3577afb0052fca65e67efdfc8e0859bb7bac87a6 upstream.
In commit a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()"), a string is copied before checking it isn't NULL. Fix this, report a usage/interface error, and return the proper error code.
--- lib/dynamic_debug.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/dynamic_debug.c +7 -2
@@ -561,9 +561,14 @@ static int ddebug_exec_queries(char *queint dynamic_debug_exec_queries (const char *query,const char *modname) {int rc; -char *qry =kstrndup (query,PAGE_SIZE ,GFP_KERNEL ); +char *qry;/* writable copy of query */ -if (!query) +if (!query) { +pr_err ("non-null query/command string expected\n" ); +return -EINVAL ; + } + qry =kstrndup (query,PAGE_SIZE ,GFP_KERNEL ); +if (!qry)return -ENOMEM ; rc =ddebug_exec_queries (qry, modname);
Greg Kroah-Hartman
maintainerPATCH 579/717 USB: serial: mos7720: fix parallel-port state restore
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 975323ab8f116667676c30ca3502a6757bd89e8d upstream.
The parallel-port restore operations is called when a driver claims the port and is supposed to restore the provided state (e.g. saved when releasing the port).
--- drivers/usb/serial/mos7720.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/mos7720.c +2 -0
@@ -639,6 +639,8 @@ static void parport_mos7715_restore_statspin_unlock (&release_lock);return ; } + mos_parport->shadowDCR = s->u.pc.ctr; + mos_parport->shadowECR = s->u.pc.ecr;write_parport_reg_nonblock (mos_parport,MOS7720_DCR , mos_parport->shadowDCR); write_parport_reg_nonblock(mos_parport, MOS7720_ECR,
Greg Kroah-Hartman
maintainerPATCH 621/717 um: Fix time-travel mode
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
commit ff9632d2a66512436d616ef4c380a0e73f748db1 upstream.
Since the time-travel rework, basic time-travel mode hasn't worked properly, but there's no longer a need for this WARN_ON() so just remove it and thereby fix things.
--- arch/um/kernel/time.c | 5 ----- 1 file changed, 5 deletions(-)
arch/um/kernel/time.c +0 -5
@@ -260,11 +260,6 @@ static void __time_travel_add_event(strustruct time_travel_event *tmp;bool inserted = false; -if (WARN (time_travel_mode ==TT_MODE_BASIC && - e != &time_travel_timer_event, -"only timer events can be handled in basic mode" )) -return ; -if (e->pending)return ;
Greg Kroah-Hartman
maintainerPATCH 580/717 USB: serial: digi_acceleport: fix write-wakeup deadlocks
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 5098e77962e7c8947f87bd8c5869c83e000a522a upstream.
The driver must not call tty_wakeup() while holding its private lock as line disciplines are allowed to call back into write() from write_wakeup(), leading to a deadlock.
Also remove the unneeded work struct that was used to defer wakeup in order to work around a possible race in ancient times (see comment about n_tty write_chan() in commit 14b54e39b412 ("USB: serial: remove changelogs and old todo entries")).
--- drivers/usb/serial/digi_acceleport.c | 45 ++++++++++------------------------- 1 file changed, 13 insertions(+), 32 deletions(-)
drivers/usb/serial/digi_acceleport.c +13 -32
@@ -19,7 +19,6 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <linux/workqueue.h> #include <linux/uaccess.h> #include <linux/usb.h> #include <linux/wait.h>
@@ -198,14 +197,12 @@ struct digi_port {int dp_throttle_restart;wait_queue_head_t dp_flush_wait;wait_queue_head_t dp_close_wait;/* wait queue for close */ -struct work_struct dp_wakeup_work;struct usb_serial_port *dp_port; };/* Local Function Declarations */ -static void digi_wakeup_write_lock (struct work_struct *work);static int digi_write_oob_command (struct usb_serial_port *port,unsigned char *buf,int count,int interruptible); static int digi_write_inb_command(struct usb_serial_port *port,
@@ -356,26 +353,6 @@ __releases(lock)return timeout; } - -/* -* Digi Wakeup Write -* -* Wake up port, line discipline, and tty processes sleeping -* on writes. -*/ - -static void digi_wakeup_write_lock (struct work_struct *work) -{ -struct digi_port *priv = - container_of(work, struct digi_port, dp_wakeup_work); -struct usb_serial_port *port = priv->dp_port; -unsigned long flags; - -spin_lock_irqsave (&priv->dp_port_lock, flags); -tty_port_tty_wakeup (&port->port); -spin_unlock_irqrestore (&priv->dp_port_lock, flags); -} -/* * Digi Write OOB Command *
@@ -986,6 +963,7 @@ static void digi_write_bulk_callback(strunsigned long flags;int ret =0 ;int status = urb->status; +bool wakeup;/* port and serial sanity check */ if (port ==NULL || (priv =usb_get_serial_port_data (port)) ==NULL ) {
@@ -1012,6 +990,7 @@ static void digi_write_bulk_callback(str }/* try to send any buffered data on this port */ + wakeup = true;spin_lock_irqsave (&priv->dp_port_lock, flags); priv->dp_write_urb_in_use =0 ;if (priv->dp_out_buf_len >0 ) {
@@ -1027,19 +1006,18 @@ static void digi_write_bulk_callback(strif (ret ==0 ) { priv->dp_write_urb_in_use =1 ; priv->dp_out_buf_len =0 ; + wakeup = false; } } -/* wake up processes sleeping on writes immediately */ -tty_port_tty_wakeup (&port->port); -/* also queue up a wakeup at scheduler time, in case we */ -/* lost the race in write_chan(). */ -schedule_work (&priv->dp_wakeup_work); -spin_unlock_irqrestore (&priv->dp_port_lock, flags); +if (ret && ret != -EPERM )dev_err_console (port,"%s: usb_submit_urb failed, ret=%d, port=%d\n" , __func__, ret, priv->dp_port_num); + +if (wakeup) +tty_port_tty_wakeup (&port->port); }static int digi_write_room (struct tty_struct *tty)
@@ -1239,7 +1217,6 @@ static int digi_port_init(struct usb_serinit_waitqueue_head (&priv->dp_transmit_idle_wait);init_waitqueue_head (&priv->dp_flush_wait);init_waitqueue_head (&priv->dp_close_wait); -INIT_WORK (&priv->dp_wakeup_work, digi_wakeup_write_lock); priv->dp_port = port;init_waitqueue_head (&port->write_wait);
@@ -1508,13 +1485,14 @@ static int digi_read_oob_callback(struct rts =C_CRTSCTS (tty);if (tty && opcode ==DIGI_CMD_READ_INPUT_SIGNALS ) { +bool wakeup = false; +spin_lock_irqsave (&priv->dp_port_lock, flags);/* convert from digi flags to termiox flags */ if (val &DIGI_READ_INPUT_SIGNALS_CTS ) { priv->dp_modem_signals |=TIOCM_CTS ; -/* port must be open to use tty struct */ if (rts) -tty_port_tty_wakeup (&port->port); + wakeup = true; }else { priv->dp_modem_signals &= ~TIOCM_CTS ;/* port must be open to use tty struct */
@@ -1533,6 +1511,9 @@ static int digi_read_oob_callback(struct priv->dp_modem_signals &= ~TIOCM_CD ;spin_unlock_irqrestore (&priv->dp_port_lock, flags); + +if (wakeup) +tty_port_tty_wakeup (&port->port); }else if (opcode ==DIGI_CMD_TRANSMIT_IDLE ) {spin_lock_irqsave (&priv->dp_port_lock, flags); priv->dp_transmit_idle =1 ;
Greg Kroah-Hartman
maintainerPATCH 581/717 USB: serial: keyspan_pda: fix dropped unthrottle interrupts
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 696c541c8c6cfa05d65aa24ae2b9e720fc01766e upstream.
Commit c528fcb116e6 ("USB: serial: keyspan_pda: fix receive sanity checks") broke write-unthrottle handling by dropping well-formed unthrottle-interrupt packets which are precisely two bytes long. This could lead to blocked writers not being woken up when buffer space again becomes available.
Instead, stop unconditionally printing the third byte which is (presumably) only valid on modem-line changes.
--- drivers/usb/serial/keyspan_pda.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/serial/keyspan_pda.c +2 -2
@@ -172,11 +172,11 @@ static void keyspan_pda_rx_interrupt(strbreak ;case 1 :/* status interrupt */ -if (len <3 ) { +if (len <2 ) {dev_warn (&port->dev,"short interrupt message received\n" );break ; } -dev_dbg (&port->dev,"rx int, d1=%d, d2=%d\n" , data[1 ], data[2 ]); +dev_dbg (&port->dev,"rx int, d1=%d\n" , data[1 ]);switch (data[1 ]) {case 1 :/* modemline change */ break ;
Greg Kroah-Hartman
maintainerPATCH 609/717 powerpc/rtas: Fix typo of ibm,open-errinjct in RTAS filter
In reply to Greg Kroah-HartmanFrom: Tyrel Datwyler <[email protected]>
commit f10881a46f8914428110d110140a455c66bdf27b upstream.
Commit bd59380c5ba4 ("powerpc/rtas: Restrict RTAS requests from userspace") introduced the following error when invoking the errinjct userspace tool:
[root@ltcalpine2-lp5 librtas]# errinjct open
[327884.071171] sys_rtas: RTAS call blocked - exploit attempt? [327884.071186] sys_rtas: token=0x26, nargs=0 (called by errinjct) errinjct: Could not open RTAS error injection facility errinjct: librtas: open: Unexpected I/O error
The entry for ibm,open-errinjct in rtas_filter array has a typo where the "j" is omitted in the rtas call name. After fixing this typo the errinjct tool functions again as expected.
[root@ltcalpine2-lp5 linux]# errinjct open
RTAS error injection facility open, token = 1
--- arch/powerpc/kernel/rtas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/rtas.c +1 -1
@@ -1030,7 +1030,7 @@ static struct rtas_filter rtas_filters[] { "ibm,display-message", -1, 0, -1, -1, -1 }, { "ibm,errinjct", -1, 2, -1, -1, -1, 1024 }, { "ibm,close-errinjct", -1, -1, -1, -1, -1 }, - { "ibm,open-errinct", -1, -1, -1, -1, -1 }, + { "ibm,open-errinjct", -1, -1, -1, -1, -1 }, { "ibm,get-config-addr-info2", -1, -1, -1, -1, -1 }, { "ibm,get-dynamic-sensor-state", -1, 1, -1, -1, -1 }, { "ibm,get-indices", -1, 2, 3, -1, -1 },
Greg Kroah-Hartman
maintainerPATCH 619/717 ima: Dont modify file descriptor mode on the fly
In reply to Greg Kroah-HartmanFrom: Roberto Sassu <[email protected]>
commit 207cdd565dfc95a0a5185263a567817b7ebf5467 upstream.
Commit a408e4a86b36b ("ima: open a new file instance if no read permissions") already introduced a second open to measure a file when the original file descriptor does not allow it. However, it didn't remove the existing method of changing the mode of the original file descriptor, which is still necessary if the current process does not have enough privileges to open a new one.
Changing the mode isn't really an option, as the filesystem might need to do preliminary steps to make the read possible. Thus, this patch removes the code and keeps the second open as the only option to measure a file when it is unreadable with the original file descriptor.
--- security/integrity/ima/ima_crypto.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
security/integrity/ima/ima_crypto.c +5 -15
@@ -537,7 +537,7 @@ int ima_calc_file_hash(struct file *fileloff_t i_size;int rc;struct file *f = file; -bool new_file_instance = false, modified_mode = false; +bool new_file_instance = false;/* * For consistency, fail file's opened with the O_DIRECT flag on
@@ -555,18 +555,10 @@ int ima_calc_file_hash(struct file *file O_TRUNC | O_CREAT | O_NOCTTY | O_EXCL); flags |=O_RDONLY ; f =dentry_open (&file->f_path, flags, file->f_cred); -if (IS_ERR (f)) { -/* -* Cannot open the file again, lets modify f_mode -* of original and continue -*/ -pr_info_ratelimited ("Unable to reopen file for reading.\n" ); - f = file; - f->f_mode |=FMODE_READ ; - modified_mode = true; - }else { - new_file_instance = true; - } +if (IS_ERR (f)) +return PTR_ERR (f); + + new_file_instance = true; } i_size =i_size_read (file_inode (f));
@@ -581,8 +573,6 @@ int ima_calc_file_hash(struct file *file out:if (new_file_instance)fput (f); -else if (modified_mode) - f->f_mode &= ~FMODE_READ ;return rc; }
Greg Kroah-Hartman
maintainerPATCH 620/717 um: Remove use of asprinf in umid.c
In reply to Greg Kroah-HartmanFrom: Anton Ivanov <[email protected]>
commit 97be7ceaf7fea68104824b6aa874cff235333ac1 upstream.
asprintf is not compatible with the existing uml memory allocation mechanism. Its use on the "user" side of UML results in a corrupt slab state.
--- arch/um/os-Linux/umid.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
arch/um/os-Linux/umid.c +5 -12
@@ -137,20 +137,13 @@ static inline int is_umdir_used(char *di {char pid[sizeof ("nnnnnnnnn" )], *end, *file;int dead, fd, p, n, err; -size_t filelen; +size_t filelen =strlen (dir) +sizeof ("/pid" ) +1 ; - err =asprintf (&file,"%s/pid" , dir); -if (err <0 ) -return 0 ; + file =malloc (filelen); +if (!file) +return -ENOMEM ; - filelen =strlen (file); - - n =snprintf (file, filelen,"%s/pid" , dir); -if (n >= filelen) { -printk (UM_KERN_ERR "is_umdir_used - pid filename too long\n" ); - err = -E2BIG ; - goto out; - } +snprintf (file, filelen,"%s/pid" , dir); dead =0 ; fd =open (file,O_RDONLY );
Greg Kroah-Hartman
maintainerPATCH 624/717 SMB3.1.1: remove confusing mount warning when no SPNEGO info on negprot rsp
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
commit bc7c4129d4cdc56d1b5477c1714246f27df914dd upstream.
Azure does not send an SPNEGO blob in the negotiate protocol response, so we shouldn't assume that it is there when validating the location of the first negotiate context. This avoids the potential confusing mount warning:
CIFS: Invalid negotiate context offset
--- fs/cifs/smb2misc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
fs/cifs/smb2misc.c +12 -4
@@ -94,6 +94,8 @@ static const __le16 smb2_rsp_struct_size /* SMB2_OPLOCK_BREAK */ cpu_to_le16(24) }; +#define SMB311_NEGPROT_BASE_SIZE (sizeof(struct smb2_sync_hdr) + sizeof(struct smb2_negotiate_rsp)) +static __u32 get_neg_ctxt_len (struct smb2_sync_hdr *hdr,__u32 len,__u32 non_ctxlen) {
@@ -109,11 +111,17 @@ static __u32 get_neg_ctxt_len(struct smb/* Make sure that negotiate contexts start after gss security blob */ nc_offset =le32_to_cpu (pneg_rsp->NegotiateContextOffset); -if (nc_offset < non_ctxlen) { -pr_warn_once ("Invalid negotiate context offset\n" ); +if (nc_offset +1 < non_ctxlen) { +pr_warn_once ("Invalid negotiate context offset %d\n" , nc_offset);return 0 ; - } - size_of_pad_before_neg_ctxts = nc_offset - non_ctxlen; + }else if (nc_offset +1 == non_ctxlen) { +cifs_dbg (FYI ,"no SPNEGO security blob in negprot rsp\n" ); + size_of_pad_before_neg_ctxts =0 ; + }else if (non_ctxlen ==SMB311_NEGPROT_BASE_SIZE ) +/* has padding, but no SPNEGO blob */ + size_of_pad_before_neg_ctxts = nc_offset - non_ctxlen +1 ; +else + size_of_pad_before_neg_ctxts = nc_offset - non_ctxlen;/* Verify that at least minimal negotiate contexts fit within frame */ if (len < nc_offset + (neg_count *sizeof (struct smb2_neg_context ))) {
Greg Kroah-Hartman
maintainerPATCH 622/717 ceph: fix race in concurrent __ceph_remove_cap invocations
In reply to Greg Kroah-HartmanFrom: Luis Henriques <[email protected]>
commit e5cafce3ad0f8652d6849314d951459c2bff7233 upstream.
A NULL pointer dereference may occur in __ceph_remove_cap with some of the callbacks used in ceph_iterate_session_caps, namely trim_caps_cb and remove_session_caps_cb. Those callers hold the session->s_mutex, so they are prevented from concurrent execution, but ceph_evict_inode does not.
Since the callers of this function hold the i_ceph_lock, the fix is simply a matter of returning immediately if caps->ci is NULL.
Cc: [email protected]
URL: https://tracker.ceph.com/issues/43272
--- fs/ceph/caps.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/ceph/caps.c +9 -2
@@ -1140,12 +1140,19 @@ void __ceph_remove_cap(struct ceph_cap * {struct ceph_mds_session *session = cap->session;struct ceph_inode_info *ci = cap->ci; -struct ceph_mds_client *mdsc = -ceph_sb_to_client (ci->vfs_inode.i_sb)->mdsc; +struct ceph_mds_client *mdsc;int removed =0 ; +/* 'ci' being NULL means the remove have already occurred */ +if (!ci) { +dout ("%s: cap inode is NULL\n" , __func__); +return ; + } +dout ("__ceph_remove_cap %p from %p\n" , cap, &ci->vfs_inode); + mdsc =ceph_inode_to_client (&ci->vfs_inode)->mdsc; +/* remove from inode's cap rbtree, and clear auth cap */ rb_erase (&cap->ci_node, &ci->i_caps);if (ci->i_auth_cap == cap) {
Greg Kroah-Hartman
maintainerPATCH 623/717 SMB3: avoid confusing warning message on mount to Azure
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
commit ebcd6de98754d9b6a5f89d7835864b1c365d432f upstream.
Mounts to Azure cause an unneeded warning message in dmesg
"CIFS: VFS: parse_server_interfaces: incomplete interface info"
Azure rounds up the size (by 8 additional bytes, to a 16 byte boundary) of the structure returned on the query of the server interfaces at mount time. This is permissible even though different than other servers so do not log a warning if query network interfaces response is only rounded up by 8 bytes or fewer.
--- fs/cifs/smb2ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/smb2ops.c +2 -1
@@ -477,7 +477,8 @@ parse_server_interfaces(struct network_i goto out; } -if (bytes_left || p->Next) +/* Azure rounds the buffer size up 8, to a 16 byte boundary */ +if ((bytes_left >8 ) || p->Next)cifs_dbg (VFS ,"%s: incomplete interface info\n" , __func__);
Greg Kroah-Hartman
maintainerPATCH 625/717 SMB3.1.1: do not log warning message if server doesnt populate salt
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
commit 7955f105afb6034af344038d663bc98809483cdd upstream.
In the negotiate protocol preauth context, the server is not required to populate the salt (although it is done by most servers) so do not warn on mount.
We retain the checks (warn) that the preauth context is the minimum size and that the salt does not exceed DataLength of the SMB response. Although we use the defaults in the case that the preauth context response is invalid, these checks may be useful in the future as servers add support for additional mechanisms.
--- fs/cifs/smb2pdu.c | 7 +++++-- fs/cifs/smb2pdu.h | 14 +++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-)
fs/cifs/smb2pdu.c +5 -2
@@ -427,8 +427,8 @@ build_preauth_ctxt(struct smb2_preauth_n pneg_ctxt->ContextType =SMB2_PREAUTH_INTEGRITY_CAPABILITIES ; pneg_ctxt->DataLength =cpu_to_le16 (38 ); pneg_ctxt->HashAlgorithmCount =cpu_to_le16 (1 ); - pneg_ctxt->SaltLength =cpu_to_le16 (SMB311_SALT_SIZE ); -get_random_bytes (pneg_ctxt->Salt,SMB311_SALT_SIZE ); + pneg_ctxt->SaltLength =cpu_to_le16 (SMB311_LINUX_CLIENT_SALT_SIZE ); +get_random_bytes (pneg_ctxt->Salt,SMB311_LINUX_CLIENT_SALT_SIZE ); pneg_ctxt->HashAlgorithms =SMB2_PREAUTH_INTEGRITY_SHA512 ; }
@@ -566,6 +566,9 @@ static void decode_preauth_context(strucif (len <MIN_PREAUTH_CTXT_DATA_LEN ) {pr_warn_once ("server sent bad preauth context\n" );return ; + }else if (len <MIN_PREAUTH_CTXT_DATA_LEN +le16_to_cpu (ctxt->SaltLength)) { +pr_warn_once ("server sent invalid SaltLength\n" ); +return ; }if (le16_to_cpu (ctxt->HashAlgorithmCount) !=1 )pr_warn_once ("Invalid SMB3 hash algorithm count\n" );
fs/cifs/smb2pdu.h +11 -3
@@ -333,12 +333,20 @@ struct smb2_neg_context {/* Followed by array of data */ } __packed; -#define SMB311_SALT_SIZE 32 +#define SMB311_LINUX_CLIENT_SALT_SIZE 32/* Hash Algorithm Types */ #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)#define SMB2_PREAUTH_HASH_SIZE 64 -#define MIN_PREAUTH_CTXT_DATA_LEN (SMB311_SALT_SIZE + 6) +/* +* SaltLength that the server send can be zero, so the only three required +* fields (all __le16) end up six bytes total, so the minimum context data len +* in the response is six bytes which accounts for +* +* HashAlgorithmCount, SaltLength, and 1 HashAlgorithm. +*/ +#define MIN_PREAUTH_CTXT_DATA_LEN 6 +struct smb2_preauth_neg_context {__le16 ContextType;/* 1 */ __le16 DataLength;
@@ -346,7 +354,7 @@ struct smb2_preauth_neg_context {__le16 HashAlgorithmCount;/* 1 */ __le16 SaltLength;__le16 HashAlgorithms;/* HashAlgorithms[0] since only one defined */ -__u8 Salt[SMB311_SALT_SIZE ]; +__u8 Salt[SMB311_LINUX_CLIENT_SALT_SIZE ]; } __packed;/* Encryption Algorithms Ciphers */
Greg Kroah-Hartman
maintainerPATCH 626/717 ubifs: wbuf: Dont leak kernel memory to flash
In reply to Greg Kroah-HartmanFrom: Richard Weinberger <[email protected]>
commit 20f1431160c6b590cdc269a846fc5a448abf5b98 upstream.
Write buffers use a kmalloc()'ed buffer, they can leak up to seven bytes of kernel memory to flash if writes are not aligned.
So use ubifs_pad() to fill these gaps with padding bytes. This was never a problem while scanning because the scanner logic manually aligns node lengths and skips over these gaps.
--- fs/ubifs/io.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
fs/ubifs/io.c +11 -2
@@ -319,7 +319,7 @@ void ubifs_pad(const struct ubifs_info * {uint32_t crc; -ubifs_assert (c, pad >=0 && !(pad &7 )); +ubifs_assert (c, pad >=0 );if (pad >=UBIFS_PAD_NODE_SZ ) {struct ubifs_ch *ch = buf;
@@ -764,6 +764,10 @@ int ubifs_wbuf_write_nolock(struct ubifs* write-buffer. */ memcpy (wbuf->buf + wbuf->used, buf, len); +if (aligned_len > len) { +ubifs_assert (c, aligned_len - len <8 ); +ubifs_pad (c, wbuf->buf + wbuf->used + len, aligned_len - len); + }if (aligned_len == wbuf->avail) { dbg_io("flush jhead %s wbuf to LEB %d:%d",
@@ -856,13 +860,18 @@ int ubifs_wbuf_write_nolock(struct ubifs }spin_lock (&wbuf->lock); -if (aligned_len) +if (aligned_len) {/* * And now we have what's left and what does not take whole * max. write unit, so write it to the write-buffer and we are * done. */ memcpy (wbuf->buf, buf + written, len); +if (aligned_len > len) { +ubifs_assert (c, aligned_len - len <8 ); +ubifs_pad (c, wbuf->buf + len, aligned_len - len); + } + }if (c->leb_size - wbuf->offs >= c->max_write_size) wbuf->size = c->max_write_size;
Greg Kroah-Hartman
maintainerPATCH 628/717 jffs2: Fix ignoring mounting options problem during remounting
In reply to Greg Kroah-HartmanFrom: lizhe <[email protected]>
commit 08cd274f9b8283a1da93e2ccab216a336da83525 upstream.
The jffs2 mount options will be ignored when remounting jffs2. It can be easily reproduced with the steps listed below.
1. mount -t jffs2 -o compr=none /dev/mtdblockx /mnt
2. mount -o remount compr=zlib /mnt
Since ec10a24f10c8, the option parsing happens before fill_super and then pass fc, which contains the options parsing results, to function jffs2_reconfigure during remounting. But function jffs2_reconfigure do not update c->mount_opts.
This patch add a function jffs2_update_mount_opts to fix this problem.
By the way, I notice that tmpfs use the same way to update remounting options. If it is necessary to unify them?
--- fs/jffs2/super.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
fs/jffs2/super.c +17 -0
@@ -215,11 +215,28 @@ static int jffs2_parse_param(struct fs_creturn 0 ; } +static inline void jffs2_update_mount_opts (struct fs_context *fc) +{ +struct jffs2_sb_info *new_c = fc->s_fs_info; +struct jffs2_sb_info *c =JFFS2_SB_INFO (fc->root->d_sb); + +mutex_lock (&c->alloc_sem); +if (new_c->mount_opts.override_compr) { + c->mount_opts.override_compr = new_c->mount_opts.override_compr; + c->mount_opts.compr = new_c->mount_opts.compr; + } +if (new_c->mount_opts.rp_size) + c->mount_opts.rp_size = new_c->mount_opts.rp_size; +mutex_unlock (&c->alloc_sem); +} +static int jffs2_reconfigure (struct fs_context *fc) {struct super_block *sb = fc->root->d_sb;sync_filesystem (sb); +jffs2_update_mount_opts (fc); +return jffs2_do_remount_fs (sb, fc); }
Greg Kroah-Hartman
maintainerPATCH 630/717 inotify: convert to handle_inode_event() interface
In reply to Greg Kroah-HartmanFrom: Amir Goldstein <[email protected]>
commit 1a2620a99803ad660edc5d22fd9c66cce91ceb1c upstream.
Convert inotify to use the simple handle_inode_event() interface to get rid of the code duplication between the generic helper fsnotify_handle_event() and the inotify_handle_event() callback, which also happen to be buggy code.
The bug will be fixed in the generic helper.
--- fs/notify/inotify/inotify.h | 9 ++---- fs/notify/inotify/inotify_fsnotify.c | 51 +++++------------------------------ fs/notify/inotify/inotify_user.c | 8 +---- 3 files changed, 14 insertions(+), 54 deletions(-)
fs/notify/inotify/inotify.h +4 -5
@@ -24,11 +24,10 @@ static inline struct inotify_event_infoextern void inotify_ignored_and_remove_idr (struct fsnotify_mark *fsn_mark,struct fsnotify_group *group); -extern int inotify_handle_event (struct fsnotify_group *group,u32 mask, -const void *data,int data_type, -struct inode *dir, -const struct qstr *file_name,u32 cookie, -struct fsnotify_iter_info *iter_info); +extern int inotify_handle_inode_event (struct fsnotify_mark *inode_mark, +u32 mask,struct inode *inode, +struct inode *dir, +const struct qstr *name,u32 cookie);extern const struct fsnotify_ops inotify_fsnotify_ops;extern struct kmem_cache *inotify_inode_mark_cachep;
fs/notify/inotify/inotify_fsnotify.c +8 -43
84 lines not on this page · raw message
fs/notify/inotify/inotify_user.c +2 -6
@@ -486,14 +486,10 @@ void inotify_ignored_and_remove_idr(stru struct fsnotify_group *group) {struct inotify_inode_mark *i_mark; -struct fsnotify_iter_info iter_info = { }; - -fsnotify_iter_set_report_type_mark (&iter_info,FSNOTIFY_OBJ_TYPE_INODE , - fsn_mark);/* Queue ignore event for the watch */ -inotify_handle_event (group,FS_IN_IGNORED ,NULL ,FSNOTIFY_EVENT_NONE , -NULL ,NULL ,0 , &iter_info); +inotify_handle_inode_event (fsn_mark,FS_IN_IGNORED ,NULL ,NULL ,NULL , +0 ); i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);/* remove this mark from the idr */
Greg Kroah-Hartman
maintainerPATCH 633/717 drm/panfrost: Fix job timeout handling
In reply to Greg Kroah-HartmanFrom: Boris Brezillon <[email protected]>
commit 1a11a88cfd9a97e13be8bc880c4795f9844fbbec upstream.
If more than two jobs end up timeout-ing concurrently, only one of them (the one attached to the scheduler acquiring the lock) is fully handled. The other one remains in a dangling state where it's no longer part of the scheduling queue, but still blocks something in scheduler, leading to repetitive timeouts when new jobs are queued.
Let's make sure all bad jobs are properly handled by the thread acquiring the lock.
v3:
- Add Steven's R-b
- Don't take the sched_lock when stopping the schedulers
v2:
- Fix the subject prefix
- Stop the scheduler before returning from panfrost_job_timedout()
- Call cancel_delayed_work_sync() after drm_sched_stop() to make sure no timeout handlers are in flight when we reset the GPU (Steven Price)
- Make sure we release the reset lock before restarting the schedulers (Steven Price)
--- drivers/gpu/drm/panfrost/panfrost_job.c | 62 +++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 9 deletions(-)
drivers/gpu/drm/panfrost/panfrost_job.c +53 -9
@@ -25,7 +25,8 @@struct panfrost_queue_state {struct drm_gpu_scheduler sched; - +bool stopped; +struct mutex lock;u64 fence_context;u64 emit_seqno; };
@@ -369,6 +370,24 @@ void panfrost_job_enable_interrupts(strujob_write (pfdev,JOB_INT_MASK , irq_mask); } +static bool panfrost_scheduler_stop (struct panfrost_queue_state *queue, +struct drm_sched_job *bad) +{ +bool stopped = false; + +mutex_lock (&queue->lock); +if (!queue->stopped) { +drm_sched_stop (&queue->sched, bad); +if (bad) +drm_sched_increase_karma (bad); + queue->stopped = true; + stopped = true; + } +mutex_unlock (&queue->lock); + +return stopped; +} +static void panfrost_job_timedout (struct drm_sched_job *sched_job) {struct panfrost_job *job =to_panfrost_job (sched_job);
@@ -392,19 +411,39 @@ static void panfrost_job_timedout(structjob_read (pfdev,JS_TAIL_LO (js)), sched_job); +/* Scheduler is already stopped, nothing to do. */ +if (!panfrost_scheduler_stop (&pfdev->js->queue[js], sched_job)) +return ; +if (!mutex_trylock (&pfdev->reset_lock))return ;for (i =0 ; i <NUM_JOB_SLOTS ; i++) {struct drm_gpu_scheduler *sched = &pfdev->js->queue[i].sched; -drm_sched_stop (sched, sched_job); -if (js != i) -/* Ensure any timeouts on other slots have finished */ +/* +* If the queue is still active, make sure we wait for any +* pending timeouts. +*/ +if (!pfdev->js->queue[i].stopped) +cancel_delayed_work_sync (&sched->work_tdr); + +/* +* If the scheduler was not already stopped, there's a tiny +* chance a timeout has expired just before we stopped it, and +* drm_sched_stop() does not flush pending works. Let's flush +* them now so the timeout handler doesn't get called in the +* middle of a reset. +*/ +if (panfrost_scheduler_stop (&pfdev->js->queue[i],NULL ))cancel_delayed_work_sync (&sched->work_tdr); - } -drm_sched_increase_karma (sched_job); +/* +* Now that we cancelled the pending timeouts, we can safely +* reset the stopped state. +*/ + pfdev->js->queue[i].stopped = false; + }spin_lock_irqsave (&pfdev->js->job_lock, flags);for (i =0 ; i <NUM_JOB_SLOTS ; i++) {
@@ -421,11 +460,11 @@ static void panfrost_job_timedout(structfor (i =0 ; i <NUM_JOB_SLOTS ; i++)drm_sched_resubmit_jobs (&pfdev->js->queue[i].sched); +mutex_unlock (&pfdev->reset_lock); +/* restart scheduler after GPU is usable again */ for (i =0 ; i <NUM_JOB_SLOTS ; i++)drm_sched_start (&pfdev->js->queue[i].sched, true); - -mutex_unlock (&pfdev->reset_lock); }static const struct drm_sched_backend_ops panfrost_sched_ops = {
@@ -558,6 +597,7 @@ int panfrost_job_open(struct panfrost_fiint ret, i;for (i =0 ; i <NUM_JOB_SLOTS ; i++) { +mutex_init (&js->queue[i].lock); sched = &js->queue[i].sched; ret = drm_sched_entity_init(&panfrost_priv->sched_entity[i], DRM_SCHED_PRIORITY_NORMAL, &sched,
@@ -570,10 +610,14 @@ int panfrost_job_open(struct panfrost_fivoid panfrost_job_close (struct panfrost_file_priv *panfrost_priv) { +struct panfrost_device *pfdev = panfrost_priv->pfdev; +struct panfrost_job_slot *js = pfdev->js;int i; -for (i =0 ; i <NUM_JOB_SLOTS ; i++) +for (i =0 ; i <NUM_JOB_SLOTS ; i++) {drm_sched_entity_destroy (&panfrost_priv->sched_entity[i]); +mutex_destroy (&js->queue[i].lock); + } }int panfrost_job_is_idle (struct panfrost_device *pfdev)
Greg Kroah-Hartman
maintainerPATCH 635/717 drm/amd/display: Honor the offset for plane 0.
In reply to Greg Kroah-HartmanFrom: Bas Nieuwenhuizen <[email protected]>
commit be7b9b327e79cd2db07b659af599867b629b2f66 upstream.
With modifiers I'd like to support non-dedicated buffers for images.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +9 -5
@@ -3746,6 +3746,7 @@ fill_plane_dcc_attributes(struct amdgpu_struct dc *dc = adev->dm.dc;struct dc_dcc_surface_param input;struct dc_surface_dcc_cap output; +uint64_t plane_address = afb->address + afb->base.offsets[0 ];uint32_t offset =AMDGPU_TILING_GET (info,DCC_OFFSET_256B );uint32_t i64b =AMDGPU_TILING_GET (info,DCC_INDEPENDENT_64B ) !=0 ;uint64_t dcc_address;
@@ -3789,7 +3790,7 @@ fill_plane_dcc_attributes(struct amdgpu_AMDGPU_TILING_GET (info,DCC_PITCH_MAX ) +1 ; dcc->independent_64b_blks = i64b; - dcc_address =get_dcc_address (afb->address, info); + dcc_address =get_dcc_address (plane_address, info); address->grph.meta_addr.low_part =lower_32_bits (dcc_address); address->grph.meta_addr.high_part =upper_32_bits (dcc_address);
@@ -3820,6 +3821,8 @@ fill_plane_buffer_attributes(struct amdg address->tmz_surface = tmz_surface;if (format <SURFACE_PIXEL_FORMAT_VIDEO_BEGIN ) { +uint64_t addr = afb->address + fb->offsets[0 ]; + plane_size->surface_size.x =0 ; plane_size->surface_size.y =0 ; plane_size->surface_size.width = fb->width;
@@ -3828,9 +3831,10 @@ fill_plane_buffer_attributes(struct amdg fb->pitches[0 ] / fb->format->cpp[0 ]; address->type =PLN_ADDR_TYPE_GRAPHICS ; - address->grph.addr.low_part =lower_32_bits (afb->address); - address->grph.addr.high_part =upper_32_bits (afb->address); + address->grph.addr.low_part =lower_32_bits (addr); + address->grph.addr.high_part =upper_32_bits (addr); }else if (format <SURFACE_PIXEL_FORMAT_INVALID ) { +uint64_t luma_addr = afb->address + fb->offsets[0 ];uint64_t chroma_addr = afb->address + fb->offsets[1 ]; plane_size->surface_size.x =0 ;
@@ -3851,9 +3855,9 @@ fill_plane_buffer_attributes(struct amdg address->type =PLN_ADDR_TYPE_VIDEO_PROGRESSIVE ; address->video_progressive.luma_addr.low_part = -lower_32_bits (afb->address); +lower_32_bits (luma_addr); address->video_progressive.luma_addr.high_part = -upper_32_bits (afb->address); +upper_32_bits (luma_addr); address->video_progressive.chroma_addr.low_part =lower_32_bits (chroma_addr); address->video_progressive.chroma_addr.high_part =
Greg Kroah-Hartman
maintainerPATCH 632/717 jfs: Fix array index bounds check in dbAdjTree
In reply to Greg Kroah-HartmanFrom: Dave Kleikamp <[email protected]>
commit c61b3e4839007668360ed8b87d7da96d2e59fc6c upstream.
Bounds checking tools can flag a bug in dbAdjTree() for an array index out of bounds in dmt_stree. Since dmt_stree can refer to the stree in both structures dmaptree and dmapctl, use the larger array to eliminate the false positive.
--- fs/jfs/jfs_dmap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/jfs_dmap.h +1 -1
@@ -183,7 +183,7 @@ typedef union dmtree {#define dmt_leafidx t1.leafidx#define dmt_height t1.height#define dmt_budmin t1.budmin -#define dmt_stree t1.stree +#define dmt_stree t2.stree/* * on-disk aggregate disk allocation map descriptor.
Greg Kroah-Hartman
maintainerPATCH 611/717 powerpc/feature: Add CPU_FTR_NOEXECUTE to G2_LE
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 197493af414ee22427be3343637ac290a791925a upstream.
G2_LE has a 603 core, add CPU_FTR_NOEXECUTE.
--- arch/powerpc/include/asm/cputable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/cputable.h +1 -1
@@ -369,7 +369,7 @@ static inline void cpu_feature_keys_init CPU_FTR_PPC_LE | CPU_FTR_NEED_PAIRED_STWCX)#define CPU_FTRS_82XX (CPU_FTR_COMMON | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_NOEXECUTE)#define CPU_FTRS_G2_LE (CPU_FTR_COMMON | CPU_FTR_MAYBE_CAN_DOZE | \ - CPU_FTR_MAYBE_CAN_NAP) + CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_NOEXECUTE)#define CPU_FTRS_E300 (CPU_FTR_MAYBE_CAN_DOZE | \ CPU_FTR_MAYBE_CAN_NAP | \ CPU_FTR_COMMON | CPU_FTR_NOEXECUTE)
Greg Kroah-Hartman
maintainerPATCH 616/717 powerpc/powernv/memtrace: Dont leak kernel memory to user space
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
commit c74cf7a3d59a21b290fe0468f5b470d0b8ee37df upstream.
We currently leak kernel memory to user space, because memory offlining doesn't do any implicit clearing of memory and we are missing explicit clearing of memory.
Let's keep it simple and clear pages before removing the linear mapping.
Reproduced in QEMU/TCG with 10 GiB of main memory:
[root@localhost ~]# dd obs=9G if=/dev/urandom of=/dev/null
[... wait until "free -m" used counter no longer changes and cancel] 19665802+0 records in
1+0 records out
9663676416 bytes (9.7 GB, 9.0 GiB) copied, 135.548 s, 71.3 MB/s [root@localhost ~]# cat /sys/devices/system/memory/block_size_bytes 40000000
[root@localhost ~]# echo 0x40000000 > /sys/kernel/debug/powerpc/memtrace/enable
[ 402.978663][ T1086] page:000000001bc4bc74 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x24900 [ 402.980063][ T1086] flags: 0x7ffff000001000(reserved) [ 402.980415][ T1086] raw: 007ffff000001000 c00c000000924008 c00c000000924008 0000000000000000 [ 402.980627][ T1086] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 [ 402.980845][ T1086] page dumped because: unmovable page [ 402.989608][ T1086] Offlined Pages 16384 [ 403.324155][ T1086] memtrace: Allocated trace memory on node 0 at 0x0000000200000000
Before this patch:
[root@localhost ~]# hexdump -C /sys/kernel/debug/powerpc/memtrace/00000000/trace | head
00000000 c8 25 72 51 4d 26 36 c5 5c c2 56 15 d5 1a cd 10 |.%rQM&6.\.V.....|
00000010 19 b9 50 b2 cb e3 60 b8 ec 0a f3 ec 4b 3c 39 f0 |..P...`.....K<9.|$
00000020 4e 5a 4c cf bd 26 19 ff 37 79 13 67 24 b7 b8 57 |NZL..&..7y.g$..W|$
00000030 98 3e f5 be 6f 14 6a bd a4 52 bc 6e e9 e0 c1 5d |.>..o.j..R.n...]|$
00000040 76 b3 ae b5 88 d7 da e3 64 23 85 2c 10 88 07 b6 |v.......d#.,....|$
00000050 9a d8 91 de f7 50 27 69 2e 64 9c 6f d3 19 45 79 |.....P'i.d.o..Ey|$
00000060 6a 6f 8a 61 71 19 1f c7 f1 df 28 26 ca 0f 84 55 |jo.aq.....(&...U|$
00000070 01 3f be e4 e2 e1 da ff 7b 8c 8e 32 37 b4 24 53 |.?......{..27.$S|$
00000080 1b 70 30 45 56 e6 8c c4 0e b5 4c fb 9f dd 88 06 |.p0EV.....L.....|$
00000090 ef c4 18 79 f1 60 b1 5c 79 59 4d f4 36 d7 4a 5c |...y.`.\yYM.6.J\|$After this patch:
[root@localhost ~]# hexdump -C /sys/kernel/debug/powerpc/memtrace/00000000/trace | head 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| *
40000000
--- arch/powerpc/platforms/powernv/memtrace.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/powerpc/platforms/powernv/memtrace.c +22 -0
@@ -67,6 +67,23 @@ static int change_memblock_state(structreturn 0 ; } +static void memtrace_clear_range (unsigned long start_pfn, +unsigned long nr_pages) +{ +unsigned long pfn; + +/* +* As pages are offline, we cannot trust the memmap anymore. As HIGHMEM +* does not apply, avoid passing around "struct page" and use +* clear_page() instead directly. +*/ +for (pfn = start_pfn; pfn < start_pfn + nr_pages; pfn++) { +if (IS_ALIGNED (pfn,PAGES_PER_SECTION )) +cond_resched (); +clear_page (__va (PFN_PHYS (pfn))); + } +} +/* called with device_hotplug_lock held */ static bool memtrace_offline_pages (u32 nid,u64 start_pfn,u64 nr_pages) {
@@ -112,6 +129,11 @@ static u64 memtrace_alloc_node(u32 nid,for (base_pfn = end_pfn; base_pfn > start_pfn; base_pfn -= nr_pages) {if (memtrace_offline_pages (nid, base_pfn, nr_pages) == true) {/* +* Clear the range while we still have a linear +* mapping. +*/ +memtrace_clear_range (base_pfn, nr_pages); +/* * Remove memory in memory block size chunks so that * iomem resources are always split to the same size and * we never try to remove memory that spans two iomem
Greg Kroah-Hartman
maintainerPATCH 634/717 drm/panfrost: Move the GPU reset bits outside the timeout handler
In reply to Greg Kroah-HartmanFrom: Boris Brezillon <[email protected]>
commit 5bc5cc2819c2c0adb644919e3e790b504ea47e0a upstream.
We've fixed many races in panfrost_job_timedout() but some remain. Instead of trying to fix it again, let's simplify the logic and move the reset bits to a separate work scheduled when one of the queue reports a timeout.
v5:
- Simplify panfrost_scheduler_stop() (Steven Price)
- Always restart the queue in panfrost_scheduler_start() even if the status is corrupted (Steven Price)
v4:
- Rework the logic to prevent a race between drm_sched_start() (reset work) and drm_sched_job_timedout() (timeout work)
- Drop Steven's R-b
- Add dma_fence annotation to the panfrost_reset() function (Daniel Vetter)
v3:
- Replace the atomic_cmpxchg() by an atomic_xchg() (Robin Murphy)
- Add Steven's R-b
v2:
- Use atomic_cmpxchg() to conditionally schedule the reset work (Steven Price)
--- drivers/gpu/drm/panfrost/panfrost_device.c | 1 drivers/gpu/drm/panfrost/panfrost_device.h | 6 drivers/gpu/drm/panfrost/panfrost_job.c | 187 +++++++++++++++++++---------- 3 files changed, 130 insertions(+), 64 deletions(-)
drivers/gpu/drm/panfrost/panfrost_device.c +0 -1
@@ -206,7 +206,6 @@ int panfrost_device_init(struct panfroststruct resource *res;mutex_init (&pfdev->sched_lock); -mutex_init (&pfdev->reset_lock);INIT_LIST_HEAD (&pfdev->scheduled_jobs);INIT_LIST_HEAD (&pfdev->as_lru_list);
drivers/gpu/drm/panfrost/panfrost_device.h +5 -1
@@ -105,7 +105,11 @@ struct panfrost_device {struct panfrost_perfcnt *perfcnt;struct mutex sched_lock; -struct mutex reset_lock; + +struct { +struct work_struct work; +atomic_t pending; + } reset;struct mutex shrinker_lock;struct list_head shrinker_list;
drivers/gpu/drm/panfrost/panfrost_job.c +125 -62
252 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 652/717 spi: rb4xx: Dont leak SPI master in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit a4729c3506c3eb1a6ca5c0289f4e7cafa4115065 upstream.
If the calls to devm_clk_get(), devm_spi_register_master() or clk_prepare_enable() fail on probe of the Mikrotik RB4xx SPI driver, the spi_master struct is erroneously not freed.
Fix by switching over to the new devm_spi_alloc_master() helper.
--- drivers/spi/spi-rb4xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-rb4xx.c +1 -1
@@ -143,7 +143,7 @@ static int rb4xx_spi_probe(struct platfoif (IS_ERR (spi_base))return PTR_ERR (spi_base); - master =spi_alloc_master (&pdev->dev,sizeof (*rbspi)); + master =devm_spi_alloc_master (&pdev->dev,sizeof (*rbspi));if (!master)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 608/717 powerpc: Fix incorrect stw{, ux, u, x} instructions in __set_pte_at
In reply to Greg Kroah-HartmanFrom: Mathieu Desnoyers <[email protected]>
commit d85be8a49e733dcd23674aa6202870d54bf5600d upstream.
The placeholder for instruction selection should use the second argument's operand, which is %1, not %0. This could generate incorrect assembly code if the memory addressing of operand %0 is a different form from that of operand %1.
Also remove the %Un placeholder because having %Un placeholders for two operands which are based on the same local var (ptep) doesn't make much sense. By the way, it doesn't change the current behaviour because "<>" constraint is missing for the associated "=m".
[chleroy: revised commit log iaw segher's comments and removed %U0]
--- arch/powerpc/include/asm/book3s/32/pgtable.h | 4 ++-- arch/powerpc/include/asm/nohash/pgtable.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/book3s/32/pgtable.h +2 -2
@@ -524,9 +524,9 @@ static inline void __set_pte_at(struct mif (pte_val (*ptep) & _PAGE_HASHPTE)flush_hash_entry (mm, ptep, addr); __asm__ __volatile__("\ -stw%U0%X0 %2,%0\n\ +stw%X0 %2,%0\n\ eieio\n\ -stw%U0%X0 %L2,%1" +stw%X1 %L2,%1" :"=m" (*ptep),"=m" (*((unsigned char *)ptep+4 )) :"r" (pte) :"memory" );
arch/powerpc/include/asm/nohash/pgtable.h +2 -2
@@ -192,9 +192,9 @@ static inline void __set_pte_at(struct m*/ if (IS_ENABLED (CONFIG_PPC32 ) &&IS_ENABLED (CONFIG_PTE_64BIT ) && !percpu) { __asm__ __volatile__("\ -stw%U0%X0 %2,%0\n\ +stw%X0 %2,%0\n\ eieio\n\ -stw%U0%X0 %L2,%1" +stw%X1 %L2,%1" :"=m" (*ptep),"=m" (*((unsigned char *)ptep+4 )) :"r" (pte) :"memory" );return ;
Greg Kroah-Hartman
maintainerPATCH 612/717 powerpc/xmon: Change printk() to pr_cont()
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 7c6c86b36a36dd4a13d30bba07718e767aa2e7a1 upstream.
Since some time now, printk() adds carriage return, leading to unusable xmon output if there is no udbg backend available:
[ 54.288722] sysrq: Entering xmon [ 54.292209] Vector: 0 at [cace3d2c] [ 54.292274] pc: [ 54.292331] c0023650 [ 54.292468] : xmon+0x28/0x58 [ 54.292519] [ 54.292574] lr: [ 54.292630] c0023724 [ 54.292749] : sysrq_handle_xmon+0xa4/0xfc [ 54.292801] [ 54.292867] sp: cace3de8 [ 54.292931] msr: 9032 [ 54.292999] current = 0xc28d0000 [ 54.293072] pid = 377, comm = sh [ 54.293157] Linux version 5.10.0-rc6-s3k-dev-01364-gedf13f0ccd76-dirty ([email protected]) (powerpc64-linux-gcc (GCC) 10.1.0, GNU ld (GNU Binutils) 2.34) #4211 PREEMPT Fri Dec 4 09:32:11 UTC 2020 [ 54.293287] enter ? for help [ 54.293470] [cace3de8] [ 54.293532] c0023724 [ 54.293654] sysrq_handle_xmon+0xa4/0xfc [ 54.293711] (unreliable) ... [ 54.296002] [ 54.296159] --- Exception: c01 (System Call) at [ 54.296217] 0fd4e784 [ 54.296303] [ 54.296375] SP (7fca6ff0) is in userspace [ 54.296431] mon> [ 54.296484] <no input ...>
Use pr_cont() instead.
--- arch/powerpc/xmon/nonstdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/xmon/nonstdio.c +1 -1
@@ -178,7 +178,7 @@ void xmon_printf(const char *format, ...if (n && rc ==0 ) {/* No udbg hooks, fallback to printk() - dangerous */ -printk ("%s" , xmon_outbuf); +pr_cont ("%s" , xmon_outbuf); } }
Greg Kroah-Hartman
maintainerPATCH 613/717 powerpc/8xx: Fix early debug when SMC1 is relocated
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 1e78f723d6a52966bfe3804209dbf404fdc9d3bb upstream.
When SMC1 is relocated and early debug is selected, the board hangs is ppc_md.setup_arch(). This is because ones the microcode has been loaded and SMC1 relocated, early debug writes in the weed.
To allow smooth continuation, the SMC1 parameter RAM set up by the bootloader have to be copied into the new location.
--- arch/powerpc/include/asm/cpm1.h | 1 + arch/powerpc/platforms/8xx/micropatch.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
arch/powerpc/include/asm/cpm1.h +1 -0
@@ -68,6 +68,7 @@ extern void cpm_reset(void);#define PROFF_SPI ((uint)0x0180)#define PROFF_SCC3 ((uint)0x0200)#define PROFF_SMC1 ((uint)0x0280) +#define PROFF_DSP1 ((uint)0x02c0)#define PROFF_SCC4 ((uint)0x0300)#define PROFF_SMC2 ((uint)0x0380)
arch/powerpc/platforms/8xx/micropatch.c +11 -0
@@ -360,6 +360,17 @@ void __init cpm_load_patch(cpm8xx_t *cp)if (IS_ENABLED (CONFIG_SMC_UCODE_PATCH )) {smc_uart_t *smp; +if (IS_ENABLED (CONFIG_PPC_EARLY_DEBUG_CPM )) { +int i; + +for (i =0 ; i <sizeof (*smp); i +=4 ) { +u32 __iomem *src = (u32 __iomem *)&cp->cp_dparam[PROFF_SMC1 + i]; +u32 __iomem *dst = (u32 __iomem *)&cp->cp_dparam[PROFF_DSP1 + i]; + +out_be32 (dst,in_be32 (src)); + } + } + smp = (smc_uart_t *)&cp->cp_dparam[PROFF_SMC1 ];out_be16 (&smp->smc_rpbase,0x1ec0 ); smp = (smc_uart_t *)&cp->cp_dparam[PROFF_SMC2 ];
Greg Kroah-Hartman
maintainerPATCH 614/717 powerpc/mm: Fix verification of MMU_FTR_TYPE_44x
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 17179aeb9d34cc81e1a4ae3f85e5b12b13a1f8d0 upstream.
MMU_FTR_TYPE_44x cannot be checked by cpu_has_feature()
Use mmu_has_feature() instead
--- arch/powerpc/mm/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/mem.c +1 -1
@@ -532,7 +532,7 @@ void __flush_dcache_icache(void *p)* space occurs, before returning to user space. */ -if (cpu_has_feature (MMU_FTR_TYPE_44x)) +if (mmu_has_feature (MMU_FTR_TYPE_44x))return ;invalidate_icache_range (addr, addr +PAGE_SIZE );
Greg Kroah-Hartman
maintainerPATCH 656/717 spi: spi-qcom-qspi: Fix use-after-free on unbind
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 6cfd39e212dee2e77a0227ce4e0f55fa06d79f46 upstream.
qcom_qspi_remove() accesses the driver's private data after calling spi_unregister_master() even though that function releases the last reference on the spi_master and thereby frees the private data.
Fix by switching over to the new devm_spi_alloc_master() helper which keeps the private data accessible until the driver has unbound.
--- drivers/spi/spi-qcom-qspi.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-)
drivers/spi/spi-qcom-qspi.c +16 -26
@@ -462,7 +462,7 @@ static int qcom_qspi_probe(struct platfo dev = &pdev->dev; - master =spi_alloc_master (dev,sizeof (*ctrl)); + master =devm_spi_alloc_master (dev,sizeof (*ctrl));if (!master)return -ENOMEM ;
@@ -473,54 +473,49 @@ static int qcom_qspi_probe(struct platfospin_lock_init (&ctrl->lock); ctrl->dev = dev; ctrl->base =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (ctrl->base)) { - ret =PTR_ERR (ctrl->base); - goto exit_probe_master_put; - } +if (IS_ERR (ctrl->base)) +return PTR_ERR (ctrl->base); ctrl->clks =devm_kcalloc (dev,QSPI_NUM_CLKS ,sizeof (*ctrl->clks),GFP_KERNEL ); -if (!ctrl->clks) { - ret = -ENOMEM ; - goto exit_probe_master_put; - } +if (!ctrl->clks) +return -ENOMEM ; ctrl->clks[QSPI_CLK_CORE ].id ="core" ; ctrl->clks[QSPI_CLK_IFACE ].id ="iface" ; ret =devm_clk_bulk_get (dev,QSPI_NUM_CLKS , ctrl->clks);if (ret) - goto exit_probe_master_put; +return ret; ctrl->icc_path_cpu_to_qspi =devm_of_icc_get (dev,"qspi-config" ); -if (IS_ERR (ctrl->icc_path_cpu_to_qspi)) { - ret =dev_err_probe (dev,PTR_ERR (ctrl->icc_path_cpu_to_qspi), -"Failed to get cpu path\n" ); - goto exit_probe_master_put; - } +if (IS_ERR (ctrl->icc_path_cpu_to_qspi)) +return dev_err_probe (dev,PTR_ERR (ctrl->icc_path_cpu_to_qspi), +"Failed to get cpu path\n" ); +/* Set BW vote for register access */ ret =icc_set_bw (ctrl->icc_path_cpu_to_qspi,Bps_to_icc (1000 ),Bps_to_icc (1000 ));if (ret) {dev_err (ctrl->dev,"%s: ICC BW voting failed for cpu: %d\n" , __func__, ret); - goto exit_probe_master_put; +return ret; } ret =icc_disable (ctrl->icc_path_cpu_to_qspi);if (ret) {dev_err (ctrl->dev,"%s: ICC disable failed for cpu: %d\n" , __func__, ret); - goto exit_probe_master_put; +return ret; } ret =platform_get_irq (pdev,0 );if (ret <0 ) - goto exit_probe_master_put; +return ret; ret =devm_request_irq (dev, ret, qcom_qspi_irq,IRQF_TRIGGER_HIGH ,dev_name (dev), ctrl);if (ret) {dev_err (dev,"Failed to request irq %d\n" , ret); - goto exit_probe_master_put; +return ret; } master->max_speed_hz =300000000 ;
@@ -537,10 +532,8 @@ static int qcom_qspi_probe(struct platfo master->auto_runtime_pm = true; ctrl->opp_table =dev_pm_opp_set_clkname (&pdev->dev,"core" ); -if (IS_ERR (ctrl->opp_table)) { - ret =PTR_ERR (ctrl->opp_table); - goto exit_probe_master_put; - } +if (IS_ERR (ctrl->opp_table)) +return PTR_ERR (ctrl->opp_table);/* OPP table is optional */ ret =dev_pm_opp_of_add_table (&pdev->dev);if (ret && ret != -ENODEV ) {
@@ -562,9 +555,6 @@ static int qcom_qspi_probe(struct platfo exit_probe_put_clkname:dev_pm_opp_put_clkname (ctrl->opp_table); -exit_probe_master_put: -spi_master_put (master); -return ret; }
Greg Kroah-Hartman
maintainerPATCH 659/717 spi: mt7621: Disable clock in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 24f7033405abe195224ec793dbc3d7a27dec0b98 upstream.
Commit 702b15cb9712 ("spi: mt7621: fix missing clk_disable_unprepare() on error in mt7621_spi_probe") sought to disable the SYS clock on probe errors, but only did so for 2 of 3 potentially failing calls: The clock needs to be disabled on failure of devm_spi_register_controller() as well.
Moreover, the commit purports to fix a bug in commit cbd66c626e16 ("spi:
mt7621: Move SPI driver out of staging") but in reality the bug has existed since the driver was first introduced.
--- drivers/spi/spi-mt7621.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/spi/spi-mt7621.c +5 -1
@@ -382,7 +382,11 @@ static int mt7621_spi_probe(struct platfreturn ret; } -return devm_spi_register_controller (&pdev->dev, master); + ret =devm_spi_register_controller (&pdev->dev, master); +if (ret) +clk_disable_unprepare (clk); + +return ret; }static int mt7621_spi_remove (struct platform_device *pdev)
Greg Kroah-Hartman
maintainerPATCH 651/717 spi: pic32: Dont leak DMA channels in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit c575e9113bff5e024d75481613faed5ef9d465b2 upstream.
If the calls to devm_request_irq() or devm_spi_register_master() fail on probe of the PIC32 SPI driver, the DMA channels requested by pic32_spi_dma_prep() are erroneously not released. Plug the leak.
--- drivers/spi/spi-pic32.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-pic32.c +1 -0
@@ -839,6 +839,7 @@ static int pic32_spi_probe(struct platforeturn 0 ; err_bailout: +pic32_spi_dma_unprep (pic32s);clk_disable_unprepare (pic32s->clk); err_master:spi_master_put (master);
Greg Kroah-Hartman
maintainerPATCH 655/717 spi: spi-geni-qcom: Fix use-after-free on unbind
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 8f96c434dfbc85ffa755d6634c8c1cb2233fcf24 upstream.
spi_geni_remove() accesses the driver's private data after calling spi_unregister_master() even though that function releases the last reference on the spi_master and thereby frees the private data.
Moreover, since commit 1a9e489e6128 ("spi: spi-geni-qcom: Use OPP API to set clk/perf state"), spi_geni_probe() leaks the spi_master allocation if the calls to dev_pm_opp_set_clkname() or dev_pm_opp_of_add_table() fail.
Fix by switching over to the new devm_spi_alloc_master() helper which keeps the private data accessible until the driver has unbound and also avoids the spi_master leak on probe.
--- drivers/spi/spi-geni-qcom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-geni-qcom.c +1 -2
@@ -603,7 +603,7 @@ static int spi_geni_probe(struct platforif (IS_ERR (clk))return PTR_ERR (clk); - spi =spi_alloc_master (dev,sizeof (*mas)); + spi =devm_spi_alloc_master (dev,sizeof (*mas));if (!spi)return -ENOMEM ;
@@ -673,7 +673,6 @@ spi_geni_probe_free_irq:free_irq (mas->irq, spi); spi_geni_probe_runtime_disable:pm_runtime_disable (dev); -spi_master_put (spi);dev_pm_opp_of_remove_table (&pdev->dev); put_clkname:dev_pm_opp_put_clkname (mas->se.opp_table);
Greg Kroah-Hartman
maintainerPATCH 660/717 spi: mt7621: Dont leak SPI master in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 46b5c4fb87ce8211e0f9b0383dbde72c3652d2ba upstream.
If the calls to device_reset() or devm_spi_register_controller() fail on probe of the MediaTek MT7621 SPI driver, the spi_controller struct is erroneously not freed. Fix by switching over to the new devm_spi_alloc_master() helper.
Additionally, there's an ordering issue in mt7621_spi_remove() wherein the spi_controller is unregistered after disabling the SYS clock. The correct order is to call spi_unregister_controller() *before* this teardown step because bus accesses may still be ongoing until that function returns.
All of these bugs have existed since the driver was first introduced, so it seems fair to fix them together in a single commit.
--- drivers/spi/spi-mt7621.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi-mt7621.c +3 -2
@@ -350,7 +350,7 @@ static int mt7621_spi_probe(struct platfif (status)return status; - master =spi_alloc_master (&pdev->dev,sizeof (*rs)); + master =devm_spi_alloc_master (&pdev->dev,sizeof (*rs));if (!master) {dev_info (&pdev->dev,"master allocation failed\n" );clk_disable_unprepare (clk);
@@ -382,7 +382,7 @@ static int mt7621_spi_probe(struct platfreturn ret; } - ret =devm_spi_register_controller (&pdev->dev, master); + ret =spi_register_controller (master);if (ret)clk_disable_unprepare (clk);
@@ -397,6 +397,7 @@ static int mt7621_spi_remove(struct plat master =dev_get_drvdata (&pdev->dev); rs =spi_controller_get_devdata (master); +spi_unregister_controller (master);clk_disable_unprepare (rs->clk);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 661/717 spi: atmel-quadspi: Disable clock in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 0e685017c7ba1a2fe9f6f1e7a9302890747d934c upstream.
If the call to of_device_get_match_data() fails on probe of the Atmel QuadSPI driver, the clock "aq->pclk" is erroneously not unprepared and disabled. Fix it.
--- drivers/spi/atmel-quadspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/atmel-quadspi.c +1 -1
@@ -591,7 +591,7 @@ static int atmel_qspi_probe(struct platfif (!aq->caps) {dev_err (&pdev->dev,"Could not retrieve QSPI caps\n" ); err = -EINVAL ; - goto exit; + goto disable_pclk; }if (aq->caps->has_qspick) {
Greg Kroah-Hartman
maintainerPATCH 665/717 mtd: parser: cmdline: Fix parsing of part-names with colons
In reply to Greg Kroah-HartmanFrom: Sven Eckelmann <[email protected]>
commit 639a82434f16a6df0ce0e7c8595976f1293940fd upstream.
Some devices (especially QCA ones) are already using hardcoded partition names with colons in it. The OpenMesh A62 for example provides following mtd relevant information via cmdline:
root=31:11 mtdparts=spi0.0:256k(0:SBL1),128k(0:MIBIB),384k(0:QSEE),64k(0:CDT),64k(0:DDRPARAMS),64k(0:APPSBLENV),512k(0:APPSBL),64k(0:ART),64k(custom),64k(0:KEYS),0x002b0000(kernel),0x00c80000(rootfs),15552k(inactive) rootfsname=rootfs rootwait
The change to split only on the last colon between mtd-id and partitions will cause newpart to see following string for the first partition:
KEYS),0x002b0000(kernel),0x00c80000(rootfs),15552k(inactive)
Such a partition list cannot be parsed and thus the device fails to boot.
Avoid this behavior by making sure that the start of the first part-name ("(") will also be the last byte the mtd-id split algorithm is using for its colon search.
--- drivers/mtd/parsers/cmdlinepart.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/mtd/parsers/cmdlinepart.c +13 -1
@@ -226,7 +226,7 @@ static int mtdpart_setup_real(char *s)struct cmdline_mtd_partition *this_mtd;struct mtd_partition *parts;int mtd_id_len, num_parts; -char *p, *mtd_id, *semicol; +char *p, *mtd_id, *semicol, *open_parenth;/* * Replace the first ';' by a NULL char so strrchr can work
@@ -236,6 +236,14 @@ static int mtdpart_setup_real(char *s)if (semicol) *semicol ='\0' ; +/* +* make sure that part-names with ":" will not be handled as +* part of the mtd-id with an ":" +*/ + open_parenth =strchr (s,'(' ); +if (open_parenth) + *open_parenth ='\0' ; + mtd_id = s;/*
@@ -245,6 +253,10 @@ static int mtdpart_setup_real(char *s)*/ p =strrchr (s,':' ); +/* Restore the '(' now. */ +if (open_parenth) + *open_parenth ='(' ; +/* Restore the ';' now. */ if (semicol) *semicol =';' ;
Greg Kroah-Hartman
maintainerPATCH 643/717 spi: atmel-quadspi: Fix use-after-free on unbind
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit c7b884561cb5b641f3dbba950094110794119a6d upstream.
atmel_qspi_remove() accesses the driver's private data after calling spi_unregister_controller() even though that function releases the last reference on the spi_controller and thereby frees the private data.
Fix by switching over to the new devm_spi_alloc_master() helper which keeps the private data accessible until the driver has unbound.
--- drivers/spi/atmel-quadspi.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/spi/atmel-quadspi.c +5 -10
@@ -535,7 +535,7 @@ static int atmel_qspi_probe(struct platfstruct resource *res;int irq, err =0 ; - ctrl =spi_alloc_master (&pdev->dev,sizeof (*aq)); + ctrl =devm_spi_alloc_master (&pdev->dev,sizeof (*aq));if (!ctrl)return -ENOMEM ;
@@ -557,8 +557,7 @@ static int atmel_qspi_probe(struct platf aq->regs =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (aq->regs)) {dev_err (&pdev->dev,"missing registers\n" ); - err =PTR_ERR (aq->regs); - goto exit; +return PTR_ERR (aq->regs); }/* Map the AHB memory */
@@ -566,8 +565,7 @@ static int atmel_qspi_probe(struct platf aq->mem =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (aq->mem)) {dev_err (&pdev->dev,"missing AHB memory\n" ); - err =PTR_ERR (aq->mem); - goto exit; +return PTR_ERR (aq->mem); } aq->mmap_size =resource_size (res);
@@ -579,15 +577,14 @@ static int atmel_qspi_probe(struct platfif (IS_ERR (aq->pclk)) {dev_err (&pdev->dev,"missing peripheral clock\n" ); - err =PTR_ERR (aq->pclk); - goto exit; +return PTR_ERR (aq->pclk); }/* Enable the peripheral clock */ err =clk_prepare_enable (aq->pclk);if (err) {dev_err (&pdev->dev,"failed to enable the peripheral clock\n" ); - goto exit; +return err; } aq->caps =of_device_get_match_data (&pdev->dev);
@@ -638,8 +635,6 @@ disable_qspick:clk_disable_unprepare (aq->qspick); disable_pclk:clk_disable_unprepare (aq->pclk); -exit: -spi_controller_put (ctrl);return err; }
Greg Kroah-Hartman
maintainerPATCH 662/717 spi: atmel-quadspi: Fix AHB memory accesses
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
commit cac8c821059639b015586abf61623c62cc549a13 upstream.
Following error was seen when mounting a 16MByte ubifs:
UBIFS error (ubi0:0 pid 1893): check_lpt_type.constprop.6: invalid type (15) in LPT node type
QSPI_IFR.TFRTYP was not set correctly. When data transfer is enabled and one wants to access the serial memory through AHB in order to:
- read in the serial memory, but not a memory data, for example a JEDEC-ID, QSPI_IFR.TFRTYP must be written to '0' (both sama5d2 and sam9x60).
- read in the serial memory, and particularly a memory data, TFRTYP must be written to '1' (both sama5d2 and sam9x60).
- write in the serial memory, but not a memory data, for example writing the configuration or the QSPI_SR, TFRTYP must be written to '2' for sama5d2 and to '0' for sam9x60.
- write in the serial memory in particular to program a memory data, TFRTYP must be written to '3' for sama5d2 and to '1' for sam9x60.
Fix the setting of the QSPI_IFR.TFRTYP field.
--- drivers/spi/atmel-quadspi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/spi/atmel-quadspi.c +7 -3
@@ -365,10 +365,14 @@ static int atmel_qspi_set_cfg(struct atmif (dummy_cycles) ifr |=QSPI_IFR_NBDUM (dummy_cycles); -/* Set data enable */ -if (op->data.nbytes) +/* Set data enable and data transfer type. */ +if (op->data.nbytes) { ifr |=QSPI_IFR_DATAEN ; +if (op->addr.nbytes) + ifr |=QSPI_IFR_TFRTYP_MEM ; + } +/* * If the QSPI controller is set in regular SPI mode, set it in * Serial Memory Mode (SMM).
@@ -393,7 +397,7 @@ static int atmel_qspi_set_cfg(struct atmatmel_qspi_write (icr, aq,QSPI_WICR );atmel_qspi_write (ifr, aq,QSPI_IFR ); }else { -if (op->data.dir ==SPI_MEM_DATA_OUT ) +if (op->data.nbytes && op->data.dir ==SPI_MEM_DATA_OUT ) ifr |=QSPI_IFR_SAMA5D2_WRITE_TRSFR ;/* Set QSPI Instruction Frame registers */
Greg Kroah-Hartman
maintainerPATCH 669/717 scsi: qla2xxx: Fix crash during driver load on big endian machines
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 8de309e7299a00b3045fb274f82b326f356404f0 upstream.
Crash stack:
[576544.715489] Unable to handle kernel paging request for data at address 0xd00000000f970000 [576544.715497] Faulting instruction address: 0xd00000000f880f64 [576544.715503] Oops: Kernel access of bad area, sig: 11 [#1] [576544.715506] SMP NR_CPUS=2048 NUMA pSeries : [576544.715703] NIP [d00000000f880f64] .qla27xx_fwdt_template_valid+0x94/0x100 [qla2xxx] [576544.715722] LR [d00000000f7952dc] .qla24xx_load_risc_flash+0x2fc/0x590 [qla2xxx] [576544.715726] Call Trace: [576544.715731] [c0000004d0ffb000] [c0000006fe02c350] 0xc0000006fe02c350 (unreliable) [576544.715750] [c0000004d0ffb080] [d00000000f7952dc] .qla24xx_load_risc_flash+0x2fc/0x590 [qla2xxx] [576544.715770] [c0000004d0ffb170] [d00000000f7aa034] .qla81xx_load_risc+0x84/0x1a0 [qla2xxx] [576544.715789] [c0000004d0ffb210] [d00000000f79f7c8] .qla2x00_setup_chip+0xc8/0x910 [qla2xxx] [576544.715808] [c0000004d0ffb300] [d00000000f7a631c] .qla2x00_initialize_adapter+0x4dc/0xb00 [qla2xxx] [576544.715826] [c0000004d0ffb3e0] [d00000000f78ce28] .qla2x00_probe_one+0xf08/0x2200 [qla2xxx]
--- drivers/scsi/qla2xxx/qla_tmpl.c | 9 +++++---- drivers/scsi/qla2xxx/qla_tmpl.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/scsi/qla2xxx/qla_tmpl.c +5 -4
@@ -928,7 +928,8 @@ qla27xx_template_checksum(void *p, ulongstatic inline int qla27xx_verify_template_checksum (struct qla27xx_fwdt_template *tmp) { -return qla27xx_template_checksum (tmp, tmp->template_size) ==0 ; +return qla27xx_template_checksum (tmp, +le32_to_cpu (tmp->template_size)) ==0 ; } static inline int
@@ -944,7 +945,7 @@ qla27xx_execute_fwdt_template(struct scsulong len =0 ;if (qla27xx_fwdt_template_valid (tmp)) { - len = tmp->template_size; + len =le32_to_cpu (tmp->template_size); tmp =memcpy (buf, tmp, len);ql27xx_edit_template (vha, tmp);qla27xx_walk_template (vha, tmp, buf, &len);
@@ -960,7 +961,7 @@ qla27xx_fwdt_calculate_dump_size(structulong len =0 ;if (qla27xx_fwdt_template_valid (tmp)) { - len = tmp->template_size; + len =le32_to_cpu (tmp->template_size);qla27xx_walk_template (vha, tmp,NULL , &len); }
@@ -972,7 +973,7 @@ qla27xx_fwdt_template_size(void *p) {struct qla27xx_fwdt_template *tmp = p; -return tmp->template_size; +return le32_to_cpu (tmp->template_size); }int
drivers/scsi/qla2xxx/qla_tmpl.h +1 -1
@@ -12,7 +12,7 @@struct __packed qla27xx_fwdt_template {__le32 template_type;__le32 entry_offset; -uint32_t template_size; +__le32 template_size;uint32_t count;/* borrow field for running/residual count */ __le32 entry_count;
Greg Kroah-Hartman
maintainerPATCH 654/717 spi: sc18is602: Dont leak SPI master in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 5b8c88462d83331dacb48aeaec8388117fef82e0 upstream.
If the call to devm_gpiod_get_optional() fails on probe of the NXP SC18IS602/603 SPI driver, the spi_master struct is erroneously not freed.
Fix by switching over to the new devm_spi_alloc_master() helper.
--- drivers/spi/spi-sc18is602.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/spi/spi-sc18is602.c +2 -11
@@ -238,13 +238,12 @@ static int sc18is602_probe(struct i2c_clstruct sc18is602_platform_data *pdata =dev_get_platdata (dev);struct sc18is602 *hw;struct spi_master *master; -int error;if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C |I2C_FUNC_SMBUS_WRITE_BYTE_DATA ))return -EINVAL ; - master =spi_alloc_master (dev,sizeof (struct sc18is602 )); + master =devm_spi_alloc_master (dev,sizeof (struct sc18is602 ));if (!master)return -ENOMEM ;
@@ -298,15 +297,7 @@ static int sc18is602_probe(struct i2c_cl master->min_speed_hz = hw->freq /128 ; master->max_speed_hz = hw->freq /4 ; - error =devm_spi_register_master (dev, master); -if (error) - goto error_reg; - -return 0 ; - -error_reg: -spi_master_put (master); -return error; +return devm_spi_register_master (dev, master); }static const struct i2c_device_id sc18is602_id[] = {
Greg Kroah-Hartman
maintainerPATCH 658/717 spi: synquacer: Disable clock in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 8853b2503014aca5c793d2c7f0aabc990b32bdad upstream.
If the calls to platform_get_irq() or devm_request_irq() fail on probe of the SynQuacer SPI driver, the clock "sspi->clk" is erroneously not unprepared and disabled.
If the clock rate "master->max_speed_hz" cannot be determined, the same happens and in addition the spi_master struct is not freed.
Fix it.
--- drivers/spi/spi-synquacer.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/spi/spi-synquacer.c +8 -7
@@ -657,7 +657,8 @@ static int synquacer_spi_probe(struct plif (!master->max_speed_hz) {dev_err (&pdev->dev,"missing clock source\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto disable_clk; } master->min_speed_hz = master->max_speed_hz /254 ;
@@ -670,7 +671,7 @@ static int synquacer_spi_probe(struct pl rx_irq =platform_get_irq (pdev,0 );if (rx_irq <=0 ) { ret = rx_irq; - goto put_spi; + goto disable_clk; }snprintf (sspi->rx_irq_name,SYNQUACER_HSSPI_IRQ_NAME_MAX ,"%s-rx" ,dev_name (&pdev->dev));
@@ -678,13 +679,13 @@ static int synquacer_spi_probe(struct pl 0, sspi->rx_irq_name, sspi);if (ret) {dev_err (&pdev->dev,"request rx_irq failed (%d)\n" , ret); - goto put_spi; + goto disable_clk; } tx_irq =platform_get_irq (pdev,1 );if (tx_irq <=0 ) { ret = tx_irq; - goto put_spi; + goto disable_clk; }snprintf (sspi->tx_irq_name,SYNQUACER_HSSPI_IRQ_NAME_MAX ,"%s-tx" ,dev_name (&pdev->dev));
@@ -692,7 +693,7 @@ static int synquacer_spi_probe(struct pl 0, sspi->tx_irq_name, sspi);if (ret) {dev_err (&pdev->dev,"request tx_irq failed (%d)\n" , ret); - goto put_spi; + goto disable_clk; } master->dev.of_node = np;
@@ -710,7 +711,7 @@ static int synquacer_spi_probe(struct pl ret =synquacer_spi_enable (master);if (ret) - goto fail_enable; + goto disable_clk;pm_runtime_set_active (sspi->dev);pm_runtime_enable (sspi->dev);
@@ -723,7 +724,7 @@ static int synquacer_spi_probe(struct pl disable_pm:pm_runtime_disable (sspi->dev); -fail_enable: +disable_clk:clk_disable_unprepare (sspi->clk); put_spi:spi_master_put (master);
Greg Kroah-Hartman
maintainerPATCH 663/717 soc: qcom: smp2p: Safely acquire spinlock without IRQs
In reply to Greg Kroah-HartmanFrom: Evan Green <[email protected]>
commit fc3e62e25c3896855b7c3d72df19ca6be3459c9f upstream.
smp2p_update_bits() should disable interrupts when it acquires its spinlock. This is important because without the _irqsave, a priority inversion can occur.
This function is called both with interrupts enabled in qcom_q6v5_request_stop(), and with interrupts disabled in ipa_smp2p_panic_notifier(). IRQ handling of spinlocks should be consistent to avoid the panic notifier deadlocking because it's sitting on the thread that's already got the lock via _request_stop().
Found via lockdep.
--- drivers/soc/qcom/smp2p.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/soc/qcom/smp2p.c +3 -2
@@ -318,15 +318,16 @@ static int qcom_smp2p_inbound_entry(strustatic int smp2p_update_bits (void *data,u32 mask,u32 value) {struct smp2p_entry *entry = data; +unsigned long flags;u32 orig;u32 val; -spin_lock (&entry->lock); +spin_lock_irqsave (&entry->lock, flags); val = orig =readl (entry->value); val &= ~mask; val |= value;writel (val, entry->value); -spin_unlock (&entry->lock); +spin_unlock_irqrestore (&entry->lock, flags);if (val != orig)qcom_smp2p_kick (entry->smp2p);
Greg Kroah-Hartman
maintainerPATCH 666/717 mtd: core: Fix refcounting for unpartitioned MTDs
In reply to Greg Kroah-HartmanFrom: Richard Weinberger <[email protected]>
commit 1ca71415f075353974524e96ed175306d8a937a8 upstream.
Apply changes to usecount also to the master partition. Otherwise we have no refcounting at all if an MTD has no partitions.
--- drivers/mtd/mtdcore.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mtd/mtdcore.c +4 -0
@@ -993,6 +993,8 @@ int __get_mtd_device(struct mtd_info *mt } } + master->usecount++; +while (mtd->parent) { mtd->usecount++; mtd = mtd->parent;
@@ -1059,6 +1061,8 @@ void __put_mtd_device(struct mtd_info *m mtd = mtd->parent; } + master->usecount--; +if (master->_put_device) master->_put_device (master);
Greg Kroah-Hartman
maintainerPATCH 667/717 mtd: rawnand: qcom: Fix DMA sync on FLASH_STATUS register read
In reply to Greg Kroah-HartmanFrom: Praveenkumar I <[email protected]>
commit bc3686021122de953858a5be4cbf6e3f1d821e79 upstream.
After each codeword NAND_FLASH_STATUS is read for possible operational failures. But there is no DMA sync for CPU operation before reading it and this leads to incorrect or older copy of DMA buffer in reg_read_buf.
This patch adds the DMA sync on reg_read_buf for CPU before reading it.
--- drivers/mtd/nand/raw/qcom_nandc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/nand/raw/qcom_nandc.c +2 -0
@@ -1570,6 +1570,8 @@ static int check_flash_errors(struct qcostruct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);int i; +nandc_read_buffer_sync (nandc, true); +for (i =0 ; i < cw_cnt; i++) {u32 flash =le32_to_cpu (nandc->reg_read_buf[i]);
Greg Kroah-Hartman
maintainerPATCH 668/717 mtd: rawnand: meson: fix meson_nfc_dma_buffer_release() arguments
In reply to Greg Kroah-HartmanFrom: Sergei Antonov <[email protected]>
commit c13d845e9a69580424d40b7b101c37d4f71bcd63 upstream.
Arguments 'infolen' and 'datalen' to meson_nfc_dma_buffer_release() were mixed up.
--- drivers/mtd/nand/raw/meson_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/meson_nand.c +1 -1
@@ -510,7 +510,7 @@ static int meson_nfc_dma_buffer_setup(st }static void meson_nfc_dma_buffer_release (struct nand_chip *nand, -int infolen,int datalen, +int datalen,int infolen,enum dma_data_direction dir) {struct meson_nfc *nfc =nand_get_controller_data (nand);
Greg Kroah-Hartman
maintainerPATCH 671/717 scsi: lpfc: Fix scheduling call while in softirq context in lpfc_unreg_rpi
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
commit e7dab164a9aa457f89d4528452bdfc3e15ac98b6 upstream.
The following call trace was seen during HBA reset testing:
BUG: scheduling while atomic: swapper/2/0/0x10000100 ... Call Trace: dump_stack+0x19/0x1b __schedule_bug+0x64/0x72 __schedule+0x782/0x840 __cond_resched+0x26/0x30 _cond_resched+0x3a/0x50 mempool_alloc+0xa0/0x170 lpfc_unreg_rpi+0x151/0x630 [lpfc] lpfc_sli_abts_recover_port+0x171/0x190 [lpfc] lpfc_sli4_abts_err_handler+0xb2/0x1f0 [lpfc] lpfc_sli4_io_xri_aborted+0x256/0x300 [lpfc] lpfc_sli4_sp_handle_abort_xri_wcqe.isra.51+0xa3/0x190 [lpfc] lpfc_sli4_fp_handle_cqe+0x89/0x4d0 [lpfc] __lpfc_sli4_process_cq+0xdb/0x2e0 [lpfc] __lpfc_sli4_hba_process_cq+0x41/0x100 [lpfc] lpfc_cq_poll_hdler+0x1a/0x30 [lpfc] irq_poll_softirq+0xc7/0x100 __do_softirq+0xf5/0x280 call_softirq+0x1c/0x30 do_softirq+0x65/0xa0 irq_exit+0x105/0x110 do_IRQ+0x56/0xf0 common_interrupt+0x16a/0x16a
With the conversion to blk_io_poll for better interrupt latency in normal cases, it introduced this code path, executed when I/O aborts or logouts are seen, which attempts to allocate memory for a mailbox command to be issued. The allocation is GFP_KERNEL, thus it could attempt to sleep.
Fix by creating a work element that performs the event handling for the remote port. This will have the mailbox commands and other items performed in the work element, not the irq. A much better method as the "irq" routine does not stall while performing all this deep handling code.
Ensure that allocation failures are handled and send LOGO on failure.
Additionally, enlarge the mailbox memory pool to reduce the possibility of additional allocation in this path.
--- drivers/scsi/lpfc/lpfc.h | 2 - drivers/scsi/lpfc/lpfc_disc.h | 2 + drivers/scsi/lpfc/lpfc_hbadisc.c | 35 +++++++++++++++++++++ drivers/scsi/lpfc/lpfc_init.c | 46 ++++++++++++++++------------ drivers/scsi/lpfc/lpfc_mem.c | 5 +-- drivers/scsi/lpfc/lpfc_nvme.c | 18 +++++++--- drivers/scsi/lpfc/lpfc_sli.c | 64 +++++++++++++++++++++++++++++++-------- drivers/scsi/lpfc/lpfc_sli4.h | 6 +-- 8 files changed, 136 insertions(+), 42 deletions(-)
drivers/scsi/lpfc/lpfc.h +1 -1
@@ -753,7 +753,7 @@ struct lpfc_hba {#define HBA_SP_QUEUE_EVT 0x8/* Slow-path qevt posted to worker thread*/ #define HBA_POST_RECEIVE_BUFFER 0x10/* Rcv buffers need to be posted */ #define HBA_PERSISTENT_TOPO 0x20/* Persistent topology support in hba */ -#define ELS_XRI_ABORT_EVENT 0x40 +#define ELS_XRI_ABORT_EVENT 0x40/* ELS_XRI abort event was queued */ #define ASYNC_EVENT 0x80#define LINK_DISABLED 0x100/* Link disabled by user */ #define FCF_TS_INPROG 0x200/* FCF table scan in progress */
drivers/scsi/lpfc/lpfc_disc.h +2 -0
@@ -41,6 +41,7 @@ enum lpfc_work_type {LPFC_EVT_DEV_LOSS ,LPFC_EVT_FASTPATH_MGMT_EVT ,LPFC_EVT_RESET_HBA , + LPFC_EVT_RECOVER_PORT };/* structure used to queue event to the discovery tasklet */
@@ -128,6 +129,7 @@ struct lpfc_nodelist {struct lpfc_vport *vport;struct lpfc_work_evt els_retry_evt;struct lpfc_work_evt dev_loss_evt; +struct lpfc_work_evt recovery_evt;struct kref kref;atomic_t cmd_pending;uint32_t cmd_qdepth;
drivers/scsi/lpfc/lpfc_hbadisc.c +35 -0
@@ -552,6 +552,15 @@ lpfc_work_list_done(struct lpfc_hba *phb fcf_inuse, nlp_did);break ; +case LPFC_EVT_RECOVER_PORT : + ndlp = (struct lpfc_nodelist *)(evtp->evt_arg1); +lpfc_sli_abts_recover_port (ndlp->vport, ndlp); + free_evt =0 ; +/* decrement the node reference count held for +* this queued work +*/ +lpfc_nlp_put (ndlp); +break ;case LPFC_EVT_ONLINE :if (phba->link_state <LPFC_LINK_DOWN ) *(int *) (evtp->evt_arg1) =lpfc_online (phba);
@@ -4515,6 +4524,8 @@ lpfc_initialize_node(struct lpfc_vport *INIT_LIST_HEAD (&ndlp->els_retry_evt.evt_listp);INIT_LIST_HEAD (&ndlp->dev_loss_evt.evt_listp);timer_setup (&ndlp->nlp_delayfunc, lpfc_els_retry_delay,0 ); +INIT_LIST_HEAD (&ndlp->recovery_evt.evt_listp); + ndlp->nlp_DID = did; ndlp->vport = vport; ndlp->phba = vport->phba;
@@ -5011,6 +5022,29 @@ lpfc_unreg_rpi(struct lpfc_vport *vport,mempool_free (mbox, phba->mbox_mem_pool); acc_plogi =1 ; } + }else { +lpfc_printf_vlog (vport,KERN_INFO , +LOG_NODE |LOG_DISCOVERY , +"1444 Failed to allocate mempool " +"unreg_rpi UNREG x%x, " +"DID x%x, flag x%x, " +"ndlp x%px\n" , + ndlp->nlp_rpi, ndlp->nlp_DID, + ndlp->nlp_flag, ndlp); + +/* Because mempool_alloc failed, we +* will issue a LOGO here and keep the rpi alive if +* not unloading. +*/ +if (!(vport->load_flag &FC_UNLOADING )) { + ndlp->nlp_flag &= ~NLP_UNREG_INP ; +lpfc_issue_els_logo (vport, ndlp,0 ); + ndlp->nlp_prev_state = ndlp->nlp_state; +lpfc_nlp_set_state (vport, ndlp, +NLP_STE_NPR_NODE ); + } + +return 1 ; }lpfc_no_rpi (phba, ndlp); out:
@@ -5214,6 +5248,7 @@ lpfc_cleanup_node(struct lpfc_vport *vpolist_del_init (&ndlp->els_retry_evt.evt_listp);list_del_init (&ndlp->dev_loss_evt.evt_listp); +list_del_init (&ndlp->recovery_evt.evt_listp);lpfc_cleanup_vports_rrqs (vport, ndlp);if (phba->sli_rev ==LPFC_SLI_REV4 ) ndlp->nlp_flag |=NLP_RELEASE_RPI ;
drivers/scsi/lpfc/lpfc_init.c +27 -19
94 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_mem.c +3 -2
@@ -46,6 +46,7 @@#define LPFC_MEM_POOL_SIZE 64/* max elem in non-DMA safety pool */ #define LPFC_DEVICE_DATA_POOL_SIZE 64/* max elements in device data pool */ #define LPFC_RRQ_POOL_SIZE 256/* max elements in non-DMA pool */ +#define LPFC_MBX_POOL_SIZE 256/* max elements in MBX non-DMA pool */ int lpfc_mem_alloc_active_rrq_pool_s4 (struct lpfc_hba *phba) {
@@ -111,8 +112,8 @@ lpfc_mem_alloc(struct lpfc_hba *phba, in pool->current_count++; } - phba->mbox_mem_pool =mempool_create_kmalloc_pool (LPFC_MEM_POOL_SIZE , -sizeof (LPFC_MBOXQ_t)); + phba->mbox_mem_pool =mempool_create_kmalloc_pool (LPFC_MBX_POOL_SIZE , +sizeof (LPFC_MBOXQ_t));if (!phba->mbox_mem_pool) goto fail_free_mbuf_pool;
drivers/scsi/lpfc/lpfc_nvme.c +13 -5
@@ -2280,6 +2280,8 @@ lpfc_nvme_lport_unreg_wait(struct lpfc_vint ret, i, pending =0 ;struct lpfc_sli_ring *pring;struct lpfc_hba *phba = vport->phba; +struct lpfc_sli4_hdw_queue *qp; +int abts_scsi, abts_nvme;/* Host transport has to clean up and confirm requiring an indefinite * wait. Print a message if a 10 second wait expires and renew the
@@ -2290,17 +2292,23 @@ lpfc_nvme_lport_unreg_wait(struct lpfc_v ret =wait_for_completion_timeout (lport_unreg_cmp, wait_tmo);if (unlikely (!ret)) { pending =0 ; + abts_scsi =0 ; + abts_nvme =0 ;for (i =0 ; i < phba->cfg_hdw_queue; i++) { - pring = phba->sli4_hba.hdwq[i].io_wq->pring; + qp = &phba->sli4_hba.hdwq[i]; + pring = qp->io_wq->pring;if (!pring)continue ; -if (pring->txcmplq_cnt) - pending += pring->txcmplq_cnt; + pending += pring->txcmplq_cnt; + abts_scsi += qp->abts_scsi_io_bufs; + abts_nvme += qp->abts_nvme_io_bufs; }lpfc_printf_vlog (vport,KERN_ERR ,LOG_TRACE_EVENT ,"6176 Lport x%px Localport x%px wait " -"timed out. Pending %d. Renewing.\n" , - lport, vport->localport, pending); +"timed out. Pending %d [%d:%d]. " +"Renewing.\n" , + lport, vport->localport, pending, + abts_scsi, abts_nvme);continue ; }break ;
drivers/scsi/lpfc/lpfc_sli.c +52 -12
114 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_sli4.h +3 -3
@@ -920,8 +920,9 @@ struct lpfc_sli4_hba {struct list_head sp_queue_event;struct list_head sp_cqe_event_pool;struct list_head sp_asynce_work_queue; -struct list_head sp_fcp_xri_aborted_work_queue; +spinlock_t asynce_list_lock;/* protect sp_asynce_work_queue list */ struct list_head sp_els_xri_aborted_work_queue; +spinlock_t els_xri_abrt_list_lock;/* protect els_xri_aborted list */ struct list_head sp_unsol_work_queue;struct lpfc_sli4_link link_state;struct lpfc_sli4_lnk_info lnk_info;
@@ -1103,8 +1104,7 @@ void lpfc_sli4_async_event_proc(struct lvoid lpfc_sli4_fcf_redisc_event_proc (struct lpfc_hba *);int lpfc_sli4_resume_rpi (struct lpfc_nodelist *,void (*)(struct lpfc_hba *,LPFC_MBOXQ_t *),void *); -void lpfc_sli4_fcp_xri_abort_event_proc (struct lpfc_hba *); -void lpfc_sli4_els_xri_abort_event_proc (struct lpfc_hba *); +void lpfc_sli4_els_xri_abort_event_proc (struct lpfc_hba *phba);void lpfc_sli4_nvme_xri_aborted (struct lpfc_hba *phba,struct sli4_wcqe_xri_aborted *axri,struct lpfc_io_buf *lpfc_ncmd);
Greg Kroah-Hartman
maintainerPATCH 645/717 spi: ar934x: Dont leak SPI master in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 236924ee531d6251c8d10e9177b7742a60534ed5 upstream.
If the call to devm_spi_register_controller() fails on probe of the Qualcomm Atheros AR934x/QCA95xx SPI driver, the spi_controller struct is erroneously not freed. Fix by switching over to the new devm_spi_alloc_master() helper.
Moreover, the controller's clock is enabled on probe but not disabled if any of the subsequent probe steps fail.
Finally, there's an ordering issue in ar934x_spi_remove() wherein the clock is disabled even though the controller is not yet unregistered. It is unregistered after ar934x_spi_remove() by the devres framework. As long as it is not unregistered, SPI transfers may still be ongoing and disabling the clock may break them. It is not possible to use devm_spi_register_controller() in this case, so move to the non-devm variant.
All of these bugs have existed since the driver was first introduced, so it seems fair to fix them together in a single commit.
--- drivers/spi/spi-ar934x.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/spi/spi-ar934x.c +11 -3
@@ -176,10 +176,11 @@ static int ar934x_spi_probe(struct platfif (ret)return ret; - ctlr =spi_alloc_master (&pdev->dev,sizeof (*sp)); + ctlr =devm_spi_alloc_master (&pdev->dev,sizeof (*sp));if (!ctlr) {dev_info (&pdev->dev,"failed to allocate spi controller\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto err_clk_disable; }/* disable flash mapping and expose spi controller registers */
@@ -202,7 +203,13 @@ static int ar934x_spi_probe(struct platf sp->clk_freq =clk_get_rate (clk); sp->ctlr = ctlr; -return devm_spi_register_controller (&pdev->dev, ctlr); + ret =spi_register_controller (ctlr); +if (!ret) +return 0 ; + +err_clk_disable: +clk_disable_unprepare (clk); +return ret; }static int ar934x_spi_remove (struct platform_device *pdev)
@@ -213,6 +220,7 @@ static int ar934x_spi_remove(struct plat ctlr =dev_get_drvdata (&pdev->dev); sp =spi_controller_get_devdata (ctlr); +spi_unregister_controller (ctlr);clk_disable_unprepare (sp->clk);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 646/717 spi: davinci: Fix use-after-free on unbind
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 373afef350a93519b4b8d636b0895da8650b714b upstream.
davinci_spi_remove() accesses the driver's private data after it's been freed with spi_master_put().
Fix by moving the spi_master_put() to the end of the function.
--- drivers/spi/spi-davinci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-davinci.c +1 -1
@@ -1040,13 +1040,13 @@ static int davinci_spi_remove(struct plaspi_bitbang_stop (&dspi->bitbang);clk_disable_unprepare (dspi->clk); -spi_master_put (master);if (dspi->dma_rx) {dma_release_channel (dspi->dma_rx);dma_release_channel (dspi->dma_tx); } +spi_master_put (master);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 649/717 spi: mxic: Dont leak SPI master in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit cc53711b2191cf3b3210283ae89bf0abb98c70a3 upstream.
If the calls to devm_clk_get() or devm_ioremap_resource() fail on probe of the Macronix SPI driver, the spi_master struct is erroneously not freed.
Fix by switching over to the new devm_spi_alloc_master() helper.
--- drivers/spi/spi-mxic.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/spi/spi-mxic.c +2 -8
@@ -529,7 +529,7 @@ static int mxic_spi_probe(struct platforstruct mxic_spi *mxic;int ret; - master =spi_alloc_master (&pdev->dev,sizeof (struct mxic_spi )); + master =devm_spi_alloc_master (&pdev->dev,sizeof (struct mxic_spi ));if (!master)return -ENOMEM ;
@@ -574,15 +574,9 @@ static int mxic_spi_probe(struct platfor ret =spi_register_master (master);if (ret) {dev_err (&pdev->dev,"spi_register_master failed\n" ); - goto err_put_master; +pm_runtime_disable (&pdev->dev); } -return 0 ; - -err_put_master: -spi_master_put (master); -pm_runtime_disable (&pdev->dev); -return ret; }
Greg Kroah-Hartman
maintainerPATCH 673/717 openat2: reject RESOLVE_BENEATH|RESOLVE_IN_ROOT
In reply to Greg Kroah-HartmanFrom: Aleksa Sarai <[email protected]>
commit 398840f8bb935d33c64df4ec4fed77a7d24c267d upstream.
This was an oversight in the original implementation, as it makes no sense to specify both scoping flags to the same openat2(2) invocation (before this patch, the result of such an invocation was equivalent to RESOLVE_IN_ROOT being ignored).
This is a userspace-visible ABI change, but the only user of openat2(2) at the moment is LXC which doesn't specify both flags and so no userspace programs will break as a result.
--- fs/open.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/open.c +4 -0
@@ -1010,6 +1010,10 @@ inline int build_open_flags(const structif (how->resolve & ~VALID_RESOLVE_FLAGS )return -EINVAL ; +/* Scoping flags are mutually exclusive. */ +if ((how->resolve &RESOLVE_BENEATH ) && (how->resolve &RESOLVE_IN_ROOT )) +return -EINVAL ; +/* Deal with the mode. */ if (WILL_CREATE (flags)) {if (how->mode & ~S_IALLUGO )
Greg Kroah-Hartman
maintainerPATCH 674/717 iio: buffer: Fix demux update
In reply to Greg Kroah-HartmanFrom: Nuno Sá <[email protected]>
commit 19ef7b70ca9487773c29b449adf0c70f540a0aab upstream.
When updating the buffer demux, we will skip a scan element from the device in the case in_ind != out_ind and we enter the while loop. in_ind should only be refreshed with find_next_bit() in the end of the loop.
Note, to cause problems we need a situation where we are skippig over an element (channel not enabled) that happens to not have the same size
as the next element. Whilst this is a possible situation we haven't
actually identified any cases in mainline where it happens as most drivers have consistent channel storage sizes with the exception of the timestamp which is the last element and hence never skipped over.
--- drivers/iio/industrialio-buffer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/industrialio-buffer.c +3 -3
@@ -865,12 +865,12 @@ static int iio_buffer_update_demux(struc indio_dev->masklength, in_ind + 1);while (in_ind != out_ind) { - in_ind =find_next_bit (indio_dev->active_scan_mask, - indio_dev->masklength, - in_ind +1 ); length =iio_storage_bytes_for_si (indio_dev, in_ind);/* Make sure we are aligned */ in_loc =roundup (in_loc, length) + length; + in_ind =find_next_bit (indio_dev->active_scan_mask, + indio_dev->masklength, + in_ind +1 ); } length =iio_storage_bytes_for_si (indio_dev, in_ind); out_loc =roundup (out_loc, length);
Greg Kroah-Hartman
maintainerPATCH 676/717 iio: imu: st_lsm6dsx: fix edge-trigger interrupts
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
commit 3f9bce7a22a3f8ac9d885c9d75bc45569f24ac8b upstream.
If we are using edge IRQs, new samples can arrive while processing current interrupt since there are no hw guarantees the irq line stays "low" long enough to properly detect the new interrupt. In this case the new sample will be missed.
Polling FIFO status register in st_lsm6dsx_handler_thread routine allow us to read new samples even if the interrupt arrives while processing previous data and the timeslot where the line is "low" is too short to be properly detected.
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +21 -5
@@ -2255,19 +2255,35 @@ st_lsm6dsx_report_motion_event(struct ststatic irqreturn_t st_lsm6dsx_handler_thread (int irq,void *private) {struct st_lsm6dsx_hw *hw = private; +int fifo_len =0 , len;bool event; -int count; event =st_lsm6dsx_report_motion_event (hw);if (!hw->settings->fifo_ops.read_fifo)return event ?IRQ_HANDLED :IRQ_NONE ; -mutex_lock (&hw->fifo_lock); - count = hw->settings->fifo_ops.read_fifo (hw); -mutex_unlock (&hw->fifo_lock); +/* +* If we are using edge IRQs, new samples can arrive while +* processing current interrupt since there are no hw +* guarantees the irq line stays "low" long enough to properly +* detect the new interrupt. In this case the new sample will +* be missed. +* Polling FIFO status register allow us to read new +* samples even if the interrupt arrives while processing +* previous data and the timeslot where the line is "low" is +* too short to be properly detected. +*/ +do { +mutex_lock (&hw->fifo_lock); + len = hw->settings->fifo_ops.read_fifo (hw); +mutex_unlock (&hw->fifo_lock); -return count || event ?IRQ_HANDLED :IRQ_NONE ; +if (len >0 ) + fifo_len += len; + }while (len >0 ); + +return fifo_len || event ?IRQ_HANDLED :IRQ_NONE ; }static int st_lsm6dsx_irq_setup (struct st_lsm6dsx_hw *hw)
Greg Kroah-Hartman
maintainerPATCH 689/717 clk: mvebu: a3700: fix the XTAL MODE pin to MPP1_9
In reply to Greg Kroah-HartmanFrom: Terry Zhou <[email protected]>
commit 6f37689cf6b38fff96de52e7f0d3e78f22803ba0 upstream.
There is an error in the current code that the XTAL MODE pin was set to NB MPP1_31 which should be NB MPP1_9. The latch register of NB MPP1_9 has different offset of 0x8.
--- drivers/clk/mvebu/armada-37xx-xtal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/mvebu/armada-37xx-xtal.c +2 -2
@@ -13,8 +13,8 @@#include <linux/platform_device.h> #include <linux/regmap.h> -#define NB_GPIO1_LATCH 0xC -#define XTAL_MODE BIT(31) +#define NB_GPIO1_LATCH 0x8 +#define XTAL_MODE BIT(9)static int armada_3700_xtal_clock_probe (struct platform_device *pdev) {
Greg Kroah-Hartman
maintainerPATCH 690/717 clk: tegra: Do not return 0 on failure
In reply to Greg Kroah-HartmanFrom: Nicolin Chen <[email protected]>
commit 6160aca443148416994c022a35c77daeba948ea6 upstream.
Return values from read_dt_param() will be either TRUE (1) or FALSE (0), while dfll_fetch_pwm_params() returns 0 on success or an ERR code on failure.
So this patch fixes the bug of returning 0 on failure.
--- drivers/clk/tegra/clk-dfll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/tegra/clk-dfll.c +2 -2
@@ -1856,13 +1856,13 @@ static int dfll_fetch_pwm_params(struct &td->reg_init_uV);if (!ret) {dev_err (td->dev,"couldn't get initialized voltage\n" ); -return ret; +return -EINVAL ; } ret =read_dt_param (td,"nvidia,pwm-period-nanoseconds" , &pwm_period);if (!ret) {dev_err (td->dev,"couldn't get PWM period\n" ); -return ret; +return -EINVAL ; } td->pwm_rate = (NSEC_PER_SEC / pwm_period) * (MAX_DFLL_VOLTAGES -1 );
Greg Kroah-Hartman
maintainerPATCH 695/717 xen-blkback: set ring->xenblkd to NULL after kthread_stop()
In reply to Greg Kroah-HartmanFrom: Pawel Wieczorkiewicz <[email protected]>
commit 1c728719a4da6e654afb9cc047164755072ed7c9 upstream.
When xen_blkif_disconnect() is called, the kernel thread behind the block interface is stopped by calling kthread_stop(ring->xenblkd). The ring->xenblkd thread pointer being non-NULL determines if the thread has been already stopped.
Normally, the thread's function xen_blkif_schedule() sets the ring->xenblkd to NULL, when the thread's main loop ends.
However, when the thread has not been started yet (i.e. wake_up_process() has not been called on it), the xen_blkif_schedule() function would not be called yet.
In such case the kthread_stop() call returns -EINTR and the ring->xenblkd remains dangling.
When this happens, any consecutive call to xen_blkif_disconnect (for example in frontend_changed() callback) leads to a kernel crash in kthread_stop() (e.g. NULL pointer dereference in exit_creds()).
This is XSA-350.
--- drivers/block/xen-blkback/xenbus.c | 1 + 1 file changed, 1 insertion(+)
drivers/block/xen-blkback/xenbus.c +1 -0
@@ -274,6 +274,7 @@ static int xen_blkif_disconnect(struct xif (ring->xenblkd) {kthread_stop (ring->xenblkd); + ring->xenblkd =NULL ;wake_up (&ring->shutdown_wq); }
Greg Kroah-Hartman
maintainerPATCH 641/717 spi: pxa2xx: Fix use-after-free on unbind
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 5626308bb94d9f930aa5f7c77327df4c6daa7759 upstream.
pxa2xx_spi_remove() accesses the driver's private data after calling spi_unregister_controller() even though that function releases the last reference on the spi_controller and thereby frees the private data.
Fix by switching over to the new devm_spi_alloc_master/slave() helper which keeps the private data accessible until the driver has unbound.
--- drivers/spi/spi-pxa2xx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/spi/spi-pxa2xx.c +2 -3
@@ -1686,9 +1686,9 @@ static int pxa2xx_spi_probe(struct platf }if (platform_info->is_slave) - controller =spi_alloc_slave (dev,sizeof (struct driver_data )); + controller =devm_spi_alloc_slave (dev,sizeof (*drv_data));else - controller =spi_alloc_master (dev,sizeof (struct driver_data )); + controller =devm_spi_alloc_master (dev,sizeof (*drv_data));if (!controller) {dev_err (&pdev->dev,"cannot alloc spi_controller\n" );
@@ -1911,7 +1911,6 @@ out_error_dma_irq_alloc:free_irq (ssp->irq, drv_data); out_error_controller_alloc: -spi_controller_put (controller);pxa_ssp_free (ssp);return status; }
Greg Kroah-Hartman
maintainerPATCH 696/717 xen/xenbus: Allow watches discard events before queueing
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
commit fed1755b118147721f2c87b37b9d66e62c39b668 upstream.
If handling logics of watch events are slower than the events enqueue logic and the events can be created from the guests, the guests could trigger memory pressure by intensively inducing the events, because it will create a huge number of pending events that exhausting the memory.
Fortunately, some watch events could be ignored, depending on its handler callback. For example, if the callback has interest in only one single path, the watch wouldn't want multiple pending events. Or, some watches could ignore events to same path.
To let such watches to volutarily help avoiding the memory pressure situation, this commit introduces new watch callback, 'will_handle'. If it is not NULL, it will be called for each new event just before enqueuing it. Then, if the callback returns false, the event will be discarded. No watch is using the callback for now, though.
This is part of XSA-349
--- drivers/net/xen-netback/xenbus.c | 4 ++++ drivers/xen/xenbus/xenbus_client.c | 1 + drivers/xen/xenbus/xenbus_xs.c | 5 ++++- include/xen/xenbus.h | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-)
drivers/net/xen-netback/xenbus.c +4 -0
@@ -557,12 +557,14 @@ static int xen_register_credit_watch(strreturn -ENOMEM ;snprintf (node, maxlen,"%s/rate" , dev->nodename); vif->credit_watch.node = node; + vif->credit_watch.will_handle =NULL ; vif->credit_watch.callback = xen_net_rate_changed; err =register_xenbus_watch (&vif->credit_watch);if (err) {pr_err ("Failed to set watcher %s\n" , vif->credit_watch.node);kfree (node); vif->credit_watch.node =NULL ; + vif->credit_watch.will_handle =NULL ; vif->credit_watch.callback =NULL ; }return err;
@@ -609,6 +611,7 @@ static int xen_register_mcast_ctrl_watchsnprintf (node, maxlen,"%s/request-multicast-control" , dev->otherend); vif->mcast_ctrl_watch.node = node; + vif->mcast_ctrl_watch.will_handle =NULL ; vif->mcast_ctrl_watch.callback = xen_mcast_ctrl_changed; err =register_xenbus_watch (&vif->mcast_ctrl_watch);if (err) {
@@ -616,6 +619,7 @@ static int xen_register_mcast_ctrl_watch vif->mcast_ctrl_watch.node);kfree (node); vif->mcast_ctrl_watch.node =NULL ; + vif->mcast_ctrl_watch.will_handle =NULL ; vif->mcast_ctrl_watch.callback =NULL ; }return err;
drivers/xen/xenbus/xenbus_client.c +1 -0
@@ -133,6 +133,7 @@ int xenbus_watch_path(struct xenbus_deviint err; watch->node = path; + watch->will_handle =NULL ; watch->callback = callback; err =register_xenbus_watch (watch);
drivers/xen/xenbus/xenbus_xs.c +4 -1
@@ -705,7 +705,10 @@ int xs_watch_msg(struct xs_watch_event *spin_lock (&watches_lock); event->handle =find_watch (event->token); -if (event->handle !=NULL ) { +if (event->handle !=NULL && + (!event->handle->will_handle || + event->handle->will_handle (event->handle, + event->path, event->token))) {spin_lock (&watch_events_lock);list_add_tail (&event->list, &watch_events);wake_up (&watch_events_waitq);
include/xen/xenbus.h +7 -0
@@ -61,6 +61,13 @@ struct xenbus_watch/* Path being watched. */ const char *node; +/* +* Called just before enqueing new event while a spinlock is held. +* The event will be discarded if this callback returns false. +*/ +bool (*will_handle)(struct xenbus_watch *, +const char *path,const char *token); +/* Callback (executed in a process context with no locks held). */ void (*callback)(struct xenbus_watch *,const char *path,const char *token);
Greg Kroah-Hartman
maintainerPATCH 698/717 xen/xenbus/xen_bus_type: Support will_handle watch callback
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
commit be987200fbaceaef340872841d4f7af2c5ee8dc3 upstream.
This commit adds support of the 'will_handle' watch callback for 'xen_bus_type' users.
This is part of XSA-349
--- drivers/xen/xenbus/xenbus.h | 2 ++ drivers/xen/xenbus/xenbus_probe.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus.h +2 -0
@@ -44,6 +44,8 @@ struct xen_bus_type {int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE ],const char *nodename);int (*probe)(struct xen_bus_type *bus,const char *type,const char *dir); +bool (*otherend_will_handle)(struct xenbus_watch *watch, +const char *path,const char *token);void (*otherend_changed)(struct xenbus_watch *watch,const char *path,const char *token);struct bus_type bus;
drivers/xen/xenbus/xenbus_probe.c +2 -1
@@ -136,7 +136,8 @@ static int watch_otherend(struct xenbus_ container_of(dev->dev.bus, struct xen_bus_type, bus);return xenbus_watch_pathfmt (dev, &dev->otherend_watch, -NULL , bus->otherend_changed, + bus->otherend_will_handle, + bus->otherend_changed,"%s/%s" , dev->otherend,"state" ); }
Greg Kroah-Hartman
maintainerPATCH 706/717 platform/x86: intel-vbtn: Allow switch events on Acer Switch Alpha 12
In reply to Greg Kroah-HartmanFrom: Carlos Garnacho <[email protected]>
commit fe6000990394639ed374cb76c313be3640714f47 upstream.
This 2-in-1 model (Product name: Switch SA5-271) features a SW_TABLET_MODE that works as it would be expected, both when detaching the keyboard and when folding it behind the tablet body.
It used to work until the introduction of the allow list at commit 8169bd3e6e193 ("platform/x86: intel-vbtn: Switch to an allow-list for SW_TABLET_MODE reporting"). Add this model to it, so that the Virtual Buttons device announces the EV_SW features again.
--- drivers/platform/x86/intel-vbtn.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/platform/x86/intel-vbtn.c +6 -0
@@ -216,6 +216,12 @@ static const struct dmi_system_id dmi_sw DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion 13 x360 PC"), }, }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), + DMI_MATCH(DMI_PRODUCT_NAME, "Switch SA5-271"), + }, + }, {}/* Array terminator */ };
Greg Kroah-Hartman
maintainerPATCH 648/717 spi: gpio: Dont leak SPI master in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 7174dc655ef0578877b0b4598e69619d2be28b4d upstream.
If the call to devm_spi_register_master() fails on probe of the GPIO SPI driver, the spi_master struct is erroneously not freed:
After allocating the spi_master, its reference count is 1. The driver unconditionally decrements the reference count on unbind using a devm action. Before calling devm_spi_register_master(), the driver unconditionally increments the reference count because on success, that function will decrement the reference count on unbind. However on failure, devm_spi_register_master() does *not* decrement the reference count, so the spi_master is leaked.
The issue was introduced by commits 8b797490b4db ("spi: gpio: Make sure spi_master_put() is called in every error path") and 79567c1a321e ("spi:
gpio: Use devm_spi_register_master()"), which sought to plug leaks introduced by 9b00bc7b901f ("spi: spi-gpio: Rewrite to use GPIO descriptors") but missed this remaining leak.
The situation was later aggravated by commit d3b0ffa1d75d ("spi: gpio:
prevent memory leak in spi_gpio_probe"), which introduced a use-after-free because it releases a reference on the spi_master if devm_add_action_or_reset() fails even though the function already does that.
Fix by switching over to the new devm_spi_alloc_master() helper.
--- drivers/spi/spi-gpio.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/spi/spi-gpio.c +2 -13
@@ -350,11 +350,6 @@ static int spi_gpio_probe_pdata(struct preturn 0 ; } -static void spi_gpio_put (void *data) -{ -spi_master_put (data); -} -static int spi_gpio_probe (struct platform_device *pdev) {int status;
@@ -363,16 +358,10 @@ static int spi_gpio_probe(struct platforstruct device *dev = &pdev->dev;struct spi_bitbang *bb; - master =spi_alloc_master (dev,sizeof (*spi_gpio)); + master =devm_spi_alloc_master (dev,sizeof (*spi_gpio));if (!master)return -ENOMEM ; - status =devm_add_action_or_reset (&pdev->dev, spi_gpio_put, master); -if (status) { -spi_master_put (master); -return status; - } -if (pdev->dev.of_node) status =spi_gpio_probe_dt (pdev, master);else
@@ -432,7 +421,7 @@ static int spi_gpio_probe(struct platforif (status)return status; -return devm_spi_register_master (&pdev->dev,spi_master_get (master)); +return devm_spi_register_master (&pdev->dev, master); }MODULE_ALIAS ("platform:" DRIVER_NAME );
Greg Kroah-Hartman
maintainerPATCH 694/717 driver: core: Fix list corruption after device_del()
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 66482f640755b31cb94371ff6cef17400cda6db5 upstream.
The device_links_purge() function (called from device_del()) tries to remove the links.needs_suppliers list entry, but it's using list_del(), hence it doesn't initialize after the removal. This is OK for normal cases where device_del() is called via device_destroy(). However, it's not guaranteed that the device object will be really deleted soon after device_del(). In a minor case like HD-audio codec reconfiguration that re-initializes the device after device_del(), it may lead to a crash by the corrupted list entry.
As a simple fix, replace list_del() with list_del_init() in order to make the list intact after the device_del() call.
--- drivers/base/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/core.c +1 -1
@@ -1386,7 +1386,7 @@ static void device_links_purge(struct dereturn ;mutex_lock (&wfs_lock); -list_del (&dev->links.needs_suppliers); +list_del_init (&dev->links.needs_suppliers);mutex_unlock (&wfs_lock);/*
Greg Kroah-Hartman
maintainerPATCH 701/717 memory: jz4780_nemc: Fix an error pointer vs NULL check in probe()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 96999c797ec1ef41259f00b4ddf9cf33b342cb78 upstream.
The devm_ioremap() function returns NULL on error, it doesn't return error pointers. This bug could lead to an Oops during probe.
--- drivers/memory/jz4780-nemc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/memory/jz4780-nemc.c +2 -2
@@ -306,9 +306,9 @@ static int jz4780_nemc_probe(struct plat } nemc->base =devm_ioremap (dev, res->start,NEMC_REG_LEN ); -if (IS_ERR (nemc->base)) { +if (!nemc->base) {dev_err (dev,"failed to get I/O memory\n" ); -return PTR_ERR (nemc->base); +return -ENOMEM ; }writel (0 , nemc->base +NEMC_NFCSR );
Greg Kroah-Hartman
maintainerPATCH 704/717 memory: renesas-rpc-if: Fix unbalanced pm_runtime_enable in rpcif_{enable,disable}_rpm
In reply to Greg Kroah-HartmanFrom: Lad Prabhakar <[email protected]>
commit 61a6d854b9555b420fbfae62ef26baa8b9493b32 upstream.
rpcif_enable_rpm calls pm_runtime_enable, so rpcif_disable_rpm needs to call pm_runtime_disable and not pm_runtime_put_sync.
--- drivers/memory/renesas-rpc-if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/renesas-rpc-if.c +1 -1
@@ -212,7 +212,7 @@ EXPORT_SYMBOL(rpcif_enable_rpm);void rpcif_disable_rpm (struct rpcif *rpc) { -pm_runtime_put_sync (rpc->dev); +pm_runtime_disable (rpc->dev); }EXPORT_SYMBOL (rpcif_disable_rpm);
Greg Kroah-Hartman
maintainerPATCH 644/717 spi: spi-mtk-nor: Dont leak SPI master in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 0f4ad8d59f33b24dd86739f3be23e6af1a86f5a9 upstream.
If the call to devm_spi_register_controller() fails on probe of the MediaTek SPI NOR driver, the spi_controller struct is erroneously not freed.
Since commit a1daaa991ed1 ("spi: spi-mtk-nor: use dma_alloc_coherent() for bounce buffer"), the same happens if the call to dmam_alloc_coherent() fails.
Since commit 3bfd9103c7af ("spi: spi-mtk-nor: Add power management support"), the same happens if the call to mtk_nor_enable_clk() fails.
Fix by switching over to the new devm_spi_alloc_master() helper.
--- drivers/spi/spi-mtk-nor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-mtk-nor.c +1 -1
@@ -768,7 +768,7 @@ static int mtk_nor_probe(struct platformreturn -EINVAL ; } - ctlr =spi_alloc_master (&pdev->dev,sizeof (*sp)); + ctlr =devm_spi_alloc_master (&pdev->dev,sizeof (*sp));if (!ctlr) {dev_err (&pdev->dev,"failed to allocate spi controller\n" );return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 657/717 spi: st-ssc4: Fix unbalanced pm_runtime_disable() in probe error path
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit 5ef76dac0f2c26aeae4ee79eb830280f16d5aceb upstream.
If the calls to devm_platform_ioremap_resource(), irq_of_parse_and_map() or devm_request_irq() fail on probe of the ST SSC4 SPI driver, the runtime PM disable depth is incremented even though it was not decremented before. Fix it.
--- drivers/spi/spi-st-ssc4.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi-st-ssc4.c +3 -2
@@ -375,13 +375,14 @@ static int spi_st_probe(struct platform_ ret =devm_spi_register_master (&pdev->dev, master);if (ret) {dev_err (&pdev->dev,"Failed to register master\n" ); - goto clk_disable; + goto rpm_disable; }return 0 ; -clk_disable: +rpm_disable:pm_runtime_disable (&pdev->dev); +clk_disable:clk_disable_unprepare (spi_st->clk); put_master:spi_master_put (master);
Greg Kroah-Hartman
maintainerPATCH 670/717 scsi: lpfc: Fix invalid sleeping context in lpfc_sli4_nvmet_alloc()
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
commit 62e3a931db60daf94fdb3159d685a5bc6ad4d0cf upstream.
The following calltrace was seen:
BUG: sleeping function called from invalid context at mm/slab.h:494 ... Call Trace: dump_stack+0x9a/0xf0 ___might_sleep.cold.63+0x13d/0x178 slab_pre_alloc_hook+0x6a/0x90 kmem_cache_alloc_trace+0x3a/0x2d0 lpfc_sli4_nvmet_alloc+0x4c/0x280 [lpfc] lpfc_post_rq_buffer+0x2e7/0xa60 [lpfc] lpfc_sli4_hba_setup+0x6b4c/0xa4b0 [lpfc] lpfc_pci_probe_one_s4.isra.15+0x14f8/0x2280 [lpfc] lpfc_pci_probe_one+0x260/0x2880 [lpfc] local_pci_probe+0xd4/0x180 work_for_cpu_fn+0x51/0xa0 process_one_work+0x8f0/0x17b0 worker_thread+0x536/0xb50 kthread+0x30c/0x3d0 ret_from_fork+0x3a/0x50
A prior patch introduced a spin_lock_irqsave(hbalock) in the lpfc_post_rq_buffer() routine. Call trace is seen as the hbalock is held with interrupts disabled during a GFP_KERNEL allocation in lpfc_sli4_nvmet_alloc().
Fix by reordering locking so that hbalock not held when calling sli4_nvmet_alloc() (aka rqb_buf_list()).
--- drivers/scsi/lpfc/lpfc_mem.c | 4 +--- drivers/scsi/lpfc/lpfc_sli.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-)
drivers/scsi/lpfc/lpfc_mem.c +1 -3
@@ -588,8 +588,6 @@ lpfc_sli4_rb_free(struct lpfc_hba *phba,* Description: Allocates a DMA-mapped receive buffer from the lpfc_hrb_pool PCI * pool along a non-DMA-mapped container for it. * -* Notes: Not interrupt-safe. Must be called with no locks held. -* * Returns: * pointer to HBQ on success * NULL on failure
@@ -599,7 +597,7 @@ lpfc_sli4_nvmet_alloc(struct lpfc_hba *p {struct rqb_dmabuf *dma_buf; - dma_buf =kzalloc (sizeof (struct rqb_dmabuf ),GFP_KERNEL ); + dma_buf =kzalloc (sizeof (*dma_buf),GFP_KERNEL );if (!dma_buf)return NULL ;
drivers/scsi/lpfc/lpfc_sli.c +8 -2
@@ -7248,12 +7248,16 @@ lpfc_post_rq_buffer(struct lpfc_hba *phbstruct rqb_dmabuf *rqb_buffer;LIST_HEAD (rqb_buf_list); -spin_lock_irqsave (&phba->hbalock, flags); rqbp = hrq->rqbp;for (i =0 ; i < count; i++) { +spin_lock_irqsave (&phba->hbalock, flags);/* IF RQ is already full, don't bother */ -if (rqbp->buffer_count + i >= rqbp->entry_count -1 ) +if (rqbp->buffer_count + i >= rqbp->entry_count -1 ) { +spin_unlock_irqrestore (&phba->hbalock, flags);break ; + } +spin_unlock_irqrestore (&phba->hbalock, flags); + rqb_buffer = rqbp->rqb_alloc_buffer (phba);if (!rqb_buffer)break ;
@@ -7262,6 +7266,8 @@ lpfc_post_rq_buffer(struct lpfc_hba *phb rqb_buffer->idx = idx;list_add_tail (&rqb_buffer->hbuf.list, &rqb_buf_list); } + +spin_lock_irqsave (&phba->hbalock, flags);while (!list_empty (&rqb_buf_list)) { list_remove_head(&rqb_buf_list, rqb_buffer, struct rqb_dmabuf, hbuf.list);
Greg Kroah-Hartman
maintainerPATCH 687/717 pinctrl: sunxi: Always call chained_irq_{enter, exit} in sunxi_pinctrl_irq_handler
In reply to Greg Kroah-HartmanFrom: Yangtao Li <[email protected]>
commit a1158e36f876f6269978a4176e3a1d48d27fe7a1 upstream.
It is found on many allwinner soc that there is a low probability that the interrupt status cannot be read in sunxi_pinctrl_irq_handler. This will cause the interrupt status of a gpio bank to always be active on gic, preventing gic from responding to other spi interrupts correctly.
So we should call the chained_irq_* each time enter sunxi_pinctrl_irq_handler().
--- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +4 -2
@@ -1142,20 +1142,22 @@ static void sunxi_pinctrl_irq_handler(stif (bank == pctl->desc->irq_banks)return ; +chained_irq_enter (chip, desc); + reg =sunxi_irq_status_reg_from_bank (pctl->desc, bank); val =readl (pctl->membase + reg);if (val) {int irqoffset; -chained_irq_enter (chip, desc);for_each_set_bit (irqoffset, &val,IRQ_PER_BANK ) {int pin_irq =irq_find_mapping (pctl->domain, bank *IRQ_PER_BANK + irqoffset);generic_handle_irq (pin_irq); } -chained_irq_exit (chip, desc); } + +chained_irq_exit (chip, desc); } static int sunxi_pinctrl_add_function(struct sunxi_pinctrl *pctl,
Greg Kroah-Hartman
maintainerPATCH 697/717 xen/xenbus: Add will_handle callback support in xenbus_watch_path()
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
commit 2e85d32b1c865bec703ce0c962221a5e955c52c2 upstream.
Some code does not directly make 'xenbus_watch' object and call 'register_xenbus_watch()' but use 'xenbus_watch_path()' instead. This commit adds support of 'will_handle' callback in the 'xenbus_watch_path()' and it's wrapper, 'xenbus_watch_pathfmt()'.
This is part of XSA-349
--- drivers/block/xen-blkback/xenbus.c | 3 ++- drivers/net/xen-netback/xenbus.c | 2 +- drivers/xen/xen-pciback/xenbus.c | 2 +- drivers/xen/xenbus/xenbus_client.c | 9 +++++++-- drivers/xen/xenbus/xenbus_probe.c | 2 +- include/xen/xenbus.h | 6 +++++- 6 files changed, 17 insertions(+), 7 deletions(-)
drivers/block/xen-blkback/xenbus.c +2 -1
@@ -676,7 +676,8 @@ static int xen_blkbk_probe(struct xenbus/* setup back pointer */ be->blkif->be = be; - err =xenbus_watch_pathfmt (dev, &be->backend_watch, backend_changed, + err =xenbus_watch_pathfmt (dev, &be->backend_watch,NULL , + backend_changed,"%s/%s" , dev->nodename,"physical-device" );if (err) goto fail;
drivers/net/xen-netback/xenbus.c +1 -1
@@ -824,7 +824,7 @@ static void connect(struct backend_infoxenvif_carrier_on (be->vif);unregister_hotplug_status_watch (be); - err =xenbus_watch_pathfmt (dev, &be->hotplug_status_watch, + err =xenbus_watch_pathfmt (dev, &be->hotplug_status_watch,NULL , hotplug_status_changed,"%s/%s" , dev->nodename,"hotplug-status" );if (!err)
drivers/xen/xen-pciback/xenbus.c +1 -1
@@ -689,7 +689,7 @@ static int xen_pcibk_xenbus_probe(struct/* watch the backend node for backend configuration information */ err =xenbus_watch_path (dev, dev->nodename, &pdev->be_watch, - xen_pcibk_be_watch); +NULL , xen_pcibk_be_watch);if (err) goto out;
drivers/xen/xenbus/xenbus_client.c +7 -2
@@ -127,19 +127,22 @@ EXPORT_SYMBOL_GPL(xenbus_strstate);*/ int xenbus_watch_path (struct xenbus_device *dev,const char *path,struct xenbus_watch *watch, +bool (*will_handle)(struct xenbus_watch *, +const char *,const char *),void (*callback)(struct xenbus_watch *,const char *,const char *)) {int err; watch->node = path; - watch->will_handle =NULL ; + watch->will_handle = will_handle; watch->callback = callback; err =register_xenbus_watch (watch);if (err) { watch->node =NULL ; + watch->will_handle =NULL ; watch->callback =NULL ;xenbus_dev_fatal (dev, err,"adding watch on %s" , path); }
@@ -166,6 +169,8 @@ EXPORT_SYMBOL_GPL(xenbus_watch_path);*/ int xenbus_watch_pathfmt (struct xenbus_device *dev,struct xenbus_watch *watch, +bool (*will_handle)(struct xenbus_watch *, +const char *,const char *),void (*callback)(struct xenbus_watch *,const char *,const char *),const char *pathfmt, ...)
@@ -182,7 +187,7 @@ int xenbus_watch_pathfmt(struct xenbus_dxenbus_dev_fatal (dev, -ENOMEM ,"allocating path for watch" );return -ENOMEM ; } - err =xenbus_watch_path (dev, path, watch, callback); + err =xenbus_watch_path (dev, path, watch, will_handle, callback);if (err)kfree (path);
drivers/xen/xenbus/xenbus_probe.c +1 -1
@@ -136,7 +136,7 @@ static int watch_otherend(struct xenbus_ container_of(dev->dev.bus, struct xen_bus_type, bus);return xenbus_watch_pathfmt (dev, &dev->otherend_watch, - bus->otherend_changed, +NULL , bus->otherend_changed,"%s/%s" , dev->otherend,"state" ); }
include/xen/xenbus.h +5 -1
@@ -204,10 +204,14 @@ void xenbus_probe(struct work_struct *);int xenbus_watch_path (struct xenbus_device *dev,const char *path,struct xenbus_watch *watch, +bool (*will_handle)(struct xenbus_watch *, +const char *,const char *),void (*callback)(struct xenbus_watch *,const char *,const char *)); -__printf(4, 5) +__printf(5, 6)int xenbus_watch_pathfmt (struct xenbus_device *dev,struct xenbus_watch *watch, +bool (*will_handle)(struct xenbus_watch *, +const char *,const char *),void (*callback)(struct xenbus_watch *,const char *,const char *),const char *pathfmt, ...);
Greg Kroah-Hartman
maintainerPATCH 681/717 iio:imu:bmi160: Fix too large a buffer.
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit dc7de42d6b50a07b37feeba4c6b5136290fcee81 upstream.
The comment implies this device has 3 sensor types, but it only has an accelerometer and a gyroscope (both 3D). As such the buffer does not need to be as long as stated.
Note I've separated this from the following patch which fixes the alignment for passing to iio_push_to_buffers_with_timestamp() as they are different issues even if they affect the same line of code.
--- drivers/iio/imu/bmi160/bmi160_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/imu/bmi160/bmi160_core.c +2 -2
@@ -427,8 +427,8 @@ static irqreturn_t bmi160_trigger_handlestruct iio_poll_func *pf = p;struct iio_dev *indio_dev = pf->indio_dev;struct bmi160_data *data =iio_priv (indio_dev); -__le16 buf[16 ]; -/* 3 sens x 3 axis x __le16 + 3 x __le16 pad + 4 x __le16 tstamp */ +__le16 buf[12 ]; +/* 2 sens x 3 axis x __le16 + 2 x __le16 pad + 4 x __le16 tstamp */ int i, ret, j =0 , base =BMI160_REG_DATA_MAGN_XOUT_L ;__le16 sample;
Greg Kroah-Hartman
maintainerPATCH 682/717 iio:imu:bmi160: Fix alignment and data leak issues
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 7b6b51234df6cd8b04fe736b0b89c25612d896b8 upstream.
One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable array in the iio_priv() data with alignment explicitly requested. This data is allocated with kzalloc() so no data can leak apart from previous readings.
In this driver, depending on which channels are enabled, the timestamp can be in a number of locations. Hence we cannot use a structure to specify the data layout without it being misleading.
--- drivers/iio/imu/bmi160/bmi160.h | 7 +++++++ drivers/iio/imu/bmi160/bmi160_core.c | 6 ++---- 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/iio/imu/bmi160/bmi160.h +7 -0
@@ -10,6 +10,13 @@ struct bmi160_data {struct iio_trigger *trig;struct regulator_bulk_data supplies[2 ];struct iio_mount_matrix orientation; +/* +* Ensure natural alignment for timestamp if present. +* Max length needed: 2 * 3 channels + 4 bytes padding + 8 byte ts. +* If fewer channels are enabled, less space may be needed, as +* long as the timestamp is still aligned to 8 bytes. +*/ +__le16 buf[12 ]__aligned(8) ; };extern const struct regmap_config bmi160_regmap_config;
drivers/iio/imu/bmi160/bmi160_core.c +2 -4
@@ -427,8 +427,6 @@ static irqreturn_t bmi160_trigger_handlestruct iio_poll_func *pf = p;struct iio_dev *indio_dev = pf->indio_dev;struct bmi160_data *data =iio_priv (indio_dev); -__le16 buf[12 ]; -/* 2 sens x 3 axis x __le16 + 2 x __le16 pad + 4 x __le16 tstamp */ int i, ret, j =0 , base =BMI160_REG_DATA_MAGN_XOUT_L ;__le16 sample;
@@ -438,10 +436,10 @@ static irqreturn_t bmi160_trigger_handle &sample, sizeof(sample));if (ret) goto done; - buf[j++] = sample; + data->buf[j++] = sample; } -iio_push_to_buffers_with_timestamp (indio_dev, buf, pf->timestamp); +iio_push_to_buffers_with_timestamp (indio_dev, data->buf, pf->timestamp); done:iio_trigger_notify_done (indio_dev->trig);return IRQ_HANDLED ;
Greg Kroah-Hartman
maintainerPATCH 683/717 iio:adc:ti-ads124s08: Fix buffer being too long.
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit b0bd27f02d768e3a861c4e6c27f8e369720e6c25 upstream.
The buffer is expressed as a u32 array, yet the extra space for the s64 timestamp was expressed as sizeof(s64)/sizeof(u16). This will result in 2 extra u32 elements.
Fix by dividing by sizeof(u32).
--- drivers/iio/adc/ti-ads124s08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti-ads124s08.c +1 -1
@@ -269,7 +269,7 @@ static irqreturn_t ads124s_trigger_handlstruct iio_poll_func *pf = p;struct iio_dev *indio_dev = pf->indio_dev;struct ads124s_private *priv =iio_priv (indio_dev); -u32 buffer[ADS124S08_MAX_CHANNELS +sizeof (s64)/sizeof (u16)]; +u32 buffer[ADS124S08_MAX_CHANNELS +sizeof (s64)/sizeof (u32)];int scan_index, j =0 ;int ret;
Greg Kroah-Hartman
maintainerPATCH 703/717 memory: renesas-rpc-if: Return correct value to the caller of rpcif_manual_xfer()
In reply to Greg Kroah-HartmanFrom: Lad Prabhakar <[email protected]>
commit a0453f4ed066cae651b3119ed11f52d31dae1eca upstream.
In the error path of rpcif_manual_xfer() the value of ret is overwritten by value returned by reset_control_reset() function and thus returning incorrect value to the caller.
This patch makes sure the correct value is returned to the caller of rpcif_manual_xfer() by dropping the overwrite of ret in error path. Also now we ignore the value returned by reset_control_reset() in the error path and instead print a error message when it fails.
--- drivers/memory/renesas-rpc-if.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/memory/renesas-rpc-if.c +2 -1
@@ -508,7 +508,8 @@ exit:return ret; err_out: - ret =reset_control_reset (rpc->rstc); +if (reset_control_reset (rpc->rstc)) +dev_err (rpc->dev,"Failed to reset HW\n" );rpcif_hw_init (rpc, rpc->bus_size ==2 ); goto exit; }
Greg Kroah-Hartman
maintainerPATCH 678/717 iio:light:st_uvis25: Fix timestamp alignment and prevent data leak.
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit d837a996f57c29a985177bc03b0e599082047f27 upstream.
One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable structure in the iio_priv()
This data is allocated with kzalloc() so no data can leak apart from previous readings.
A local unsigned int variable is used for the regmap call so it is clear there is no potential issue with writing into the padding of the structure.
--- drivers/iio/light/st_uvis25.h | 5 +++++ drivers/iio/light/st_uvis25_core.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/iio/light/st_uvis25.h +5 -0
@@ -27,6 +27,11 @@ struct st_uvis25_hw {struct iio_trigger *trig;bool enabled;int irq; +/* Ensure timestamp is naturally aligned */ +struct { +u8 chan; +s64 ts__aligned(8) ; + } scan; };extern const struct dev_pm_ops st_uvis25_pm_ops;
drivers/iio/light/st_uvis25_core.c +5 -3
@@ -232,17 +232,19 @@ static const struct iio_buffer_setup_opsstatic irqreturn_t st_uvis25_buffer_handler_thread (int irq,void *p) { -u8 buffer[ALIGN (sizeof (u8),sizeof (s64)) +sizeof (s64)];struct iio_poll_func *pf = p;struct iio_dev *iio_dev = pf->indio_dev;struct st_uvis25_hw *hw =iio_priv (iio_dev); +unsigned int val;int err; - err =regmap_read (hw->regmap,ST_UVIS25_REG_OUT_ADDR , (int *)buffer); + err =regmap_read (hw->regmap,ST_UVIS25_REG_OUT_ADDR , &val);if (err <0 ) goto out; -iio_push_to_buffers_with_timestamp (iio_dev, buffer, + hw->scan.chan = val; + +iio_push_to_buffers_with_timestamp (iio_dev, &hw->scan,iio_get_time_ns (iio_dev)); out:
Greg Kroah-Hartman
maintainerPATCH 647/717 spi: fsl: fix use of spisel_boot signal on MPC8309
In reply to Greg Kroah-HartmanFrom: Rasmus Villemoes <[email protected]>
commit 122541f2b10897b08f7f7e6db5f1eb693e51f0a1 upstream.
Commit 0f0581b24bd0 ("spi: fsl: Convert to use CS GPIO descriptors") broke the use of the SPISEL_BOOT signal as a chip select on the MPC8309.
pdata->max_chipselect, which becomes master->num_chipselect, must be initialized to take into account the possibility that there's one more chip select in use than the number of GPIO chip selects.
--- drivers/spi/spi-fsl-spi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/spi/spi-fsl-spi.c +8 -3
@@ -716,10 +716,11 @@ static int of_fsl_spi_probe(struct platf type =fsl_spi_get_type (&ofdev->dev);if (type ==TYPE_FSL ) {struct fsl_spi_platform_data *pdata =dev_get_platdata (dev); +bool spisel_boot = false;#if IS_ENABLED (CONFIG_FSL_SOC )struct mpc8xxx_spi_probe_info *pinfo =to_of_pinfo (pdata); -bool spisel_boot =of_property_read_bool (np,"fsl,spisel_boot" ); + spisel_boot =of_property_read_bool (np,"fsl,spisel_boot" );if (spisel_boot) { pinfo->immr_spi_cs =ioremap (get_immrbase () +IMMR_SPI_CS_OFFSET ,4 );if (!pinfo->immr_spi_cs)
@@ -734,10 +735,14 @@ static int of_fsl_spi_probe(struct platf* supported on the GRLIB variant. */ ret =gpiod_count (dev,"cs" ); -if (ret <=0 ) +if (ret <0 ) + ret =0 ; +if (ret ==0 && !spisel_boot) { pdata->max_chipselect =1 ; -else + }else { + pdata->max_chipselect = ret + spisel_boot; pdata->cs_control = fsl_spi_cs_control; + } } ret =of_address_to_resource (np,0 , &mem);
Greg Kroah-Hartman
maintainerPATCH 672/717 scsi: lpfc: Re-fix use after free in lpfc_rq_buf_free()
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
commit e5785d3ec32f5f44dd88cd7b398e496742630469 upstream.
Commit 9816ef6ecbc1 ("scsi: lpfc: Use after free in lpfc_rq_buf_free()") was made to correct a use after free condition in lpfc_rq_buf_free(). Unfortunately, a subsequent patch cut on a tree without the fix inadvertently reverted the fix.
Put the fix back: Move the freeing of the rqb_entry to after the print function that references it.
--- drivers/scsi/lpfc/lpfc_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_mem.c +1 -1
@@ -721,7 +721,6 @@ lpfc_rq_buf_free(struct lpfc_hba *phba, drqe.address_hi =putPaddrHigh (rqb_entry->dbuf.phys); rc =lpfc_sli4_rq_put (rqb_entry->hrq, rqb_entry->drq, &hrqe, &drqe);if (rc <0 ) { - (rqbp->rqb_free_buffer)(phba, rqb_entry); lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "6409 Cannot post to HRQ %d: %x %x %x " "DRQ %x %x\n",
@@ -731,6 +730,7 @@ lpfc_rq_buf_free(struct lpfc_hba *phba, rqb_entry->hrq->entry_count, rqb_entry->drq->host_index, rqb_entry->drq->hba_index); + (rqbp->rqb_free_buffer)(phba, rqb_entry); }else {list_add_tail (&rqb_entry->hbuf.list, &rqbp->rqb_buffer_list); rqbp->buffer_count++;
Greg Kroah-Hartman
maintainerPATCH 710/717 PCI: Fix pci_slot_release() NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Jubin Zhong <[email protected]>
commit 4684709bf81a2d98152ed6b610e3d5c403f9bced upstream.
If kobject_init_and_add() fails, pci_slot_release() is called to delete slot->list from parent->slots. But slot->list hasn't been initialized yet, so we dereference a NULL pointer:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 ... CPU: 10 PID: 1 Comm: swapper/0 Not tainted 4.4.240 #197 task: ffffeb398a45ef10 task.stack: ffffeb398a470000 PC is at __list_del_entry_valid+0x5c/0xb0 LR is at pci_slot_release+0x84/0xe4 ... __list_del_entry_valid+0x5c/0xb0 pci_slot_release+0x84/0xe4 kobject_put+0x184/0x1c4 pci_create_slot+0x17c/0x1b4 __pci_hp_initialize+0x68/0xa4 pciehp_probe+0x1a4/0x2fc pcie_port_probe_service+0x58/0x84 driver_probe_device+0x320/0x470
Initialize slot->list before calling kobject_init_and_add() to avoid this.
--- drivers/pci/slot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/slot.c +3 -3
@@ -272,6 +272,9 @@ placeholder: goto err; } +INIT_LIST_HEAD (&slot->list); +list_add (&slot->list, &parent->slots); + err =kobject_init_and_add (&slot->kobj, &pci_slot_ktype,NULL ,"%s" , slot_name);if (err) {
@@ -279,9 +282,6 @@ placeholder: goto err; } -INIT_LIST_HEAD (&slot->list); -list_add (&slot->list, &parent->slots); -down_read (&pci_bus_sem);list_for_each_entry (dev, &parent->devices, bus_list)if (PCI_SLOT (dev->devfn) == slot_nr)
Greg Kroah-Hartman
maintainerPATCH 684/717 iio:adc:ti-ads124s08: Fix alignment and data leak issues.
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 1e405bc2512f80a903ddd6ba8740cee885238d7f upstream.
One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable structure in the iio_priv() data with alignment explicitly requested. This data is allocated with kzalloc() so no data can leak apart from previous readings.
In this driver the timestamp can end up in various different locations depending on what other channels are enabled. As a result, we don't use a structure to specify it's position as that would be misleading.
--- drivers/iio/adc/ti-ads124s08.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/iio/adc/ti-ads124s08.c +10 -3
@@ -99,6 +99,14 @@ struct ads124s_private {struct gpio_desc *reset_gpio;struct spi_device *spi;struct mutex lock; +/* +* Used to correctly align data. +* Ensure timestamp is naturally aligned. +* Note that the full buffer length may not be needed if not +* all channels are enabled, as long as the alignment of the +* timestamp is maintained. +*/ +u32 buffer[ADS124S08_MAX_CHANNELS +sizeof (s64)/sizeof (u32)]__aligned(8) ;u8 data[5 ]____cacheline_aligned ; };
@@ -269,7 +277,6 @@ static irqreturn_t ads124s_trigger_handlstruct iio_poll_func *pf = p;struct iio_dev *indio_dev = pf->indio_dev;struct ads124s_private *priv =iio_priv (indio_dev); -u32 buffer[ADS124S08_MAX_CHANNELS +sizeof (s64)/sizeof (u32)];int scan_index, j =0 ;int ret;
@@ -284,7 +291,7 @@ static irqreturn_t ads124s_trigger_handlif (ret)dev_err (&priv->spi->dev,"Start ADC conversions failed\n" ); - buffer[j] =ads124s_read (indio_dev, scan_index); + priv->buffer[j] =ads124s_read (indio_dev, scan_index); ret =ads124s_write_cmd (indio_dev,ADS124S08_STOP_CONV );if (ret)dev_err (&priv->spi->dev,"Stop ADC conversions failed\n" );
@@ -292,7 +299,7 @@ static irqreturn_t ads124s_trigger_handl j++; } -iio_push_to_buffers_with_timestamp (indio_dev, buffer, +iio_push_to_buffers_with_timestamp (indio_dev, priv->buffer, pf->timestamp);iio_trigger_notify_done (indio_dev->trig);