From: Sasha Levin Date: Mon, 20 Nov 2023 14:23:34 +0000 (-0500) Subject: Fixes for 4.19 X-Git-Tag: v4.14.331~149 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bef59846288d08ac3bef27cf6bf9d30523aa22af;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.19 Signed-off-by: Sasha Levin --- diff --git a/queue-4.19/alsa-hda-fix-possible-null-ptr-deref-when-assigning-.patch b/queue-4.19/alsa-hda-fix-possible-null-ptr-deref-when-assigning-.patch new file mode 100644 index 00000000000..fc064a673ae --- /dev/null +++ b/queue-4.19/alsa-hda-fix-possible-null-ptr-deref-when-assigning-.patch @@ -0,0 +1,42 @@ +From 1e011b3edc37d0f8212258cf5a49eb1f22bef095 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 6 Oct 2023 12:28:55 +0200 +Subject: ALSA: hda: Fix possible null-ptr-deref when assigning a stream + +From: Cezary Rojewski + +[ Upstream commit f93dc90c2e8ed664985e366aa6459ac83cdab236 ] + +While AudioDSP drivers assign streams exclusively of HOST or LINK type, +nothing blocks a user to attempt to assign a COUPLED stream. As +supplied substream instance may be a stub, what is the case when +code-loading, such scenario ends with null-ptr-deref. + +Signed-off-by: Cezary Rojewski +Link: https://lore.kernel.org/r/20231006102857.749143-2-cezary.rojewski@intel.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/hda/hdac_stream.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c +index eee422390d8e2..2569f82b6fa02 100644 +--- a/sound/hda/hdac_stream.c ++++ b/sound/hda/hdac_stream.c +@@ -241,8 +241,10 @@ struct hdac_stream *snd_hdac_stream_assign(struct hdac_bus *bus, + struct hdac_stream *res = NULL; + + /* make a non-zero unique key for the substream */ +- int key = (substream->pcm->device << 16) | (substream->number << 2) | +- (substream->stream + 1); ++ int key = (substream->number << 2) | (substream->stream + 1); ++ ++ if (substream->pcm) ++ key |= (substream->pcm->device << 16); + + list_for_each_entry(azx_dev, &bus->stream_list, list) { + if (azx_dev->direction != substream->stream) +-- +2.42.0 + diff --git a/queue-4.19/arm-9320-1-fix-stack-depot-irq-stack-filter.patch b/queue-4.19/arm-9320-1-fix-stack-depot-irq-stack-filter.patch new file mode 100644 index 00000000000..6a8a7ddab6d --- /dev/null +++ b/queue-4.19/arm-9320-1-fix-stack-depot-irq-stack-filter.patch @@ -0,0 +1,45 @@ +From 1a2f5cafc3c12836959fdc2836e96f06136f8a1e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 21 Aug 2023 08:45:21 +0100 +Subject: ARM: 9320/1: fix stack depot IRQ stack filter + +From: Vincent Whitchurch + +[ Upstream commit b0150014878c32197cfa66e3e2f79e57f66babc0 ] + +Place IRQ handlers such as gic_handle_irq() in the irqentry section even +if FUNCTION_GRAPH_TRACER is not enabled. Without this, the stack +depot's filter_irq_stacks() does not correctly filter out IRQ stacks in +those configurations, which hampers deduplication and eventually leads +to "Stack depot reached limit capacity" splats with KASAN. + +A similar fix was done for arm64 in commit f6794950f0e5ba37e3bbed +("arm64: set __exception_irq_entry with __irq_entry as a default"). + +Link: https://lore.kernel.org/r/20230803-arm-irqentry-v1-1-8aad8e260b1c@axis.com + +Signed-off-by: Vincent Whitchurch +Signed-off-by: Russell King (Oracle) +Signed-off-by: Sasha Levin +--- + arch/arm/include/asm/exception.h | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/arch/arm/include/asm/exception.h b/arch/arm/include/asm/exception.h +index 58e039a851af0..3c82975d46db3 100644 +--- a/arch/arm/include/asm/exception.h ++++ b/arch/arm/include/asm/exception.h +@@ -10,10 +10,6 @@ + + #include + +-#ifdef CONFIG_FUNCTION_GRAPH_TRACER + #define __exception_irq_entry __irq_entry +-#else +-#define __exception_irq_entry +-#endif + + #endif /* __ASM_ARM_EXCEPTION_H */ +-- +2.42.0 + diff --git a/queue-4.19/atm-iphase-do-pci-error-checks-on-own-line.patch b/queue-4.19/atm-iphase-do-pci-error-checks-on-own-line.patch new file mode 100644 index 00000000000..a7f2a219833 --- /dev/null +++ b/queue-4.19/atm-iphase-do-pci-error-checks-on-own-line.patch @@ -0,0 +1,68 @@ +From 57a32d3b8f1b90f65f05f5fd8696d49e19c356e4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 11 Sep 2023 15:53:51 +0300 +Subject: atm: iphase: Do PCI error checks on own line +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilpo Järvinen + +[ Upstream commit c28742447ca9879b52fbaf022ad844f0ffcd749c ] + +In get_esi() PCI errors are checked inside line-split "if" conditions (in +addition to the file not following the coding style). To make the code in +get_esi() more readable, fix the coding style and use the usual error +handling pattern with a separate variable. + +In addition, initialization of 'error' variable at declaration is not +needed. + +No functional changes intended. + +Link: https://lore.kernel.org/r/20230911125354.25501-4-ilpo.jarvinen@linux.intel.com +Signed-off-by: Ilpo Järvinen +Signed-off-by: Bjorn Helgaas +Signed-off-by: Sasha Levin +--- + drivers/atm/iphase.c | 20 +++++++++++--------- + 1 file changed, 11 insertions(+), 9 deletions(-) + +diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c +index 827c6d5e61774..b6d8c2660e4a0 100644 +--- a/drivers/atm/iphase.c ++++ b/drivers/atm/iphase.c +@@ -2290,19 +2290,21 @@ static int get_esi(struct atm_dev *dev) + static int reset_sar(struct atm_dev *dev) + { + IADEV *iadev; +- int i, error = 1; ++ int i, error; + unsigned int pci[64]; + + iadev = INPH_IA_DEV(dev); +- for(i=0; i<64; i++) +- if ((error = pci_read_config_dword(iadev->pci, +- i*4, &pci[i])) != PCIBIOS_SUCCESSFUL) +- return error; ++ for (i = 0; i < 64; i++) { ++ error = pci_read_config_dword(iadev->pci, i * 4, &pci[i]); ++ if (error != PCIBIOS_SUCCESSFUL) ++ return error; ++ } + writel(0, iadev->reg+IPHASE5575_EXT_RESET); +- for(i=0; i<64; i++) +- if ((error = pci_write_config_dword(iadev->pci, +- i*4, pci[i])) != PCIBIOS_SUCCESSFUL) +- return error; ++ for (i = 0; i < 64; i++) { ++ error = pci_write_config_dword(iadev->pci, i * 4, pci[i]); ++ if (error != PCIBIOS_SUCCESSFUL) ++ return error; ++ } + udelay(5); + return 0; + } +-- +2.42.0 + diff --git a/queue-4.19/bluetooth-fix-double-free-in-hci_conn_cleanup.patch b/queue-4.19/bluetooth-fix-double-free-in-hci_conn_cleanup.patch new file mode 100644 index 00000000000..ee752f9e5d0 --- /dev/null +++ b/queue-4.19/bluetooth-fix-double-free-in-hci_conn_cleanup.patch @@ -0,0 +1,139 @@ +From 11cd3786c879c60c8f6897309a8070561f3b2724 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 18 Oct 2023 12:30:55 +0200 +Subject: Bluetooth: Fix double free in hci_conn_cleanup + +From: ZhengHan Wang + +[ Upstream commit a85fb91e3d728bdfc80833167e8162cce8bc7004 ] + +syzbot reports a slab use-after-free in hci_conn_hash_flush [1]. +After releasing an object using hci_conn_del_sysfs in the +hci_conn_cleanup function, releasing the same object again +using the hci_dev_put and hci_conn_put functions causes a double free. +Here's a simplified flow: + +hci_conn_del_sysfs: + hci_dev_put + put_device + kobject_put + kref_put + kobject_release + kobject_cleanup + kfree_const + kfree(name) + +hci_dev_put: + ... + kfree(name) + +hci_conn_put: + put_device + ... + kfree(name) + +This patch drop the hci_dev_put and hci_conn_put function +call in hci_conn_cleanup function, because the object is +freed in hci_conn_del_sysfs function. + +This patch also fixes the refcounting in hci_conn_add_sysfs() and +hci_conn_del_sysfs() to take into account device_add() failures. + +This fixes CVE-2023-28464. + +Link: https://syzkaller.appspot.com/bug?id=1bb51491ca5df96a5f724899d1dbb87afda61419 [1] + +Signed-off-by: ZhengHan Wang +Co-developed-by: Luiz Augusto von Dentz +Signed-off-by: Luiz Augusto von Dentz +Signed-off-by: Sasha Levin +--- + net/bluetooth/hci_conn.c | 6 ++---- + net/bluetooth/hci_sysfs.c | 23 ++++++++++++----------- + 2 files changed, 14 insertions(+), 15 deletions(-) + +diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c +index b876e97b61c92..0e837feaa527e 100644 +--- a/net/bluetooth/hci_conn.c ++++ b/net/bluetooth/hci_conn.c +@@ -125,13 +125,11 @@ static void hci_conn_cleanup(struct hci_conn *conn) + if (hdev->notify) + hdev->notify(hdev, HCI_NOTIFY_CONN_DEL); + +- hci_conn_del_sysfs(conn); +- + debugfs_remove_recursive(conn->debugfs); + +- hci_dev_put(hdev); ++ hci_conn_del_sysfs(conn); + +- hci_conn_put(conn); ++ hci_dev_put(hdev); + } + + static void le_scan_cleanup(struct work_struct *work) +diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c +index ccd2c377bf83c..266112c960ee8 100644 +--- a/net/bluetooth/hci_sysfs.c ++++ b/net/bluetooth/hci_sysfs.c +@@ -33,7 +33,7 @@ void hci_conn_init_sysfs(struct hci_conn *conn) + { + struct hci_dev *hdev = conn->hdev; + +- BT_DBG("conn %p", conn); ++ bt_dev_dbg(hdev, "conn %p", conn); + + conn->dev.type = &bt_link; + conn->dev.class = bt_class; +@@ -46,27 +46,30 @@ void hci_conn_add_sysfs(struct hci_conn *conn) + { + struct hci_dev *hdev = conn->hdev; + +- BT_DBG("conn %p", conn); ++ bt_dev_dbg(hdev, "conn %p", conn); + + if (device_is_registered(&conn->dev)) + return; + + dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle); + +- if (device_add(&conn->dev) < 0) { ++ if (device_add(&conn->dev) < 0) + bt_dev_err(hdev, "failed to register connection device"); +- return; +- } +- +- hci_dev_hold(hdev); + } + + void hci_conn_del_sysfs(struct hci_conn *conn) + { + struct hci_dev *hdev = conn->hdev; + +- if (!device_is_registered(&conn->dev)) ++ bt_dev_dbg(hdev, "conn %p", conn); ++ ++ if (!device_is_registered(&conn->dev)) { ++ /* If device_add() has *not* succeeded, use *only* put_device() ++ * to drop the reference count. ++ */ ++ put_device(&conn->dev); + return; ++ } + + while (1) { + struct device *dev; +@@ -78,9 +81,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn) + put_device(dev); + } + +- device_del(&conn->dev); +- +- hci_dev_put(hdev); ++ device_unregister(&conn->dev); + } + + static void bt_host_release(struct device *dev) +-- +2.42.0 + diff --git a/queue-4.19/cifs-spnego-add-in-host_key_len.patch b/queue-4.19/cifs-spnego-add-in-host_key_len.patch new file mode 100644 index 00000000000..54811bb6f8b --- /dev/null +++ b/queue-4.19/cifs-spnego-add-in-host_key_len.patch @@ -0,0 +1,43 @@ +From 8a761194e0ba13efa4f7387479c02e445c701a59 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 13 Nov 2023 17:52:32 +0300 +Subject: cifs: spnego: add ';' in HOST_KEY_LEN + +From: Anastasia Belova + +[ Upstream commit ff31ba19d732efb9aca3633935d71085e68d5076 ] + +"host=" should start with ';' (as in cifs_get_spnego_key) +So its length should be 6. + +Found by Linux Verification Center (linuxtesting.org) with SVACE. + +Reviewed-by: Paulo Alcantara (SUSE) +Fixes: 7c9c3760b3a5 ("[CIFS] add constants for string lengths of keynames in SPNEGO upcall string") +Signed-off-by: Anastasia Belova +Co-developed-by: Ekaterina Esina +Signed-off-by: Ekaterina Esina +Signed-off-by: Steve French +Signed-off-by: Sasha Levin +--- + fs/cifs/cifs_spnego.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c +index 7f01c6e607918..6eb65988321fc 100644 +--- a/fs/cifs/cifs_spnego.c ++++ b/fs/cifs/cifs_spnego.c +@@ -76,8 +76,8 @@ struct key_type cifs_spnego_key_type = { + * strlen(";sec=ntlmsspi") */ + #define MAX_MECH_STR_LEN 13 + +-/* strlen of "host=" */ +-#define HOST_KEY_LEN 5 ++/* strlen of ";host=" */ ++#define HOST_KEY_LEN 6 + + /* strlen of ";ip4=" or ";ip6=" */ + #define IP_KEY_LEN 5 +-- +2.42.0 + diff --git a/queue-4.19/clocksource-drivers-timer-atmel-tcb-fix-initializati.patch b/queue-4.19/clocksource-drivers-timer-atmel-tcb-fix-initializati.patch new file mode 100644 index 00000000000..d9ac8eb85eb --- /dev/null +++ b/queue-4.19/clocksource-drivers-timer-atmel-tcb-fix-initializati.patch @@ -0,0 +1,56 @@ +From de258b11e8ff9c7b6af2780ff51e2aae1278137c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 7 Oct 2023 18:17:13 +0200 +Subject: clocksource/drivers/timer-atmel-tcb: Fix initialization on SAM9 + hardware + +From: Ronald Wahl + +[ Upstream commit 6d3bc4c02d59996d1d3180d8ed409a9d7d5900e0 ] + +On SAM9 hardware two cascaded 16 bit timers are used to form a 32 bit +high resolution timer that is used as scheduler clock when the kernel +has been configured that way (CONFIG_ATMEL_CLOCKSOURCE_TCB). + +The driver initially triggers a reset-to-zero of the two timers but this +reset is only performed on the next rising clock. For the first timer +this is ok - it will be in the next 60ns (16MHz clock). For the chained +second timer this will only happen after the first timer overflows, i.e. +after 2^16 clocks (~4ms with a 16MHz clock). So with other words the +scheduler clock resets to 0 after the first 2^16 clock cycles. + +It looks like that the scheduler does not like this and behaves wrongly +over its lifetime, e.g. some tasks are scheduled with a long delay. Why +that is and if there are additional requirements for this behaviour has +not been further analysed. + +There is a simple fix for resetting the second timer as well when the +first timer is reset and this is to set the ATMEL_TC_ASWTRG_SET bit in +the Channel Mode register (CMR) of the first timer. This will also rise +the TIOA line (clock input of the second timer) when a software trigger +respective SYNC is issued. + +Signed-off-by: Ronald Wahl +Acked-by: Alexandre Belloni +Signed-off-by: Daniel Lezcano +Link: https://lore.kernel.org/r/20231007161803.31342-1-rwahl@gmx.de +Signed-off-by: Sasha Levin +--- + drivers/clocksource/tcb_clksrc.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c +index 43f4d5c4d6fa4..998d9115add6b 100644 +--- a/drivers/clocksource/tcb_clksrc.c ++++ b/drivers/clocksource/tcb_clksrc.c +@@ -294,6 +294,7 @@ static void __init tcb_setup_dual_chan(struct atmel_tc *tc, int mck_divisor_idx) + writel(mck_divisor_idx /* likely divide-by-8 */ + | ATMEL_TC_WAVE + | ATMEL_TC_WAVESEL_UP /* free-run */ ++ | ATMEL_TC_ASWTRG_SET /* TIOA0 rises at software trigger */ + | ATMEL_TC_ACPA_SET /* TIOA0 rises at 0 */ + | ATMEL_TC_ACPC_CLEAR, /* (duty cycle 50%) */ + tcaddr + ATMEL_TC_REG(0, CMR)); +-- +2.42.0 + diff --git a/queue-4.19/clocksource-drivers-timer-imx-gpt-fix-potential-memo.patch b/queue-4.19/clocksource-drivers-timer-imx-gpt-fix-potential-memo.patch new file mode 100644 index 00000000000..f146ab71e7f --- /dev/null +++ b/queue-4.19/clocksource-drivers-timer-imx-gpt-fix-potential-memo.patch @@ -0,0 +1,66 @@ +From 222b0ae4a21b6f6afb4f1d9c9d2631178ad577c2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 9 Oct 2023 16:39:22 +0800 +Subject: clocksource/drivers/timer-imx-gpt: Fix potential memory leak + +From: Jacky Bai + +[ Upstream commit 8051a993ce222a5158bccc6ac22ace9253dd71cb ] + +Fix coverity Issue CID 250382: Resource leak (RESOURCE_LEAK). +Add kfree when error return. + +Signed-off-by: Jacky Bai +Reviewed-by: Peng Fan +Signed-off-by: Daniel Lezcano +Link: https://lore.kernel.org/r/20231009083922.1942971-1-ping.bai@nxp.com +Signed-off-by: Sasha Levin +--- + drivers/clocksource/timer-imx-gpt.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c +index 165fbbb1c9a04..0e67026d782fe 100644 +--- a/drivers/clocksource/timer-imx-gpt.c ++++ b/drivers/clocksource/timer-imx-gpt.c +@@ -473,12 +473,16 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t + return -ENOMEM; + + imxtm->base = of_iomap(np, 0); +- if (!imxtm->base) +- return -ENXIO; ++ if (!imxtm->base) { ++ ret = -ENXIO; ++ goto err_kfree; ++ } + + imxtm->irq = irq_of_parse_and_map(np, 0); +- if (imxtm->irq <= 0) +- return -EINVAL; ++ if (imxtm->irq <= 0) { ++ ret = -EINVAL; ++ goto err_kfree; ++ } + + imxtm->clk_ipg = of_clk_get_by_name(np, "ipg"); + +@@ -491,11 +495,15 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t + + ret = _mxc_timer_init(imxtm); + if (ret) +- return ret; ++ goto err_kfree; + + initialized = 1; + + return 0; ++ ++err_kfree: ++ kfree(imxtm); ++ return ret; + } + + static int __init imx1_timer_init_dt(struct device_node *np) +-- +2.42.0 + diff --git a/queue-4.19/crypto-pcrypt-fix-hungtask-for-padata_reset.patch b/queue-4.19/crypto-pcrypt-fix-hungtask-for-padata_reset.patch new file mode 100644 index 00000000000..5ed7e57a38d --- /dev/null +++ b/queue-4.19/crypto-pcrypt-fix-hungtask-for-padata_reset.patch @@ -0,0 +1,106 @@ +From 907a844b8b3bcaa80f29962411726dadaa4f7868 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Sep 2023 13:33:41 +0000 +Subject: crypto: pcrypt - Fix hungtask for PADATA_RESET + +From: Lu Jialin + +[ Upstream commit 8f4f68e788c3a7a696546291258bfa5fdb215523 ] + +We found a hungtask bug in test_aead_vec_cfg as follows: + +INFO: task cryptomgr_test:391009 blocked for more than 120 seconds. +"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. +Call trace: + __switch_to+0x98/0xe0 + __schedule+0x6c4/0xf40 + schedule+0xd8/0x1b4 + schedule_timeout+0x474/0x560 + wait_for_common+0x368/0x4e0 + wait_for_completion+0x20/0x30 + wait_for_completion+0x20/0x30 + test_aead_vec_cfg+0xab4/0xd50 + test_aead+0x144/0x1f0 + alg_test_aead+0xd8/0x1e0 + alg_test+0x634/0x890 + cryptomgr_test+0x40/0x70 + kthread+0x1e0/0x220 + ret_from_fork+0x10/0x18 + Kernel panic - not syncing: hung_task: blocked tasks + +For padata_do_parallel, when the return err is 0 or -EBUSY, it will call +wait_for_completion(&wait->completion) in test_aead_vec_cfg. In normal +case, aead_request_complete() will be called in pcrypt_aead_serial and the +return err is 0 for padata_do_parallel. But, when pinst->flags is +PADATA_RESET, the return err is -EBUSY for padata_do_parallel, and it +won't call aead_request_complete(). Therefore, test_aead_vec_cfg will +hung at wait_for_completion(&wait->completion), which will cause +hungtask. + +The problem comes as following: +(padata_do_parallel) | + rcu_read_lock_bh(); | + err = -EINVAL; | (padata_replace) + | pinst->flags |= PADATA_RESET; + err = -EBUSY | + if (pinst->flags & PADATA_RESET) | + rcu_read_unlock_bh() | + return err + +In order to resolve the problem, we replace the return err -EBUSY with +-EAGAIN, which means parallel_data is changing, and the caller should call +it again. + +v3: +remove retry and just change the return err. +v2: +introduce padata_try_do_parallel() in pcrypt_aead_encrypt and +pcrypt_aead_decrypt to solve the hungtask. + +Signed-off-by: Lu Jialin +Signed-off-by: Guo Zihua +Signed-off-by: Herbert Xu +Signed-off-by: Sasha Levin +--- + crypto/pcrypt.c | 4 ++++ + kernel/padata.c | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c +index 62e11835f220e..1e9de81ef84fa 100644 +--- a/crypto/pcrypt.c ++++ b/crypto/pcrypt.c +@@ -174,6 +174,8 @@ static int pcrypt_aead_encrypt(struct aead_request *req) + err = pcrypt_do_parallel(padata, &ctx->cb_cpu, &pencrypt); + if (!err) + return -EINPROGRESS; ++ if (err == -EBUSY) ++ return -EAGAIN; + + return err; + } +@@ -218,6 +220,8 @@ static int pcrypt_aead_decrypt(struct aead_request *req) + err = pcrypt_do_parallel(padata, &ctx->cb_cpu, &pdecrypt); + if (!err) + return -EINPROGRESS; ++ if (err == -EBUSY) ++ return -EAGAIN; + + return err; + } +diff --git a/kernel/padata.c b/kernel/padata.c +index 7f2b6d369fd47..a9e14183e1884 100644 +--- a/kernel/padata.c ++++ b/kernel/padata.c +@@ -121,7 +121,7 @@ int padata_do_parallel(struct padata_instance *pinst, + if (!cpumask_test_cpu(cb_cpu, pd->cpumask.cbcpu)) + goto out; + +- err = -EBUSY; ++ err = -EBUSY; + if ((pinst->flags & PADATA_RESET)) + goto out; + +-- +2.42.0 + diff --git a/queue-4.19/drm-amd-display-avoid-null-dereference-of-timing-gen.patch b/queue-4.19/drm-amd-display-avoid-null-dereference-of-timing-gen.patch new file mode 100644 index 00000000000..ee5e53d0b01 --- /dev/null +++ b/queue-4.19/drm-amd-display-avoid-null-dereference-of-timing-gen.patch @@ -0,0 +1,48 @@ +From 6c1d4403241dce78af1000e31b098c8d04a09a54 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 8 Sep 2023 10:14:49 +0800 +Subject: drm/amd/display: Avoid NULL dereference of timing generator + +From: Wayne Lin + +[ Upstream commit b1904ed480cee3f9f4036ea0e36d139cb5fee2d6 ] + +[Why & How] +Check whether assigned timing generator is NULL or not before +accessing its funcs to prevent NULL dereference. + +Reviewed-by: Jun Lei +Acked-by: Hersen Wu +Signed-off-by: Wayne Lin +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +index fdcc8ab19bf3f..25b8a8f933821 100644 +--- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c ++++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +@@ -281,7 +281,7 @@ uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream) + for (i = 0; i < MAX_PIPES; i++) { + struct timing_generator *tg = res_ctx->pipe_ctx[i].stream_res.tg; + +- if (res_ctx->pipe_ctx[i].stream != stream) ++ if (res_ctx->pipe_ctx[i].stream != stream || !tg) + continue; + + return tg->funcs->get_frame_count(tg); +@@ -305,7 +305,7 @@ bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream, + for (i = 0; i < MAX_PIPES; i++) { + struct timing_generator *tg = res_ctx->pipe_ctx[i].stream_res.tg; + +- if (res_ctx->pipe_ctx[i].stream != stream) ++ if (res_ctx->pipe_ctx[i].stream != stream || !tg) + continue; + + tg->funcs->get_scanoutpos(tg, +-- +2.42.0 + diff --git a/queue-4.19/drm-amd-fix-ubsan-array-index-out-of-bounds-for-pola.patch b/queue-4.19/drm-amd-fix-ubsan-array-index-out-of-bounds-for-pola.patch new file mode 100644 index 00000000000..7fe8e9fb9e5 --- /dev/null +++ b/queue-4.19/drm-amd-fix-ubsan-array-index-out-of-bounds-for-pola.patch @@ -0,0 +1,81 @@ +From 693b54e401ec770a9ada089fd69822cc64939f1c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 4 Oct 2023 15:46:44 -0500 +Subject: drm/amd: Fix UBSAN array-index-out-of-bounds for Polaris and Tonga + +From: Mario Limonciello + +[ Upstream commit 0f0e59075b5c22f1e871fbd508d6e4f495048356 ] + +For pptable structs that use flexible array sizes, use flexible arrays. + +Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2036742 +Signed-off-by: Mario Limonciello +Acked-by: Alex Deucher +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h b/drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h +index d5a4a08c6d392..0c61e2bc14cde 100644 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h +@@ -164,7 +164,7 @@ typedef struct _ATOM_Tonga_State { + typedef struct _ATOM_Tonga_State_Array { + UCHAR ucRevId; + UCHAR ucNumEntries; /* Number of entries. */ +- ATOM_Tonga_State entries[1]; /* Dynamically allocate entries. */ ++ ATOM_Tonga_State entries[]; /* Dynamically allocate entries. */ + } ATOM_Tonga_State_Array; + + typedef struct _ATOM_Tonga_MCLK_Dependency_Record { +@@ -210,7 +210,7 @@ typedef struct _ATOM_Polaris_SCLK_Dependency_Record { + typedef struct _ATOM_Polaris_SCLK_Dependency_Table { + UCHAR ucRevId; + UCHAR ucNumEntries; /* Number of entries. */ +- ATOM_Polaris_SCLK_Dependency_Record entries[1]; /* Dynamically allocate entries. */ ++ ATOM_Polaris_SCLK_Dependency_Record entries[]; /* Dynamically allocate entries. */ + } ATOM_Polaris_SCLK_Dependency_Table; + + typedef struct _ATOM_Tonga_PCIE_Record { +@@ -222,7 +222,7 @@ typedef struct _ATOM_Tonga_PCIE_Record { + typedef struct _ATOM_Tonga_PCIE_Table { + UCHAR ucRevId; + UCHAR ucNumEntries; /* Number of entries. */ +- ATOM_Tonga_PCIE_Record entries[1]; /* Dynamically allocate entries. */ ++ ATOM_Tonga_PCIE_Record entries[]; /* Dynamically allocate entries. */ + } ATOM_Tonga_PCIE_Table; + + typedef struct _ATOM_Polaris10_PCIE_Record { +@@ -235,7 +235,7 @@ typedef struct _ATOM_Polaris10_PCIE_Record { + typedef struct _ATOM_Polaris10_PCIE_Table { + UCHAR ucRevId; + UCHAR ucNumEntries; /* Number of entries. */ +- ATOM_Polaris10_PCIE_Record entries[1]; /* Dynamically allocate entries. */ ++ ATOM_Polaris10_PCIE_Record entries[]; /* Dynamically allocate entries. */ + } ATOM_Polaris10_PCIE_Table; + + +@@ -252,7 +252,7 @@ typedef struct _ATOM_Tonga_MM_Dependency_Record { + typedef struct _ATOM_Tonga_MM_Dependency_Table { + UCHAR ucRevId; + UCHAR ucNumEntries; /* Number of entries. */ +- ATOM_Tonga_MM_Dependency_Record entries[1]; /* Dynamically allocate entries. */ ++ ATOM_Tonga_MM_Dependency_Record entries[]; /* Dynamically allocate entries. */ + } ATOM_Tonga_MM_Dependency_Table; + + typedef struct _ATOM_Tonga_Voltage_Lookup_Record { +@@ -265,7 +265,7 @@ typedef struct _ATOM_Tonga_Voltage_Lookup_Record { + typedef struct _ATOM_Tonga_Voltage_Lookup_Table { + UCHAR ucRevId; + UCHAR ucNumEntries; /* Number of entries. */ +- ATOM_Tonga_Voltage_Lookup_Record entries[1]; /* Dynamically allocate entries. */ ++ ATOM_Tonga_Voltage_Lookup_Record entries[]; /* Dynamically allocate entries. */ + } ATOM_Tonga_Voltage_Lookup_Table; + + typedef struct _ATOM_Tonga_Fan_Table { +-- +2.42.0 + diff --git a/queue-4.19/drm-amd-fix-ubsan-array-index-out-of-bounds-for-smu7.patch b/queue-4.19/drm-amd-fix-ubsan-array-index-out-of-bounds-for-smu7.patch new file mode 100644 index 00000000000..ef6e169c6db --- /dev/null +++ b/queue-4.19/drm-amd-fix-ubsan-array-index-out-of-bounds-for-smu7.patch @@ -0,0 +1,69 @@ +From e0be1432cc3bbf90eb7b1a89c3b717b391b21739 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 4 Oct 2023 15:22:52 -0500 +Subject: drm/amd: Fix UBSAN array-index-out-of-bounds for SMU7 + +From: Mario Limonciello + +[ Upstream commit 760efbca74a405dc439a013a5efaa9fadc95a8c3 ] + +For pptable structs that use flexible array sizes, use flexible arrays. + +Suggested-by: Felix Held +Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2874 +Signed-off-by: Mario Limonciello +Acked-by: Alex Deucher +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/include/pptable.h | 4 ++-- + drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/gpu/drm/amd/include/pptable.h b/drivers/gpu/drm/amd/include/pptable.h +index 0b6a057e0a4c4..5aac8d545bdc6 100644 +--- a/drivers/gpu/drm/amd/include/pptable.h ++++ b/drivers/gpu/drm/amd/include/pptable.h +@@ -78,7 +78,7 @@ typedef struct _ATOM_PPLIB_THERMALCONTROLLER + typedef struct _ATOM_PPLIB_STATE + { + UCHAR ucNonClockStateIndex; +- UCHAR ucClockStateIndices[1]; // variable-sized ++ UCHAR ucClockStateIndices[]; // variable-sized + } ATOM_PPLIB_STATE; + + +@@ -473,7 +473,7 @@ typedef struct _ATOM_PPLIB_STATE_V2 + /** + * Driver will read the first ucNumDPMLevels in this array + */ +- UCHAR clockInfoIndex[1]; ++ UCHAR clockInfoIndex[]; + } ATOM_PPLIB_STATE_V2; + + typedef struct _StateArray{ +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h b/drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h +index 1e870f58dd12a..d5a4a08c6d392 100644 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h +@@ -179,7 +179,7 @@ typedef struct _ATOM_Tonga_MCLK_Dependency_Record { + typedef struct _ATOM_Tonga_MCLK_Dependency_Table { + UCHAR ucRevId; + UCHAR ucNumEntries; /* Number of entries. */ +- ATOM_Tonga_MCLK_Dependency_Record entries[1]; /* Dynamically allocate entries. */ ++ ATOM_Tonga_MCLK_Dependency_Record entries[]; /* Dynamically allocate entries. */ + } ATOM_Tonga_MCLK_Dependency_Table; + + typedef struct _ATOM_Tonga_SCLK_Dependency_Record { +@@ -194,7 +194,7 @@ typedef struct _ATOM_Tonga_SCLK_Dependency_Record { + typedef struct _ATOM_Tonga_SCLK_Dependency_Table { + UCHAR ucRevId; + UCHAR ucNumEntries; /* Number of entries. */ +- ATOM_Tonga_SCLK_Dependency_Record entries[1]; /* Dynamically allocate entries. */ ++ ATOM_Tonga_SCLK_Dependency_Record entries[]; /* Dynamically allocate entries. */ + } ATOM_Tonga_SCLK_Dependency_Table; + + typedef struct _ATOM_Polaris_SCLK_Dependency_Record { +-- +2.42.0 + diff --git a/queue-4.19/drm-amdgpu-fix-a-null-pointer-access-when-the-smc_rr.patch b/queue-4.19/drm-amdgpu-fix-a-null-pointer-access-when-the-smc_rr.patch new file mode 100644 index 00000000000..76154d4b9d4 --- /dev/null +++ b/queue-4.19/drm-amdgpu-fix-a-null-pointer-access-when-the-smc_rr.patch @@ -0,0 +1,105 @@ +From 9717149f93997f771a16d3185082e320ef0bedab Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 23 Oct 2023 12:56:37 +0000 +Subject: drm/amdgpu: Fix a null pointer access when the smc_rreg pointer is + NULL + +From: Qu Huang + +[ Upstream commit 5104fdf50d326db2c1a994f8b35dcd46e63ae4ad ] + +In certain types of chips, such as VEGA20, reading the amdgpu_regs_smc file could result in an abnormal null pointer access when the smc_rreg pointer is NULL. Below are the steps to reproduce this issue and the corresponding exception log: + +1. Navigate to the directory: /sys/kernel/debug/dri/0 +2. Execute command: cat amdgpu_regs_smc +3. Exception Log:: +[4005007.702554] BUG: kernel NULL pointer dereference, address: 0000000000000000 +[4005007.702562] #PF: supervisor instruction fetch in kernel mode +[4005007.702567] #PF: error_code(0x0010) - not-present page +[4005007.702570] PGD 0 P4D 0 +[4005007.702576] Oops: 0010 [#1] SMP NOPTI +[4005007.702581] CPU: 4 PID: 62563 Comm: cat Tainted: G OE 5.15.0-43-generic #46-Ubunt u +[4005007.702590] RIP: 0010:0x0 +[4005007.702598] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6. +[4005007.702600] RSP: 0018:ffffa82b46d27da0 EFLAGS: 00010206 +[4005007.702605] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffa82b46d27e68 +[4005007.702609] RDX: 0000000000000001 RSI: 0000000000000000 RDI: ffff9940656e0000 +[4005007.702612] RBP: ffffa82b46d27dd8 R08: 0000000000000000 R09: ffff994060c07980 +[4005007.702615] R10: 0000000000020000 R11: 0000000000000000 R12: 00007f5e06753000 +[4005007.702618] R13: ffff9940656e0000 R14: ffffa82b46d27e68 R15: 00007f5e06753000 +[4005007.702622] FS: 00007f5e0755b740(0000) GS:ffff99479d300000(0000) knlGS:0000000000000000 +[4005007.702626] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +[4005007.702629] CR2: ffffffffffffffd6 CR3: 00000003253fc000 CR4: 00000000003506e0 +[4005007.702633] Call Trace: +[4005007.702636] +[4005007.702640] amdgpu_debugfs_regs_smc_read+0xb0/0x120 [amdgpu] +[4005007.703002] full_proxy_read+0x5c/0x80 +[4005007.703011] vfs_read+0x9f/0x1a0 +[4005007.703019] ksys_read+0x67/0xe0 +[4005007.703023] __x64_sys_read+0x19/0x20 +[4005007.703028] do_syscall_64+0x5c/0xc0 +[4005007.703034] ? do_user_addr_fault+0x1e3/0x670 +[4005007.703040] ? exit_to_user_mode_prepare+0x37/0xb0 +[4005007.703047] ? irqentry_exit_to_user_mode+0x9/0x20 +[4005007.703052] ? irqentry_exit+0x19/0x30 +[4005007.703057] ? exc_page_fault+0x89/0x160 +[4005007.703062] ? asm_exc_page_fault+0x8/0x30 +[4005007.703068] entry_SYSCALL_64_after_hwframe+0x44/0xae +[4005007.703075] RIP: 0033:0x7f5e07672992 +[4005007.703079] Code: c0 e9 b2 fe ff ff 50 48 8d 3d fa b2 0c 00 e8 c5 1d 02 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 e c 28 48 89 54 24 +[4005007.703083] RSP: 002b:00007ffe03097898 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 +[4005007.703088] RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007f5e07672992 +[4005007.703091] RDX: 0000000000020000 RSI: 00007f5e06753000 RDI: 0000000000000003 +[4005007.703094] RBP: 00007f5e06753000 R08: 00007f5e06752010 R09: 00007f5e06752010 +[4005007.703096] R10: 0000000000000022 R11: 0000000000000246 R12: 0000000000022000 +[4005007.703099] R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000020000 +[4005007.703105] +[4005007.703107] Modules linked in: nf_tables libcrc32c nfnetlink algif_hash af_alg binfmt_misc nls_ iso8859_1 ipmi_ssif ast intel_rapl_msr intel_rapl_common drm_vram_helper drm_ttm_helper amd64_edac t tm edac_mce_amd kvm_amd ccp mac_hid k10temp kvm acpi_ipmi ipmi_si rapl sch_fq_codel ipmi_devintf ipm i_msghandler msr parport_pc ppdev lp parport mtd pstore_blk efi_pstore ramoops pstore_zone reed_solo mon ip_tables x_tables autofs4 ib_uverbs ib_core amdgpu(OE) amddrm_ttm_helper(OE) amdttm(OE) iommu_v 2 amd_sched(OE) amdkcl(OE) drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops cec rc_core drm igb ahci xhci_pci libahci i2c_piix4 i2c_algo_bit xhci_pci_renesas dca +[4005007.703184] CR2: 0000000000000000 +[4005007.703188] ---[ end trace ac65a538d240da39 ]--- +[4005007.800865] RIP: 0010:0x0 +[4005007.800871] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6. +[4005007.800874] RSP: 0018:ffffa82b46d27da0 EFLAGS: 00010206 +[4005007.800878] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffa82b46d27e68 +[4005007.800881] RDX: 0000000000000001 RSI: 0000000000000000 RDI: ffff9940656e0000 +[4005007.800883] RBP: ffffa82b46d27dd8 R08: 0000000000000000 R09: ffff994060c07980 +[4005007.800886] R10: 0000000000020000 R11: 0000000000000000 R12: 00007f5e06753000 +[4005007.800888] R13: ffff9940656e0000 R14: ffffa82b46d27e68 R15: 00007f5e06753000 +[4005007.800891] FS: 00007f5e0755b740(0000) GS:ffff99479d300000(0000) knlGS:0000000000000000 +[4005007.800895] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +[4005007.800898] CR2: ffffffffffffffd6 CR3: 00000003253fc000 CR4: 00000000003506e0 + +Signed-off-by: Qu Huang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +index ee4a0b7cb452f..41a9cc9e0f9db 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +@@ -391,6 +391,9 @@ static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf, + ssize_t result = 0; + int r; + ++ if (!adev->smc_rreg) ++ return -EPERM; ++ + if (size & 0x3 || *pos & 0x3) + return -EINVAL; + +@@ -430,6 +433,9 @@ static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user * + ssize_t result = 0; + int r; + ++ if (!adev->smc_wreg) ++ return -EPERM; ++ + if (size & 0x3 || *pos & 0x3) + return -EINVAL; + +-- +2.42.0 + diff --git a/queue-4.19/fs-jfs-add-check-for-negative-db_l2nbperpage.patch b/queue-4.19/fs-jfs-add-check-for-negative-db_l2nbperpage.patch new file mode 100644 index 00000000000..d695dbc2d72 --- /dev/null +++ b/queue-4.19/fs-jfs-add-check-for-negative-db_l2nbperpage.patch @@ -0,0 +1,46 @@ +From 40f0282980913392a247e2b0463a1e754d6804ab Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 2 Oct 2023 17:56:58 +0800 +Subject: fs/jfs: Add check for negative db_l2nbperpage + +From: Juntong Deng + +[ Upstream commit 525b861a008143048535011f3816d407940f4bfa ] + +l2nbperpage is log2(number of blks per page), and the minimum legal +value should be 0, not negative. + +In the case of l2nbperpage being negative, an error will occur +when subsequently used as shift exponent. + +Syzbot reported this bug: + +UBSAN: shift-out-of-bounds in fs/jfs/jfs_dmap.c:799:12 +shift exponent -16777216 is negative + +Reported-by: syzbot+debee9ab7ae2b34b0307@syzkaller.appspotmail.com +Closes: https://syzkaller.appspot.com/bug?extid=debee9ab7ae2b34b0307 +Signed-off-by: Juntong Deng +Signed-off-by: Dave Kleikamp +Signed-off-by: Sasha Levin +--- + fs/jfs/jfs_dmap.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c +index b20fffc8b4c13..5e20d7270d5f2 100644 +--- a/fs/jfs/jfs_dmap.c ++++ b/fs/jfs/jfs_dmap.c +@@ -193,7 +193,8 @@ int dbMount(struct inode *ipbmap) + bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree); + + bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage); +- if (bmp->db_l2nbperpage > L2PSIZE - L2MINBLOCKSIZE) { ++ if (bmp->db_l2nbperpage > L2PSIZE - L2MINBLOCKSIZE || ++ bmp->db_l2nbperpage < 0) { + err = -EINVAL; + goto err_release_metapage; + } +-- +2.42.0 + diff --git a/queue-4.19/fs-jfs-add-validity-check-for-db_maxag-and-db_agpref.patch b/queue-4.19/fs-jfs-add-validity-check-for-db_maxag-and-db_agpref.patch new file mode 100644 index 00000000000..ed3384cb826 --- /dev/null +++ b/queue-4.19/fs-jfs-add-validity-check-for-db_maxag-and-db_agpref.patch @@ -0,0 +1,50 @@ +From b48a58c18c28425ef99ebf2150c037ea382b3397 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 4 Oct 2023 02:06:41 +0800 +Subject: fs/jfs: Add validity check for db_maxag and db_agpref + +From: Juntong Deng + +[ Upstream commit 64933ab7b04881c6c18b21ff206c12278341c72e ] + +Both db_maxag and db_agpref are used as the index of the +db_agfree array, but there is currently no validity check for +db_maxag and db_agpref, which can lead to errors. + +The following is related bug reported by Syzbot: + +UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dmap.c:639:20 +index 7936 is out of range for type 'atomic_t[128]' + +Add checking that the values of db_maxag and db_agpref are valid +indexes for the db_agfree array. + +Reported-by: syzbot+38e876a8aa44b7115c76@syzkaller.appspotmail.com +Closes: https://syzkaller.appspot.com/bug?extid=38e876a8aa44b7115c76 +Signed-off-by: Juntong Deng +Signed-off-by: Dave Kleikamp +Signed-off-by: Sasha Levin +--- + fs/jfs/jfs_dmap.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c +index 5e20d7270d5f2..eb86d170f2246 100644 +--- a/fs/jfs/jfs_dmap.c ++++ b/fs/jfs/jfs_dmap.c +@@ -208,6 +208,12 @@ int dbMount(struct inode *ipbmap) + bmp->db_maxlevel = le32_to_cpu(dbmp_le->dn_maxlevel); + bmp->db_maxag = le32_to_cpu(dbmp_le->dn_maxag); + bmp->db_agpref = le32_to_cpu(dbmp_le->dn_agpref); ++ if (bmp->db_maxag >= MAXAG || bmp->db_maxag < 0 || ++ bmp->db_agpref >= MAXAG || bmp->db_agpref < 0) { ++ err = -EINVAL; ++ goto err_release_metapage; ++ } ++ + bmp->db_aglevel = le32_to_cpu(dbmp_le->dn_aglevel); + bmp->db_agheight = le32_to_cpu(dbmp_le->dn_agheight); + bmp->db_agwidth = le32_to_cpu(dbmp_le->dn_agwidth); +-- +2.42.0 + diff --git a/queue-4.19/gfs2-ignore-negated-quota-changes.patch b/queue-4.19/gfs2-ignore-negated-quota-changes.patch new file mode 100644 index 00000000000..89b61e8b960 --- /dev/null +++ b/queue-4.19/gfs2-ignore-negated-quota-changes.patch @@ -0,0 +1,91 @@ +From ab21df57b12025d1be8e91921778eb34432d82ab Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 21 Sep 2023 08:46:43 -0500 +Subject: gfs2: ignore negated quota changes + +From: Bob Peterson + +[ Upstream commit 4c6a08125f2249531ec01783a5f4317d7342add5 ] + +When lots of quota changes are made, there may be cases in which an +inode's quota information is increased and then decreased, such as when +blocks are added to a file, then deleted from it. If the timing is +right, function do_qc can add pending quota changes to a transaction, +then later, another call to do_qc can negate those changes, resulting +in a net gain of 0. The quota_change information is recorded in the qc +buffer (and qd element of the inode as well). The buffer is added to the +transaction by the first call to do_qc, but a subsequent call changes +the value from non-zero back to zero. At that point it's too late to +remove the buffer_head from the transaction. Later, when the quota sync +code is called, the zero-change qd element is discovered and flagged as +an assert warning. If the fs is mounted with errors=panic, the kernel +will panic. + +This is usually seen when files are truncated and the quota changes are +negated by punch_hole/truncate which uses gfs2_quota_hold and +gfs2_quota_unhold rather than block allocations that use gfs2_quota_lock +and gfs2_quota_unlock which automatically do quota sync. + +This patch solves the problem by adding a check to qd_check_sync such +that net-zero quota changes already added to the transaction are no +longer deemed necessary to be synced, and skipped. + +In this case references are taken for the qd and the slot from do_qc +so those need to be put. The normal sequence of events for a normal +non-zero quota change is as follows: + +gfs2_quota_change + do_qc + qd_hold + slot_hold + +Later, when the changes are to be synced: + +gfs2_quota_sync + qd_fish + qd_check_sync + gets qd ref via lockref_get_not_dead + do_sync + do_qc(QC_SYNC) + qd_put + lockref_put_or_lock + qd_unlock + qd_put + lockref_put_or_lock + +In the net-zero change case, we add a check to qd_check_sync so it puts +the qd and slot references acquired in gfs2_quota_change and skip the +unneeded sync. + +Signed-off-by: Bob Peterson +Signed-off-by: Andreas Gruenbacher +Signed-off-by: Sasha Levin +--- + fs/gfs2/quota.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c +index dd0f9bc13164b..9f753595d90ee 100644 +--- a/fs/gfs2/quota.c ++++ b/fs/gfs2/quota.c +@@ -434,6 +434,17 @@ static int qd_check_sync(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd, + (sync_gen && (qd->qd_sync_gen >= *sync_gen))) + return 0; + ++ /* ++ * If qd_change is 0 it means a pending quota change was negated. ++ * We should not sync it, but we still have a qd reference and slot ++ * reference taken by gfs2_quota_change -> do_qc that need to be put. ++ */ ++ if (!qd->qd_change && test_and_clear_bit(QDF_CHANGE, &qd->qd_flags)) { ++ slot_put(qd); ++ qd_put(qd); ++ return 0; ++ } ++ + if (!lockref_get_not_dead(&qd->qd_lockref)) + return 0; + +-- +2.42.0 + diff --git a/queue-4.19/hid-add-quirk-for-dell-pro-wireless-keyboard-and-mou.patch b/queue-4.19/hid-add-quirk-for-dell-pro-wireless-keyboard-and-mou.patch new file mode 100644 index 00000000000..7a047370415 --- /dev/null +++ b/queue-4.19/hid-add-quirk-for-dell-pro-wireless-keyboard-and-mou.patch @@ -0,0 +1,47 @@ +From d61828ac332f8fc7267fb58c18814c6609bebb2c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 27 Oct 2023 15:32:09 +0200 +Subject: HID: Add quirk for Dell Pro Wireless Keyboard and Mouse KM5221W + +From: Jiri Kosina + +[ Upstream commit 62cc9c3cb3ec1bf31cc116146185ed97b450836a ] + +This device needs ALWAYS_POLL quirk, otherwise it keeps reconnecting +indefinitely. + +Reported-by: Robert Ayrapetyan +Signed-off-by: Jiri Kosina +Signed-off-by: Sasha Levin +--- + drivers/hid/hid-ids.h | 1 + + drivers/hid/hid-quirks.c | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h +index a9d6f8acf70b5..93faf083e550b 100644 +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -343,6 +343,7 @@ + + #define USB_VENDOR_ID_DELL 0x413c + #define USB_DEVICE_ID_DELL_PIXART_USB_OPTICAL_MOUSE 0x301a ++#define USB_DEVICE_ID_DELL_PRO_WIRELESS_KM5221W 0x4503 + + #define USB_VENDOR_ID_DELORME 0x1163 + #define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 +diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c +index a2ab338166e61..0b85f95810b30 100644 +--- a/drivers/hid/hid-quirks.c ++++ b/drivers/hid/hid-quirks.c +@@ -68,6 +68,7 @@ static const struct hid_device_id hid_quirks[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_STRAFE), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51), HID_QUIRK_NOGET }, + { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_PIXART_USB_OPTICAL_MOUSE), HID_QUIRK_ALWAYS_POLL }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_PRO_WIRELESS_KM5221W), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC), HID_QUIRK_NOGET }, + { HID_USB_DEVICE(USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_2NES2SNES), HID_QUIRK_MULTI_INPUT }, + { HID_USB_DEVICE(USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_4NES4SNES), HID_QUIRK_MULTI_INPUT }, +-- +2.42.0 + diff --git a/queue-4.19/i2c-sun6i-p2wi-prevent-potential-division-by-zero.patch b/queue-4.19/i2c-sun6i-p2wi-prevent-potential-division-by-zero.patch new file mode 100644 index 00000000000..248ad18a493 --- /dev/null +++ b/queue-4.19/i2c-sun6i-p2wi-prevent-potential-division-by-zero.patch @@ -0,0 +1,39 @@ +From 1df93a5846aa446887a5fd5a83e8ef5eddcd3ba6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 13 Apr 2016 08:54:30 +0800 +Subject: i2c: sun6i-p2wi: Prevent potential division by zero + +From: Axel Lin + +[ Upstream commit 5ac61d26b8baff5b2e5a9f3dc1ef63297e4b53e7 ] + +Make sure we don't OOPS in case clock-frequency is set to 0 in a DT. The +variable set here is later used as a divisor. + +Signed-off-by: Axel Lin +Acked-by: Boris Brezillon +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-sun6i-p2wi.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c +index 7c07ce116e384..540c33f4e3500 100644 +--- a/drivers/i2c/busses/i2c-sun6i-p2wi.c ++++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c +@@ -202,6 +202,11 @@ static int p2wi_probe(struct platform_device *pdev) + return -EINVAL; + } + ++ if (clk_freq == 0) { ++ dev_err(dev, "clock-frequency is set to 0 in DT\n"); ++ return -EINVAL; ++ } ++ + if (of_get_child_count(np) > 1) { + dev_err(dev, "P2WI only supports one slave device\n"); + return -EINVAL; +-- +2.42.0 + diff --git a/queue-4.19/ipvlan-add-ipvlan_route_v6_outbound-helper.patch b/queue-4.19/ipvlan-add-ipvlan_route_v6_outbound-helper.patch new file mode 100644 index 00000000000..68c07c48589 --- /dev/null +++ b/queue-4.19/ipvlan-add-ipvlan_route_v6_outbound-helper.patch @@ -0,0 +1,272 @@ +From 8c220ef4833ff7f36cce1182a9d9170407fcb142 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 9 Nov 2023 15:22:41 +0000 +Subject: ipvlan: add ipvlan_route_v6_outbound() helper + +From: Eric Dumazet + +[ Upstream commit 18f039428c7df183b09c69ebf10ffd4e521035d2 ] + +Inspired by syzbot reports using a stack of multiple ipvlan devices. + +Reduce stack size needed in ipvlan_process_v6_outbound() by moving +the flowi6 struct used for the route lookup in an non inlined +helper. ipvlan_route_v6_outbound() needs 120 bytes on the stack, +immediately reclaimed. + +Also make sure ipvlan_process_v4_outbound() is not inlined. + +We might also have to lower MAX_NEST_DEV, because only syzbot uses +setups with more than four stacked devices. + +BUG: TASK stack guard page was hit at ffffc9000e803ff8 (stack is ffffc9000e804000..ffffc9000e808000) +stack guard page: 0000 [#1] SMP KASAN +CPU: 0 PID: 13442 Comm: syz-executor.4 Not tainted 6.1.52-syzkaller #0 +Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023 +RIP: 0010:kasan_check_range+0x4/0x2a0 mm/kasan/generic.c:188 +Code: 48 01 c6 48 89 c7 e8 db 4e c1 03 31 c0 5d c3 cc 0f 0b eb 02 0f 0b b8 ea ff ff ff 5d c3 cc 00 00 cc cc 00 00 cc cc 55 48 89 e5 <41> 57 41 56 41 55 41 54 53 b0 01 48 85 f6 0f 84 a4 01 00 00 48 89 +RSP: 0018:ffffc9000e804000 EFLAGS: 00010246 +RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff817e5bf2 +RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffffffff887c6568 +RBP: ffffc9000e804000 R08: 0000000000000000 R09: 0000000000000000 +R10: 0000000000000000 R11: dffffc0000000001 R12: 1ffff92001d0080c +R13: dffffc0000000000 R14: ffffffff87e6b100 R15: 0000000000000000 +FS: 00007fd0c55826c0(0000) GS:ffff8881f6800000(0000) knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: ffffc9000e803ff8 CR3: 0000000170ef7000 CR4: 00000000003506f0 +DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 +DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 +Call Trace: +<#DF> + + +[] __kasan_check_read+0x11/0x20 mm/kasan/shadow.c:31 +[] instrument_atomic_read include/linux/instrumented.h:72 [inline] +[] _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline] +[] cpumask_test_cpu include/linux/cpumask.h:506 [inline] +[] cpu_online include/linux/cpumask.h:1092 [inline] +[] trace_lock_acquire include/trace/events/lock.h:24 [inline] +[] lock_acquire+0xe2/0x590 kernel/locking/lockdep.c:5632 +[] rcu_lock_acquire+0x2e/0x40 include/linux/rcupdate.h:306 +[] rcu_read_lock include/linux/rcupdate.h:747 [inline] +[] ip6_pol_route+0x15d/0x1440 net/ipv6/route.c:2221 +[] ip6_pol_route_output+0x50/0x80 net/ipv6/route.c:2606 +[] pol_lookup_func include/net/ip6_fib.h:584 [inline] +[] fib6_rule_lookup+0x265/0x620 net/ipv6/fib6_rules.c:116 +[] ip6_route_output_flags_noref+0x2d9/0x3a0 net/ipv6/route.c:2638 +[] ip6_route_output_flags+0xca/0x340 net/ipv6/route.c:2651 +[] ip6_route_output include/net/ip6_route.h:100 [inline] +[] ipvlan_process_v6_outbound drivers/net/ipvlan/ipvlan_core.c:473 [inline] +[] ipvlan_process_outbound drivers/net/ipvlan/ipvlan_core.c:529 [inline] +[] ipvlan_xmit_mode_l3 drivers/net/ipvlan/ipvlan_core.c:602 [inline] +[] ipvlan_queue_xmit+0xc33/0x1be0 drivers/net/ipvlan/ipvlan_core.c:677 +[] ipvlan_start_xmit+0x49/0x100 drivers/net/ipvlan/ipvlan_main.c:229 +[] netdev_start_xmit include/linux/netdevice.h:4966 [inline] +[] xmit_one net/core/dev.c:3644 [inline] +[] dev_hard_start_xmit+0x320/0x980 net/core/dev.c:3660 +[] __dev_queue_xmit+0x16b2/0x3370 net/core/dev.c:4324 +[] dev_queue_xmit include/linux/netdevice.h:3067 [inline] +[] neigh_hh_output include/net/neighbour.h:529 [inline] +[] neigh_output include/net/neighbour.h:543 [inline] +[] ip6_finish_output2+0x160d/0x1ae0 net/ipv6/ip6_output.c:139 +[] __ip6_finish_output net/ipv6/ip6_output.c:200 [inline] +[] ip6_finish_output+0x6c6/0xb10 net/ipv6/ip6_output.c:211 +[] NF_HOOK_COND include/linux/netfilter.h:298 [inline] +[] ip6_output+0x2bc/0x3d0 net/ipv6/ip6_output.c:232 +[] dst_output include/net/dst.h:444 [inline] +[] ip6_local_out+0x10f/0x140 net/ipv6/output_core.c:161 +[] ipvlan_process_v6_outbound drivers/net/ipvlan/ipvlan_core.c:483 [inline] +[] ipvlan_process_outbound drivers/net/ipvlan/ipvlan_core.c:529 [inline] +[] ipvlan_xmit_mode_l3 drivers/net/ipvlan/ipvlan_core.c:602 [inline] +[] ipvlan_queue_xmit+0x1174/0x1be0 drivers/net/ipvlan/ipvlan_core.c:677 +[] ipvlan_start_xmit+0x49/0x100 drivers/net/ipvlan/ipvlan_main.c:229 +[] netdev_start_xmit include/linux/netdevice.h:4966 [inline] +[] xmit_one net/core/dev.c:3644 [inline] +[] dev_hard_start_xmit+0x320/0x980 net/core/dev.c:3660 +[] __dev_queue_xmit+0x16b2/0x3370 net/core/dev.c:4324 +[] dev_queue_xmit include/linux/netdevice.h:3067 [inline] +[] neigh_hh_output include/net/neighbour.h:529 [inline] +[] neigh_output include/net/neighbour.h:543 [inline] +[] ip6_finish_output2+0x160d/0x1ae0 net/ipv6/ip6_output.c:139 +[] __ip6_finish_output net/ipv6/ip6_output.c:200 [inline] +[] ip6_finish_output+0x6c6/0xb10 net/ipv6/ip6_output.c:211 +[] NF_HOOK_COND include/linux/netfilter.h:298 [inline] +[] ip6_output+0x2bc/0x3d0 net/ipv6/ip6_output.c:232 +[] dst_output include/net/dst.h:444 [inline] +[] ip6_local_out+0x10f/0x140 net/ipv6/output_core.c:161 +[] ipvlan_process_v6_outbound drivers/net/ipvlan/ipvlan_core.c:483 [inline] +[] ipvlan_process_outbound drivers/net/ipvlan/ipvlan_core.c:529 [inline] +[] ipvlan_xmit_mode_l3 drivers/net/ipvlan/ipvlan_core.c:602 [inline] +[] ipvlan_queue_xmit+0x1174/0x1be0 drivers/net/ipvlan/ipvlan_core.c:677 +[] ipvlan_start_xmit+0x49/0x100 drivers/net/ipvlan/ipvlan_main.c:229 +[] netdev_start_xmit include/linux/netdevice.h:4966 [inline] +[] xmit_one net/core/dev.c:3644 [inline] +[] dev_hard_start_xmit+0x320/0x980 net/core/dev.c:3660 +[] __dev_queue_xmit+0x16b2/0x3370 net/core/dev.c:4324 +[] dev_queue_xmit include/linux/netdevice.h:3067 [inline] +[] neigh_hh_output include/net/neighbour.h:529 [inline] +[] neigh_output include/net/neighbour.h:543 [inline] +[] ip6_finish_output2+0x160d/0x1ae0 net/ipv6/ip6_output.c:139 +[] __ip6_finish_output net/ipv6/ip6_output.c:200 [inline] +[] ip6_finish_output+0x6c6/0xb10 net/ipv6/ip6_output.c:211 +[] NF_HOOK_COND include/linux/netfilter.h:298 [inline] +[] ip6_output+0x2bc/0x3d0 net/ipv6/ip6_output.c:232 +[] dst_output include/net/dst.h:444 [inline] +[] ip6_local_out+0x10f/0x140 net/ipv6/output_core.c:161 +[] ipvlan_process_v6_outbound drivers/net/ipvlan/ipvlan_core.c:483 [inline] +[] ipvlan_process_outbound drivers/net/ipvlan/ipvlan_core.c:529 [inline] +[] ipvlan_xmit_mode_l3 drivers/net/ipvlan/ipvlan_core.c:602 [inline] +[] ipvlan_queue_xmit+0x1174/0x1be0 drivers/net/ipvlan/ipvlan_core.c:677 +[] ipvlan_start_xmit+0x49/0x100 drivers/net/ipvlan/ipvlan_main.c:229 +[] netdev_start_xmit include/linux/netdevice.h:4966 [inline] +[] xmit_one net/core/dev.c:3644 [inline] +[] dev_hard_start_xmit+0x320/0x980 net/core/dev.c:3660 +[] __dev_queue_xmit+0x16b2/0x3370 net/core/dev.c:4324 +[] dev_queue_xmit include/linux/netdevice.h:3067 [inline] +[] neigh_hh_output include/net/neighbour.h:529 [inline] +[] neigh_output include/net/neighbour.h:543 [inline] +[] ip6_finish_output2+0x160d/0x1ae0 net/ipv6/ip6_output.c:139 +[] __ip6_finish_output net/ipv6/ip6_output.c:200 [inline] +[] ip6_finish_output+0x6c6/0xb10 net/ipv6/ip6_output.c:211 +[] NF_HOOK_COND include/linux/netfilter.h:298 [inline] +[] ip6_output+0x2bc/0x3d0 net/ipv6/ip6_output.c:232 +[] dst_output include/net/dst.h:444 [inline] +[] ip6_local_out+0x10f/0x140 net/ipv6/output_core.c:161 +[] ipvlan_process_v6_outbound drivers/net/ipvlan/ipvlan_core.c:483 [inline] +[] ipvlan_process_outbound drivers/net/ipvlan/ipvlan_core.c:529 [inline] +[] ipvlan_xmit_mode_l3 drivers/net/ipvlan/ipvlan_core.c:602 [inline] +[] ipvlan_queue_xmit+0x1174/0x1be0 drivers/net/ipvlan/ipvlan_core.c:677 +[] ipvlan_start_xmit+0x49/0x100 drivers/net/ipvlan/ipvlan_main.c:229 +[] netdev_start_xmit include/linux/netdevice.h:4966 [inline] +[] xmit_one net/core/dev.c:3644 [inline] +[] dev_hard_start_xmit+0x320/0x980 net/core/dev.c:3660 +[] __dev_queue_xmit+0x16b2/0x3370 net/core/dev.c:4324 +[] dev_queue_xmit include/linux/netdevice.h:3067 [inline] +[] neigh_resolve_output+0x64e/0x750 net/core/neighbour.c:1560 +[] neigh_output include/net/neighbour.h:545 [inline] +[] ip6_finish_output2+0x1643/0x1ae0 net/ipv6/ip6_output.c:139 +[] __ip6_finish_output net/ipv6/ip6_output.c:200 [inline] +[] ip6_finish_output+0x6c6/0xb10 net/ipv6/ip6_output.c:211 +[] NF_HOOK_COND include/linux/netfilter.h:298 [inline] +[] ip6_output+0x2bc/0x3d0 net/ipv6/ip6_output.c:232 +[] dst_output include/net/dst.h:444 [inline] +[] NF_HOOK include/linux/netfilter.h:309 [inline] +[] ip6_xmit+0x11a4/0x1b20 net/ipv6/ip6_output.c:352 +[] sctp_v6_xmit+0x9ae/0x1230 net/sctp/ipv6.c:250 +[] sctp_packet_transmit+0x25de/0x2bc0 net/sctp/output.c:653 +[] sctp_packet_singleton+0x202/0x310 net/sctp/outqueue.c:783 +[] sctp_outq_flush_ctrl net/sctp/outqueue.c:914 [inline] +[] sctp_outq_flush+0x661/0x3d40 net/sctp/outqueue.c:1212 +[] sctp_outq_uncork+0x79/0xb0 net/sctp/outqueue.c:764 +[] sctp_side_effects net/sctp/sm_sideeffect.c:1199 [inline] +[] sctp_do_sm+0x55c0/0x5c30 net/sctp/sm_sideeffect.c:1170 +[] sctp_primitive_ASSOCIATE+0x97/0xc0 net/sctp/primitive.c:73 +[] sctp_sendmsg_to_asoc+0xf62/0x17b0 net/sctp/socket.c:1839 +[] sctp_sendmsg+0x212e/0x33b0 net/sctp/socket.c:2029 +[] inet_sendmsg+0x149/0x310 net/ipv4/af_inet.c:849 +[] sock_sendmsg_nosec net/socket.c:716 [inline] +[] sock_sendmsg net/socket.c:736 [inline] +[] ____sys_sendmsg+0x572/0x8c0 net/socket.c:2504 +[] ___sys_sendmsg net/socket.c:2558 [inline] +[] __sys_sendmsg+0x271/0x360 net/socket.c:2587 +[] __do_sys_sendmsg net/socket.c:2596 [inline] +[] __se_sys_sendmsg net/socket.c:2594 [inline] +[] __x64_sys_sendmsg+0x7f/0x90 net/socket.c:2594 +[] do_syscall_x64 arch/x86/entry/common.c:51 [inline] +[] do_syscall_64+0x53/0x80 arch/x86/entry/common.c:84 +[] entry_SYSCALL_64_after_hwframe+0x63/0xcd + +Fixes: 2ad7bf363841 ("ipvlan: Initial check-in of the IPVLAN driver.") +Reported-by: syzbot +Signed-off-by: Eric Dumazet +Cc: Mahesh Bandewar +Cc: Willem de Bruijn +Reviewed-by: Willem de Bruijn +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ipvlan/ipvlan_core.c | 41 +++++++++++++++++++------------- + 1 file changed, 25 insertions(+), 16 deletions(-) + +diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c +index ecb10fb249af4..34126abb28d8d 100644 +--- a/drivers/net/ipvlan/ipvlan_core.c ++++ b/drivers/net/ipvlan/ipvlan_core.c +@@ -418,7 +418,7 @@ static struct ipvl_addr *ipvlan_addr_lookup(struct ipvl_port *port, + return addr; + } + +-static int ipvlan_process_v4_outbound(struct sk_buff *skb) ++static noinline_for_stack int ipvlan_process_v4_outbound(struct sk_buff *skb) + { + const struct iphdr *ip4h = ip_hdr(skb); + struct net_device *dev = skb->dev; +@@ -460,13 +460,11 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb) + } + + #if IS_ENABLED(CONFIG_IPV6) +-static int ipvlan_process_v6_outbound(struct sk_buff *skb) ++ ++static noinline_for_stack int ++ipvlan_route_v6_outbound(struct net_device *dev, struct sk_buff *skb) + { + const struct ipv6hdr *ip6h = ipv6_hdr(skb); +- struct net_device *dev = skb->dev; +- struct net *net = dev_net(dev); +- struct dst_entry *dst; +- int err, ret = NET_XMIT_DROP; + struct flowi6 fl6 = { + .flowi6_oif = dev->ifindex, + .daddr = ip6h->daddr, +@@ -476,27 +474,38 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb) + .flowi6_mark = skb->mark, + .flowi6_proto = ip6h->nexthdr, + }; ++ struct dst_entry *dst; ++ int err; + +- dst = ip6_route_output(net, NULL, &fl6); +- if (dst->error) { +- ret = dst->error; ++ dst = ip6_route_output(dev_net(dev), NULL, &fl6); ++ err = dst->error; ++ if (err) { + dst_release(dst); +- goto err; ++ return err; + } + skb_dst_set(skb, dst); ++ return 0; ++} ++ ++static int ipvlan_process_v6_outbound(struct sk_buff *skb) ++{ ++ struct net_device *dev = skb->dev; ++ int err, ret = NET_XMIT_DROP; ++ ++ err = ipvlan_route_v6_outbound(dev, skb); ++ if (unlikely(err)) { ++ DEV_STATS_INC(dev, tx_errors); ++ kfree_skb(skb); ++ return err; ++ } + + memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); + +- err = ip6_local_out(net, skb->sk, skb); ++ err = ip6_local_out(dev_net(dev), skb->sk, skb); + if (unlikely(net_xmit_eval(err))) + DEV_STATS_INC(dev, tx_errors); + else + ret = NET_XMIT_SUCCESS; +- goto out; +-err: +- DEV_STATS_INC(dev, tx_errors); +- kfree_skb(skb); +-out: + return ret; + } + #else +-- +2.42.0 + diff --git a/queue-4.19/jfs-fix-array-index-out-of-bounds-in-dbfindleaf.patch b/queue-4.19/jfs-fix-array-index-out-of-bounds-in-dbfindleaf.patch new file mode 100644 index 00000000000..610d671af8b --- /dev/null +++ b/queue-4.19/jfs-fix-array-index-out-of-bounds-in-dbfindleaf.patch @@ -0,0 +1,87 @@ +From 1d96f184cb27fd062989726b6c28eaf190b712db Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 4 Oct 2023 11:17:18 +0530 +Subject: jfs: fix array-index-out-of-bounds in dbFindLeaf + +From: Manas Ghandat + +[ Upstream commit 22cad8bc1d36547cdae0eef316c47d917ce3147c ] + +Currently while searching for dmtree_t for sufficient free blocks there +is an array out of bounds while getting element in tp->dm_stree. To add +the required check for out of bound we first need to determine the type +of dmtree. Thus added an extra parameter to dbFindLeaf so that the type +of tree can be determined and the required check can be applied. + +Reported-by: syzbot+aea1ad91e854d0a83e04@syzkaller.appspotmail.com +Closes: https://syzkaller.appspot.com/bug?extid=aea1ad91e854d0a83e04 +Signed-off-by: Manas Ghandat +Signed-off-by: Dave Kleikamp +Signed-off-by: Sasha Levin +--- + fs/jfs/jfs_dmap.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c +index eb86d170f2246..2f452b5ee7313 100644 +--- a/fs/jfs/jfs_dmap.c ++++ b/fs/jfs/jfs_dmap.c +@@ -100,7 +100,7 @@ static int dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, + static int dbExtend(struct inode *ip, s64 blkno, s64 nblocks, s64 addnblocks); + static int dbFindBits(u32 word, int l2nb); + static int dbFindCtl(struct bmap * bmp, int l2nb, int level, s64 * blkno); +-static int dbFindLeaf(dmtree_t * tp, int l2nb, int *leafidx); ++static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl); + static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno, + int nblocks); + static int dbFreeDmap(struct bmap * bmp, struct dmap * dp, s64 blkno, +@@ -1798,7 +1798,7 @@ static int dbFindCtl(struct bmap * bmp, int l2nb, int level, s64 * blkno) + * dbFindLeaf() returns the index of the leaf at which + * free space was found. + */ +- rc = dbFindLeaf((dmtree_t *) dcp, l2nb, &leafidx); ++ rc = dbFindLeaf((dmtree_t *) dcp, l2nb, &leafidx, true); + + /* release the buffer. + */ +@@ -2045,7 +2045,7 @@ dbAllocDmapLev(struct bmap * bmp, + * free space. if sufficient free space is found, dbFindLeaf() + * returns the index of the leaf at which free space was found. + */ +- if (dbFindLeaf((dmtree_t *) & dp->tree, l2nb, &leafidx)) ++ if (dbFindLeaf((dmtree_t *) &dp->tree, l2nb, &leafidx, false)) + return -ENOSPC; + + if (leafidx < 0) +@@ -3005,14 +3005,18 @@ static void dbAdjTree(dmtree_t * tp, int leafno, int newval) + * leafidx - return pointer to be set to the index of the leaf + * describing at least l2nb free blocks if sufficient + * free blocks are found. ++ * is_ctl - determines if the tree is of type ctl + * + * RETURN VALUES: + * 0 - success + * -ENOSPC - insufficient free blocks. + */ +-static int dbFindLeaf(dmtree_t * tp, int l2nb, int *leafidx) ++static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl) + { + int ti, n = 0, k, x = 0; ++ int max_size; ++ ++ max_size = is_ctl ? CTLTREESIZE : TREESIZE; + + /* first check the root of the tree to see if there is + * sufficient free space. +@@ -3033,6 +3037,8 @@ static int dbFindLeaf(dmtree_t * tp, int l2nb, int *leafidx) + /* sufficient free space found. move to the next + * level (or quit if this is the last level). + */ ++ if (x + n > max_size) ++ return -ENOSPC; + if (l2nb <= tp->dmt_stree[x + n]) + break; + } +-- +2.42.0 + diff --git a/queue-4.19/jfs-fix-array-index-out-of-bounds-in-dialloc.patch b/queue-4.19/jfs-fix-array-index-out-of-bounds-in-dialloc.patch new file mode 100644 index 00000000000..bc2584e0544 --- /dev/null +++ b/queue-4.19/jfs-fix-array-index-out-of-bounds-in-dialloc.patch @@ -0,0 +1,48 @@ +From c134838789586c2e549fb28f628076383ac2b69d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 4 Oct 2023 13:10:40 +0530 +Subject: jfs: fix array-index-out-of-bounds in diAlloc + +From: Manas Ghandat + +[ Upstream commit 05d9ea1ceb62a55af6727a69269a4fd310edf483 ] + +Currently there is not check against the agno of the iag while +allocating new inodes to avoid fragmentation problem. Added the check +which is required. + +Reported-by: syzbot+79d792676d8ac050949f@syzkaller.appspotmail.com +Closes: https://syzkaller.appspot.com/bug?extid=79d792676d8ac050949f +Signed-off-by: Manas Ghandat +Signed-off-by: Dave Kleikamp +Signed-off-by: Sasha Levin +--- + fs/jfs/jfs_imap.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c +index 7565e00e88182..b45cc109e5063 100644 +--- a/fs/jfs/jfs_imap.c ++++ b/fs/jfs/jfs_imap.c +@@ -1335,7 +1335,7 @@ diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp) + int diAlloc(struct inode *pip, bool dir, struct inode *ip) + { + int rc, ino, iagno, addext, extno, bitno, sword; +- int nwords, rem, i, agno; ++ int nwords, rem, i, agno, dn_numag; + u32 mask, inosmap, extsmap; + struct inode *ipimap; + struct metapage *mp; +@@ -1371,6 +1371,9 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip) + + /* get the ag number of this iag */ + agno = BLKTOAG(JFS_IP(pip)->agstart, JFS_SBI(pip->i_sb)); ++ dn_numag = JFS_SBI(pip->i_sb)->bmap->db_numag; ++ if (agno < 0 || agno > dn_numag) ++ return -EIO; + + if (atomic_read(&JFS_SBI(pip->i_sb)->bmap->db_active[agno])) { + /* +-- +2.42.0 + diff --git a/queue-4.19/locking-ww_mutex-test-fix-potential-workqueue-corrup.patch b/queue-4.19/locking-ww_mutex-test-fix-potential-workqueue-corrup.patch new file mode 100644 index 00000000000..f341fe57901 --- /dev/null +++ b/queue-4.19/locking-ww_mutex-test-fix-potential-workqueue-corrup.patch @@ -0,0 +1,119 @@ +From f14b34070fdf36806c7b77d3e7901a0cafffb69b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 22 Sep 2023 04:36:00 +0000 +Subject: locking/ww_mutex/test: Fix potential workqueue corruption + +From: John Stultz + +[ Upstream commit bccdd808902f8c677317cec47c306e42b93b849e ] + +In some cases running with the test-ww_mutex code, I was seeing +odd behavior where sometimes it seemed flush_workqueue was +returning before all the work threads were finished. + +Often this would cause strange crashes as the mutexes would be +freed while they were being used. + +Looking at the code, there is a lifetime problem as the +controlling thread that spawns the work allocates the +"struct stress" structures that are passed to the workqueue +threads. Then when the workqueue threads are finished, +they free the stress struct that was passed to them. + +Unfortunately the workqueue work_struct node is in the stress +struct. Which means the work_struct is freed before the work +thread returns and while flush_workqueue is waiting. + +It seems like a better idea to have the controlling thread +both allocate and free the stress structures, so that we can +be sure we don't corrupt the workqueue by freeing the structure +prematurely. + +So this patch reworks the test to do so, and with this change +I no longer see the early flush_workqueue returns. + +Signed-off-by: John Stultz +Signed-off-by: Ingo Molnar +Link: https://lore.kernel.org/r/20230922043616.19282-3-jstultz@google.com +Signed-off-by: Sasha Levin +--- + kernel/locking/test-ww_mutex.c | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c +index 65a3b7e55b9fc..4fd05d9d5d6d1 100644 +--- a/kernel/locking/test-ww_mutex.c ++++ b/kernel/locking/test-ww_mutex.c +@@ -439,7 +439,6 @@ static void stress_inorder_work(struct work_struct *work) + } while (!time_after(jiffies, stress->timeout)); + + kfree(order); +- kfree(stress); + } + + struct reorder_lock { +@@ -504,7 +503,6 @@ static void stress_reorder_work(struct work_struct *work) + list_for_each_entry_safe(ll, ln, &locks, link) + kfree(ll); + kfree(order); +- kfree(stress); + } + + static void stress_one_work(struct work_struct *work) +@@ -525,8 +523,6 @@ static void stress_one_work(struct work_struct *work) + break; + } + } while (!time_after(jiffies, stress->timeout)); +- +- kfree(stress); + } + + #define STRESS_INORDER BIT(0) +@@ -537,15 +533,24 @@ static void stress_one_work(struct work_struct *work) + static int stress(int nlocks, int nthreads, unsigned int flags) + { + struct ww_mutex *locks; +- int n; ++ struct stress *stress_array; ++ int n, count; + + locks = kmalloc_array(nlocks, sizeof(*locks), GFP_KERNEL); + if (!locks) + return -ENOMEM; + ++ stress_array = kmalloc_array(nthreads, sizeof(*stress_array), ++ GFP_KERNEL); ++ if (!stress_array) { ++ kfree(locks); ++ return -ENOMEM; ++ } ++ + for (n = 0; n < nlocks; n++) + ww_mutex_init(&locks[n], &ww_class); + ++ count = 0; + for (n = 0; nthreads; n++) { + struct stress *stress; + void (*fn)(struct work_struct *work); +@@ -569,9 +574,7 @@ static int stress(int nlocks, int nthreads, unsigned int flags) + if (!fn) + continue; + +- stress = kmalloc(sizeof(*stress), GFP_KERNEL); +- if (!stress) +- break; ++ stress = &stress_array[count++]; + + INIT_WORK(&stress->work, fn); + stress->locks = locks; +@@ -586,6 +589,7 @@ static int stress(int nlocks, int nthreads, unsigned int flags) + + for (n = 0; n < nlocks; n++) + ww_mutex_destroy(&locks[n]); ++ kfree(stress_array); + kfree(locks); + + return 0; +-- +2.42.0 + diff --git a/queue-4.19/macvlan-don-t-propagate-promisc-change-to-lower-dev-.patch b/queue-4.19/macvlan-don-t-propagate-promisc-change-to-lower-dev-.patch new file mode 100644 index 00000000000..ecaf31931f4 --- /dev/null +++ b/queue-4.19/macvlan-don-t-propagate-promisc-change-to-lower-dev-.patch @@ -0,0 +1,61 @@ +From ee9e36ce2a761a782146dfb05b9c24b7c27bf602 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 14 Nov 2023 18:59:15 +0100 +Subject: macvlan: Don't propagate promisc change to lower dev in passthru + +From: Vlad Buslov + +[ Upstream commit 7e1caeace0418381f36b3aa8403dfd82fc57fc53 ] + +Macvlan device in passthru mode sets its lower device promiscuous mode +according to its MACVLAN_FLAG_NOPROMISC flag instead of synchronizing it to +its own promiscuity setting. However, macvlan_change_rx_flags() function +doesn't check the mode before propagating such changes to the lower device +which can cause net_device->promiscuity counter overflow as illustrated by +reproduction example [0] and resulting dmesg log [1]. Fix the issue by +first verifying the mode in macvlan_change_rx_flags() function before +propagating promiscuous mode change to the lower device. + +[0]: +ip link add macvlan1 link enp8s0f0 type macvlan mode passthru +ip link set macvlan1 promisc on +ip l set dev macvlan1 up +ip link set macvlan1 promisc off +ip l set dev macvlan1 down +ip l set dev macvlan1 up + +[1]: +[ 5156.281724] macvlan1: entered promiscuous mode +[ 5156.285467] mlx5_core 0000:08:00.0 enp8s0f0: entered promiscuous mode +[ 5156.287639] macvlan1: left promiscuous mode +[ 5156.288339] mlx5_core 0000:08:00.0 enp8s0f0: left promiscuous mode +[ 5156.290907] mlx5_core 0000:08:00.0 enp8s0f0: entered promiscuous mode +[ 5156.317197] mlx5_core 0000:08:00.0 enp8s0f0: promiscuity touches roof, set promiscuity failed. promiscuity feature of device might be broken. + +Fixes: efdbd2b30caa ("macvlan: Propagate promiscuity setting to lower devices.") +Reviewed-by: Gal Pressman +Signed-off-by: Vlad Buslov +Reviewed-by: Jiri Pirko +Link: https://lore.kernel.org/r/20231114175915.1649154-1-vladbu@nvidia.com +Signed-off-by: Paolo Abeni +Signed-off-by: Sasha Levin +--- + drivers/net/macvlan.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c +index e1f95fd08d721..29d5fd46c09a0 100644 +--- a/drivers/net/macvlan.c ++++ b/drivers/net/macvlan.c +@@ -769,7 +769,7 @@ static void macvlan_change_rx_flags(struct net_device *dev, int change) + if (dev->flags & IFF_UP) { + if (change & IFF_ALLMULTI) + dev_set_allmulti(lowerdev, dev->flags & IFF_ALLMULTI ? 1 : -1); +- if (change & IFF_PROMISC) ++ if (!macvlan_passthru(vlan->port) && change & IFF_PROMISC) + dev_set_promiscuity(lowerdev, + dev->flags & IFF_PROMISC ? 1 : -1); + +-- +2.42.0 + diff --git a/queue-4.19/media-gspca-cpia1-shift-out-of-bounds-in-set_flicker.patch b/queue-4.19/media-gspca-cpia1-shift-out-of-bounds-in-set_flicker.patch new file mode 100644 index 00000000000..3b60dd15cfd --- /dev/null +++ b/queue-4.19/media-gspca-cpia1-shift-out-of-bounds-in-set_flicker.patch @@ -0,0 +1,53 @@ +From f4864e428d2df7746d81de2aacc9b27053dc2265 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 30 Aug 2023 13:14:01 +0530 +Subject: media: gspca: cpia1: shift-out-of-bounds in set_flicker + +From: Rajeshwar R Shinde + +[ Upstream commit 099be1822d1f095433f4b08af9cc9d6308ec1953 ] + +Syzkaller reported the following issue: +UBSAN: shift-out-of-bounds in drivers/media/usb/gspca/cpia1.c:1031:27 +shift exponent 245 is too large for 32-bit type 'int' + +When the value of the variable "sd->params.exposure.gain" exceeds the +number of bits in an integer, a shift-out-of-bounds error is reported. It +is triggered because the variable "currentexp" cannot be left-shifted by +more than the number of bits in an integer. In order to avoid invalid +range during left-shift, the conditional expression is added. + +Reported-by: syzbot+e27f3dbdab04e43b9f73@syzkaller.appspotmail.com +Closes: https://lore.kernel.org/all/20230818164522.12806-1-coolrrsh@gmail.com +Link: https://syzkaller.appspot.com/bug?extid=e27f3dbdab04e43b9f73 +Signed-off-by: Rajeshwar R Shinde +Signed-off-by: Hans Verkuil +Signed-off-by: Sasha Levin +--- + drivers/media/usb/gspca/cpia1.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c +index 2b09af8865f40..5e785343528cc 100644 +--- a/drivers/media/usb/gspca/cpia1.c ++++ b/drivers/media/usb/gspca/cpia1.c +@@ -28,6 +28,7 @@ + + #include + #include ++#include + + #include "gspca.h" + +@@ -1033,6 +1034,8 @@ static int set_flicker(struct gspca_dev *gspca_dev, int on, int apply) + sd->params.exposure.expMode = 2; + sd->exposure_status = EXPOSURE_NORMAL; + } ++ if (sd->params.exposure.gain >= BITS_PER_TYPE(currentexp)) ++ return -EINVAL; + currentexp = currentexp << sd->params.exposure.gain; + sd->params.exposure.gain = 0; + /* round down current exposure to nearest value */ +-- +2.42.0 + diff --git a/queue-4.19/media-vivid-avoid-integer-overflow.patch b/queue-4.19/media-vivid-avoid-integer-overflow.patch new file mode 100644 index 00000000000..94f1d73a718 --- /dev/null +++ b/queue-4.19/media-vivid-avoid-integer-overflow.patch @@ -0,0 +1,47 @@ +From acd91101fd5f096c77d0358210e277e111f36c39 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 23 Sep 2023 17:20:48 +0200 +Subject: media: vivid: avoid integer overflow + +From: Hans Verkuil + +[ Upstream commit 4567ebf8e8f9546b373e78e3b7d584cc30b62028 ] + +Fixes these compiler warnings: + +drivers/media/test-drivers/vivid/vivid-rds-gen.c: In function 'vivid_rds_gen_fill': +drivers/media/test-drivers/vivid/vivid-rds-gen.c:147:56: warning: '.' directive output may be truncated writing 1 byte into a region of size between 0 and 3 [-Wformat-truncation=] + 147 | snprintf(rds->psname, sizeof(rds->psname), "%6d.%1d", + | ^ +drivers/media/test-drivers/vivid/vivid-rds-gen.c:147:52: note: directive argument in the range [0, 9] + 147 | snprintf(rds->psname, sizeof(rds->psname), "%6d.%1d", + | ^~~~~~~~~ +drivers/media/test-drivers/vivid/vivid-rds-gen.c:147:9: note: 'snprintf' output between 9 and 12 bytes into a destination of size 9 + 147 | snprintf(rds->psname, sizeof(rds->psname), "%6d.%1d", + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 148 | freq / 16, ((freq & 0xf) * 10) / 16); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Signed-off-by: Hans Verkuil +Acked-by: Arnd Bergmann +Signed-off-by: Sasha Levin +--- + drivers/media/platform/vivid/vivid-rds-gen.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/media/platform/vivid/vivid-rds-gen.c b/drivers/media/platform/vivid/vivid-rds-gen.c +index 39ca9a56448c0..9f6009ac5e255 100644 +--- a/drivers/media/platform/vivid/vivid-rds-gen.c ++++ b/drivers/media/platform/vivid/vivid-rds-gen.c +@@ -145,7 +145,7 @@ void vivid_rds_gen_fill(struct vivid_rds_gen *rds, unsigned freq, + rds->ta = alt; + rds->ms = true; + snprintf(rds->psname, sizeof(rds->psname), "%6d.%1d", +- freq / 16, ((freq & 0xf) * 10) / 16); ++ (freq / 16) % 1000000, (((freq & 0xf) * 10) / 16) % 10); + if (alt) + strlcpy(rds->radiotext, + " The Radio Data System can switch between different Radio Texts ", +-- +2.42.0 + diff --git a/queue-4.19/net-annotate-data-races-around-sk-sk_dst_pending_con.patch b/queue-4.19/net-annotate-data-races-around-sk-sk_dst_pending_con.patch new file mode 100644 index 00000000000..40c0ebc5379 --- /dev/null +++ b/queue-4.19/net-annotate-data-races-around-sk-sk_dst_pending_con.patch @@ -0,0 +1,82 @@ +From d5eea98032d1b00c51fd2a31b4e98b28acd8eb0a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 21 Sep 2023 20:28:18 +0000 +Subject: net: annotate data-races around sk->sk_dst_pending_confirm + +From: Eric Dumazet + +[ Upstream commit eb44ad4e635132754bfbcb18103f1dcb7058aedd ] + +This field can be read or written without socket lock being held. + +Add annotations to avoid load-store tearing. + +Signed-off-by: Eric Dumazet +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + include/net/sock.h | 6 +++--- + net/core/sock.c | 2 +- + net/ipv4/tcp_output.c | 2 +- + 3 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/include/net/sock.h b/include/net/sock.h +index c0df14e5a0754..81888513b3b93 100644 +--- a/include/net/sock.h ++++ b/include/net/sock.h +@@ -1918,7 +1918,7 @@ static inline void dst_negative_advice(struct sock *sk) + if (ndst != dst) { + rcu_assign_pointer(sk->sk_dst_cache, ndst); + sk_tx_queue_clear(sk); +- sk->sk_dst_pending_confirm = 0; ++ WRITE_ONCE(sk->sk_dst_pending_confirm, 0); + } + } + } +@@ -1929,7 +1929,7 @@ __sk_dst_set(struct sock *sk, struct dst_entry *dst) + struct dst_entry *old_dst; + + sk_tx_queue_clear(sk); +- sk->sk_dst_pending_confirm = 0; ++ WRITE_ONCE(sk->sk_dst_pending_confirm, 0); + old_dst = rcu_dereference_protected(sk->sk_dst_cache, + lockdep_sock_is_held(sk)); + rcu_assign_pointer(sk->sk_dst_cache, dst); +@@ -1942,7 +1942,7 @@ sk_dst_set(struct sock *sk, struct dst_entry *dst) + struct dst_entry *old_dst; + + sk_tx_queue_clear(sk); +- sk->sk_dst_pending_confirm = 0; ++ WRITE_ONCE(sk->sk_dst_pending_confirm, 0); + old_dst = xchg((__force struct dst_entry **)&sk->sk_dst_cache, dst); + dst_release(old_dst); + } +diff --git a/net/core/sock.c b/net/core/sock.c +index e1d0c8c715b87..62d169bcfcfa1 100644 +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -496,7 +496,7 @@ struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie) + + if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) { + sk_tx_queue_clear(sk); +- sk->sk_dst_pending_confirm = 0; ++ WRITE_ONCE(sk->sk_dst_pending_confirm, 0); + RCU_INIT_POINTER(sk->sk_dst_cache, NULL); + dst_release(dst); + return NULL; +diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c +index 3dd62cf739e32..a0875dc60e08f 100644 +--- a/net/ipv4/tcp_output.c ++++ b/net/ipv4/tcp_output.c +@@ -1090,7 +1090,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, + skb_set_hash_from_sk(skb, sk); + refcount_add(skb->truesize, &sk->sk_wmem_alloc); + +- skb_set_dst_pending_confirm(skb, sk->sk_dst_pending_confirm); ++ skb_set_dst_pending_confirm(skb, READ_ONCE(sk->sk_dst_pending_confirm)); + + /* Build TCP header and checksum it. */ + th = (struct tcphdr *)skb->data; +-- +2.42.0 + diff --git a/queue-4.19/net-annotate-data-races-around-sk-sk_tx_queue_mappin.patch b/queue-4.19/net-annotate-data-races-around-sk-sk_tx_queue_mappin.patch new file mode 100644 index 00000000000..4336c01033b --- /dev/null +++ b/queue-4.19/net-annotate-data-races-around-sk-sk_tx_queue_mappin.patch @@ -0,0 +1,65 @@ +From 895f9fa758664b12cfecbaa06144afd5cabb801e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 21 Sep 2023 20:28:17 +0000 +Subject: net: annotate data-races around sk->sk_tx_queue_mapping + +From: Eric Dumazet + +[ Upstream commit 0bb4d124d34044179b42a769a0c76f389ae973b6 ] + +This field can be read or written without socket lock being held. + +Add annotations to avoid load-store tearing. + +Signed-off-by: Eric Dumazet +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + include/net/sock.h | 20 ++++++++++++++++---- + 1 file changed, 16 insertions(+), 4 deletions(-) + +diff --git a/include/net/sock.h b/include/net/sock.h +index 373e34b46a3c9..c0df14e5a0754 100644 +--- a/include/net/sock.h ++++ b/include/net/sock.h +@@ -1759,21 +1759,33 @@ static inline void sk_tx_queue_set(struct sock *sk, int tx_queue) + /* sk_tx_queue_mapping accept only upto a 16-bit value */ + if (WARN_ON_ONCE((unsigned short)tx_queue >= USHRT_MAX)) + return; +- sk->sk_tx_queue_mapping = tx_queue; ++ /* Paired with READ_ONCE() in sk_tx_queue_get() and ++ * other WRITE_ONCE() because socket lock might be not held. ++ */ ++ WRITE_ONCE(sk->sk_tx_queue_mapping, tx_queue); + } + + #define NO_QUEUE_MAPPING USHRT_MAX + + static inline void sk_tx_queue_clear(struct sock *sk) + { +- sk->sk_tx_queue_mapping = NO_QUEUE_MAPPING; ++ /* Paired with READ_ONCE() in sk_tx_queue_get() and ++ * other WRITE_ONCE() because socket lock might be not held. ++ */ ++ WRITE_ONCE(sk->sk_tx_queue_mapping, NO_QUEUE_MAPPING); + } + + static inline int sk_tx_queue_get(const struct sock *sk) + { +- if (sk && sk->sk_tx_queue_mapping != NO_QUEUE_MAPPING) +- return sk->sk_tx_queue_mapping; ++ if (sk) { ++ /* Paired with WRITE_ONCE() in sk_tx_queue_clear() ++ * and sk_tx_queue_set(). ++ */ ++ int val = READ_ONCE(sk->sk_tx_queue_mapping); + ++ if (val != NO_QUEUE_MAPPING) ++ return val; ++ } + return -1; + } + +-- +2.42.0 + diff --git a/queue-4.19/net-ethernet-cortina-fix-max-rx-frame-define.patch b/queue-4.19/net-ethernet-cortina-fix-max-rx-frame-define.patch new file mode 100644 index 00000000000..0e0d3d52df1 --- /dev/null +++ b/queue-4.19/net-ethernet-cortina-fix-max-rx-frame-define.patch @@ -0,0 +1,55 @@ +From 6ae56d1c5665562ffa5749ea74a189bcb64fbe04 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 9 Nov 2023 10:03:12 +0100 +Subject: net: ethernet: cortina: Fix max RX frame define + +From: Linus Walleij + +[ Upstream commit 510e35fb931ffc3b100e5d5ae4595cd3beca9f1a ] + +Enumerator 3 is 1548 bytes according to the datasheet. +Not 1542. + +Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") +Reviewed-by: Andrew Lunn +Signed-off-by: Linus Walleij +Reviewed-by: Vladimir Oltean +Link: https://lore.kernel.org/r/20231109-gemini-largeframe-fix-v4-1-6e611528db08@linaro.org +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/cortina/gemini.c | 4 ++-- + drivers/net/ethernet/cortina/gemini.h | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c +index f8a3d1fecb0a5..db38b087fc5ce 100644 +--- a/drivers/net/ethernet/cortina/gemini.c ++++ b/drivers/net/ethernet/cortina/gemini.c +@@ -433,8 +433,8 @@ static const struct gmac_max_framelen gmac_maxlens[] = { + .val = CONFIG0_MAXLEN_1536, + }, + { +- .max_l3_len = 1542, +- .val = CONFIG0_MAXLEN_1542, ++ .max_l3_len = 1548, ++ .val = CONFIG0_MAXLEN_1548, + }, + { + .max_l3_len = 9212, +diff --git a/drivers/net/ethernet/cortina/gemini.h b/drivers/net/ethernet/cortina/gemini.h +index 0b12f89bf89a3..321427aaff4cc 100644 +--- a/drivers/net/ethernet/cortina/gemini.h ++++ b/drivers/net/ethernet/cortina/gemini.h +@@ -787,7 +787,7 @@ union gmac_config0 { + #define CONFIG0_MAXLEN_1536 0 + #define CONFIG0_MAXLEN_1518 1 + #define CONFIG0_MAXLEN_1522 2 +-#define CONFIG0_MAXLEN_1542 3 ++#define CONFIG0_MAXLEN_1548 3 + #define CONFIG0_MAXLEN_9k 4 /* 9212 */ + #define CONFIG0_MAXLEN_10k 5 /* 10236 */ + #define CONFIG0_MAXLEN_1518__6 6 +-- +2.42.0 + diff --git a/queue-4.19/net-ethernet-cortina-fix-mtu-max-setting.patch b/queue-4.19/net-ethernet-cortina-fix-mtu-max-setting.patch new file mode 100644 index 00000000000..cafbd2eb33c --- /dev/null +++ b/queue-4.19/net-ethernet-cortina-fix-mtu-max-setting.patch @@ -0,0 +1,91 @@ +From 50eba439a84b0713b35a232d3e5b9ea492b7a753 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 9 Nov 2023 10:03:14 +0100 +Subject: net: ethernet: cortina: Fix MTU max setting + +From: Linus Walleij + +[ Upstream commit dc6c0bfbaa947dd7976e30e8c29b10c868b6fa42 ] + +The RX max frame size is over 10000 for the Gemini ethernet, +but the TX max frame size is actually just 2047 (0x7ff after +checking the datasheet). Reflect this in what we offer to Linux, +cap the MTU at the TX max frame minus ethernet headers. + +We delete the code disabling the hardware checksum for large +MTUs as netdev->mtu can no longer be larger than +netdev->max_mtu meaning the if()-clause in gmac_fix_features() +is never true. + +Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") +Reviewed-by: Andrew Lunn +Signed-off-by: Linus Walleij +Reviewed-by: Vladimir Oltean +Link: https://lore.kernel.org/r/20231109-gemini-largeframe-fix-v4-3-6e611528db08@linaro.org +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/cortina/gemini.c | 17 ++++------------- + drivers/net/ethernet/cortina/gemini.h | 2 +- + 2 files changed, 5 insertions(+), 14 deletions(-) + +diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c +index 3e38c0309bc8e..b7ebe5eb46f5a 100644 +--- a/drivers/net/ethernet/cortina/gemini.c ++++ b/drivers/net/ethernet/cortina/gemini.c +@@ -2019,15 +2019,6 @@ static int gmac_change_mtu(struct net_device *netdev, int new_mtu) + return 0; + } + +-static netdev_features_t gmac_fix_features(struct net_device *netdev, +- netdev_features_t features) +-{ +- if (netdev->mtu + ETH_HLEN + VLAN_HLEN > MTU_SIZE_BIT_MASK) +- features &= ~GMAC_OFFLOAD_FEATURES; +- +- return features; +-} +- + static int gmac_set_features(struct net_device *netdev, + netdev_features_t features) + { +@@ -2248,7 +2239,6 @@ static const struct net_device_ops gmac_351x_ops = { + .ndo_set_mac_address = gmac_set_mac_address, + .ndo_get_stats64 = gmac_get_stats64, + .ndo_change_mtu = gmac_change_mtu, +- .ndo_fix_features = gmac_fix_features, + .ndo_set_features = gmac_set_features, + }; + +@@ -2504,11 +2494,12 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) + + netdev->hw_features = GMAC_OFFLOAD_FEATURES; + netdev->features |= GMAC_OFFLOAD_FEATURES | NETIF_F_GRO; +- /* We can handle jumbo frames up to 10236 bytes so, let's accept +- * payloads of 10236 bytes minus VLAN and ethernet header ++ /* We can receive jumbo frames up to 10236 bytes but only ++ * transmit 2047 bytes so, let's accept payloads of 2047 ++ * bytes minus VLAN and ethernet header + */ + netdev->min_mtu = ETH_MIN_MTU; +- netdev->max_mtu = 10236 - VLAN_ETH_HLEN; ++ netdev->max_mtu = MTU_SIZE_BIT_MASK - VLAN_ETH_HLEN; + + port->freeq_refill = 0; + netif_napi_add(netdev, &port->napi, gmac_napi_poll, +diff --git a/drivers/net/ethernet/cortina/gemini.h b/drivers/net/ethernet/cortina/gemini.h +index 321427aaff4cc..ad913f15e89ba 100644 +--- a/drivers/net/ethernet/cortina/gemini.h ++++ b/drivers/net/ethernet/cortina/gemini.h +@@ -502,7 +502,7 @@ union gmac_txdesc_3 { + #define SOF_BIT 0x80000000 + #define EOF_BIT 0x40000000 + #define EOFIE_BIT BIT(29) +-#define MTU_SIZE_BIT_MASK 0x1fff ++#define MTU_SIZE_BIT_MASK 0x7ff /* Max MTU 2047 bytes */ + + /* GMAC Tx Descriptor */ + struct gmac_txdesc { +-- +2.42.0 + diff --git a/queue-4.19/net-ethernet-cortina-handle-large-frames.patch b/queue-4.19/net-ethernet-cortina-handle-large-frames.patch new file mode 100644 index 00000000000..993a4cbeee9 --- /dev/null +++ b/queue-4.19/net-ethernet-cortina-handle-large-frames.patch @@ -0,0 +1,111 @@ +From 629c9dceb6ec304bec9fb5507b37e1133bfa5147 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 9 Nov 2023 10:03:13 +0100 +Subject: net: ethernet: cortina: Handle large frames + +From: Linus Walleij + +[ Upstream commit d4d0c5b4d279bfe3585fbd806efefd3e51c82afa ] + +The Gemini ethernet controller provides hardware checksumming +for frames up to 1514 bytes including ethernet headers but not +FCS. + +If we start sending bigger frames (after first bumping up the MTU +on both interfaces sending and receiving the frames), truncated +packets start to appear on the target such as in this tcpdump +resulting from ping -s 1474: + +23:34:17.241983 14:d6:4d:a8:3c:4f (oui Unknown) > bc:ae:c5:6b:a8:3d (oui Unknown), +ethertype IPv4 (0x0800), length 1514: truncated-ip - 2 bytes missing! +(tos 0x0, ttl 64, id 32653, offset 0, flags [DF], proto ICMP (1), length 1502) +OpenWrt.lan > Fecusia: ICMP echo request, id 1672, seq 50, length 1482 + +If we bypass the hardware checksumming and provide a software +fallback, everything starts working fine up to the max TX MTU +of 2047 bytes, for example ping -s2000 192.168.1.2: + +00:44:29.587598 bc:ae:c5:6b:a8:3d (oui Unknown) > 14:d6:4d:a8:3c:4f (oui Unknown), +ethertype IPv4 (0x0800), length 2042: +(tos 0x0, ttl 64, id 51828, offset 0, flags [none], proto ICMP (1), length 2028) +Fecusia > OpenWrt.lan: ICMP echo reply, id 1683, seq 4, length 2008 + +The bit enabling to bypass hardware checksum (or any of the +"TSS" bits) are undocumented in the hardware reference manual. +The entire hardware checksum unit appears undocumented. The +conclusion that we need to use the "bypass" bit was found by +trial-and-error. + +Since no hardware checksum will happen, we slot in a software +checksum fallback. + +Check for the condition where we need to compute checksum on the +skb with either hardware or software using == CHECKSUM_PARTIAL instead +of != CHECKSUM_NONE which is an incomplete check according to +. + +On the D-Link DIR-685 router this fixes a bug on the conduit +interface to the RTL8366RB DSA switch: as the switch needs to add +space for its tag it increases the MTU on the conduit interface +to 1504 and that means that when the router sends packages +of 1500 bytes these get an extra 4 bytes of DSA tag and the +transfer fails because of the erroneous hardware checksumming, +affecting such basic functionality as the LuCI web interface. + +Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") +Signed-off-by: Linus Walleij +Reviewed-by: Vladimir Oltean +Link: https://lore.kernel.org/r/20231109-gemini-largeframe-fix-v4-2-6e611528db08@linaro.org +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/cortina/gemini.c | 24 +++++++++++++++++++++++- + 1 file changed, 23 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c +index db38b087fc5ce..3e38c0309bc8e 100644 +--- a/drivers/net/ethernet/cortina/gemini.c ++++ b/drivers/net/ethernet/cortina/gemini.c +@@ -1153,6 +1153,7 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, + dma_addr_t mapping; + unsigned short mtu; + void *buffer; ++ int ret; + + mtu = ETH_HLEN; + mtu += netdev->mtu; +@@ -1167,9 +1168,30 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, + word3 |= mtu; + } + +- if (skb->ip_summed != CHECKSUM_NONE) { ++ if (skb->len >= ETH_FRAME_LEN) { ++ /* Hardware offloaded checksumming isn't working on frames ++ * bigger than 1514 bytes. A hypothesis about this is that the ++ * checksum buffer is only 1518 bytes, so when the frames get ++ * bigger they get truncated, or the last few bytes get ++ * overwritten by the FCS. ++ * ++ * Just use software checksumming and bypass on bigger frames. ++ */ ++ if (skb->ip_summed == CHECKSUM_PARTIAL) { ++ ret = skb_checksum_help(skb); ++ if (ret) ++ return ret; ++ } ++ word1 |= TSS_BYPASS_BIT; ++ } else if (skb->ip_summed == CHECKSUM_PARTIAL) { + int tcp = 0; + ++ /* We do not switch off the checksumming on non TCP/UDP ++ * frames: as is shown from tests, the checksumming engine ++ * is smart enough to see that a frame is not actually TCP ++ * or UDP and then just pass it through without any changes ++ * to the frame. ++ */ + if (skb->protocol == htons(ETH_P_IP)) { + word1 |= TSS_IP_CHKSUM_BIT; + tcp = ip_hdr(skb)->protocol == IPPROTO_TCP; +-- +2.42.0 + diff --git a/queue-4.19/nfsv4.1-fix-sp4_mach_cred-protection-for-pnfs-io.patch b/queue-4.19/nfsv4.1-fix-sp4_mach_cred-protection-for-pnfs-io.patch new file mode 100644 index 00000000000..aaf92b38d5f --- /dev/null +++ b/queue-4.19/nfsv4.1-fix-sp4_mach_cred-protection-for-pnfs-io.patch @@ -0,0 +1,48 @@ +From bd5d29a3bcca8dd3bff45d688ee5be2206ab969a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 13 Oct 2023 11:04:10 -0400 +Subject: NFSv4.1: fix SP4_MACH_CRED protection for pnfs IO + +From: Olga Kornievskaia + +[ Upstream commit 5cc7688bae7f0757c39c1d3dfdd827b724061067 ] + +If the client is doing pnfs IO and Kerberos is configured and EXCHANGEID +successfully negotiated SP4_MACH_CRED and WRITE/COMMIT are on the +list of state protected operations, then we need to make sure to +choose the DS's rpc_client structure instead of the MDS's one. + +Fixes: fb91fb0ee7b2 ("NFS: Move call to nfs4_state_protect_write() to nfs4_write_setup()") +Signed-off-by: Olga Kornievskaia +Signed-off-by: Trond Myklebust +Signed-off-by: Sasha Levin +--- + fs/nfs/nfs4proc.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c +index 3651619468d74..c44efead1a329 100644 +--- a/fs/nfs/nfs4proc.c ++++ b/fs/nfs/nfs4proc.c +@@ -5143,7 +5143,7 @@ static void nfs4_proc_write_setup(struct nfs_pgio_header *hdr, + + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE]; + nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0, 0); +- nfs4_state_protect_write(server->nfs_client, clnt, msg, hdr); ++ nfs4_state_protect_write(hdr->ds_clp ? hdr->ds_clp : server->nfs_client, clnt, msg, hdr); + } + + static void nfs4_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) +@@ -5184,7 +5184,8 @@ static void nfs4_proc_commit_setup(struct nfs_commit_data *data, struct rpc_mess + data->res.server = server; + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT]; + nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0); +- nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_COMMIT, clnt, msg); ++ nfs4_state_protect(data->ds_clp ? data->ds_clp : server->nfs_client, ++ NFS_SP4_MACH_CRED_COMMIT, clnt, msg); + } + + static int _nfs4_proc_commit(struct file *dst, struct nfs_commitargs *args, +-- +2.42.0 + diff --git a/queue-4.19/perf-core-bail-out-early-if-the-request-aux-area-is-.patch b/queue-4.19/perf-core-bail-out-early-if-the-request-aux-area-is-.patch new file mode 100644 index 00000000000..4c82b6772f3 --- /dev/null +++ b/queue-4.19/perf-core-bail-out-early-if-the-request-aux-area-is-.patch @@ -0,0 +1,76 @@ +From 49529549aa6ad736e5c285118db4471fa0d9d655 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 7 Sep 2023 08:43:07 +0800 +Subject: perf/core: Bail out early if the request AUX area is out of bound + +From: Shuai Xue + +[ Upstream commit 54aee5f15b83437f23b2b2469bcf21bdd9823916 ] + +When perf-record with a large AUX area, e.g 4GB, it fails with: + + #perf record -C 0 -m ,4G -e arm_spe_0// -- sleep 1 + failed to mmap with 12 (Cannot allocate memory) + +and it reveals a WARNING with __alloc_pages(): + + ------------[ cut here ]------------ + WARNING: CPU: 44 PID: 17573 at mm/page_alloc.c:5568 __alloc_pages+0x1ec/0x248 + Call trace: + __alloc_pages+0x1ec/0x248 + __kmalloc_large_node+0xc0/0x1f8 + __kmalloc_node+0x134/0x1e8 + rb_alloc_aux+0xe0/0x298 + perf_mmap+0x440/0x660 + mmap_region+0x308/0x8a8 + do_mmap+0x3c0/0x528 + vm_mmap_pgoff+0xf4/0x1b8 + ksys_mmap_pgoff+0x18c/0x218 + __arm64_sys_mmap+0x38/0x58 + invoke_syscall+0x50/0x128 + el0_svc_common.constprop.0+0x58/0x188 + do_el0_svc+0x34/0x50 + el0_svc+0x34/0x108 + el0t_64_sync_handler+0xb8/0xc0 + el0t_64_sync+0x1a4/0x1a8 + +'rb->aux_pages' allocated by kcalloc() is a pointer array which is used to +maintains AUX trace pages. The allocated page for this array is physically +contiguous (and virtually contiguous) with an order of 0..MAX_ORDER. If the +size of pointer array crosses the limitation set by MAX_ORDER, it reveals a +WARNING. + +So bail out early with -ENOMEM if the request AUX area is out of bound, +e.g.: + + #perf record -C 0 -m ,4G -e arm_spe_0// -- sleep 1 + failed to mmap with 12 (Cannot allocate memory) + +Signed-off-by: Shuai Xue +Signed-off-by: Peter Zijlstra (Intel) +Signed-off-by: Ingo Molnar +Signed-off-by: Sasha Levin +--- + kernel/events/ring_buffer.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c +index 12f351b253bbb..2f6f77658eba2 100644 +--- a/kernel/events/ring_buffer.c ++++ b/kernel/events/ring_buffer.c +@@ -639,6 +639,12 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event, + } + } + ++ /* ++ * kcalloc_node() is unable to allocate buffer if the size is larger ++ * than: PAGE_SIZE << MAX_ORDER; directly bail out in this case. ++ */ ++ if (get_order((unsigned long)nr_pages * sizeof(void *)) > MAX_ORDER) ++ return -ENOMEM; + rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL, + node); + if (!rb->aux_pages) +-- +2.42.0 + diff --git a/queue-4.19/platform-x86-thinkpad_acpi-add-battery-quirk-for-thi.patch b/queue-4.19/platform-x86-thinkpad_acpi-add-battery-quirk-for-thi.patch new file mode 100644 index 00000000000..e9b71a5a527 --- /dev/null +++ b/queue-4.19/platform-x86-thinkpad_acpi-add-battery-quirk-for-thi.patch @@ -0,0 +1,38 @@ +From 4840ebca1756d56b211209449d513864b850798e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 24 Oct 2023 22:09:21 +0300 +Subject: platform/x86: thinkpad_acpi: Add battery quirk for Thinkpad X120e +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Olli Asikainen + +[ Upstream commit 916646758aea81a143ce89103910f715ed923346 ] + +Thinkpad X120e also needs this battery quirk. + +Signed-off-by: Olli Asikainen +Link: https://lore.kernel.org/r/20231024190922.2742-1-olli.asikainen@gmail.com +Reviewed-by: Ilpo Järvinen +Signed-off-by: Ilpo Järvinen +Signed-off-by: Sasha Levin +--- + drivers/platform/x86/thinkpad_acpi.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c +index 912ce5cb2f084..1036ec368ddac 100644 +--- a/drivers/platform/x86/thinkpad_acpi.c ++++ b/drivers/platform/x86/thinkpad_acpi.c +@@ -9699,6 +9699,7 @@ static const struct tpacpi_quirk battery_quirk_table[] __initconst = { + * Individual addressing is broken on models that expose the + * primary battery as BAT1. + */ ++ TPACPI_Q_LNV('8', 'F', true), /* Thinkpad X120e */ + TPACPI_Q_LNV('J', '7', true), /* B5400 */ + TPACPI_Q_LNV('J', 'I', true), /* Thinkpad 11e */ + TPACPI_Q_LNV3('R', '0', 'B', true), /* Thinkpad 11e gen 3 */ +-- +2.42.0 + diff --git a/queue-4.19/ppp-limit-mru-to-64k.patch b/queue-4.19/ppp-limit-mru-to-64k.patch new file mode 100644 index 00000000000..ba4e4f3893c --- /dev/null +++ b/queue-4.19/ppp-limit-mru-to-64k.patch @@ -0,0 +1,76 @@ +From 45226fb91d643236d8f22057a0ac3142cafe47e6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 12 Nov 2023 22:16:32 -0500 +Subject: ppp: limit MRU to 64K + +From: Willem de Bruijn + +[ Upstream commit c0a2a1b0d631fc460d830f52d06211838874d655 ] + +ppp_sync_ioctl allows setting device MRU, but does not sanity check +this input. + +Limit to a sane upper bound of 64KB. + +No implementation I could find generates larger than 64KB frames. +RFC 2823 mentions an upper bound of PPP over SDL of 64KB based on the +16-bit length field. Other protocols will be smaller, such as PPPoE +(9KB jumbo frame) and PPPoA (18190 maximum CPCS-SDU size, RFC 2364). +PPTP and L2TP encapsulate in IP. + +Syzbot managed to trigger alloc warning in __alloc_pages: + + if (WARN_ON_ONCE_GFP(order > MAX_ORDER, gfp)) + + WARNING: CPU: 1 PID: 37 at mm/page_alloc.c:4544 __alloc_pages+0x3ab/0x4a0 mm/page_alloc.c:4544 + + __alloc_skb+0x12b/0x330 net/core/skbuff.c:651 + __netdev_alloc_skb+0x72/0x3f0 net/core/skbuff.c:715 + netdev_alloc_skb include/linux/skbuff.h:3225 [inline] + dev_alloc_skb include/linux/skbuff.h:3238 [inline] + ppp_sync_input drivers/net/ppp/ppp_synctty.c:669 [inline] + ppp_sync_receive+0xff/0x680 drivers/net/ppp/ppp_synctty.c:334 + tty_ldisc_receive_buf+0x14c/0x180 drivers/tty/tty_buffer.c:390 + tty_port_default_receive_buf+0x70/0xb0 drivers/tty/tty_port.c:37 + receive_buf drivers/tty/tty_buffer.c:444 [inline] + flush_to_ldisc+0x261/0x780 drivers/tty/tty_buffer.c:494 + process_one_work+0x884/0x15c0 kernel/workqueue.c:2630 + +With call + + ioctl$PPPIOCSMRU1(r1, 0x40047452, &(0x7f0000000100)=0x5e6417a8) + +Similar code exists in other drivers that implement ppp_channel_ops +ioctl PPPIOCSMRU. Those might also be in scope. Notably excluded from +this are pppol2tp_ioctl and pppoe_ioctl. + +This code goes back to the start of git history. + +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Reported-by: syzbot+6177e1f90d92583bcc58@syzkaller.appspotmail.com +Signed-off-by: Willem de Bruijn +Reviewed-by: Eric Dumazet +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ppp/ppp_synctty.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c +index e0de8b32df46a..7a1b903d3fb89 100644 +--- a/drivers/net/ppp/ppp_synctty.c ++++ b/drivers/net/ppp/ppp_synctty.c +@@ -467,6 +467,10 @@ ppp_sync_ioctl(struct ppp_channel *chan, unsigned int cmd, unsigned long arg) + case PPPIOCSMRU: + if (get_user(val, (int __user *) argp)) + break; ++ if (val > U16_MAX) { ++ err = -EINVAL; ++ break; ++ } + if (val < PPP_MRU) + val = PPP_MRU; + ap->mru = val; +-- +2.42.0 + diff --git a/queue-4.19/ptp-annotate-data-race-around-q-head-and-q-tail.patch b/queue-4.19/ptp-annotate-data-race-around-q-head-and-q-tail.patch new file mode 100644 index 00000000000..db12d115bc9 --- /dev/null +++ b/queue-4.19/ptp-annotate-data-race-around-q-head-and-q-tail.patch @@ -0,0 +1,98 @@ +From 061696c1e5e484e60c36122b3b82e5681bb196b8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 9 Nov 2023 17:48:59 +0000 +Subject: ptp: annotate data-race around q->head and q->tail + +From: Eric Dumazet + +[ Upstream commit 73bde5a3294853947252cd9092a3517c7cb0cd2d ] + +As I was working on a syzbot report, I found that KCSAN would +probably complain that reading q->head or q->tail without +barriers could lead to invalid results. + +Add corresponding READ_ONCE() and WRITE_ONCE() to avoid +load-store tearing. + +Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.") +Signed-off-by: Eric Dumazet +Acked-by: Richard Cochran +Link: https://lore.kernel.org/r/20231109174859.3995880-1-edumazet@google.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/ptp/ptp_chardev.c | 3 ++- + drivers/ptp/ptp_clock.c | 5 +++-- + drivers/ptp/ptp_private.h | 8 ++++++-- + drivers/ptp/ptp_sysfs.c | 3 ++- + 4 files changed, 13 insertions(+), 6 deletions(-) + +diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c +index 796eeffdf93b1..8ff2dd5c52e64 100644 +--- a/drivers/ptp/ptp_chardev.c ++++ b/drivers/ptp/ptp_chardev.c +@@ -346,7 +346,8 @@ ssize_t ptp_read(struct posix_clock *pc, + + for (i = 0; i < cnt; i++) { + event[i] = queue->buf[queue->head]; +- queue->head = (queue->head + 1) % PTP_MAX_TIMESTAMPS; ++ /* Paired with READ_ONCE() in queue_cnt() */ ++ WRITE_ONCE(queue->head, (queue->head + 1) % PTP_MAX_TIMESTAMPS); + } + + spin_unlock_irqrestore(&queue->lock, flags); +diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c +index 89632cc9c28fc..1e92bd897aa45 100644 +--- a/drivers/ptp/ptp_clock.c ++++ b/drivers/ptp/ptp_clock.c +@@ -68,10 +68,11 @@ static void enqueue_external_timestamp(struct timestamp_event_queue *queue, + dst->t.sec = seconds; + dst->t.nsec = remainder; + ++ /* Both WRITE_ONCE() are paired with READ_ONCE() in queue_cnt() */ + if (!queue_free(queue)) +- queue->head = (queue->head + 1) % PTP_MAX_TIMESTAMPS; ++ WRITE_ONCE(queue->head, (queue->head + 1) % PTP_MAX_TIMESTAMPS); + +- queue->tail = (queue->tail + 1) % PTP_MAX_TIMESTAMPS; ++ WRITE_ONCE(queue->tail, (queue->tail + 1) % PTP_MAX_TIMESTAMPS); + + spin_unlock_irqrestore(&queue->lock, flags); + } +diff --git a/drivers/ptp/ptp_private.h b/drivers/ptp/ptp_private.h +index 05f6b6a9bbd58..1e02b5ae6127b 100644 +--- a/drivers/ptp/ptp_private.h ++++ b/drivers/ptp/ptp_private.h +@@ -68,9 +68,13 @@ struct ptp_clock { + * that a writer might concurrently increment the tail does not + * matter, since the queue remains nonempty nonetheless. + */ +-static inline int queue_cnt(struct timestamp_event_queue *q) ++static inline int queue_cnt(const struct timestamp_event_queue *q) + { +- int cnt = q->tail - q->head; ++ /* ++ * Paired with WRITE_ONCE() in enqueue_external_timestamp(), ++ * ptp_read(), extts_fifo_show(). ++ */ ++ int cnt = READ_ONCE(q->tail) - READ_ONCE(q->head); + return cnt < 0 ? PTP_MAX_TIMESTAMPS + cnt : cnt; + } + +diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c +index f97a5eefa2e23..b9e2f08960688 100644 +--- a/drivers/ptp/ptp_sysfs.c ++++ b/drivers/ptp/ptp_sysfs.c +@@ -91,7 +91,8 @@ static ssize_t extts_fifo_show(struct device *dev, + qcnt = queue_cnt(queue); + if (qcnt) { + event = queue->buf[queue->head]; +- queue->head = (queue->head + 1) % PTP_MAX_TIMESTAMPS; ++ /* Paired with READ_ONCE() in queue_cnt() */ ++ WRITE_ONCE(queue->head, (queue->head + 1) % PTP_MAX_TIMESTAMPS); + } + spin_unlock_irqrestore(&queue->lock, flags); + +-- +2.42.0 + diff --git a/queue-4.19/pwm-fix-double-shift-bug.patch b/queue-4.19/pwm-fix-double-shift-bug.patch new file mode 100644 index 00000000000..86728a4d786 --- /dev/null +++ b/queue-4.19/pwm-fix-double-shift-bug.patch @@ -0,0 +1,45 @@ +From 82d7d1c702f124f0496b87df9eac851fb14a9d60 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 25 Oct 2023 14:58:18 +0300 +Subject: pwm: Fix double shift bug +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Dan Carpenter + +[ Upstream commit d27abbfd4888d79dd24baf50e774631046ac4732 ] + +These enums are passed to set/test_bit(). The set/test_bit() functions +take a bit number instead of a shifted value. Passing a shifted value +is a double shift bug like doing BIT(BIT(1)). The double shift bug +doesn't cause a problem here because we are only checking 0 and 1 but +if the value was 5 or above then it can lead to a buffer overflow. + +Signed-off-by: Dan Carpenter +Reviewed-by: Uwe Kleine-König +Reviewed-by: Sam Protsenko +Signed-off-by: Thierry Reding +Signed-off-by: Sasha Levin +--- + include/linux/pwm.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/include/linux/pwm.h b/include/linux/pwm.h +index bd7d611d63e91..c6e981035c3fd 100644 +--- a/include/linux/pwm.h ++++ b/include/linux/pwm.h +@@ -44,8 +44,8 @@ struct pwm_args { + }; + + enum { +- PWMF_REQUESTED = 1 << 0, +- PWMF_EXPORTED = 1 << 1, ++ PWMF_REQUESTED = 0, ++ PWMF_EXPORTED = 1, + }; + + /* +-- +2.42.0 + diff --git a/queue-4.19/rdma-hfi1-use-field_get-to-extract-link-width.patch b/queue-4.19/rdma-hfi1-use-field_get-to-extract-link-width.patch new file mode 100644 index 00000000000..28c68f560fa --- /dev/null +++ b/queue-4.19/rdma-hfi1-use-field_get-to-extract-link-width.patch @@ -0,0 +1,63 @@ +From 8df727e8ee981ad43378a0e45273ea0299d243e2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 19 Sep 2023 15:56:41 +0300 +Subject: RDMA/hfi1: Use FIELD_GET() to extract Link Width +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilpo Järvinen + +[ Upstream commit 8bf7187d978610b9e327a3d92728c8864a575ebd ] + +Use FIELD_GET() to extract PCIe Negotiated Link Width field instead of +custom masking and shifting, and remove extract_width() which only +wraps that FIELD_GET(). + +Signed-off-by: Ilpo Järvinen +Link: https://lore.kernel.org/r/20230919125648.1920-2-ilpo.jarvinen@linux.intel.com +Reviewed-by: Jonathan Cameron +Reviewed-by: Dean Luick +Signed-off-by: Leon Romanovsky +Signed-off-by: Sasha Levin +--- + drivers/infiniband/hw/hfi1/pcie.c | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c +index a8dd12e525f81..e1b6da7775584 100644 +--- a/drivers/infiniband/hw/hfi1/pcie.c ++++ b/drivers/infiniband/hw/hfi1/pcie.c +@@ -45,6 +45,7 @@ + * + */ + ++#include + #include + #include + #include +@@ -273,12 +274,6 @@ static u32 extract_speed(u16 linkstat) + return speed; + } + +-/* return the PCIe link speed from the given link status */ +-static u32 extract_width(u16 linkstat) +-{ +- return (linkstat & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT; +-} +- + /* read the link status and set dd->{lbus_width,lbus_speed,lbus_info} */ + static void update_lbus_info(struct hfi1_devdata *dd) + { +@@ -291,7 +286,7 @@ static void update_lbus_info(struct hfi1_devdata *dd) + return; + } + +- dd->lbus_width = extract_width(linkstat); ++ dd->lbus_width = FIELD_GET(PCI_EXP_LNKSTA_NLW, linkstat); + dd->lbus_speed = extract_speed(linkstat); + snprintf(dd->lbus_info, sizeof(dd->lbus_info), + "PCIe,%uMHz,x%u", dd->lbus_speed, dd->lbus_width); +-- +2.42.0 + diff --git a/queue-4.19/scsi-libfc-fix-potential-null-pointer-dereference-in.patch b/queue-4.19/scsi-libfc-fix-potential-null-pointer-dereference-in.patch new file mode 100644 index 00000000000..ce468156519 --- /dev/null +++ b/queue-4.19/scsi-libfc-fix-potential-null-pointer-dereference-in.patch @@ -0,0 +1,44 @@ +From 2ec39df30a48bd289a8e3679d55f15bf5746249e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 11 Oct 2023 21:03:50 +0800 +Subject: scsi: libfc: Fix potential NULL pointer dereference in + fc_lport_ptp_setup() + +From: Wenchao Hao + +[ Upstream commit 4df105f0ce9f6f30cda4e99f577150d23f0c9c5f ] + +fc_lport_ptp_setup() did not check the return value of fc_rport_create() +which can return NULL and would cause a NULL pointer dereference. Address +this issue by checking return value of fc_rport_create() and log error +message on fc_rport_create() failed. + +Signed-off-by: Wenchao Hao +Link: https://lore.kernel.org/r/20231011130350.819571-1-haowenchao2@huawei.com +Reviewed-by: Simon Horman +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/libfc/fc_lport.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c +index f653109d56af0..f84c8a9846abb 100644 +--- a/drivers/scsi/libfc/fc_lport.c ++++ b/drivers/scsi/libfc/fc_lport.c +@@ -250,6 +250,12 @@ static void fc_lport_ptp_setup(struct fc_lport *lport, + } + mutex_lock(&lport->disc.disc_mutex); + lport->ptp_rdata = fc_rport_create(lport, remote_fid); ++ if (!lport->ptp_rdata) { ++ printk(KERN_WARNING "libfc: Failed to setup lport 0x%x\n", ++ lport->port_id); ++ mutex_unlock(&lport->disc.disc_mutex); ++ return; ++ } + kref_get(&lport->ptp_rdata->kref); + lport->ptp_rdata->ids.port_name = remote_wwpn; + lport->ptp_rdata->ids.node_name = remote_wwnn; +-- +2.42.0 + diff --git a/queue-4.19/selftests-efivarfs-create-read-fix-a-resource-leak.patch b/queue-4.19/selftests-efivarfs-create-read-fix-a-resource-leak.patch new file mode 100644 index 00000000000..799135df9b1 --- /dev/null +++ b/queue-4.19/selftests-efivarfs-create-read-fix-a-resource-leak.patch @@ -0,0 +1,37 @@ +From dc2f8244c957b2fa1d78e0873f413ea6a7b5c957 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 17 Oct 2023 18:59:21 -0700 +Subject: selftests/efivarfs: create-read: fix a resource leak + +From: zhujun2 + +[ Upstream commit 3f6f8a8c5e11a9b384a36df4f40f0c9a653b6975 ] + +The opened file should be closed in main(), otherwise resource +leak will occur that this problem was discovered by code reading + +Signed-off-by: zhujun2 +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/efivarfs/create-read.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/tools/testing/selftests/efivarfs/create-read.c b/tools/testing/selftests/efivarfs/create-read.c +index 9674a19396a32..7bc7af4eb2c17 100644 +--- a/tools/testing/selftests/efivarfs/create-read.c ++++ b/tools/testing/selftests/efivarfs/create-read.c +@@ -32,8 +32,10 @@ int main(int argc, char **argv) + rc = read(fd, buf, sizeof(buf)); + if (rc != 0) { + fprintf(stderr, "Reading a new var should return EOF\n"); ++ close(fd); + return EXIT_FAILURE; + } + ++ close(fd); + return EXIT_SUCCESS; + } +-- +2.42.0 + diff --git a/queue-4.19/series b/queue-4.19/series new file mode 100644 index 00000000000..38dfa61a866 --- /dev/null +++ b/queue-4.19/series @@ -0,0 +1,47 @@ +locking-ww_mutex-test-fix-potential-workqueue-corrup.patch +perf-core-bail-out-early-if-the-request-aux-area-is-.patch +clocksource-drivers-timer-imx-gpt-fix-potential-memo.patch +clocksource-drivers-timer-atmel-tcb-fix-initializati.patch +x86-mm-drop-the-4-mb-restriction-on-minimal-numa-nod.patch +wifi-mac80211-don-t-return-unset-power-in-ieee80211_.patch +wifi-ath9k-fix-clang-specific-fortify-warnings.patch +wifi-ath10k-fix-clang-specific-fortify-warning.patch +net-annotate-data-races-around-sk-sk_tx_queue_mappin.patch +net-annotate-data-races-around-sk-sk_dst_pending_con.patch +bluetooth-fix-double-free-in-hci_conn_cleanup.patch +platform-x86-thinkpad_acpi-add-battery-quirk-for-thi.patch +drm-amd-fix-ubsan-array-index-out-of-bounds-for-smu7.patch +drm-amd-fix-ubsan-array-index-out-of-bounds-for-pola.patch +drm-amdgpu-fix-a-null-pointer-access-when-the-smc_rr.patch +selftests-efivarfs-create-read-fix-a-resource-leak.patch +crypto-pcrypt-fix-hungtask-for-padata_reset.patch +rdma-hfi1-use-field_get-to-extract-link-width.patch +fs-jfs-add-check-for-negative-db_l2nbperpage.patch +fs-jfs-add-validity-check-for-db_maxag-and-db_agpref.patch +jfs-fix-array-index-out-of-bounds-in-dbfindleaf.patch +jfs-fix-array-index-out-of-bounds-in-dialloc.patch +arm-9320-1-fix-stack-depot-irq-stack-filter.patch +alsa-hda-fix-possible-null-ptr-deref-when-assigning-.patch +atm-iphase-do-pci-error-checks-on-own-line.patch +scsi-libfc-fix-potential-null-pointer-dereference-in.patch +hid-add-quirk-for-dell-pro-wireless-keyboard-and-mou.patch +tty-vcc-add-check-for-kstrdup-in-vcc_probe.patch +usb-gadget-f_ncm-always-set-current-gadget-in-ncm_bi.patch +i2c-sun6i-p2wi-prevent-potential-division-by-zero.patch +media-gspca-cpia1-shift-out-of-bounds-in-set_flicker.patch +media-vivid-avoid-integer-overflow.patch +gfs2-ignore-negated-quota-changes.patch +drm-amd-display-avoid-null-dereference-of-timing-gen.patch +pwm-fix-double-shift-bug.patch +nfsv4.1-fix-sp4_mach_cred-protection-for-pnfs-io.patch +ipvlan-add-ipvlan_route_v6_outbound-helper.patch +tty-fix-uninit-value-access-in-ppp_sync_receive.patch +tipc-fix-kernel-infoleak-due-to-uninitialized-tlv-va.patch +ppp-limit-mru-to-64k.patch +xen-events-fix-delayed-eoi-list-handling.patch +ptp-annotate-data-race-around-q-head-and-q-tail.patch +net-ethernet-cortina-fix-max-rx-frame-define.patch +net-ethernet-cortina-handle-large-frames.patch +net-ethernet-cortina-fix-mtu-max-setting.patch +macvlan-don-t-propagate-promisc-change-to-lower-dev-.patch +cifs-spnego-add-in-host_key_len.patch diff --git a/queue-4.19/tipc-fix-kernel-infoleak-due-to-uninitialized-tlv-va.patch b/queue-4.19/tipc-fix-kernel-infoleak-due-to-uninitialized-tlv-va.patch new file mode 100644 index 00000000000..cdc3a9a0300 --- /dev/null +++ b/queue-4.19/tipc-fix-kernel-infoleak-due-to-uninitialized-tlv-va.patch @@ -0,0 +1,113 @@ +From 6871cccd8dda7de174c18ce33c630d47df6aa021 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 11 Nov 2023 01:39:47 +0900 +Subject: tipc: Fix kernel-infoleak due to uninitialized TLV value + +From: Shigeru Yoshida + +[ Upstream commit fb317eb23b5ee4c37b0656a9a52a3db58d9dd072 ] + +KMSAN reported the following kernel-infoleak issue: + +===================================================== +BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:114 [inline] +BUG: KMSAN: kernel-infoleak in copy_to_user_iter lib/iov_iter.c:24 [inline] +BUG: KMSAN: kernel-infoleak in iterate_ubuf include/linux/iov_iter.h:29 [inline] +BUG: KMSAN: kernel-infoleak in iterate_and_advance2 include/linux/iov_iter.h:245 [inline] +BUG: KMSAN: kernel-infoleak in iterate_and_advance include/linux/iov_iter.h:271 [inline] +BUG: KMSAN: kernel-infoleak in _copy_to_iter+0x4ec/0x2bc0 lib/iov_iter.c:186 + instrument_copy_to_user include/linux/instrumented.h:114 [inline] + copy_to_user_iter lib/iov_iter.c:24 [inline] + iterate_ubuf include/linux/iov_iter.h:29 [inline] + iterate_and_advance2 include/linux/iov_iter.h:245 [inline] + iterate_and_advance include/linux/iov_iter.h:271 [inline] + _copy_to_iter+0x4ec/0x2bc0 lib/iov_iter.c:186 + copy_to_iter include/linux/uio.h:197 [inline] + simple_copy_to_iter net/core/datagram.c:532 [inline] + __skb_datagram_iter.5+0x148/0xe30 net/core/datagram.c:420 + skb_copy_datagram_iter+0x52/0x210 net/core/datagram.c:546 + skb_copy_datagram_msg include/linux/skbuff.h:3960 [inline] + netlink_recvmsg+0x43d/0x1630 net/netlink/af_netlink.c:1967 + sock_recvmsg_nosec net/socket.c:1044 [inline] + sock_recvmsg net/socket.c:1066 [inline] + __sys_recvfrom+0x476/0x860 net/socket.c:2246 + __do_sys_recvfrom net/socket.c:2264 [inline] + __se_sys_recvfrom net/socket.c:2260 [inline] + __x64_sys_recvfrom+0x130/0x200 net/socket.c:2260 + do_syscall_x64 arch/x86/entry/common.c:51 [inline] + do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 + entry_SYSCALL_64_after_hwframe+0x63/0x6b + +Uninit was created at: + slab_post_alloc_hook+0x103/0x9e0 mm/slab.h:768 + slab_alloc_node mm/slub.c:3478 [inline] + kmem_cache_alloc_node+0x5f7/0xb50 mm/slub.c:3523 + kmalloc_reserve+0x13c/0x4a0 net/core/skbuff.c:560 + __alloc_skb+0x2fd/0x770 net/core/skbuff.c:651 + alloc_skb include/linux/skbuff.h:1286 [inline] + tipc_tlv_alloc net/tipc/netlink_compat.c:156 [inline] + tipc_get_err_tlv+0x90/0x5d0 net/tipc/netlink_compat.c:170 + tipc_nl_compat_recv+0x1042/0x15d0 net/tipc/netlink_compat.c:1324 + genl_family_rcv_msg_doit net/netlink/genetlink.c:972 [inline] + genl_family_rcv_msg net/netlink/genetlink.c:1052 [inline] + genl_rcv_msg+0x1220/0x12c0 net/netlink/genetlink.c:1067 + netlink_rcv_skb+0x4a4/0x6a0 net/netlink/af_netlink.c:2545 + genl_rcv+0x41/0x60 net/netlink/genetlink.c:1076 + netlink_unicast_kernel net/netlink/af_netlink.c:1342 [inline] + netlink_unicast+0xf4b/0x1230 net/netlink/af_netlink.c:1368 + netlink_sendmsg+0x1242/0x1420 net/netlink/af_netlink.c:1910 + sock_sendmsg_nosec net/socket.c:730 [inline] + __sock_sendmsg net/socket.c:745 [inline] + ____sys_sendmsg+0x997/0xd60 net/socket.c:2588 + ___sys_sendmsg+0x271/0x3b0 net/socket.c:2642 + __sys_sendmsg net/socket.c:2671 [inline] + __do_sys_sendmsg net/socket.c:2680 [inline] + __se_sys_sendmsg net/socket.c:2678 [inline] + __x64_sys_sendmsg+0x2fa/0x4a0 net/socket.c:2678 + do_syscall_x64 arch/x86/entry/common.c:51 [inline] + do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 + entry_SYSCALL_64_after_hwframe+0x63/0x6b + +Bytes 34-35 of 36 are uninitialized +Memory access of size 36 starts at ffff88802d464a00 +Data copied to user address 00007ff55033c0a0 + +CPU: 0 PID: 30322 Comm: syz-executor.0 Not tainted 6.6.0-14500-g1c41041124bd #10 +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc38 04/01/2014 +===================================================== + +tipc_add_tlv() puts TLV descriptor and value onto `skb`. This size is +calculated with TLV_SPACE() macro. It adds the size of struct tlv_desc and +the length of TLV value passed as an argument, and aligns the result to a +multiple of TLV_ALIGNTO, i.e., a multiple of 4 bytes. + +If the size of struct tlv_desc plus the length of TLV value is not aligned, +the current implementation leaves the remaining bytes uninitialized. This +is the cause of the above kernel-infoleak issue. + +This patch resolves this issue by clearing data up to an aligned size. + +Fixes: d0796d1ef63d ("tipc: convert legacy nl bearer dump to nl compat") +Signed-off-by: Shigeru Yoshida +Reviewed-by: Simon Horman +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/tipc/netlink_compat.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c +index 59e8e17d8da9c..2276a0704a635 100644 +--- a/net/tipc/netlink_compat.c ++++ b/net/tipc/netlink_compat.c +@@ -101,6 +101,7 @@ static int tipc_add_tlv(struct sk_buff *skb, u16 type, void *data, u16 len) + return -EMSGSIZE; + + skb_put(skb, TLV_SPACE(len)); ++ memset(tlv, 0, TLV_SPACE(len)); + tlv->tlv_type = htons(type); + tlv->tlv_len = htons(TLV_LENGTH(len)); + if (len && data) +-- +2.42.0 + diff --git a/queue-4.19/tty-fix-uninit-value-access-in-ppp_sync_receive.patch b/queue-4.19/tty-fix-uninit-value-access-in-ppp_sync_receive.patch new file mode 100644 index 00000000000..87b335ccda6 --- /dev/null +++ b/queue-4.19/tty-fix-uninit-value-access-in-ppp_sync_receive.patch @@ -0,0 +1,82 @@ +From 27fde9ac7db846609752e025cdc27d3146c8451f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 9 Nov 2023 00:44:20 +0900 +Subject: tty: Fix uninit-value access in ppp_sync_receive() + +From: Shigeru Yoshida + +[ Upstream commit 719639853d88071dfdfd8d9971eca9c283ff314c ] + +KMSAN reported the following uninit-value access issue: + +===================================================== +BUG: KMSAN: uninit-value in ppp_sync_input drivers/net/ppp/ppp_synctty.c:690 [inline] +BUG: KMSAN: uninit-value in ppp_sync_receive+0xdc9/0xe70 drivers/net/ppp/ppp_synctty.c:334 + ppp_sync_input drivers/net/ppp/ppp_synctty.c:690 [inline] + ppp_sync_receive+0xdc9/0xe70 drivers/net/ppp/ppp_synctty.c:334 + tiocsti+0x328/0x450 drivers/tty/tty_io.c:2295 + tty_ioctl+0x808/0x1920 drivers/tty/tty_io.c:2694 + vfs_ioctl fs/ioctl.c:51 [inline] + __do_sys_ioctl fs/ioctl.c:871 [inline] + __se_sys_ioctl+0x211/0x400 fs/ioctl.c:857 + __x64_sys_ioctl+0x97/0xe0 fs/ioctl.c:857 + do_syscall_x64 arch/x86/entry/common.c:51 [inline] + do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 + entry_SYSCALL_64_after_hwframe+0x63/0x6b + +Uninit was created at: + __alloc_pages+0x75d/0xe80 mm/page_alloc.c:4591 + __alloc_pages_node include/linux/gfp.h:238 [inline] + alloc_pages_node include/linux/gfp.h:261 [inline] + __page_frag_cache_refill+0x9a/0x2c0 mm/page_alloc.c:4691 + page_frag_alloc_align+0x91/0x5d0 mm/page_alloc.c:4722 + page_frag_alloc include/linux/gfp.h:322 [inline] + __netdev_alloc_skb+0x215/0x6d0 net/core/skbuff.c:728 + netdev_alloc_skb include/linux/skbuff.h:3225 [inline] + dev_alloc_skb include/linux/skbuff.h:3238 [inline] + ppp_sync_input drivers/net/ppp/ppp_synctty.c:669 [inline] + ppp_sync_receive+0x237/0xe70 drivers/net/ppp/ppp_synctty.c:334 + tiocsti+0x328/0x450 drivers/tty/tty_io.c:2295 + tty_ioctl+0x808/0x1920 drivers/tty/tty_io.c:2694 + vfs_ioctl fs/ioctl.c:51 [inline] + __do_sys_ioctl fs/ioctl.c:871 [inline] + __se_sys_ioctl+0x211/0x400 fs/ioctl.c:857 + __x64_sys_ioctl+0x97/0xe0 fs/ioctl.c:857 + do_syscall_x64 arch/x86/entry/common.c:51 [inline] + do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 + entry_SYSCALL_64_after_hwframe+0x63/0x6b + +CPU: 0 PID: 12950 Comm: syz-executor.1 Not tainted 6.6.0-14500-g1c41041124bd #10 +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc38 04/01/2014 +===================================================== + +ppp_sync_input() checks the first 2 bytes of the data are PPP_ALLSTATIONS +and PPP_UI. However, if the data length is 1 and the first byte is +PPP_ALLSTATIONS, an access to an uninitialized value occurs when checking +PPP_UI. This patch resolves this issue by checking the data length. + +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Signed-off-by: Shigeru Yoshida +Reviewed-by: Simon Horman +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ppp/ppp_synctty.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c +index 047f6c68a4419..e0de8b32df46a 100644 +--- a/drivers/net/ppp/ppp_synctty.c ++++ b/drivers/net/ppp/ppp_synctty.c +@@ -702,7 +702,7 @@ ppp_sync_input(struct syncppp *ap, const unsigned char *buf, + + /* strip address/control field if present */ + p = skb->data; +- if (p[0] == PPP_ALLSTATIONS && p[1] == PPP_UI) { ++ if (skb->len >= 2 && p[0] == PPP_ALLSTATIONS && p[1] == PPP_UI) { + /* chop off address/control */ + if (skb->len < 3) + goto err; +-- +2.42.0 + diff --git a/queue-4.19/tty-vcc-add-check-for-kstrdup-in-vcc_probe.patch b/queue-4.19/tty-vcc-add-check-for-kstrdup-in-vcc_probe.patch new file mode 100644 index 00000000000..f691b08f821 --- /dev/null +++ b/queue-4.19/tty-vcc-add-check-for-kstrdup-in-vcc_probe.patch @@ -0,0 +1,76 @@ +From 0749af72efa910e0c925c2cacd032e30c7ccf3aa Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Sep 2023 11:52:20 +0800 +Subject: tty: vcc: Add check for kstrdup() in vcc_probe() + +From: Yi Yang + +[ Upstream commit d81ffb87aaa75f842cd7aa57091810353755b3e6 ] + +Add check for the return value of kstrdup() and return the error, if it +fails in order to avoid NULL pointer dereference. + +Signed-off-by: Yi Yang +Reviewed-by: Jiri Slaby +Link: https://lore.kernel.org/r/20230904035220.48164-1-yiyang13@huawei.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/tty/vcc.c | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c +index 10a832a2135e2..31ecba1133159 100644 +--- a/drivers/tty/vcc.c ++++ b/drivers/tty/vcc.c +@@ -586,18 +586,22 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id) + return -ENOMEM; + + name = kstrdup(dev_name(&vdev->dev), GFP_KERNEL); ++ if (!name) { ++ rv = -ENOMEM; ++ goto free_port; ++ } + + rv = vio_driver_init(&port->vio, vdev, VDEV_CONSOLE_CON, vcc_versions, + ARRAY_SIZE(vcc_versions), NULL, name); + if (rv) +- goto free_port; ++ goto free_name; + + port->vio.debug = vcc_dbg_vio; + vcc_ldc_cfg.debug = vcc_dbg_ldc; + + rv = vio_ldc_alloc(&port->vio, &vcc_ldc_cfg, port); + if (rv) +- goto free_port; ++ goto free_name; + + spin_lock_init(&port->lock); + +@@ -631,6 +635,11 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id) + goto unreg_tty; + } + port->domain = kstrdup(domain, GFP_KERNEL); ++ if (!port->domain) { ++ rv = -ENOMEM; ++ goto unreg_tty; ++ } ++ + + mdesc_release(hp); + +@@ -660,8 +669,9 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id) + vcc_table_remove(port->index); + free_ldc: + vio_ldc_free(&port->vio); +-free_port: ++free_name: + kfree(name); ++free_port: + kfree(port); + + return rv; +-- +2.42.0 + diff --git a/queue-4.19/usb-gadget-f_ncm-always-set-current-gadget-in-ncm_bi.patch b/queue-4.19/usb-gadget-f_ncm-always-set-current-gadget-in-ncm_bi.patch new file mode 100644 index 00000000000..c342baf384d --- /dev/null +++ b/queue-4.19/usb-gadget-f_ncm-always-set-current-gadget-in-ncm_bi.patch @@ -0,0 +1,137 @@ +From a6a4cb117d87e422aec23d0795b7fc4add8cc092 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 20 Oct 2023 17:33:24 +0200 +Subject: usb: gadget: f_ncm: Always set current gadget in ncm_bind() + +From: Hardik Gajjar + +[ Upstream commit a04224da1f3424b2c607b12a3bd1f0e302fb8231 ] + +Previously, gadget assignment to the net device occurred exclusively +during the initial binding attempt. + +Nevertheless, the gadget pointer could change during bind/unbind +cycles due to various conditions, including the unloading/loading +of the UDC device driver or the detachment/reconnection of an +OTG-capable USB hub device. + +This patch relocates the gether_set_gadget() function out from +ncm_opts->bound condition check, ensuring that the correct gadget +is assigned during each bind request. + +The provided logs demonstrate the consistency of ncm_opts throughout +the power cycle, while the gadget may change. + +* OTG hub connected during boot up and assignment of gadget and + ncm_opts pointer + +[ 2.366301] usb 2-1.5: New USB device found, idVendor=2996, idProduct=0105 +[ 2.366304] usb 2-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3 +[ 2.366306] usb 2-1.5: Product: H2H Bridge +[ 2.366308] usb 2-1.5: Manufacturer: Aptiv +[ 2.366309] usb 2-1.5: SerialNumber: 13FEB2021 +[ 2.427989] usb 2-1.5: New USB device found, VID=2996, PID=0105 +[ 2.428959] dabridge 2-1.5:1.0: dabridge 2-4 total endpoints=5, 0000000093a8d681 +[ 2.429710] dabridge 2-1.5:1.0: P(0105) D(22.06.22) F(17.3.16) H(1.1) high-speed +[ 2.429714] dabridge 2-1.5:1.0: Hub 2-2 P(0151) V(06.87) +[ 2.429956] dabridge 2-1.5:1.0: All downstream ports in host mode + +[ 2.430093] gadget 000000003c414d59 ------> gadget pointer + +* NCM opts and associated gadget pointer during First ncm_bind + +[ 34.763929] NCM opts 00000000aa304ac9 +[ 34.763930] NCM gadget 000000003c414d59 + +* OTG capable hub disconnecte or assume driver unload. + +[ 97.203114] usb 2-1: USB disconnect, device number 2 +[ 97.203118] usb 2-1.1: USB disconnect, device number 3 +[ 97.209217] usb 2-1.5: USB disconnect, device number 4 +[ 97.230990] dabr_udc deleted + +* Reconnect the OTG hub or load driver assaign new gadget pointer. + +[ 111.534035] usb 2-1.1: New USB device found, idVendor=2996, idProduct=0120, bcdDevice= 6.87 +[ 111.534038] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 +[ 111.534040] usb 2-1.1: Product: Vendor +[ 111.534041] usb 2-1.1: Manufacturer: Aptiv +[ 111.534042] usb 2-1.1: SerialNumber: Superior +[ 111.535175] usb 2-1.1: New USB device found, VID=2996, PID=0120 +[ 111.610995] usb 2-1.5: new high-speed USB device number 8 using xhci-hcd +[ 111.630052] usb 2-1.5: New USB device found, idVendor=2996, idProduct=0105, bcdDevice=21.02 +[ 111.630055] usb 2-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3 +[ 111.630057] usb 2-1.5: Product: H2H Bridge +[ 111.630058] usb 2-1.5: Manufacturer: Aptiv +[ 111.630059] usb 2-1.5: SerialNumber: 13FEB2021 +[ 111.687464] usb 2-1.5: New USB device found, VID=2996, PID=0105 +[ 111.690375] dabridge 2-1.5:1.0: dabridge 2-8 total endpoints=5, 000000000d87c961 +[ 111.691172] dabridge 2-1.5:1.0: P(0105) D(22.06.22) F(17.3.16) H(1.1) high-speed +[ 111.691176] dabridge 2-1.5:1.0: Hub 2-6 P(0151) V(06.87) +[ 111.691646] dabridge 2-1.5:1.0: All downstream ports in host mode + +[ 111.692298] gadget 00000000dc72f7a9 --------> new gadget ptr on connect + +* NCM opts and associated gadget pointer during second ncm_bind + +[ 113.271786] NCM opts 00000000aa304ac9 -----> same opts ptr used during first bind +[ 113.271788] NCM gadget 00000000dc72f7a9 ----> however new gaget ptr, that will not set + in net_device due to ncm_opts->bound = true + +Signed-off-by: Hardik Gajjar +Link: https://lore.kernel.org/r/20231020153324.82794-1-hgajjar@de.adit-jv.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/gadget/function/f_ncm.c | 27 +++++++++++---------------- + 1 file changed, 11 insertions(+), 16 deletions(-) + +diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c +index 8d23a870b7b7f..2ef2464a50432 100644 +--- a/drivers/usb/gadget/function/f_ncm.c ++++ b/drivers/usb/gadget/function/f_ncm.c +@@ -1435,7 +1435,7 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f) + struct usb_composite_dev *cdev = c->cdev; + struct f_ncm *ncm = func_to_ncm(f); + struct usb_string *us; +- int status; ++ int status = 0; + struct usb_ep *ep; + struct f_ncm_opts *ncm_opts; + +@@ -1453,22 +1453,17 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f) + f->os_desc_table[0].os_desc = &ncm_opts->ncm_os_desc; + } + +- /* +- * in drivers/usb/gadget/configfs.c:configfs_composite_bind() +- * configurations are bound in sequence with list_for_each_entry, +- * in each configuration its functions are bound in sequence +- * with list_for_each_entry, so we assume no race condition +- * with regard to ncm_opts->bound access +- */ +- if (!ncm_opts->bound) { +- mutex_lock(&ncm_opts->lock); +- gether_set_gadget(ncm_opts->net, cdev->gadget); ++ mutex_lock(&ncm_opts->lock); ++ gether_set_gadget(ncm_opts->net, cdev->gadget); ++ if (!ncm_opts->bound) + status = gether_register_netdev(ncm_opts->net); +- mutex_unlock(&ncm_opts->lock); +- if (status) +- goto fail; +- ncm_opts->bound = true; +- } ++ mutex_unlock(&ncm_opts->lock); ++ ++ if (status) ++ goto fail; ++ ++ ncm_opts->bound = true; ++ + us = usb_gstrings_attach(cdev, ncm_strings, + ARRAY_SIZE(ncm_string_defs)); + if (IS_ERR(us)) { +-- +2.42.0 + diff --git a/queue-4.19/wifi-ath10k-fix-clang-specific-fortify-warning.patch b/queue-4.19/wifi-ath10k-fix-clang-specific-fortify-warning.patch new file mode 100644 index 00000000000..7d442e2b720 --- /dev/null +++ b/queue-4.19/wifi-ath10k-fix-clang-specific-fortify-warning.patch @@ -0,0 +1,62 @@ +From 1cf0211d03eb049d19e66a1c313a393956631970 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 29 Aug 2023 12:36:02 +0300 +Subject: wifi: ath10k: fix clang-specific fortify warning + +From: Dmitry Antipov + +[ Upstream commit cb4c132ebfeac5962f7258ffc831caa0c4dada1a ] + +When compiling with clang 16.0.6 and CONFIG_FORTIFY_SOURCE=y, I've +noticed the following (somewhat confusing due to absence of an actual +source code location): + +In file included from drivers/net/wireless/ath/ath10k/debug.c:8: +In file included from ./include/linux/module.h:13: +In file included from ./include/linux/stat.h:19: +In file included from ./include/linux/time.h:60: +In file included from ./include/linux/time32.h:13: +In file included from ./include/linux/timex.h:67: +In file included from ./arch/x86/include/asm/timex.h:5: +In file included from ./arch/x86/include/asm/processor.h:23: +In file included from ./arch/x86/include/asm/msr.h:11: +In file included from ./arch/x86/include/asm/cpumask.h:5: +In file included from ./include/linux/cpumask.h:12: +In file included from ./include/linux/bitmap.h:11: +In file included from ./include/linux/string.h:254: +./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' +declared with 'warning' attribute: detected read beyond size of field (2nd +parameter); maybe use struct_group()? [-Wattribute-warning] + __read_overflow2_field(q_size_field, size); + +The compiler actually complains on 'ath10k_debug_get_et_strings()' where +fortification logic inteprets call to 'memcpy()' as an attempt to copy +the whole 'ath10k_gstrings_stats' array from it's first member and so +issues an overread warning. This warning may be silenced by passing +an address of the whole array and not the first member to 'memcpy()'. + +Signed-off-by: Dmitry Antipov +Acked-by: Jeff Johnson +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230829093652.234537-1-dmantipov@yandex.ru +Signed-off-by: Sasha Levin +--- + drivers/net/wireless/ath/ath10k/debug.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c +index 4e980e78ba95c..9586deab5c004 100644 +--- a/drivers/net/wireless/ath/ath10k/debug.c ++++ b/drivers/net/wireless/ath/ath10k/debug.c +@@ -1146,7 +1146,7 @@ void ath10k_debug_get_et_strings(struct ieee80211_hw *hw, + u32 sset, u8 *data) + { + if (sset == ETH_SS_STATS) +- memcpy(data, *ath10k_gstrings_stats, ++ memcpy(data, ath10k_gstrings_stats, + sizeof(ath10k_gstrings_stats)); + } + +-- +2.42.0 + diff --git a/queue-4.19/wifi-ath9k-fix-clang-specific-fortify-warnings.patch b/queue-4.19/wifi-ath9k-fix-clang-specific-fortify-warnings.patch new file mode 100644 index 00000000000..cb91bc9bd5a --- /dev/null +++ b/queue-4.19/wifi-ath9k-fix-clang-specific-fortify-warnings.patch @@ -0,0 +1,102 @@ +From 161d9671d9407c9bf5ec0a92542218796b51b223 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 29 Aug 2023 12:38:12 +0300 +Subject: wifi: ath9k: fix clang-specific fortify warnings +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Dmitry Antipov + +[ Upstream commit 95f97fe0ac974467ab4da215985a32b2fdf48af0 ] + +When compiling with clang 16.0.6 and CONFIG_FORTIFY_SOURCE=y, I've +noticed the following (somewhat confusing due to absence of an actual +source code location): + +In file included from drivers/net/wireless/ath/ath9k/debug.c:17: +In file included from ./include/linux/slab.h:16: +In file included from ./include/linux/gfp.h:7: +In file included from ./include/linux/mmzone.h:8: +In file included from ./include/linux/spinlock.h:56: +In file included from ./include/linux/preempt.h:79: +In file included from ./arch/x86/include/asm/preempt.h:9: +In file included from ./include/linux/thread_info.h:60: +In file included from ./arch/x86/include/asm/thread_info.h:53: +In file included from ./arch/x86/include/asm/cpufeature.h:5: +In file included from ./arch/x86/include/asm/processor.h:23: +In file included from ./arch/x86/include/asm/msr.h:11: +In file included from ./arch/x86/include/asm/cpumask.h:5: +In file included from ./include/linux/cpumask.h:12: +In file included from ./include/linux/bitmap.h:11: +In file included from ./include/linux/string.h:254: +./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' +declared with 'warning' attribute: detected read beyond size of field (2nd +parameter); maybe use struct_group()? [-Wattribute-warning] + __read_overflow2_field(q_size_field, size); + +In file included from drivers/net/wireless/ath/ath9k/htc_drv_debug.c:17: +In file included from drivers/net/wireless/ath/ath9k/htc.h:20: +In file included from ./include/linux/module.h:13: +In file included from ./include/linux/stat.h:19: +In file included from ./include/linux/time.h:60: +In file included from ./include/linux/time32.h:13: +In file included from ./include/linux/timex.h:67: +In file included from ./arch/x86/include/asm/timex.h:5: +In file included from ./arch/x86/include/asm/processor.h:23: +In file included from ./arch/x86/include/asm/msr.h:11: +In file included from ./arch/x86/include/asm/cpumask.h:5: +In file included from ./include/linux/cpumask.h:12: +In file included from ./include/linux/bitmap.h:11: +In file included from ./include/linux/string.h:254: +./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' +declared with 'warning' attribute: detected read beyond size of field (2nd +parameter); maybe use struct_group()? [-Wattribute-warning] + __read_overflow2_field(q_size_field, size); + +The compiler actually complains on 'ath9k_get_et_strings()' and +'ath9k_htc_get_et_strings()' due to the same reason: fortification logic +inteprets call to 'memcpy()' as an attempt to copy the whole array from +it's first member and so issues an overread warning. These warnings may +be silenced by passing an address of the whole array and not the first +member to 'memcpy()'. + +Signed-off-by: Dmitry Antipov +Acked-by: Toke Høiland-Jørgensen +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230829093856.234584-1-dmantipov@yandex.ru +Signed-off-by: Sasha Levin +--- + drivers/net/wireless/ath/ath9k/debug.c | 2 +- + drivers/net/wireless/ath/ath9k/htc_drv_debug.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c +index 84fe686709496..e0a4e3fa87305 100644 +--- a/drivers/net/wireless/ath/ath9k/debug.c ++++ b/drivers/net/wireless/ath/ath9k/debug.c +@@ -1297,7 +1297,7 @@ void ath9k_get_et_strings(struct ieee80211_hw *hw, + u32 sset, u8 *data) + { + if (sset == ETH_SS_STATS) +- memcpy(data, *ath9k_gstrings_stats, ++ memcpy(data, ath9k_gstrings_stats, + sizeof(ath9k_gstrings_stats)); + } + +diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c +index c55aab01fff5d..e79bbcd3279af 100644 +--- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c ++++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c +@@ -428,7 +428,7 @@ void ath9k_htc_get_et_strings(struct ieee80211_hw *hw, + u32 sset, u8 *data) + { + if (sset == ETH_SS_STATS) +- memcpy(data, *ath9k_htc_gstrings_stats, ++ memcpy(data, ath9k_htc_gstrings_stats, + sizeof(ath9k_htc_gstrings_stats)); + } + +-- +2.42.0 + diff --git a/queue-4.19/wifi-mac80211-don-t-return-unset-power-in-ieee80211_.patch b/queue-4.19/wifi-mac80211-don-t-return-unset-power-in-ieee80211_.patch new file mode 100644 index 00000000000..fcf7448ae3c --- /dev/null +++ b/queue-4.19/wifi-mac80211-don-t-return-unset-power-in-ieee80211_.patch @@ -0,0 +1,58 @@ +From f259db92245d883cc06072d4bb0d79d74b786ea2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 3 Feb 2023 10:36:36 +0800 +Subject: wifi: mac80211: don't return unset power in ieee80211_get_tx_power() + +From: Ping-Ke Shih + +[ Upstream commit e160ab85166e77347d0cbe5149045cb25e83937f ] + +We can get a UBSAN warning if ieee80211_get_tx_power() returns the +INT_MIN value mac80211 internally uses for "unset power level". + + UBSAN: signed-integer-overflow in net/wireless/nl80211.c:3816:5 + -2147483648 * 100 cannot be represented in type 'int' + CPU: 0 PID: 20433 Comm: insmod Tainted: G WC OE + Call Trace: + dump_stack+0x74/0x92 + ubsan_epilogue+0x9/0x50 + handle_overflow+0x8d/0xd0 + __ubsan_handle_mul_overflow+0xe/0x10 + nl80211_send_iface+0x688/0x6b0 [cfg80211] + [...] + cfg80211_register_wdev+0x78/0xb0 [cfg80211] + cfg80211_netdev_notifier_call+0x200/0x620 [cfg80211] + [...] + ieee80211_if_add+0x60e/0x8f0 [mac80211] + ieee80211_register_hw+0xda5/0x1170 [mac80211] + +In this case, simply return an error instead, to indicate +that no data is available. + +Cc: Zong-Zhe Yang +Signed-off-by: Ping-Ke Shih +Link: https://lore.kernel.org/r/20230203023636.4418-1-pkshih@realtek.com +Signed-off-by: Johannes Berg +Signed-off-by: Sasha Levin +--- + net/mac80211/cfg.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c +index 5659af1bec179..77d8ed184c1c4 100644 +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -2452,6 +2452,10 @@ static int ieee80211_get_tx_power(struct wiphy *wiphy, + else + *dbm = sdata->vif.bss_conf.txpower; + ++ /* INT_MIN indicates no power level was set yet */ ++ if (*dbm == INT_MIN) ++ return -EINVAL; ++ + return 0; + } + +-- +2.42.0 + diff --git a/queue-4.19/x86-mm-drop-the-4-mb-restriction-on-minimal-numa-nod.patch b/queue-4.19/x86-mm-drop-the-4-mb-restriction-on-minimal-numa-nod.patch new file mode 100644 index 00000000000..918a4b2dc79 --- /dev/null +++ b/queue-4.19/x86-mm-drop-the-4-mb-restriction-on-minimal-numa-nod.patch @@ -0,0 +1,112 @@ +From 68b27f08cc3c85accce5e39895a27e1585f8fc7f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 18 Oct 2023 12:42:50 +0200 +Subject: x86/mm: Drop the 4 MB restriction on minimal NUMA node memory size + +From: Mike Rapoport (IBM) + +[ Upstream commit a1e2b8b36820d8c91275f207e77e91645b7c6836 ] + +Qi Zheng reported crashes in a production environment and provided a +simplified example as a reproducer: + + | For example, if we use Qemu to start a two NUMA node kernel, + | one of the nodes has 2M memory (less than NODE_MIN_SIZE), + | and the other node has 2G, then we will encounter the + | following panic: + | + | BUG: kernel NULL pointer dereference, address: 0000000000000000 + | <...> + | RIP: 0010:_raw_spin_lock_irqsave+0x22/0x40 + | <...> + | Call Trace: + | + | deactivate_slab() + | bootstrap() + | kmem_cache_init() + | start_kernel() + | secondary_startup_64_no_verify() + +The crashes happen because of inconsistency between the nodemask that +has nodes with less than 4MB as memoryless, and the actual memory fed +into the core mm. + +The commit: + + 9391a3f9c7f1 ("[PATCH] x86_64: Clear more state when ignoring empty node in SRAT parsing") + +... that introduced minimal size of a NUMA node does not explain why +a node size cannot be less than 4MB and what boot failures this +restriction might fix. + +Fixes have been submitted to the core MM code to tighten up the +memory topologies it accepts and to not crash on weird input: + + mm: page_alloc: skip memoryless nodes entirely + mm: memory_hotplug: drop memoryless node from fallback lists + +Andrew has accepted them into the -mm tree, but there are no +stable SHA1's yet. + +This patch drops the limitation for minimal node size on x86: + + - which works around the crash without the fixes to the core MM. + - makes x86 topologies less weird, + - removes an arbitrary and undocumented limitation on NUMA topologies. + +[ mingo: Improved changelog clarity. ] + +Reported-by: Qi Zheng +Tested-by: Mario Casquero +Signed-off-by: Mike Rapoport (IBM) +Signed-off-by: Ingo Molnar +Acked-by: David Hildenbrand +Acked-by: Michal Hocko +Cc: Dave Hansen +Cc: Rik van Riel +Link: https://lore.kernel.org/r/ZS+2qqjEO5/867br@gmail.com +Signed-off-by: Sasha Levin +--- + arch/x86/include/asm/numa.h | 7 ------- + arch/x86/mm/numa.c | 7 ------- + 2 files changed, 14 deletions(-) + +diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h +index bbfde3d2662f4..4bcd9d0c7bee7 100644 +--- a/arch/x86/include/asm/numa.h ++++ b/arch/x86/include/asm/numa.h +@@ -11,13 +11,6 @@ + + #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) + +-/* +- * Too small node sizes may confuse the VM badly. Usually they +- * result from BIOS bugs. So dont recognize nodes as standalone +- * NUMA entities that have less than this amount of RAM listed: +- */ +-#define NODE_MIN_SIZE (4*1024*1024) +- + extern int numa_off; + + /* +diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c +index b4ff063a43712..a830d49341ecc 100644 +--- a/arch/x86/mm/numa.c ++++ b/arch/x86/mm/numa.c +@@ -585,13 +585,6 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) + if (start >= end) + continue; + +- /* +- * Don't confuse VM with a node that doesn't have the +- * minimum amount of memory: +- */ +- if (end && (end - start) < NODE_MIN_SIZE) +- continue; +- + alloc_node_data(nid); + } + +-- +2.42.0 + diff --git a/queue-4.19/xen-events-fix-delayed-eoi-list-handling.patch b/queue-4.19/xen-events-fix-delayed-eoi-list-handling.patch new file mode 100644 index 00000000000..8dd7a858a62 --- /dev/null +++ b/queue-4.19/xen-events-fix-delayed-eoi-list-handling.patch @@ -0,0 +1,47 @@ +From 68739f693340af033476547d7c967aeb8472b38e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 25 Sep 2023 17:54:13 +0200 +Subject: xen/events: fix delayed eoi list handling + +From: Juergen Gross + +[ Upstream commit 47d970204054f859f35a2237baa75c2d84fcf436 ] + +When delaying eoi handling of events, the related elements are queued +into the percpu lateeoi list. In case the list isn't empty, the +elements should be sorted by the time when eoi handling is to happen. + +Unfortunately a new element will never be queued at the start of the +list, even if it has a handling time lower than all other list +elements. + +Fix that by handling that case the same way as for an empty list. + +Fixes: e99502f76271 ("xen/events: defer eoi in case of excessive number of events") +Reported-by: Jan Beulich +Signed-off-by: Juergen Gross +Reviewed-by: Oleksandr Tyshchenko +Signed-off-by: Juergen Gross +Signed-off-by: Sasha Levin +--- + drivers/xen/events/events_base.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c +index 960666aba12bf..3b27b98175c6d 100644 +--- a/drivers/xen/events/events_base.c ++++ b/drivers/xen/events/events_base.c +@@ -490,7 +490,9 @@ static void lateeoi_list_add(struct irq_info *info) + + spin_lock_irqsave(&eoi->eoi_list_lock, flags); + +- if (list_empty(&eoi->eoi_list)) { ++ elem = list_first_entry_or_null(&eoi->eoi_list, struct irq_info, ++ eoi_list); ++ if (!elem || info->eoi_time < elem->eoi_time) { + list_add(&info->eoi_list, &eoi->eoi_list); + mod_delayed_work_on(info->eoi_cpu, system_wq, + &eoi->delayed, delay); +-- +2.42.0 +