4.19.247-rc1 review
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 169/287 irqchip: irq-xtensa-mx: fix initial IRQ affinity
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit a255ee29252066d621df5d6b420bf534c6ba5bc0 upstream.
When irq-xtensa-mx chip is used in non-SMP configuration its irq_set_affinity callback is not called leaving IRQ affinity set empty. As a result IRQ delivery does not work in that configuration. Initialize IRQ affinity of the xtensa MX interrupt distributor to CPU 0 for all external IRQ lines.
--- drivers/irqchip/irq-xtensa-mx.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/irqchip/irq-xtensa-mx.c +14 -4
@@ -141,14 +141,25 @@ static struct irq_chip xtensa_mx_irq_chi .irq_set_affinity = xtensa_mx_irq_set_affinity, }; +static void __init xtensa_mx_init_common (struct irq_domain *root_domain) +{ +unsigned int i; + +irq_set_default_host (root_domain); +secondary_init_irq (); + +/* Initialize default IRQ routing to CPU 0 */ +for (i =0 ; i <XCHAL_NUM_EXTINTERRUPTS ; ++i) +set_er (1 ,MIROUT (i)); +} +int __init xtensa_mx_init_legacy (struct device_node *interrupt_parent) {struct irq_domain *root_domain =irq_domain_add_legacy (NULL ,NR_IRQS -1 ,1 ,0 , &xtensa_mx_irq_domain_ops, &xtensa_mx_irq_chip); -irq_set_default_host (root_domain); -secondary_init_irq (); +xtensa_mx_init_common (root_domain);return 0 ; }
@@ -158,8 +169,7 @@ static int __init xtensa_mx_init(structstruct irq_domain *root_domain =irq_domain_add_linear (np,NR_IRQS , &xtensa_mx_irq_domain_ops, &xtensa_mx_irq_chip); -irq_set_default_host (root_domain); -secondary_init_irq (); +xtensa_mx_init_common (root_domain);return 0 ; }IRQCHIP_DECLARE (xtensa_mx_irq_chip,"cdns,xtensa-mx" , xtensa_mx_init);
Greg Kroah-Hartman
maintainerPATCH 170/287 mac80211: upgrade passive scan to active scan on DFS channels after beacon rx
In reply to Greg Kroah-HartmanFrom: Felix Fietkau <[email protected]>
commit b041b7b9de6e1d4362de855ab90f9d03ef323edd upstream.
In client mode, we can't connect to hidden SSID APs or SSIDs not advertised in beacons on DFS channels, since we're forced to passive scan. Fix this by sending out a probe request immediately after the first beacon, if active scan was requested by the user.
--- net/mac80211/ieee80211_i.h | 5 +++++ net/mac80211/scan.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+)
net/mac80211/ieee80211_i.h +5 -0
@@ -1072,6 +1072,9 @@ struct tpt_led_trigger {* a scan complete for an aborted scan. * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being * cancelled. +* @SCAN_BEACON_WAIT: Set whenever we're passive scanning because of radar/no-IR +* and could send a probe request after receiving a beacon. +* @SCAN_BEACON_DONE: Beacon received, we can now send a probe request */ enum {SCAN_SW_SCANNING ,
@@ -1080,6 +1083,8 @@ enum {SCAN_COMPLETED ,SCAN_ABORTED ,SCAN_HW_CANCELLED , +SCAN_BEACON_WAIT , + SCAN_BEACON_DONE, };/**
net/mac80211/scan.c +20 -0
@@ -222,6 +222,16 @@ void ieee80211_scan_rx(struct ieee80211_if (likely (!sdata1 && !sdata2))return ; +if (test_and_clear_bit (SCAN_BEACON_WAIT , &local->scanning)) { +/* +* we were passive scanning because of radar/no-IR, but +* the beacon/proberesp rx gives us an opportunity to upgrade +* to active scan +*/ +set_bit (SCAN_BEACON_DONE , &local->scanning); +ieee80211_queue_delayed_work (&local->hw, &local->scan_work,0 ); + } +if (ieee80211_is_probe_resp (mgmt->frame_control)) {struct cfg80211_scan_request *scan_req;struct cfg80211_sched_scan_request *sched_scan_req;
@@ -706,6 +716,8 @@ static int __ieee80211_start_scan(struct IEEE80211_CHAN_RADAR)) || !req->n_ssids) { next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; + if (req->n_ssids) + set_bit(SCAN_BEACON_WAIT, &local->scanning); } else {ieee80211_scan_state_send_probe (local, &next_delay); next_delay =IEEE80211_CHANNEL_TIME ;
@@ -886,6 +898,8 @@ static void ieee80211_scan_state_set_cha !scan_req->n_ssids) { *next_delay =IEEE80211_PASSIVE_CHANNEL_TIME ; local->next_scan_state =SCAN_DECISION ; +if (scan_req->n_ssids) +set_bit (SCAN_BEACON_WAIT , &local->scanning);return ; }
@@ -978,6 +992,8 @@ void ieee80211_scan_work(struct work_str goto out; } +clear_bit (SCAN_BEACON_WAIT , &local->scanning); +/* * as long as no delay is required advance immediately * without scheduling a new work
@@ -988,6 +1004,10 @@ void ieee80211_scan_work(struct work_str goto out_complete; } +if (test_and_clear_bit (SCAN_BEACON_DONE , &local->scanning) && + local->next_scan_state ==SCAN_DECISION ) + local->next_scan_state =SCAN_SEND_PROBE ; +switch (local->next_scan_state) {case SCAN_DECISION :/* if no more bands/channels left, complete scan */
Greg Kroah-Hartman
maintainerPATCH 171/287 um: chan_user: Fix winch_tramp() return value
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
commit 57ae0b67b747031bc41fb44643aa5344ab58607e upstream.
The previous fix here was only partially correct, it did result in returning a proper error value in case of error, but it also clobbered the pid that we need to return from this function (not just zero for success).
As a result, it returned 0 here, but later this is treated as a pid and used to kill the process, but since it's now 0 we kill(0, SIGKILL), which makes UML kill itself rather than just the helper thread.
Fix that and make it more obvious by using a separate variable for the pid.
--- arch/um/drivers/chan_user.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/um/drivers/chan_user.c +5 -4
@@ -220,7 +220,7 @@ static int winch_tramp(int fd, struct tt unsigned long *stack_out) {struct winch_data data; -int fds[2 ], n, err; +int fds[2 ], n, err, pid;char c; err =os_pipe (fds,1 ,1 );
@@ -238,8 +238,9 @@ static int winch_tramp(int fd, struct tt* problem with /dev/net/tun, which if held open by this * thread, prevents the TUN/TAP device from being reused. */ - err =run_helper_thread (winch_thread, &data,CLONE_FILES , stack_out); -if (err <0 ) { + pid =run_helper_thread (winch_thread, &data,CLONE_FILES , stack_out); +if (pid <0 ) { + err = pid;printk (UM_KERN_ERR "fork of winch_thread failed - errno = %d\n" , -err); goto out_close;
@@ -263,7 +264,7 @@ static int winch_tramp(int fd, struct tt goto out_close; } -return err; +return pid; out_close:close (fds[1 ]);
Greg Kroah-Hartman
maintainerPATCH 172/287 um: Fix out-of-bounds read in LDT setup
In reply to Greg Kroah-HartmanFrom: Vincent Whitchurch <[email protected]>
commit 2a4a62a14be1947fa945c5c11ebf67326381a568 upstream.
syscall_stub_data() expects the data_count parameter to be the number of longs, not bytes.
==================================================================
BUG: KASAN: stack-out-of-bounds in syscall_stub_data+0x70/0xe0 Read of size 128 at addr 000000006411f6f0 by task swapper/1 CPU: 0 PID: 1 Comm: swapper Not tainted 5.18.0+ #18 Call Trace: show_stack.cold+0x166/0x2a7 __dump_stack+0x3a/0x43 dump_stack_lvl+0x1f/0x27 print_report.cold+0xdb/0xf81 kasan_report+0x119/0x1f0 kasan_check_range+0x3a3/0x440 memcpy+0x52/0x140 syscall_stub_data+0x70/0xe0 write_ldt_entry+0xac/0x190 init_new_ldt+0x515/0x960 init_new_context+0x2c4/0x4d0 mm_init.constprop.0+0x5ed/0x760 mm_alloc+0x118/0x170 0x60033f48 do_one_initcall+0x1d7/0x860 0x60003e7b kernel_init+0x6e/0x3d4 new_thread_handler+0x1e7/0x2c0 The buggy address belongs to stack of task swapper/1 and is located at offset 64 in frame: init_new_ldt+0x0/0x960
This frame has 2 objects:
[32, 40) 'addr'
[64, 80) 'desc'
==================================================================
--- arch/x86/um/ldt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/um/ldt.c +4 -2
@@ -23,9 +23,11 @@ static long write_ldt_entry(struct mm_id {long res;void *stub_addr; + +BUILD_BUG_ON (sizeof (*desc) %sizeof (long )); + res =syscall_stub_data (mm_idp, (unsigned long *)desc, - (sizeof (*desc) +sizeof (long ) -1 ) & - ~(sizeof (long ) -1 ), +sizeof (*desc) /sizeof (long ), addr, &stub_addr);if (!res) { unsigned long args[] = { func,
Greg Kroah-Hartman
maintainerPATCH 173/287 iommu/msm: Fix an incorrect NULL check on list iterator
In reply to Greg Kroah-HartmanFrom: Xiaomeng Tong <[email protected]>
commit 8b9ad480bd1dd25f4ff4854af5685fa334a2f57a upstream.
The bug is here:
if (!iommu || iommu->dev->of_node != spec->np) {The list iterator value 'iommu' will *always* be set and non-NULL by list_for_each_entry(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found (in fact, it will point to a invalid structure object containing HEAD).
To fix the bug, use a new value 'iter' as the list iterator, while use the old value 'iommu' as a dedicated variable to point to the found one, and remove the unneeded check for 'iommu->dev->of_node != spec->np' outside the loop.
--- drivers/iommu/msm_iommu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/iommu/msm_iommu.c +7 -4
@@ -638,16 +638,19 @@ static void insert_iommu_master(struct dstatic int qcom_iommu_of_xlate (struct device *dev,struct of_phandle_args *spec) { -struct msm_iommu_dev *iommu; +struct msm_iommu_dev *iommu =NULL , *iter;unsigned long flags;int ret =0 ;spin_lock_irqsave (&msm_iommu_lock, flags); -list_for_each_entry (iommu, &qcom_iommu_devices, dev_node) -if (iommu->dev->of_node == spec->np) +list_for_each_entry (iter, &qcom_iommu_devices, dev_node) { +if (iter->dev->of_node == spec->np) { + iommu = iter;break ; + } + } -if (!iommu || iommu->dev->of_node != spec->np) { +if (!iommu) { ret = -ENODEV ; goto fail; }
Greg Kroah-Hartman
maintainerPATCH 174/287 nodemask.h: fix compilation error with GCC12
In reply to Greg Kroah-HartmanFrom: Christophe de Dinechin <[email protected]>
commit 37462a920392cb86541650a6f4121155f11f1199 upstream.
With gcc version 12.0.1 20220401 (Red Hat 12.0.1-0), building with defconfig results in the following compilation error:
| CC mm/swapfile.o | mm/swapfile.c: In function `setup_swap_info': | mm/swapfile.c:2291:47: error: array subscript -1 is below array bounds | of `struct plist_node[]' [-Werror=array-bounds] | 2291 | p->avail_lists[i].prio = 1; | | ~~~~~~~~~~~~~~^~~ | In file included from mm/swapfile.c:16: | ./include/linux/swap.h:292:27: note: while referencing `avail_lists' | 292 | struct plist_node avail_lists[]; /* | | ^~~~~~~~~~~
This is due to the compiler detecting that the mask in node_states[__state] could theoretically be zero, which would lead to first_node() returning -1 through find_first_bit.
I believe that the warning/error is legitimate. I first tried adding a test to check that the node mask is not emtpy, since a similar test exists in the case where MAX_NUMNODES == 1.
However, adding the if statement causes other warnings to appear in for_each_cpu_node_but, because it introduces a dangling else ambiguity. And unfortunately, GCC is not smart enough to detect that the added test makes the case where (node) == -1 impossible, so it still complains with the same message.
This is why I settled on replacing that with a harmless, but relatively useless (node) >= 0 test. Based on the warning for the dangling else, I also decided to fix the case where MAX_NUMNODES == 1 by moving the condition inside the for loop. It will still only be tested once. This ensures that the meaning of an else following for_each_node_mask or derivatives would not silently have a different meaning depending on the configuration.
--- include/linux/nodemask.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
include/linux/nodemask.h +6 -7
@@ -375,14 +375,13 @@ static inline void __nodes_fold(nodemask }#if MAX_NUMNODES >1 -#define for_each_node_mask (node, mask) \ - for ((node) = first_node(mask); \ - (node) < MAX_NUMNODES; \ - (node) = next_node((node), (mask))) +#define for_each_node_mask (node, mask) \ + for ((node) = first_node(mask); \ + (node >= 0) && (node) < MAX_NUMNODES; \ + (node) = next_node((node), (mask)))#else /* MAX_NUMNODES == 1 */ -#define for_each_node_mask (node, mask) \ - if (!nodes_empty(mask)) \ - for ((node) = 0; (node) < 1; (node)++) +#define for_each_node_mask (node, mask) \ + for ((node) = 0; (node) < 1 && !nodes_empty(mask); (node)++)#endif /* MAX_NUMNODES */ /*
Greg Kroah-Hartman
maintainerPATCH 175/287 hugetlb: fix huge_pmd_unshare address update
In reply to Greg Kroah-HartmanFrom: Mike Kravetz <[email protected]>
commit 48381273f8734d28ef56a5bdf1966dd8530111bc upstream.
The routine huge_pmd_unshare() is passed a pointer to an address associated with an area which may be unshared. If unshare is successful this address is updated to 'optimize' callers iterating over huge page addresses. For the optimization to work correctly, address should be updated to the last huge page in the unmapped/unshared area. However, in the common case where the passed address is PUD_SIZE aligned, the address is incorrectly updated to the address of the preceding huge page. That wastes CPU cycles as the unmapped/unshared range is scanned twice.
--- mm/hugetlb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
mm/hugetlb.c +8 -1
@@ -4837,7 +4837,14 @@ int huge_pmd_unshare(struct mm_struct *mpud_clear (pud);put_page (virt_to_page (ptep));mm_dec_nr_pmds (mm); - *addr =ALIGN (*addr,HPAGE_SIZE *PTRS_PER_PTE ) -HPAGE_SIZE ; +/* +* This update of passed address optimizes loops sequentially +* processing addresses in increments of huge page size (PMD_SIZE +* in this case). By clearing the pud, a PUD_SIZE area is unmapped. +* Update address to the 'last page' in the cleared area so that +* calling loop can move to first page past this area. +*/ + *addr |=PUD_SIZE -PMD_SIZE ;return 1 ; }#define want_pmd_share () (1)
Greg Kroah-Hartman
maintainerPATCH 176/287 rtl818x: Prevent using not initialized queues
In reply to Greg Kroah-HartmanFrom: Alexander Wetzel <[email protected]>
commit 746285cf81dc19502ab238249d75f5990bd2d231 upstream.
Using not existing queues can panic the kernel with rtl8180/rtl8185 cards. Ignore the skb priority for those cards, they only have one tx queue. Pierre Asselin ([email protected]) reported the kernel crash in the Gentoo forum:
https://forums.gentoo.org/viewtopic-t-1147832-postdays-0-postorder-asc-start-25.html
He also confirmed that this patch fixes the issue. In summary this happened:
After updating wpa_supplicant from 2.9 to 2.10 the kernel crashed with a "divide error: 0000" when connecting to an AP. Control port tx now tries to use IEEE80211_AC_VO for the priority, which wpa_supplicants starts to use in 2.10.
Since only the rtl8187se part of the driver supports QoS, the priority of the skb is set to IEEE80211_AC_BE (2) by mac80211 for rtl8180/rtl8185 cards.
rtl8180 is then unconditionally reading out the priority and finally crashes on drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c line 544 without this patch:
idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries
"ring->entries" is zero for rtl8180/rtl8185 cards, tx_ring[2] never got initialized.
--- drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c +6 -2
@@ -460,8 +460,10 @@ static void rtl8180_tx(struct ieee80211_struct rtl8180_priv *priv = dev->priv;struct rtl8180_tx_ring *ring;struct rtl8180_tx_desc *entry; +unsigned int prio =0 ;unsigned long flags; -unsigned int idx, prio, hw_prio; +unsigned int idx, hw_prio; +dma_addr_t mapping;u32 tx_flags;u8 rc_flags;
@@ -470,7 +472,9 @@ static void rtl8180_tx(struct ieee80211_/* do arithmetic and then convert to le16 */ u16 frame_duration =0 ; - prio =skb_get_queue_mapping (skb); +/* rtl8180/rtl8185 only has one useable tx queue */ +if (dev->queues >IEEE80211_AC_BK ) + prio =skb_get_queue_mapping (skb); ring = &priv->tx_ring[prio]; mapping = pci_map_single(priv->pdev, skb->data,
Greg Kroah-Hartman
maintainerPATCH 177/287 ASoC: rt5514: Fix event generation for "DSP Voice Wake Up" control
In reply to Greg Kroah-HartmanFrom: Mark Brown <[email protected]>
commit 4213ff556740bb45e2d9ff0f50d056c4e7dd0921 upstream.
The driver has a custom put function for "DSP Voice Wake Up" which does not generate event notifications on change, instead returning 0. Since we already exit early in the case that there is no change this can be fixed by unconditionally returning 1 at the end of the function.
--- sound/soc/codecs/rt5514.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt5514.c +1 -1
@@ -422,7 +422,7 @@ static int rt5514_dsp_voice_wake_up_put( } } -return 0 ; +return 1 ; }static const struct snd_kcontrol_new rt5514_snd_controls[] = {
Greg Kroah-Hartman
maintainerPATCH 178/287 carl9170: tx: fix an incorrect use of list iterator
In reply to Greg Kroah-HartmanFrom: Xiaomeng Tong <[email protected]>
commit 54a6f29522da3c914da30e50721dedf51046449a upstream.
If the previous list_for_each_entry_continue_rcu() don't exit early (no goto hit inside the loop), the iterator 'cvif' after the loop will be a bogus pointer to an invalid structure object containing the HEAD (&ar->vif_list). As a result, the use of 'cvif' after that will lead to a invalid memory access (i.e., 'cvif->id': the invalid pointer dereference when return back to/after the callsite in the carl9170_update_beacon()).
The original intention should have been to return the valid 'cvif' when found in list, NULL otherwise. So just return NULL when no entry found, to fix this bug.
--- drivers/net/wireless/ath/carl9170/tx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/carl9170/tx.c +3 -0
@@ -1554,6 +1554,9 @@ static struct carl9170_vif_info *carl917 goto out; } }while (ar->beacon_enabled && i--); + +/* no entry found in list */ +return NULL ; } out:
Greg Kroah-Hartman
maintainerPATCH 179/287 gma500: fix an incorrect NULL check on list iterator
In reply to Greg Kroah-HartmanFrom: Xiaomeng Tong <[email protected]>
commit bdef417d84536715145f6dc9cc3275c46f26295a upstream.
The bug is here:
return crtc;
The list iterator value 'crtc' will *always* be set and non-NULL by list_for_each_entry(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found.
To fix the bug, return 'crtc' when found, otherwise return NULL.
--- drivers/gpu/drm/gma500/psb_intel_display.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/gma500/psb_intel_display.c +4 -3
@@ -543,14 +543,15 @@ void psb_intel_crtc_init(struct drm_devistruct drm_crtc *psb_intel_get_crtc_from_pipe (struct drm_device *dev,int pipe) { -struct drm_crtc *crtc =NULL ; +struct drm_crtc *crtc;list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {struct gma_crtc *gma_crtc =to_gma_crtc (crtc); +if (gma_crtc->pipe == pipe) -break ; +return crtc; } -return crtc; +return NULL ; }int gma_connector_clones (struct drm_device *dev,int type_mask)
Greg Kroah-Hartman
maintainerPATCH 180/287 arm64: dts: qcom: ipq8074: fix the sleep clock frequency
In reply to Greg Kroah-HartmanFrom: Kathiravan T <[email protected]>
commit f607dd767f5d6800ffbdce5b99ba81763b023781 upstream.
Sleep clock frequency should be 32768Hz. Lets fix it.
--- arch/arm64/boot/dts/qcom/ipq8074.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/ipq8074.dtsi +1 -1
@@ -490,7 +490,7 @@ clocks { sleep_clk: sleep_clk { compatible = "fixed-clock"; - clock-frequency = <32000>; + clock-frequency = <32768>; #clock-cells = <0>; };
Greg Kroah-Hartman
maintainerPATCH 181/287 phy: qcom-qmp: fix struct clk leak on probe errors
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit f0a4bc38a12f5a0cc5ad68670d9480e91e6a94df upstream.
Make sure to release the pipe clock reference in case of a late probe error (e.g. probe deferral).
--- drivers/phy/qualcomm/phy-qcom-qmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-qmp.c +1 -1
@@ -1468,7 +1468,7 @@ int qcom_qmp_phy_create(struct device *d* all phys that don't need this. */ snprintf (prop_name,sizeof (prop_name),"pipe%d" , id); - qphy->pipe_clk =of_clk_get_by_name (np, prop_name); + qphy->pipe_clk =devm_get_clk_from_child (dev, np, prop_name);if (IS_ERR (qphy->pipe_clk)) {if (qmp->cfg->type ==PHY_TYPE_PCIE || qmp->cfg->type ==PHY_TYPE_USB3 ) {
Greg Kroah-Hartman
maintainerPATCH 182/287 docs/conf.py: Cope with removal of language=None in Sphinx 5.0.0
In reply to Greg Kroah-HartmanFrom: Akira Yokosawa <[email protected]>
commit 627f01eab93d8671d4e4afee9b148f9998d20e7c upstream.
One of the changes in Sphinx 5.0.0 [1] says [sic]:
5.0.0 final
- #10474: language does not accept None as it value. The default value of language becomes to 'en' now.
[1]: https://www.sphinx-doc.org/en/master/changes.html#release-5-0-0-released-may-30-2022
It results in a new warning from Sphinx 5.0.0 [sic]:
WARNING: Invalid configuration value found: 'language = None'. Update your configuration to a valid langauge code. Falling back to 'en' (English).
Silence the warning by using 'en'.
It works with all the Sphinx versions required for building kernel documentation (1.7.9 or later).
--- Documentation/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/conf.py +1 -1
@@ -95,7 +95,7 @@ finally: # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used:
Greg Kroah-Hartman
maintainerPATCH 183/287 dt-bindings: gpio: altera: correct interrupt-cells
In reply to Greg Kroah-HartmanFrom: Dinh Nguyen <[email protected]>
commit 3a21c3ac93aff7b4522b152399df8f6a041df56d upstream.
update documentation to correctly state the interrupt-cells to be 2.
--- Documentation/devicetree/bindings/gpio/gpio-altera.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/gpio/gpio-altera.txt +3 -2
@@ -9,8 +9,9 @@ Required properties: - The second cell is reserved and is currently unused. - gpio-controller : Marks the device node as a GPIO controller. - interrupt-controller: Mark the device node as an interrupt controller -- #interrupt-cells : Should be 1. The interrupt type is fixed in the hardware. +- #interrupt-cells : Should be 2. The interrupt type is fixed in the hardware. - The first cell is the GPIO offset number within the GPIO controller. + - The second cell is the interrupt trigger type and level flags. - interrupts: Specify the interrupt. - altr,interrupt-type: Specifies the interrupt trigger type the GPIO hardware is synthesized. This field is required if the Altera GPIO controller
@@ -38,6 +39,6 @@ gpio_altr: gpio@ff200000 { altr,interrupt-type = <IRQ_TYPE_EDGE_RISING>; #gpio-cells = <2>; gpio-controller; - #interrupt-cells = <1>; + #interrupt-cells = <2>; interrupt-controller; };
Greg Kroah-Hartman
maintainerPATCH 184/287 blk-iolatency: Fix inflight count imbalances and IO hangs on offline
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 8a177a36da6c54c98b8685d4f914cb3637d53c0d upstream.
iolatency needs to track the number of inflight IOs per cgroup. As this tracking can be expensive, it is disabled when no cgroup has iolatency configured for the device. To ensure that the inflight counters stay balanced, iolatency_set_limit() freezes the request_queue while manipulating the enabled counter, which ensures that no IO is in flight and thus all counters are zero.
Unfortunately, iolatency_set_limit() isn't the only place where the enabled counter is manipulated. iolatency_pd_offline() can also dec the counter and trigger disabling. As this disabling happens without freezing the q, this can easily happen while some IOs are in flight and thus leak the counts.
This can be easily demonstrated by turning on iolatency on an one empty cgroup while IOs are in flight in other cgroups and then removing the cgroup. Note that iolatency shouldn't have been enabled elsewhere in the system to ensure that removing the cgroup disables iolatency for the whole device.
The following keeps flipping on and off iolatency on sda:
echo +io > /sys/fs/cgroup/cgroup.subtree_control while true; do
mkdir -p /sys/fs/cgroup/test
echo '8:0 target=100000' > /sys/fs/cgroup/test/io.latency sleep 1
rmdir /sys/fs/cgroup/test
sleep 1
done
and there's concurrent fio generating direct rand reads:
fio --name test --filename=/dev/sda --direct=1 --rw=randread \
--runtime=600 --time_based --iodepth=256 --numjobs=4 --bs=4kwhile monitoring with the following drgn script:
while True:
for css in css_for_each_descendant_pre(prog['blkcg_root'].css.address_of_()):
for pos in hlist_for_each(container_of(css, 'struct blkcg', 'css').blkg_list):
blkg = container_of(pos, 'struct blkcg_gq', 'blkcg_node')
pd = blkg.pd[prog['blkcg_policy_iolatency'].plid]
if pd.value_() == 0:
continue
iolat = container_of(pd, 'struct iolatency_grp', 'pd') inflight = iolat.rq_wait.inflight.counter.value_()
if inflight:
print(f'inflight={inflight} {disk_name(blkg.q.disk).decode("utf-8")} '
f'{cgroup_path(css.cgroup).decode("utf-8")}')
time.sleep(1)
The monitoring output looks like the following:
inflight=1 sda /user.slice
inflight=1 sda /user.slice
...
inflight=14 sda /user.slice
inflight=13 sda /user.slice
inflight=17 sda /user.slice
inflight=15 sda /user.slice
inflight=18 sda /user.slice
inflight=17 sda /user.slice
inflight=20 sda /user.slice
inflight=19 sda /user.slice <- fio stopped, inflight stuck at 19 inflight=19 sda /user.slice
inflight=19 sda /user.slice
If a cgroup with stuck inflight ends up getting throttled, the throttled IOs will never get issued as there's no completion event to wake it up leading to an indefinite hang.
This patch fixes the bug by unifying enable handling into a work item which is automatically kicked off from iolatency_set_min_lat_nsec() which is called from both iolatency_set_limit() and iolatency_pd_offline() paths. Punting to a work item is necessary as iolatency_pd_offline() is called under spinlocks while freezing a request_queue requires a sleepable context.
This also simplifies the code reducing LOC sans the comments and avoids the unnecessary freezes which were happening whenever a cgroup's latency target is newly set or cleared.
--- block/blk-iolatency.c | 122 ++++++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 58 deletions(-)
block/blk-iolatency.c +64 -58
@@ -85,7 +85,17 @@ struct iolatency_grp;struct blk_iolatency {struct rq_qos rqos;struct timer_list timer; -atomic_t enabled; + +/* +* ->enabled is the master enable switch gating the throttling logic and +* inflight tracking. The number of cgroups which have iolat enabled is +* tracked in ->enable_cnt, and ->enable is flipped on/off accordingly +* from ->enable_work with the request_queue frozen. For details, See +* blkiolatency_enable_work_fn(). +*/ +bool enabled; +atomic_t enable_cnt; +struct work_struct enable_work; };static inline struct blk_iolatency *BLKIOLATENCY (struct rq_qos *rqos)
@@ -93,11 +103,6 @@ static inline struct blk_iolatency *BLKI return container_of(rqos, struct blk_iolatency, rqos); } -static inline bool blk_iolatency_enabled (struct blk_iolatency *blkiolat) -{ -return atomic_read (&blkiolat->enabled) >0 ; -} -struct child_latency_info {spinlock_t lock;
@@ -402,7 +407,7 @@ static void blkcg_iolatency_throttle(strstruct request_queue *q = rqos->q;bool issue_as_root =bio_issue_as_root_blkg (bio); -if (!blk_iolatency_enabled (blkiolat)) +if (!blkiolat->enabled)return ;rcu_read_lock ();
@@ -559,7 +564,6 @@ static void blkcg_iolatency_done_bio(stru64 window_start;u64 now =ktime_to_ns (ktime_get ());bool issue_as_root =bio_issue_as_root_blkg (bio); -bool enabled = false;int inflight =0 ; blkg = bio->bi_blkg;
@@ -570,8 +574,7 @@ static void blkcg_iolatency_done_bio(strif (!iolat)return ; - enabled =blk_iolatency_enabled (iolat->blkiolat); -if (!enabled) +if (!iolat->blkiolat->enabled)return ;while (blkg && blkg->parent) {
@@ -609,6 +612,7 @@ static void blkcg_iolatency_exit(structstruct blk_iolatency *blkiolat =BLKIOLATENCY (rqos);del_timer_sync (&blkiolat->timer); +flush_work (&blkiolat->enable_work);blkcg_deactivate_policy (rqos->q, &blkcg_policy_iolatency);kfree (blkiolat); }
@@ -680,6 +684,44 @@ next:rcu_read_unlock (); } +/** +* blkiolatency_enable_work_fn - Enable or disable iolatency on the device +* @work: enable_work of the blk_iolatency of interest +* +* iolatency needs to keep track of the number of in-flight IOs per cgroup. This +* is relatively expensive as it involves walking up the hierarchy twice for +* every IO. Thus, if iolatency is not enabled in any cgroup for the device, we +* want to disable the in-flight tracking. +* +* We have to make sure that the counting is balanced - we don't want to leak +* the in-flight counts by disabling accounting in the completion path while IOs +* are in flight. This is achieved by ensuring that no IO is in flight by +* freezing the queue while flipping ->enabled. As this requires a sleepable +* context, ->enabled flipping is punted to this work function. +*/ +static void blkiolatency_enable_work_fn (struct work_struct *work) +{ + struct blk_iolatency *blkiolat = container_of(work, struct blk_iolatency, + enable_work); +bool enabled; + +/* +* There can only be one instance of this function running for @blkiolat +* and it's guaranteed to be executed at least once after the latest +* ->enabled_cnt modification. Acting on the latest ->enable_cnt is +* sufficient. +* +* Also, we know @blkiolat is safe to access as ->enable_work is flushed +* in blkcg_iolatency_exit(). +*/ + enabled =atomic_read (&blkiolat->enable_cnt); +if (enabled != blkiolat->enabled) { +blk_mq_freeze_queue (blkiolat->rqos.q); + blkiolat->enabled = enabled; +blk_mq_unfreeze_queue (blkiolat->rqos.q); + } +} +int blk_iolatency_init (struct request_queue *q) {struct blk_iolatency *blkiolat;
@@ -705,17 +747,15 @@ int blk_iolatency_init(struct request_qu }timer_setup (&blkiolat->timer, blkiolatency_timer_fn,0 ); +INIT_WORK (&blkiolat->enable_work, blkiolatency_enable_work_fn);return 0 ; } -/* -* return 1 for enabling iolatency, return -1 for disabling iolatency, otherwise -* return 0. -*/ -static int iolatency_set_min_lat_nsec (struct blkcg_gq *blkg,u64 val) +static void iolatency_set_min_lat_nsec (struct blkcg_gq *blkg,u64 val) {struct iolatency_grp *iolat =blkg_to_lat (blkg); +struct blk_iolatency *blkiolat = iolat->blkiolat;u64 oldval = iolat->min_lat_nsec; iolat->min_lat_nsec = val;
@@ -723,13 +763,15 @@ static int iolatency_set_min_lat_nsec(st iolat->cur_win_nsec =min_t (u64, iolat->cur_win_nsec,BLKIOLATENCY_MAX_WIN_SIZE ); -if (!oldval && val) -return 1 ; +if (!oldval && val) { +if (atomic_inc_return (&blkiolat->enable_cnt) ==1 ) +schedule_work (&blkiolat->enable_work); + }if (oldval && !val) {blkcg_clear_delay (blkg); -return -1 ; +if (atomic_dec_return (&blkiolat->enable_cnt) ==0 ) +schedule_work (&blkiolat->enable_work); } -return 0 ; }static void iolatency_clear_scaling (struct blkcg_gq *blkg)
@@ -762,7 +804,6 @@ static ssize_t iolatency_set_limit(strucu64 lat_val =0 ;u64 oldval;int ret; -int enable =0 ; ret =blkg_conf_prep (blkcg, &blkcg_policy_iolatency, buf, &ctx);if (ret)
@@ -798,41 +839,12 @@ static ssize_t iolatency_set_limit(struc blkg = ctx.blkg; oldval = iolat->min_lat_nsec; - enable =iolatency_set_min_lat_nsec (blkg, lat_val); -if (enable) { -if (!blk_get_queue (blkg->q)) { - ret = -ENODEV ; - goto out; - } - -blkg_get (blkg); - } - -if (oldval != iolat->min_lat_nsec) { +iolatency_set_min_lat_nsec (blkg, lat_val); +if (oldval != iolat->min_lat_nsec)iolatency_clear_scaling (blkg); - } - ret =0 ; out:blkg_conf_finish (&ctx); -if (ret ==0 && enable) { -struct iolatency_grp *tmp =blkg_to_lat (blkg); -struct blk_iolatency *blkiolat = tmp->blkiolat; - -blk_mq_freeze_queue (blkg->q); - -if (enable ==1 ) -atomic_inc (&blkiolat->enabled); -else if (enable ==-1 ) -atomic_dec (&blkiolat->enabled); -else -WARN_ON_ONCE (1 ); - -blk_mq_unfreeze_queue (blkg->q); - -blkg_put (blkg); -blk_put_queue (blkg->q); - }return ret ?: nbytes; }
@@ -932,14 +944,8 @@ static void iolatency_pd_offline(struct {struct iolatency_grp *iolat =pd_to_lat (pd);struct blkcg_gq *blkg =lat_to_blkg (iolat); -struct blk_iolatency *blkiolat = iolat->blkiolat; -int ret; - ret =iolatency_set_min_lat_nsec (blkg,0 ); -if (ret ==1 ) -atomic_inc (&blkiolat->enabled); -if (ret ==-1 ) -atomic_dec (&blkiolat->enabled); +iolatency_set_min_lat_nsec (blkg,0 );iolatency_clear_scaling (blkg); }
Greg Kroah-Hartman
maintainerPATCH 185/287 phy: qcom-qmp: fix reset-controller leak on probe errors
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 4d2900f20edfe541f75756a00deeb2ffe7c66bc1 upstream.
Make sure to release the lane reset controller in case of a late probe error (e.g. probe deferral).
Note that due to the reset controller being defined in devicetree in "lane" child nodes, devm_reset_control_get_exclusive() cannot be used directly.
--- drivers/phy/qualcomm/phy-qcom-qmp.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/phy/qualcomm/phy-qcom-qmp.c +9 -0
@@ -1426,6 +1426,11 @@ static const struct phy_ops qcom_qmp_phy .owner = THIS_MODULE, }; +static void qcom_qmp_reset_control_put (void *data) +{ +reset_control_put (data); +} +static int qcom_qmp_phy_create (struct device *dev,struct device_node *np,int id) {
@@ -1490,6 +1495,10 @@ int qcom_qmp_phy_create(struct device *ddev_err (dev,"failed to get lane%d reset\n" , id);return PTR_ERR (qphy->lane_rst); } + ret =devm_add_action_or_reset (dev, qcom_qmp_reset_control_put, + qphy->lane_rst); +if (ret) +return ret; } generic_phy =devm_phy_create (dev, np, &qcom_qmp_phy_gen_ops);
Greg Kroah-Hartman
maintainerPATCH 186/287 RDMA/rxe: Generate a completion for unsupported/invalid opcode
In reply to Greg Kroah-HartmanFrom: Xiao Yang <[email protected]>
commit 2f917af777011c88e977b9b9a5d00b280d3a59ce upstream.
Current rxe_requester() doesn't generate a completion when processing an unsupported/invalid opcode. If rxe driver doesn't support a new opcode (e.g. RDMA Atomic Write) and RDMA library supports it, an application using the new opcode can reproduce this issue. Fix the issue by calling "goto err;".
--- drivers/infiniband/sw/rxe/rxe_req.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_req.c +1 -1
@@ -680,7 +680,7 @@ next_wqe: opcode =next_opcode (qp, wqe, wqe->wr.opcode);if (unlikely (opcode <0 )) { wqe->status =IB_WC_LOC_QP_OP_ERR ; - goto exit; + goto err; } mask = rxe_opcode[opcode].mask;
Greg Kroah-Hartman
maintainerPATCH 187/287 MIPS: IP27: Remove incorrect `cpu_has_fpu override
In reply to Greg Kroah-HartmanFrom: Maciej W. Rozycki <[email protected]>
commit 424c3781dd1cb401857585331eaaa425a13f2429 upstream.
Remove unsupported forcing of cpu_has_fpu' to 1, which makes the nofpu' kernel parameter non-functional, and also causes a link error:
ld: arch/mips/kernel/traps.o: in function `trap_init':
./arch/mips/include/asm/msa.h:(.init.text+0x348): undefined reference to `handle_fpe'
ld: ./arch/mips/include/asm/msa.h:(.init.text+0x354): undefined reference to `handle_fpe'
ld: ./arch/mips/include/asm/msa.h:(.init.text+0x360): undefined reference to `handle_fpe'
where the CONFIG_MIPS_FP_SUPPORT configuration option has been disabled.
--- arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h | 1 - 1 file changed, 1 deletion(-)
arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h +0 -1
@@ -28,7 +28,6 @@#define cpu_has_6k_cache 0#define cpu_has_8k_cache 0#define cpu_has_tx39_cache 0 -#define cpu_has_fpu 1#define cpu_has_nofpuex 0#define cpu_has_32fpr 1#define cpu_has_counter 1
Greg Kroah-Hartman
maintainerPATCH 188/287 md: bcache: check the return value of kzalloc() in detached_dev_do_request()
In reply to Greg Kroah-HartmanFrom: Jia-Ju Bai <[email protected]>
commit 40f567bbb3b0639d2ec7d1c6ad4b1b018f80cf19 upstream.
The function kzalloc() in detached_dev_do_request() can fail, so its return value should be checked.
--- drivers/md/bcache/request.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/md/bcache/request.c +6 -0
@@ -1102,6 +1102,12 @@ static void detached_dev_do_request(stru* which would call closure_get(&dc->disk.cl) */ ddip =kzalloc (sizeof (struct detached_dev_io_private ),GFP_NOIO ); +if (!ddip) { + bio->bi_status =BLK_STS_RESOURCE ; + bio->bi_end_io (bio); +return ; + } + ddip->d = d; ddip->start_time = jiffies; ddip->bi_end_io = bio->bi_end_io;
Greg Kroah-Hartman
maintainerPATCH 189/287 pcmcia: db1xxx_ss: restrict to MIPS_DB1XXX boards
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 3928cf08334ed895a31458cbebd8d4ec6d84c080 ]
When the MIPS_ALCHEMY board selection is MIPS_XXS1500 instead of MIPS_DB1XXX, the PCMCIA driver 'db1xxx_ss' has build errors due to missing DB1XXX symbols. The PCMCIA driver should be restricted to MIPS_DB1XXX instead of MIPS_ALCHEMY to fix this build error.
ERROR: modpost: "bcsr_read" [drivers/pcmcia/db1xxx_ss.ko] undefined!
ERROR: modpost: "bcsr_mod" [drivers/pcmcia/db1xxx_ss.ko] undefined!
--- drivers/pcmcia/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pcmcia/Kconfig +1 -1
@@ -146,7 +146,7 @@ config TCIC config PCMCIA_ALCHEMY_DEVBOARD tristate "Alchemy Db/Pb1xxx PCMCIA socket services" - depends on MIPS_ALCHEMY && PCMCIA + depends on MIPS_DB1XXX && PCMCIA help Enable this driver of you want PCMCIA support on your Alchemy Db1000, Db/Pb1100, Db/Pb1500, Db/Pb1550, Db/Pb1200, DB1300
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 190/287 staging: greybus: codecs: fix type confusion of list iterator variable
In reply to Greg Kroah-HartmanFrom: Jakob Koschel <[email protected]>
[ Upstream commit 84ef256550196bc06e6849a34224c998b45bd557 ]
If the list does not exit early then data == NULL and 'module' does not point to a valid list element.
Using 'module' in such a case is not valid and was therefore removed.
--- drivers/staging/greybus/audio_codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/audio_codec.c +2 -2
@@ -620,8 +620,8 @@ static int gbcodec_mute_stream(struct snd_soc_dai *dai, int mute, int stream)break ; }if (!data) { -dev_err (dai->dev,"%s:%s DATA connection missing\n" , - dai->name, module->name); +dev_err (dai->dev,"%s DATA connection missing\n" , + dai->name);mutex_unlock (&codec->lock);return -ENODEV ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 191/287 tty: goldfish: Use tty_port_destroy() to destroy port
In reply to Greg Kroah-HartmanFrom: Wang Weiyang <[email protected]>
[ Upstream commit 507b05063d1b7a1fcb9f7d7c47586fc4f3508f98 ]
In goldfish_tty_probe(), the port initialized through tty_port_init() should be destroyed in error paths.In goldfish_tty_remove(), qtty->port also should be destroyed or else might leak resources.
Fix the above by calling tty_port_destroy().
--- drivers/tty/goldfish.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/goldfish.c +2 -0
@@ -407,6 +407,7 @@ static int goldfish_tty_probe(struct platform_device *pdev) err_tty_register_device_failed:free_irq (irq, qtty); err_dec_line_count: +tty_port_destroy (&qtty->port); goldfish_tty_current_line_count--;if (goldfish_tty_current_line_count ==0 )goldfish_tty_delete_driver ();
@@ -428,6 +429,7 @@ static int goldfish_tty_remove(struct platform_device *pdev)iounmap (qtty->base); qtty->base =NULL ;free_irq (qtty->irq, pdev); +tty_port_destroy (&qtty->port); goldfish_tty_current_line_count--;if (goldfish_tty_current_line_count ==0 )goldfish_tty_delete_driver ();
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 192/287 usb: usbip: fix a refcount leak in stub_probe()
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
[ Upstream commit 9ec4cbf1cc55d126759051acfe328d489c5d6e60 ]
usb_get_dev() is called in stub_device_alloc(). When stub_probe() fails after that, usb_put_dev() needs to be called to release the reference.
Fix this by moving usb_put_dev() to sdev_free error path handling.
Find this by code review.
--- drivers/usb/usbip/stub_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/usbip/stub_dev.c +1 -1
@@ -427,7 +427,6 @@ static int stub_probe(struct usb_device *udev) (struct usb_dev_state *) udev); err_port:dev_set_drvdata (&udev->dev,NULL ); -usb_put_dev (udev);/* we already have busid_priv, just lock busid_lock */ spin_lock (&busid_priv->busid_lock);
@@ -442,6 +441,7 @@ static int stub_probe(struct usb_device *udev)put_busid_priv (busid_priv); sdev_free: +usb_put_dev (udev);stub_device_free (sdev);return rc;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 193/287 usb: usbip: add missing device lock on tweak configuration cmd
In reply to Greg Kroah-HartmanFrom: Niels Dossche <[email protected]>
[ Upstream commit d088fabace2ca337b275d1d4b36db4fe7771e44f ]
The function documentation of usb_set_configuration says that its callers should hold the device lock. This lock is held for all callsites except tweak_set_configuration_cmd. The code path can be executed for example when attaching a remote USB device. The solution is to surround the call by the device lock.
This bug was found using my experimental own-developed static analysis tool, which reported the missing lock on v5.17.2. I manually verified this bug report by doing code review as well. I runtime checked that the required lock is not held. I compiled and runtime tested this on x86_64 with a USB mouse. After applying this patch, my analyser no longer reports this potential bug.
--- drivers/usb/usbip/stub_rx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/usbip/stub_rx.c +2 -0
@@ -138,7 +138,9 @@ static int tweak_set_configuration_cmd(struct urb *urb) req = (struct usb_ctrlrequest *) urb->setup_packet; config =le16_to_cpu (req->wValue); +usb_lock_device (sdev->udev); err =usb_set_configuration (sdev->udev, config); +usb_unlock_device (sdev->udev);if (err && err != -ENODEV )dev_err (&sdev->udev->dev,"can't set config #%d, error %d\n" , config, err);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 194/287 USB: storage: karma: fix rio_karma_init return
In reply to Greg Kroah-HartmanFrom: Lin Ma <[email protected]>
[ Upstream commit b92ffb1eddd9a66a90defc556dcbf65a43c196c7 ]
The function rio_karam_init() should return -ENOMEM instead of value 0 (USB_STOR_TRANSPORT_GOOD) when allocation fails.
Similarly, it should return -EIO when rio_karma_send_command() fails.
--- drivers/usb/storage/karma.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/usb/storage/karma.c +8 -7
@@ -172,23 +172,24 @@ static void rio_karma_destructor(void *extra)static int rio_karma_init (struct us_data *us) { -int ret =0 ;struct karma_data *data =kzalloc (sizeof (struct karma_data ),GFP_NOIO );if (!data) - goto out; +return -ENOMEM ; data->recv =kmalloc (RIO_RECV_LEN ,GFP_NOIO );if (!data->recv) {kfree (data); - goto out; +return -ENOMEM ; } us->extra = data; us->extra_destructor = rio_karma_destructor; - ret =rio_karma_send_command (RIO_ENTER_STORAGE , us); - data->in_storage = (ret ==0 ); -out: -return ret; +if (rio_karma_send_command (RIO_ENTER_STORAGE , us)) +return -EIO ; + + data->in_storage =1 ; + +return 0 ; }static struct scsi_host_template karma_host_template;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 195/287 usb: musb: Fix missing of_node_put() in omap2430_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 424bef51fa530389b0b9008c9e144e40c10e8458 ]
The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done.
--- drivers/usb/musb/omap2430.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/musb/omap2430.c +1 -0
@@ -433,6 +433,7 @@ static int omap2430_probe(struct platform_device *pdev) control_node =of_parse_phandle (np,"ctrl-module" ,0 );if (control_node) { control_pdev =of_find_device_by_node (control_node); +of_node_put (control_node);if (!control_pdev) {dev_err (&pdev->dev,"Failed to get control device\n" ); ret = -EINVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 196/287 pwm: lp3943: Fix duty calculation in case period was clamped
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 5e3b07ca5cc78cd4a987e78446849e41288d87cb ]
The hardware only supports periods <= 1.6 ms and if a bigger period is requested it is clamped to 1.6 ms. In this case duty_cycle might be bigger than 1.6 ms and then the duty cycle register is written with a value bigger than LP3943_MAX_DUTY. So clamp duty_cycle accordingly.
--- drivers/pwm/pwm-lp3943.c | 1 + 1 file changed, 1 insertion(+)
drivers/pwm/pwm-lp3943.c +1 -0
@@ -128,6 +128,7 @@ static int lp3943_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,if (err)return err; + duty_ns =min (duty_ns, period_ns); val = (u8)(duty_ns *LP3943_MAX_DUTY / period_ns);return lp3943_write_byte (lp3943, reg_duty, val);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 197/287 rpmsg: qcom_smd: Fix irq_of_parse_and_map() return value
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 1a358d35066487d228a68303d808bc4721c6b1b9 ]
The irq_of_parse_and_map() returns 0 on failure, not a negative ERRNO.
--- drivers/rpmsg/qcom_smd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/qcom_smd.c +1 -1
@@ -1388,7 +1388,7 @@ static int qcom_smd_parse_edge(struct device *dev, edge->name = node->name; irq =irq_of_parse_and_map (node,0 ); -if (irq <0 ) { +if (!irq) {dev_err (dev,"required smd interrupt missing\n" ); ret = irq; goto put_node;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 198/287 usb: dwc3: pci: Fix pm_runtime_get_sync() error checking
In reply to Greg Kroah-HartmanFrom: Zheng Yongjun <[email protected]>
[ Upstream commit a03e2ddab8e735e2cc315609b297b300e9cc60d2 ]
If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1, so a test for negative value should be used to check for errors.
--- drivers/usb/dwc3/dwc3-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-pci.c +1 -1
@@ -205,7 +205,7 @@ static void dwc3_pci_resume_work(struct work_struct *work)int ret; ret =pm_runtime_get_sync (&dwc3->dev); -if (ret) { +if (ret <0 ) {pm_runtime_put_sync_autosuspend (&dwc3->dev);return ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 199/287 iio: adc: sc27xx: fix read big scale voltage not right
In reply to Greg Kroah-HartmanFrom: Cixi Geng <[email protected]>
[ Upstream commit ad930a75613282400179361e220e58b87386b8c7 ]
Fix wrong configuration value of SC27XX_ADC_SCALE_MASK and SC27XX_ADC_SCALE_SHIFT by spec documetation.
--- drivers/iio/adc/sc27xx_adc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/sc27xx_adc.c +2 -2
@@ -35,8 +35,8 @@/* Bits and mask definition for SC27XX_ADC_CH_CFG register */ #define SC27XX_ADC_CHN_ID_MASK GENMASK(4, 0) -#define SC27XX_ADC_SCALE_MASK GENMASK(10, 8) -#define SC27XX_ADC_SCALE_SHIFT 8 +#define SC27XX_ADC_SCALE_MASK GENMASK(10, 9) +#define SC27XX_ADC_SCALE_SHIFT 9/* Bits definitions for SC27XX_ADC_INT_EN registers */ #define SC27XX_ADC_IRQ_EN BIT(0)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 200/287 rpmsg: qcom_smd: Fix returning 0 if irq_of_parse_and_map() fails
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 59d6f72f6f9c92fec8757d9e29527da828e9281f ]
irq_of_parse_and_map() returns 0 on failure, so this should not be passed further as error return code.
--- drivers/rpmsg/qcom_smd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/qcom_smd.c +1 -1
@@ -1390,7 +1390,7 @@ static int qcom_smd_parse_edge(struct device *dev, irq =irq_of_parse_and_map (node,0 );if (!irq) {dev_err (dev,"required smd interrupt missing\n" ); - ret = irq; + ret = -EINVAL ; goto put_node; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 201/287 coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier
In reply to Greg Kroah-HartmanFrom: Guilherme G. Piccoli <[email protected]>
[ Upstream commit 1adff542d67a2ed1120955cb219bfff8a9c53f59 ]
The panic notifier infrastructure executes registered callbacks when a panic event happens - such callbacks are executed in atomic context, with interrupts and preemption disabled in the running CPU and all other CPUs disabled. That said, mutexes in such context are not a good idea.
This patch replaces a regular mutex with a mutex_trylock safer approach; given the nature of the mutex used in the driver, it should be pretty uncommon being unable to acquire such mutex in the panic path, hence no functional change should be observed (and if it is, that would be likely a deadlock with the regular mutex).
--- drivers/hwtracing/coresight/coresight-cpu-debug.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-cpu-debug.c +4 -3
@@ -379,9 +379,10 @@ static int debug_notifier_call(struct notifier_block *self,int cpu;struct debug_drvdata *drvdata; -mutex_lock (&debug_lock); +/* Bail out if we can't acquire the mutex or the functionality is off */ +if (!mutex_trylock (&debug_lock)) +return NOTIFY_DONE ; -/* Bail out if the functionality is disabled */ if (!debug_enable) goto skip_dump;
@@ -400,7 +401,7 @@ static int debug_notifier_call(struct notifier_block *self, skip_dump:mutex_unlock (&debug_lock); -return 0 ; +return NOTIFY_DONE ; }static struct notifier_block debug_notifier = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 202/287 soc: rockchip: Fix refcount leak in rockchip_grf_init
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 9b59588d8be91c96bfb0371e912ceb4f16315dbf ]
of_find_matching_node_and_match returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.
--- drivers/soc/rockchip/grf.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soc/rockchip/grf.c +2 -0
@@ -151,12 +151,14 @@ static int __init rockchip_grf_init(void)return -ENODEV ;if (!match || !match->data) {pr_err ("%s: missing grf data\n" , __func__); +of_node_put (np);return -EINVAL ; } grf_info = match->data; grf =syscon_node_to_regmap (np); +of_node_put (np);if (IS_ERR (grf)) {pr_err ("%s: could not get grf syscon\n" , __func__);return PTR_ERR (grf);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 203/287 clocksource/drivers/riscv: Events are stopped during CPU suspend
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
[ Upstream commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d ]
Some implementations of the SBI time extension depend on hart-local state (for example, CSRs) that are lost or hardware that is powered down when a CPU is suspended. To be safe, the clockevents driver cannot assume that timer IRQs will be received during CPU suspend.
--- drivers/clocksource/riscv_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/riscv_timer.c +1 -1
@@ -33,7 +33,7 @@ static int riscv_clock_next_event(unsigned long delta, static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { .name ="riscv_timer_clockevent" , - .features =CLOCK_EVT_FEAT_ONESHOT , + .features =CLOCK_EVT_FEAT_ONESHOT |CLOCK_EVT_FEAT_C3STOP , .rating =100 , .set_next_event = riscv_clock_next_event, };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 204/287 rtc: mt6397: check return value after calling platform_get_resource()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit d3b43eb505bffb8e4cdf6800c15660c001553fe6 ]
It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value.
--- drivers/rtc/rtc-mt6397.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/rtc/rtc-mt6397.c +2 -0
@@ -339,6 +339,8 @@ static int mtk_rtc_probe(struct platform_device *pdev)return -ENOMEM ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -EINVAL ; rtc->addr_base = res->start; rtc->irq =platform_get_irq (pdev,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 205/287 serial: meson: acquire port->lock in startup()
In reply to Greg Kroah-HartmanFrom: John Ogness <[email protected]>
[ Upstream commit 589f892ac8ef244e47c5a00ffd8605daa1eaef8e ]
The uart_ops startup() callback is called without interrupts disabled and without port->lock locked, relatively late during the boot process (from the call path of console_on_rootfs()). If the device is a console, it was already previously registered and could be actively printing messages.
Since the startup() callback is reading/writing registers used by the console write() callback (AML_UART_CONTROL), its access must be synchronized using the port->lock. Currently it is not.
The startup() callback is the only function that explicitly enables interrupts. Without the synchronization, it is possible that interrupts become accidentally permanently disabled.
CPU0 CPU1 meson_serial_console_write meson_uart_startup -------------------------- ------------------
spin_lock(port->lock)
val = readl(AML_UART_CONTROL)uart_console_write()
writel(INT_EN, AML_UART_CONTROL)writel(val, AML_UART_CONTROL)spin_unlock(port->lock)
Add port->lock synchronization to meson_uart_startup() to avoid racing with meson_serial_console_write().
Also add detailed comments to meson_uart_reset() explaining why it is *not* using port->lock synchronization.
--- drivers/tty/serial/meson_uart.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/tty/serial/meson_uart.c +13 -0
@@ -255,6 +255,14 @@ static const char *meson_uart_type(struct uart_port *port)return (port->type ==PORT_MESON ) ?"meson_uart" :NULL ; } +/* +* This function is called only from probe() using a temporary io mapping +* in order to perform a reset before setting up the device. Since the +* temporarily mapped region was successfully requested, there can be no +* console on this port at this time. Hence it is not necessary for this +* function to acquire the port->lock. (Since there is no console on this +* port at this time, the port->lock is not initialized yet.) +*/ static void meson_uart_reset (struct uart_port *port) {u32 val;
@@ -269,9 +277,12 @@ static void meson_uart_reset(struct uart_port *port)static int meson_uart_startup (struct uart_port *port) { +unsigned long flags;u32 val;int ret =0 ; +spin_lock_irqsave (&port->lock, flags); + val =readl (port->membase +AML_UART_CONTROL ); val |=AML_UART_CLEAR_ERR ;writel (val, port->membase +AML_UART_CONTROL );
@@ -287,6 +298,8 @@ static int meson_uart_startup(struct uart_port *port) val = (AML_UART_RECV_IRQ (1 ) |AML_UART_XMIT_IRQ (port->fifosize /2 ));writel (val, port->membase +AML_UART_MISC ); +spin_unlock_irqrestore (&port->lock, flags); + ret =request_irq (port->irq, meson_uart_interrupt,0 , port->name, port);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 206/287 serial: 8250_fintek: Check SER_RS485_RTS_* only with RS485
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit af0179270977508df6986b51242825d7edd59caf ]
SER_RS485_RTS_ON_SEND and SER_RS485_RTS_AFTER_SEND relate to behavior within RS485 operation. The driver checks if they have the same value which is not possible to realize with the hardware. The check is taken regardless of SER_RS485_ENABLED flag and -EINVAL is returned when the check fails, which creates problems.
This check makes it unnecessarily complicated to turn RS485 mode off as simple zeroed serial_rs485 struct will trigger that equal values check. In addition, the driver itself memsets its rs485 structure to zero when RS485 is disabled but if userspace would try to make an TIOCSRS485 ioctl() call with the very same struct, it would end up failing with -EINVAL which doesn't make much sense.
Resolve the problem by moving the check inside SER_RS485_ENABLED block.
--- drivers/tty/serial/8250/8250_fintek.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_fintek.c +4 -4
@@ -197,12 +197,12 @@ static int fintek_8250_rs485_config(struct uart_port *port,if (!pdata)return -EINVAL ; -/* Hardware do not support same RTS level on send and receive */ -if (!(rs485->flags &SER_RS485_RTS_ON_SEND ) == - !(rs485->flags &SER_RS485_RTS_AFTER_SEND )) -return -EINVAL ;if (rs485->flags &SER_RS485_ENABLED ) { +/* Hardware do not support same RTS level on send and receive */ +if (!(rs485->flags &SER_RS485_RTS_ON_SEND ) == + !(rs485->flags &SER_RS485_RTS_AFTER_SEND )) +return -EINVAL ;memset (rs485->padding,0 ,sizeof (rs485->padding)); config |=RS485_URA ; }else {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 207/287 serial: digicolor-usart: Dont allow CS5-6
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit fd63031b8c0763addcecdefe0e0c59d49646204e ]
Only CS7 and CS8 seem supported but CSIZE is not sanitized to CS8 in the default: block.
Set CSIZE correctly so that userspace knows the effective value. Incorrect CSIZE also results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout().
--- drivers/tty/serial/digicolor-usart.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/digicolor-usart.c +2 -0
@@ -309,6 +309,8 @@ static void digicolor_uart_set_termios(struct uart_port *port,case CS8 :default : config |=UA_CONFIG_CHAR_LEN ; + termios->c_cflag &= ~CSIZE ; + termios->c_cflag |=CS8 ;break ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 208/287 serial: txx9: Dont allow CS5-6
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit 79ac88655dc0551e3571ad16bdabdbe65d61553e ]
Only CS7 and CS8 are supported but CSIZE is not sanitized with CS5 or CS6 to CS8.
Set CSIZE correctly so that userspace knows the effective value. Incorrect CSIZE also results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout().
--- drivers/tty/serial/serial_txx9.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/serial_txx9.c +2 -0
@@ -649,6 +649,8 @@ serial_txx9_set_termios(struct uart_port *port, struct ktermios *termios,case CS6 :/* not supported */ case CS8 : cval |=TXX9_SILCR_UMODE_8BIT ; + termios->c_cflag &= ~CSIZE ; + termios->c_cflag |=CS8 ;break ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 209/287 serial: sh-sci: Dont allow CS5-6
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit 9b87162de8be26bf3156460b37deee6399fd0fcb ]
Only CS7 and CS8 seem supported but CSIZE is not sanitized from CS5 or CS6 to CS8.
Set CSIZE correctly so that userspace knows the effective value. Incorrect CSIZE also results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout().
--- drivers/tty/serial/sh-sci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/tty/serial/sh-sci.c +5 -1
@@ -2382,8 +2382,12 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,int best_clk =-1 ;unsigned long flags; -if ((termios->c_cflag &CSIZE ) ==CS7 ) +if ((termios->c_cflag &CSIZE ) ==CS7 ) { smr_val |=SCSMR_CHR ; + }else { + termios->c_cflag &= ~CSIZE ; + termios->c_cflag |=CS8 ; + }if (termios->c_cflag &PARENB ) smr_val |=SCSMR_PE ;if (termios->c_cflag &PARODD )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 210/287 serial: st-asc: Sanitize CSIZE and correct PARENB for CS7
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit 52bb1cb7118564166b04d52387bd8403632f5190 ]
Only CS7 and CS8 seem supported but CSIZE is not sanitized from CS5 or CS6 to CS8. In addition, ASC_CTL_MODE_7BIT_PAR suggests that CS7 has to have parity, thus add PARENB.
Incorrect CSIZE results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout().
--- drivers/tty/serial/st-asc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/st-asc.c +4 -0
@@ -540,10 +540,14 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios,/* set character length */ if ((cflag &CSIZE ) ==CS7 ) { ctrl_val |=ASC_CTL_MODE_7BIT_PAR ; + cflag |=PARENB ; }else { ctrl_val |= (cflag &PARENB ) ?ASC_CTL_MODE_8BIT_PAR :ASC_CTL_MODE_8BIT ; + cflag &= ~CSIZE ; + cflag |=CS8 ; } + termios->c_cflag = cflag;/* set stop bit */ ctrl_val |= (cflag &CSTOPB ) ?ASC_CTL_STOP_2BIT :ASC_CTL_STOP_1BIT ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 211/287 serial: stm32-usart: Correct CSIZE, bits, and parity
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit 1deeda8d2877c18bc2b9eeee10dd6d2628852848 ]
Add CSIZE sanitization for unsupported CSIZE configurations. In addition, if parity is asked for but CSx was unsupported, the sensible result is CS8+parity which requires setting USART_CR1_M0 like with 9 bits.
Incorrect CSIZE results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout().
--- drivers/tty/serial/stm32-usart.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/tty/serial/stm32-usart.c +12 -3
@@ -688,13 +688,22 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios,* CS8 or (CS7 + parity), 8 bits word aka [M1:M0] = 0b00 * M0 and M1 already cleared by cr1 initialization. */ -if (bits ==9 ) +if (bits ==9 ) { cr1 |=USART_CR1_M0 ; -else if ((bits ==7 ) && cfg->has_7bits_data) + }else if ((bits ==7 ) && cfg->has_7bits_data) { cr1 |=USART_CR1_M1 ; -else if (bits !=8 ) + }else if (bits !=8 ) {dev_dbg (port->dev,"Unsupported data bits config: %u bits\n" , bits); + cflag &= ~CSIZE ; + cflag |=CS8 ; + termios->c_cflag = cflag; + bits =8 ; +if (cflag &PARENB ) { + bits++; + cr1 |=USART_CR1_M0 ; + } + }if (cflag &PARODD ) cr1 |=USART_CR1_PS ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 212/287 firmware: dmi-sysfs: Fix memory leak in dmi_sysfs_register_handle
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 660ba678f9998aca6db74f2dd912fa5124f0fa31 ]
kobject_init_and_add() takes reference even when it fails. According to the doc of kobject_init_and_add()
If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object.
Fix this issue by calling kobject_put().
--- drivers/firmware/dmi-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/dmi-sysfs.c +1 -1
@@ -602,7 +602,7 @@ static void __init dmi_sysfs_register_handle(const struct dmi_header *dh, "%d-%d", dh->type, entry->instance);if (*ret) { -kfree (entry); +kobject_put (&entry->kobj);return ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 213/287 bus: ti-sysc: Fix warnings for unbind for serial
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit c337125b8834f9719dfda0e40b25eaa266f1b8cf ]
We can get "failed to disable" clock_unprepare warnings on unbind at least for the serial console device if the unbind is done before the device has been idled.
As some devices are using deferred idle, we must check the status for pending idle work to idle the device.
--- drivers/bus/ti-sysc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bus/ti-sysc.c +3 -1
@@ -1801,7 +1801,9 @@ static int sysc_remove(struct platform_device *pdev)struct sysc *ddata =platform_get_drvdata (pdev);int error; -cancel_delayed_work_sync (&ddata->idle_work); +/* Device can still be enabled, see deferred idle quirk in probe */ +if (cancel_delayed_work_sync (&ddata->idle_work)) +ti_sysc_idle (&ddata->idle_work.work); error =pm_runtime_get_sync (ddata->dev);if (error <0 ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 214/287 clocksource/drivers/oxnas-rps: Fix irq_of_parse_and_map() return value
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 9c04a8ff03def4df3f81219ffbe1ec9b44ff5348 ]
The irq_of_parse_and_map() returns 0 on failure, not a negative ERRNO.
--- drivers/clocksource/timer-oxnas-rps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-oxnas-rps.c +1 -1
@@ -247,7 +247,7 @@ static int __init oxnas_rps_timer_init(struct device_node *np) } rps->irq =irq_of_parse_and_map (np,0 ); -if (rps->irq <0 ) { +if (!rps->irq) { ret = -EINVAL ; goto err_iomap; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 215/287 s390/crypto: fix scatterwalk_unmap() callers in AES-GCM
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
[ Upstream commit bd52cd5e23f134019b23f0c389db0f9a436e4576 ]
The argument of scatterwalk_unmap() is supposed to be the void* that was returned by the previous scatterwalk_map() call.
The s390 AES-GCM implementation was instead passing the pointer to the struct scatter_walk.
This doesn't actually break anything because scatterwalk_unmap() only uses its argument under CONFIG_HIGHMEM and ARCH_HAS_FLUSH_ON_KUNMAP.
--- arch/s390/crypto/aes_s390.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/crypto/aes_s390.c +2 -2
@@ -861,7 +861,7 @@ static inline void _gcm_sg_unmap_and_advance(struct gcm_sg_walk *gw, unsigned int nbytes) { gw->walk_bytes_remain -= nbytes; -scatterwalk_unmap (&gw->walk); +scatterwalk_unmap (gw->walk_ptr);scatterwalk_advance (&gw->walk, nbytes);scatterwalk_done (&gw->walk,0 , gw->walk_bytes_remain); gw->walk_ptr =NULL ;
@@ -936,7 +936,7 @@ static int gcm_out_walk_go(struct gcm_sg_walk *gw, unsigned int minbytesneeded) goto out; } -scatterwalk_unmap (&gw->walk); +scatterwalk_unmap (gw->walk_ptr); gw->walk_ptr =NULL ; gw->ptr = gw->buf;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 216/287 net: ethernet: mtk_eth_soc: out of bounds read in mtk_hwlro_get_fdir_entry()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e7e7104e2d5ddf3806a28695670f21bef471f1e1 ]
The "fsp->location" variable comes from user via ethtool_get_rxnfc(). Check that it is valid to prevent an out of bounds read.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +3 -0
@@ -1575,6 +1575,9 @@ static int mtk_hwlro_get_fdir_entry(struct net_device *dev,struct ethtool_rx_flow_spec *fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; +if (fsp->location >=ARRAY_SIZE (mac->hwlro_ip)) +return -EINVAL ; +/* only tcp dst ipv4 is meaningful, others are meaningless */ fsp->flow_type =TCP_V4_FLOW ; fsp->h_u.tcp_ip4_spec.ip4dst =ntohl (mac->hwlro_ip[fsp->location]);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 217/287 net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 02ded5a173619b11728b8bf75a3fd995a2c1ff28 ]
of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when done.
mv88e6xxx_mdio_register() pass the device node to of_mdiobus_register(). We don't need the device node after it.
Add missing of_node_put() to avoid refcount leak.
--- drivers/net/dsa/mv88e6xxx/chip.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/dsa/mv88e6xxx/chip.c +1 -0
@@ -2778,6 +2778,7 @@ static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,*/ child =of_get_child_by_name (np,"mdio" ); err =mv88e6xxx_mdio_register (chip, child, false); +of_node_put (child);if (err)return err;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 218/287 modpost: fix removing numeric suffixes
In reply to Greg Kroah-HartmanFrom: Alexander Lobakin <[email protected]>
[ Upstream commit b5beffa20d83c4e15306c991ffd00de0d8628338 ]
With the -z unique-symbol linker flag or any similar mechanism, it is possible to trigger the following:
ERROR: modpost: "param_set_uint.0" [vmlinux] is a static EXPORT_SYMBOL
The reason is that for now the condition from remove_dot():
if (m && (s[n + m] == '.' || s[n + m] == 0))
which was designed to test if it's a dot or a '\0' after the suffix is never satisfied.
This is due to that s[n + m] always points to the last digit of a numeric suffix, not on the symbol next to it (from a custom debug print added to modpost):
param_set_uint.0, s[n + m] is '0', s[n + m + 1] is '\0'
So it's off-by-one and was like that since 2014.
Fix this for the sake of any potential upcoming features, but don't bother stable-backporting, as it's well hidden -- apart from that LD flag, it can be triggered only with GCC LTO which never landed upstream.
--- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
@@ -1937,7 +1937,7 @@ static char *remove_dot(char *s)if (n && s[n]) {size_t m =strspn (s + n +1 ,"0123456789" ); -if (m && (s[n + m] =='.' || s[n + m] ==0 )) +if (m && (s[n + m +1 ] =='.' || s[n + m +1 ] ==0 )) s[n] =0 ; }return s;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 219/287 jffs2: fix memory leak in jffs2_do_fill_super
In reply to Greg Kroah-HartmanFrom: Baokun Li <[email protected]>
[ Upstream commit c14adb1cf70a984ed081c67e9d27bc3caad9537c ]
If jffs2_iget() or d_make_root() in jffs2_do_fill_super() returns an error, we can observe the following kmemleak report:
--------------------------------------------
unreferenced object 0xffff888105a65340 (size 64):
comm "mount", pid 710, jiffies 4302851558 (age 58.239s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff859c45e5>] kmem_cache_alloc_trace+0x475/0x8a0
[<ffffffff86160146>] jffs2_sum_init+0x96/0x1a0
[<ffffffff86140e25>] jffs2_do_mount_fs+0x745/0x2120
[<ffffffff86149fec>] jffs2_do_fill_super+0x35c/0x810
[<ffffffff8614aae9>] jffs2_fill_super+0x2b9/0x3b0
[...]unreferenced object 0xffff8881bd7f0000 (size 65536):
comm "mount", pid 710, jiffies 4302851558 (age 58.239s) hex dump (first 32 bytes):
bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb ................ bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb ................
backtrace:
[<ffffffff858579ba>] kmalloc_order+0xda/0x110
[<ffffffff85857a11>] kmalloc_order_trace+0x21/0x130
[<ffffffff859c2ed1>] __kmalloc+0x711/0x8a0
[<ffffffff86160189>] jffs2_sum_init+0xd9/0x1a0
[<ffffffff86140e25>] jffs2_do_mount_fs+0x745/0x2120
[<ffffffff86149fec>] jffs2_do_fill_super+0x35c/0x810
[<ffffffff8614aae9>] jffs2_fill_super+0x2b9/0x3b0
[...]
--------------------------------------------This is because the resources allocated in jffs2_sum_init() are not released. Call jffs2_sum_exit() to release these resources to solve the problem.
--- fs/jffs2/fs.c | 1 + 1 file changed, 1 insertion(+)
fs/jffs2/fs.c +1 -0
@@ -598,6 +598,7 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)jffs2_free_raw_node_refs (c);kvfree (c->blocks);jffs2_clear_xattr_subsystem (c); +jffs2_sum_exit (c); out_inohash:kfree (c->inocache_list); out_wbuf:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 220/287 ubi: ubi_create_volume: Fix use-after-free when volume creation failed
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
[ Upstream commit 8c03a1c21d72210f81cb369cc528e3fde4b45411 ]
There is an use-after-free problem for 'eba_tbl' in ubi_create_volume()'s error handling path:
ubi_eba_replace_table(vol, eba_tbl)
vol->eba_tbl = tbl
out_mapping:
ubi_eba_destroy_table(eba_tbl) // Free 'eba_tbl'out_unlock:
put_device(&vol->dev)
vol_release
kfree(tbl->entries) // UAFFix it by removing redundant 'eba_tbl' releasing. Fetch a reproducer in [Link].
--- drivers/mtd/ubi/vmt.c | 1 - 1 file changed, 1 deletion(-)
drivers/mtd/ubi/vmt.c +0 -1
@@ -322,7 +322,6 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ubi->volumes[vol_id] =NULL ; ubi->vol_count -=1 ;spin_unlock (&ubi->volumes_lock); -ubi_eba_destroy_table (eba_tbl); out_acc:spin_lock (&ubi->volumes_lock); ubi->rsvd_pebs -= vol->reserved_pebs;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 221/287 nfp: only report pause frame configuration for physical device
In reply to Greg Kroah-HartmanFrom: Yu Xiao <[email protected]>
[ Upstream commit 0649e4d63420ebc8cbebef3e9d39e12ffc5eb9fa ]
Only report pause frame configuration for physical device. Logical port of both PCI PF and PCI VF do not support it.
--- drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +2 -2
@@ -292,8 +292,6 @@ nfp_net_get_link_ksettings(struct net_device *netdev,/* Init to unknowns */ ethtool_link_ksettings_add_link_mode (cmd, supported,FIBRE ); -ethtool_link_ksettings_add_link_mode (cmd, supported, Pause); -ethtool_link_ksettings_add_link_mode (cmd, advertising, Pause); cmd->base.port =PORT_OTHER ; cmd->base.speed =SPEED_UNKNOWN ; cmd->base.duplex =DUPLEX_UNKNOWN ;
@@ -301,6 +299,8 @@ nfp_net_get_link_ksettings(struct net_device *netdev, port =nfp_port_from_netdev (netdev); eth_port =nfp_port_get_eth_port (port);if (eth_port) { +ethtool_link_ksettings_add_link_mode (cmd, supported, Pause); +ethtool_link_ksettings_add_link_mode (cmd, advertising, Pause); cmd->base.autoneg = eth_port->aneg !=NFP_ANEG_DISABLED ?AUTONEG_ENABLE :AUTONEG_DISABLE ;nfp_net_set_fec_link_mode (eth_port, cmd);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 222/287 net/mlx5e: Update netdev features after changing XDP state
In reply to Greg Kroah-HartmanFrom: Maxim Mikityanskiy <[email protected]>
[ Upstream commit f6279f113ad593971999c877eb69dc3d36a75894 ]
Some features (LRO, HW GRO) conflict with XDP. If there is an attempt to enable such features while XDP is active, they will be set to off [requested on]. In order to activate these features after XDP is turned off, the driver needs to call netdev_update_features(). This commit adds this missing call after XDP state changes.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +5 -0
@@ -4327,6 +4327,11 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog) unlock:mutex_unlock (&priv->state_lock); + +/* Need to fix some features. */ +if (!err) +netdev_update_features (netdev); +return err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 223/287 tcp: tcp_rtx_synack() can be called from process context
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 0a375c822497ed6ad6b5da0792a12a6f1af10c0b ]
Laurent reported the enclosed report [1]
This bug triggers with following coditions:
0) Kernel built with CONFIG_DEBUG_PREEMPT=y
1) A new passive FastOpen TCP socket is created.
This FO socket waits for an ACK coming from client to be a complete ESTABLISHED one.
2) A socket operation on this socket goes through lock_sock() release_sock() dance.
3) While the socket is owned by the user in step 2),
a retransmit of the SYN is received and stored in socket backlog.
4) At release_sock() time, the socket backlog is processed while in process context.
5) A SYNACK packet is cooked in response of the SYN retransmit.
6) -> tcp_rtx_synack() is called in process context.
Before blamed commit, tcp_rtx_synack() was always called from BH handler, from a timer handler.
Fix this by using TCP_INC_STATS() & NET_INC_STATS() which do not assume caller is in non preemptible context.
[1]
BUG: using __this_cpu_add() in preemptible [00000000] code: epollpep/2180 caller is tcp_rtx_synack.part.0+0x36/0xc0 CPU: 10 PID: 2180 Comm: epollpep Tainted: G OE 5.16.0-0.bpo.4-amd64 #1 Debian 5.16.12-1~bpo11+1 Hardware name: Supermicro SYS-5039MC-H8TRF/X11SCD-F, BIOS 1.7 11/23/2021 Call Trace: <TASK> dump_stack_lvl+0x48/0x5e check_preemption_disabled+0xde/0xe0 tcp_rtx_synack.part.0+0x36/0xc0 tcp_rtx_synack+0x8d/0xa0 ? kmem_cache_alloc+0x2e0/0x3e0 ? apparmor_file_alloc_security+0x3b/0x1f0 inet_rtx_syn_ack+0x16/0x30 tcp_check_req+0x367/0x610 tcp_rcv_state_process+0x91/0xf60 ? get_nohz_timer_target+0x18/0x1a0 ? lock_timer_base+0x61/0x80 ? preempt_count_add+0x68/0xa0 tcp_v4_do_rcv+0xbd/0x270 __release_sock+0x6d/0xb0 release_sock+0x2b/0x90 sock_setsockopt+0x138/0x1140 ? __sys_getsockname+0x7e/0xc0 ? aa_sk_perm+0x3e/0x1a0 __sys_setsockopt+0x198/0x1e0 __x64_sys_setsockopt+0x21/0x30 do_syscall_64+0x38/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae
--- net/ipv4/tcp_output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp_output.c +2 -2
@@ -3805,8 +3805,8 @@ int tcp_rtx_synack(const struct sock *sk, struct request_sock *req)tcp_rsk (req)->txhash =net_tx_rndhash (); res = af_ops->send_synack (sk,NULL , &fl, req,NULL ,TCP_SYNACK_NORMAL );if (!res) { -__TCP_INC_STATS (sock_net (sk),TCP_MIB_RETRANSSEGS ); -__NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSYNRETRANS ); +TCP_INC_STATS (sock_net (sk),TCP_MIB_RETRANSSEGS ); +NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSYNRETRANS );if (unlikely (tcp_passive_fastopen (sk)))tcp_sk (sk)->total_retrans++;trace_tcp_retransmit_synack (sk, req);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 224/287 afs: Fix infinite loop found by xfstest generic/676
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 17eabd42560f4636648ad65ba5b20228071e2363 ]
In AFS, a directory is handled as a file that the client downloads and parses locally for the purposes of performing lookup and getdents operations. The in-kernel afs filesystem has a number of functions that do this.
A directory file is arranged as a series of 2K blocks divided into 32-byte slots, where a directory entry occupies one or more slots, plus each block starts with one or more metadata blocks.
When parsing a block, if the last slots are occupied by a dirent that occupies more than a single slot and the file position points at a slot that's not the initial one, the logic in afs_dir_iterate_block() that skips over it won't advance the file pointer to the end of it. This will cause an infinite loop in getdents() as it will keep retrying that block and failing to advance beyond the final entry.
Fix this by advancing the file pointer if the next entry will be beyond it when we skip a block.
This was found by the generic/676 xfstest but can also be triggered with something like:
~/xfstests-dev/src/t_readdir_3 /xfstest.test/z 4000 1
--- fs/afs/dir.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/afs/dir.c +4 -1
@@ -383,8 +383,11 @@ static int afs_dir_iterate_block(struct dir_context *ctx, }/* skip if starts before the current position */ -if (offset < curr) +if (offset < curr) { +if (next > curr) + ctx->pos = blkoff + next *sizeof (union afs_xdr_dirent );continue ; + }/* found the next entry */ if (!dir_emit(ctx, dire->u.name, nlen,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 225/287 tipc: check attribute length for bearer name
In reply to Greg Kroah-HartmanFrom: Hoang Le <[email protected]>
[ Upstream commit 7f36f798f89bf32c0164049cb0e3fd1af613d0bb ]
syzbot reported uninit-value:
=====================================================
BUG: KMSAN: uninit-value in string_nocheck lib/vsprintf.c:644 [inline] BUG: KMSAN: uninit-value in string+0x4f9/0x6f0 lib/vsprintf.c:725 string_nocheck lib/vsprintf.c:644 [inline] string+0x4f9/0x6f0 lib/vsprintf.c:725 vsnprintf+0x2222/0x3650 lib/vsprintf.c:2806 vprintk_store+0x537/0x2150 kernel/printk/printk.c:2158 vprintk_emit+0x28b/0xab0 kernel/printk/printk.c:2256 vprintk_default+0x86/0xa0 kernel/printk/printk.c:2283 vprintk+0x15f/0x180 kernel/printk/printk_safe.c:50 _printk+0x18d/0x1cf kernel/printk/printk.c:2293 tipc_enable_bearer net/tipc/bearer.c:371 [inline] __tipc_nl_bearer_enable+0x2022/0x22a0 net/tipc/bearer.c:1033 tipc_nl_bearer_enable+0x6c/0xb0 net/tipc/bearer.c:1042 genl_family_rcv_msg_doit net/netlink/genetlink.c:731 [inline]
- Do sanity check the attribute length for TIPC_NLA_BEARER_NAME.
- Do not use 'illegal name' in printing message.
--- net/tipc/bearer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/tipc/bearer.c +1 -2
@@ -246,9 +246,8 @@ static int tipc_enable_bearer(struct net *net, const char *name,u32 i;if (!bearer_name_validate (name, &b_names)) { - errstr ="illegal name" ;NL_SET_ERR_MSG (extack,"Illegal name" ); - goto rejected; +return res; }if (prio >TIPC_MAX_LINK_PRI && prio !=TIPC_MEDIA_LINK_PRI ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 226/287 perf c2c: Fix sorting in percent_rmt_hitm_cmp()
In reply to Greg Kroah-HartmanFrom: Leo Yan <[email protected]>
[ Upstream commit b24192a17337abbf3f44aaa75e15df14a2d0016e ]
The function percent_rmt_hitm_cmp() wrongly uses local HITMs for sorting remote HITMs.
Since this function is to sort cache lines for remote HITMs, this patch changes to use 'rmt_hitm' field for correct sorting.
--- tools/perf/builtin-c2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-c2c.c +2 -2
@@ -944,8 +944,8 @@ percent_rmt_hitm_cmp(struct perf_hpp_fmt *fmt __maybe_unused,double per_left;double per_right; - per_left =PERCENT (left, lcl_hitm); - per_right =PERCENT (right, lcl_hitm); + per_left =PERCENT (left, rmt_hitm); + per_right =PERCENT (right, rmt_hitm);return per_left - per_right; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 227/287 mips: cpc: Fix refcount leak in mips_cpc_default_phys_base
In reply to Greg Kroah-HartmanFrom: Gong Yuanjun <[email protected]>
[ Upstream commit 4107fa700f314592850e2c64608f6ede4c077476 ]
Add the missing of_node_put() to release the refcount incremented by of_find_compatible_node().
--- arch/mips/kernel/mips-cpc.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/kernel/mips-cpc.c +1 -0
@@ -31,6 +31,7 @@ phys_addr_t __weak mips_cpc_default_phys_base(void) cpc_node =of_find_compatible_node (of_root,NULL ,"mti,mips-cpc" );if (cpc_node) { err =of_address_to_resource (cpc_node,0 , &res); +of_node_put (cpc_node);if (!err)return res.start; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 228/287 tracing: Fix sleeping function called from invalid context on RT kernel
In reply to Greg Kroah-HartmanFrom: Jun Miao <[email protected]>
[ Upstream commit 12025abdc8539ed9d5014e2d647a3fd1bd3de5cd ]
When setting bootparams="trace_event=initcall:initcall_start tp_printk=1" in the cmdline, the output_printk() was called, and the spin_lock_irqsave() was called in the atomic and irq disable interrupt context suitation. On the PREEMPT_RT kernel, these locks are replaced with sleepable rt-spinlock, so the stack calltrace will be triggered.
Fix it by raw_spin_lock_irqsave when PREEMPT_RT and "trace_event=initcall:initcall_start tp_printk=1" enabled.
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0 preempt_count: 2, expected: 0 RCU nest depth: 0, expected: 0 Preemption disabled at: [<ffffffff8992303e>] try_to_wake_up+0x7e/0xba0 CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.17.1-rt17+ #19 34c5812404187a875f32bee7977f7367f9679ea7 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x60/0x8c dump_stack+0x10/0x12 __might_resched.cold+0x11d/0x155 rt_spin_lock+0x40/0x70 trace_event_buffer_commit+0x2fa/0x4c0 ? map_vsyscall+0x93/0x93 trace_event_raw_event_initcall_start+0xbe/0x110 ? perf_trace_initcall_finish+0x210/0x210 ? probe_sched_wakeup+0x34/0x40 ? ttwu_do_wakeup+0xda/0x310 ? trace_hardirqs_on+0x35/0x170 ? map_vsyscall+0x93/0x93 do_one_initcall+0x217/0x3c0 ? trace_event_raw_event_initcall_level+0x170/0x170 ? push_cpu_stop+0x400/0x400 ? cblist_init_generic+0x241/0x290 kernel_init_freeable+0x1ac/0x347 ? _raw_spin_unlock_irq+0x65/0x80 ? rest_init+0xf0/0xf0 kernel_init+0x1e/0x150 ret_from_fork+0x22/0x30 </TASK>
--- kernel/trace/trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +3 -3
@@ -2331,7 +2331,7 @@ trace_event_buffer_lock_reserve(struct ring_buffer **current_rb, }EXPORT_SYMBOL_GPL (trace_event_buffer_lock_reserve); -static DEFINE_SPINLOCK (tracepoint_iter_lock); +static DEFINE_RAW_SPINLOCK (tracepoint_iter_lock);static DEFINE_MUTEX (tracepoint_printk_mutex);static void output_printk (struct trace_event_buffer *fbuffer)
@@ -2352,14 +2352,14 @@ static void output_printk(struct trace_event_buffer *fbuffer) event = &fbuffer->trace_file->event_call->event; -spin_lock_irqsave (&tracepoint_iter_lock, flags); +raw_spin_lock_irqsave (&tracepoint_iter_lock, flags);trace_seq_init (&iter->seq); iter->ent = fbuffer->entry; event_call->event.funcs->trace (iter,0 , event);trace_seq_putc (&iter->seq,0 );printk ("%s" , iter->seq.buffer); -spin_unlock_irqrestore (&tracepoint_iter_lock, flags); +raw_spin_unlock_irqrestore (&tracepoint_iter_lock, flags); } int tracepoint_printk_sysctl(struct ctl_table *table, int write,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 229/287 tracing: Avoid adding tracer option before update_tracer_options
In reply to Greg Kroah-HartmanFrom: Mark-PK Tsai <[email protected]>
[ Upstream commit ef9188bcc6ca1d8a2ad83e826b548e6820721061 ]
To prepare for support asynchronous tracer_init_tracefs initcall, avoid calling create_trace_option_files before __update_tracer_options. Otherwise, create_trace_option_files will show warning because some tracers in trace_types list are already in tr->topts.
For example, hwlat_tracer call register_tracer in late_initcall, and global_trace.dir is already created in tracing_init_dentry, hwlat_tracer will be put into tr->topts.
Then if the __update_tracer_options is executed after hwlat_tracer registered, create_trace_option_files find that hwlat_tracer is already in tr->topts.
--- kernel/trace/trace.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/trace/trace.c +7 -0
@@ -5368,12 +5368,18 @@ static void tracing_set_nop(struct trace_array *tr) tr->current_trace = &nop_trace; } +static bool tracer_options_updated; +static void add_tracer_options (struct trace_array *tr,struct tracer *t) {/* Only enable if the directory has been created already. */ if (!tr->dir)return ; +/* Only create trace option files after update_tracer_options finish */ +if (!tracer_options_updated) +return ; +create_trace_option_files (tr, t); }
@@ -7820,6 +7826,7 @@ static void __update_tracer_options(struct trace_array *tr)static void update_tracer_options (struct trace_array *tr) {mutex_lock (&trace_types_lock); + tracer_options_updated = true;__update_tracer_options (tr);mutex_unlock (&trace_types_lock); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 230/287 i2c: cadence: Increase timeout per message if necessary
In reply to Greg Kroah-HartmanFrom: Lucas Tanure <[email protected]>
[ Upstream commit 96789dce043f5bff8b7d62aa28d52a7c59403a84 ]
Timeout as 1 second sets an upper limit on the length of the transfer executed, but there is no maximum length of a write or read message set in i2c_adapter_quirks for this controller.
This upper limit affects devices that require sending large firmware blobs over I2C.
To remove that limitation, calculate the minimal time necessary, plus some wiggle room, for every message and use it instead of the default one second, if more than one second.
--- drivers/i2c/busses/i2c-cadence.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-cadence.c +10 -2
@@ -511,7 +511,7 @@ static void cdns_i2c_master_reset(struct i2c_adapter *adap)static int cdns_i2c_process_msg (struct cdns_i2c *id,struct i2c_msg *msg,struct i2c_adapter *adap) { -unsigned long time_left; +unsigned long time_left, msg_timeout;u32 reg; id->p_msg = msg;
@@ -536,8 +536,16 @@ static int cdns_i2c_process_msg(struct cdns_i2c *id, struct i2c_msg *msg,else cdns_i2c_msend (id); +/* Minimal time to execute this message */ + msg_timeout =msecs_to_jiffies ((1000 * msg->len *BITS_PER_BYTE ) / id->i2c_clk); +/* Plus some wiggle room */ + msg_timeout +=msecs_to_jiffies (500 ); + +if (msg_timeout < adap->timeout) + msg_timeout = adap->timeout; +/* Wait for the signal of completion */ - time_left =wait_for_completion_timeout (&id->xfer_done, adap->timeout); + time_left =wait_for_completion_timeout (&id->xfer_done, msg_timeout);if (time_left ==0 ) {cdns_i2c_master_reset (adap); dev_err(id->adap.dev.parent,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 231/287 m68knommu: set ZERO_PAGE() to the allocated zeroed page
In reply to Greg Kroah-HartmanFrom: Greg Ungerer <[email protected]>
[ Upstream commit dc068f46217970d9516f16cd37972a01d50dc055 ]
The non-MMU m68k pagetable ZERO_PAGE() macro is being set to the somewhat non-sensical value of "virt_to_page(0)". The zeroth page is not in any way guaranteed to be a page full of "0". So the result is that ZERO_PAGE() will almost certainly contain random values.
We already allocate a real "empty_zero_page" in the mm setup code shared between MMU m68k and non-MMU m68k. It is just not hooked up to the ZERO_PAGE() macro for the non-MMU m68k case.
Fix ZERO_PAGE() to use the allocated "empty_zero_page" pointer.
I am not aware of any specific issues caused by the old code.
--- arch/m68k/include/asm/pgtable_no.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/include/asm/pgtable_no.h +2 -1
@@ -42,7 +42,8 @@ extern void paging_init(void);* ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc.. */ -#define ZERO_PAGE (vaddr) (virt_to_page(0)) +extern void *empty_zero_page; +#define ZERO_PAGE (vaddr) (virt_to_page(empty_zero_page))/* * No page table caches to initialise.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 232/287 m68knommu: fix undefined reference to `_init_sp
In reply to Greg Kroah-HartmanFrom: Greg Ungerer <[email protected]>
[ Upstream commit a71b9e66fee47c59b3ec34e652b5c23bc6550794 ]
When configuring a nommu classic m68k system enabling the uboot parameter passing support (CONFIG_UBOOT) will produce the following compile error:
m68k-linux-ld: arch/m68k/kernel/uboot.o: in function `process_uboot_commandline':
uboot.c:(.init.text+0x32): undefined reference to `_init_sp'
The logic to support this option is only used on ColdFire based platforms (in its head.S startup code). So make the selection of this option depend on building for a ColdFire based platform.
--- arch/m68k/Kconfig.machine | 1 + 1 file changed, 1 insertion(+)
arch/m68k/Kconfig.machine +1 -0
@@ -315,6 +315,7 @@ comment "Machine Options" config UBOOT bool "Support for U-Boot command line parameters" + depends on COLDFIRE help If you say Y here kernel will try to collect command line parameters from the initial u-boot stack.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 233/287 NFSv4: Dont hold the layoutget locks across multiple RPC calls
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 6949493884fe88500de4af182588e071cf1544ee ]
When doing layoutget as part of the open() compound, we have to be careful to release the layout locks before we can call any further RPC calls, such as setattr(). The reason is that those calls could trigger a recall, which could deadlock.
--- fs/nfs/nfs4proc.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nfs/nfs4proc.c +4 -0
@@ -2920,6 +2920,10 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, } out: +if (opendata->lgp) { +nfs4_lgopen_release (opendata->lgp); + opendata->lgp =NULL ; + }if (!opendata->cancelled)nfs4_sequence_free_slot (&opendata->o_res.seq_res);return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 234/287 video: fbdev: pxa3xx-gcu: release the resources correctly in pxa3xx_gcu_probe/remove()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit d87ad457f7e1b8d2492ca5b1531eb35030a1cc8f ]
In pxa3xx_gcu_probe(), the sequence of error lable is wrong, it will leads some resource leaked, so adjust the sequence to handle the error correctly, and if pxa3xx_gcu_add_buffer() fails, pxa3xx_gcu_free_buffers() need be called.
In pxa3xx_gcu_remove(), add missing clk_disable_unpreprare().
--- drivers/video/fbdev/pxa3xx-gcu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/video/fbdev/pxa3xx-gcu.c +7 -5
@@ -663,6 +663,7 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev)for (i =0 ; i <8 ; i++) { ret =pxa3xx_gcu_add_buffer (dev, priv);if (ret) { +pxa3xx_gcu_free_buffers (dev, priv);dev_err (dev,"failed to allocate DMA memory\n" ); goto err_disable_clk; }
@@ -678,15 +679,15 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev) SHARED_SIZE, irq);return 0 ; -err_free_dma: -dma_free_coherent (dev,SHARED_SIZE , - priv->shared, priv->shared_phys); +err_disable_clk: +clk_disable_unprepare (priv->clk); err_misc_deregister:misc_deregister (&priv->misc_dev); -err_disable_clk: -clk_disable_unprepare (priv->clk); +err_free_dma: +dma_free_coherent (dev,SHARED_SIZE , + priv->shared, priv->shared_phys);return ret; }
@@ -699,6 +700,7 @@ static int pxa3xx_gcu_remove(struct platform_device *pdev)pxa3xx_gcu_wait_idle (priv);misc_deregister (&priv->misc_dev);dma_free_coherent (dev,SHARED_SIZE , priv->shared, priv->shared_phys); +clk_disable_unprepare (priv->clk);pxa3xx_gcu_free_buffers (dev, priv);return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 235/287 xprtrdma: treat all calls not a bcall when bc_serv is NULL
In reply to Greg Kroah-HartmanFrom: Kinglong Mee <[email protected]>
[ Upstream commit 11270e7ca268e8d61b5d9e5c3a54bd1550642c9c ]
When a rdma server returns a fault format reply, nfs v3 client may treats it as a bcall when bc service is not exist.
The debug message at rpcrdma_bc_receive_call are,
[56579.837169] RPC: rpcrdma_bc_receive_call: callback XID 00000001, length=20 [56579.837174] RPC: rpcrdma_bc_receive_call: 00 00 00 01 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 04
After that, rpcrdma_bc_receive_call will meets NULL pointer as,
[ 226.057890] BUG: unable to handle kernel NULL pointer dereference at 00000000000000c8 ... [ 226.058704] RIP: 0010:_raw_spin_lock+0xc/0x20 ... [ 226.059732] Call Trace: [ 226.059878] rpcrdma_bc_receive_call+0x138/0x327 [rpcrdma] [ 226.060011] __ib_process_cq+0x89/0x170 [ib_core] [ 226.060092] ib_cq_poll_work+0x26/0x80 [ib_core] [ 226.060257] process_one_work+0x1a7/0x360 [ 226.060367] ? create_worker+0x1a0/0x1a0 [ 226.060440] worker_thread+0x30/0x390 [ 226.060500] ? create_worker+0x1a0/0x1a0 [ 226.060574] kthread+0x116/0x130 [ 226.060661] ? kthread_flush_work_fn+0x10/0x10 [ 226.060724] ret_from_fork+0x35/0x40
...
--- net/sunrpc/xprtrdma/rpc_rdma.c | 5 +++++ 1 file changed, 5 insertions(+)
net/sunrpc/xprtrdma/rpc_rdma.c +5 -0
@@ -980,6 +980,7 @@ static bool rpcrdma_is_bcall(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep) #if defined(CONFIG_SUNRPC_BACKCHANNEL) { + struct rpc_xprt *xprt = &r_xprt->rx_xprt;struct xdr_stream *xdr = &rep->rr_stream;__be32 *p;
@@ -1003,6 +1004,10 @@ rpcrdma_is_bcall(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep)if (*p !=cpu_to_be32 (RPC_CALL ))return false; +/* No bc service. */ +if (xprt->bc_serv ==NULL ) +return false; +/* Now that we are sure this is a backchannel call, * advance to the RPC header. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 236/287 ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 10d6bdf532902be1d8aa5900b3c03c5671612aa2 ]
of_find_device_by_node() takes reference, we should use put_device() to release it when not need anymore.
Add missing put_device() to avoid refcount leak.
--- drivers/ata/pata_octeon_cf.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/ata/pata_octeon_cf.c +3 -0
@@ -888,12 +888,14 @@ static int octeon_cf_probe(struct platform_device *pdev)int i; res_dma =platform_get_resource (dma_dev,IORESOURCE_MEM ,0 );if (!res_dma) { +put_device (&dma_dev->dev);of_node_put (dma_node);return -EINVAL ; } cf_port->dma_base = (u64 )devm_ioremap_nocache (&pdev->dev, res_dma->start,resource_size (res_dma));if (!cf_port->dma_base) { +put_device (&dma_dev->dev);of_node_put (dma_node);return -EINVAL ; }
@@ -903,6 +905,7 @@ static int octeon_cf_probe(struct platform_device *pdev) irq = i; irq_handler = octeon_cf_interrupt; } +put_device (&dma_dev->dev); }of_node_put (dma_node); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 237/287 af_unix: Fix a data-race in unix_dgram_peer_wake_me().
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 662a80946ce13633ae90a55379f1346c10f0c432 ]
unix_dgram_poll() calls unix_dgram_peer_wake_me() without other's lock held and check if its receive queue is full. Here we need to use unix_recvq_full_lockless() instead of unix_recvq_full(), otherwise KCSAN will report a data-race.
--- net/unix/af_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/unix/af_unix.c +1 -1
@@ -445,7 +445,7 @@ static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other)* -ECONNREFUSED. Otherwise, if we haven't queued any skbs * to other and its full, we will hang waiting for POLLOUT. */ -if (unix_recvq_full (other) && !sock_flag (other,SOCK_DEAD )) +if (unix_recvq_full_lockless (other) && !sock_flag (other,SOCK_DEAD ))return 1 ;if (connected)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 238/287 bpf, arm64: Clear prog->jited_len along prog->jited
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 10f3b29c65bb2fe0d47c2945cd0b4087be1c5218 ]
syzbot reported an illegal copy_to_user() attempt
from bpf_prog_get_info_by_fd() [1]
There was no repro yet on this bug, but I think
that commit 0aef499f3172 ("mm/usercopy: Detect vmalloc overruns") is exposing a prior bug in bpf arm64.
bpf_prog_get_info_by_fd() looks at prog->jited_len to determine if the JIT image can be copied out to user space.
My theory is that syzbot managed to get a prog where prog->jited_len has been set to 43, while prog->bpf_func has ben cleared.
It is not clear why copy_to_user(uinsns, NULL, ulen) is triggering this particular warning.
I thought find_vma_area(NULL) would not find a vm_struct. As we do not hold vmap_area_lock spinlock, it might be possible that the found vm_struct was garbage.
[1]
usercopy: Kernel memory exposure attempt detected from vmalloc (offset 792633534417210172, size 43)! kernel BUG at mm/usercopy.c:101!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 25002 Comm: syz-executor.1 Not tainted 5.18.0-syzkaller-10139-g8291eaafed36 #0 Hardware name: linux,dummy-virt (DT) pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : usercopy_abort+0x90/0x94 mm/usercopy.c:101 lr : usercopy_abort+0x90/0x94 mm/usercopy.c:89
sp : ffff80000b773a20
x29: ffff80000b773a30 x28: faff80000b745000 x27: ffff80000b773b48
x26: 0000000000000000 x25: 000000000000002b x24: 0000000000000000
x23: 00000000000000e0 x22: ffff80000b75db67 x21: 0000000000000001
x20: 000000000000002b x19: ffff80000b75db3c x18: 00000000fffffffd
x17: 2820636f6c6c616d x16: 76206d6f72662064 x15: 6574636574656420
x14: 74706d6574746120 x13: 2129333420657a69 x12: 73202c3237313031
x11: 3237313434333533 x10: 3336323937207465 x9 : 657275736f707865 x8 : ffff80000a30c550 x7 : ffff80000b773830 x6 : ffff80000b773830 x5 : 0000000000000000 x4 : ffff00007fbbaa10 x3 : 0000000000000000 x2 : 0000000000000000 x1 : f7ff000028fc0000 x0 : 0000000000000064
Call trace: usercopy_abort+0x90/0x94 mm/usercopy.c:89 check_heap_object mm/usercopy.c:186 [inline] __check_object_size mm/usercopy.c:252 [inline] __check_object_size+0x198/0x36c mm/usercopy.c:214 check_object_size include/linux/thread_info.h:199 [inline] check_copy_size include/linux/thread_info.h:235 [inline] copy_to_user include/linux/uaccess.h:159 [inline] bpf_prog_get_info_by_fd.isra.0+0xf14/0xfdc kernel/bpf/syscall.c:3993 bpf_obj_get_info_by_fd+0x12c/0x510 kernel/bpf/syscall.c:4253 __sys_bpf+0x900/0x2150 kernel/bpf/syscall.c:4956 __do_sys_bpf kernel/bpf/syscall.c:5021 [inline] __se_sys_bpf kernel/bpf/syscall.c:5019 [inline] __arm64_sys_bpf+0x28/0x40 kernel/bpf/syscall.c:5019 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x48/0x114 arch/arm64/kernel/syscall.c:52 el0_svc_common.constprop.0+0x44/0xec arch/arm64/kernel/syscall.c:142 do_el0_svc+0xa0/0xc0 arch/arm64/kernel/syscall.c:206 el0_svc+0x44/0xb0 arch/arm64/kernel/entry-common.c:624 el0t_64_sync_handler+0x1ac/0x1b0 arch/arm64/kernel/entry-common.c:642 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:581 Code: aa0003e3 d00038c0 91248000 97fff65f (d4210000)
--- arch/arm64/net/bpf_jit_comp.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/net/bpf_jit_comp.c +1 -0
@@ -938,6 +938,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)bpf_jit_binary_free (header); prog->bpf_func =NULL ; prog->jited =0 ; + prog->jited_len =0 ; goto out_off; }bpf_jit_binary_lock_ro (header);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 239/287 net/mlx4_en: Fix wrong return value on ioctl EEPROM query failure
In reply to Greg Kroah-HartmanFrom: Gal Pressman <[email protected]>
[ Upstream commit f5826c8c9d57210a17031af5527056eefdc2b7eb ]
The ioctl EEPROM query wrongly returns success on read failures, fix that by returning the appropriate error code.
--- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +1 -1
@@ -2083,7 +2083,7 @@ static int mlx4_en_get_module_eeprom(struct net_device *dev,en_err (priv,"mlx4_get_module_info i(%d) offset(%d) bytes_to_read(%d) - FAILED (0x%x)\n" , i, offset, ee->len - i, ret); -return 0 ; +return ret; } i += ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 240/287 SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer()
In reply to Greg Kroah-HartmanFrom: Chuck Lever <[email protected]>
[ Upstream commit 6c254bf3b637dd4ef4f78eb78c7447419c0161d7 ]
I found that NFSD's new NFSv3 READDIRPLUS XDR encoder was screwing up right at the end of the page array. xdr_get_next_encode_buffer() does not compute the value of xdr->end correctly:
* The check to see if we're on the final available page in xdr->buf needs to account for the space consumed by @nbytes.
* The new xdr->end value needs to account for the portion of @nbytes that is to be encoded into the previous buffer.
--- net/sunrpc/xdr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sunrpc/xdr.c +5 -1
@@ -544,7 +544,11 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr,*/ xdr->p = (void *)p + frag2bytes; space_left = xdr->buf->buflen - xdr->buf->len; - xdr->end = (void *)p +min_t (int, space_left,PAGE_SIZE ); +if (space_left - nbytes >=PAGE_SIZE ) + xdr->end = (void *)p +PAGE_SIZE ; +else + xdr->end = (void *)p + space_left - frag1bytes; + xdr->buf->page_len += frag2bytes; xdr->buf->len += nbytes;return p;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 241/287 net: mdio: unexport __init-annotated mdio_bus_init()
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit 35b42dce619701f1300fb8498dae82c9bb1f0263 ]
EXPORT_SYMBOL and __init is a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated __init. The access to a freed symbol may end up with kernel panic.
modpost used to detect it, but it has been broken for a decade.
Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds.
There are two ways to fix it:
- Remove __init
- Remove EXPORT_SYMBOL
I chose the latter for this case because the only in-tree call-site, drivers/net/phy/phy_device.c is never compiled as modular. (CONFIG_PHYLIB is boolean)
--- drivers/net/phy/mdio_bus.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/phy/mdio_bus.c +0 -1
@@ -746,7 +746,6 @@ int __init mdio_bus_init(void)return ret; } -EXPORT_SYMBOL_GPL (mdio_bus_init);#if IS_ENABLED (CONFIG_PHYLIB )void mdio_bus_exit (void )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 242/287 net: xfrm: unexport __init-annotated xfrm4_protocol_init()
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit 4a388f08d8784af48f352193d2b72aaf167a57a1 ]
EXPORT_SYMBOL and __init is a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated __init. The access to a freed symbol may end up with kernel panic.
modpost used to detect it, but it has been broken for a decade.
Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds.
There are two ways to fix it:
- Remove __init
- Remove EXPORT_SYMBOL
I chose the latter for this case because the only in-tree call-site, net/ipv4/xfrm4_policy.c is never compiled as modular. (CONFIG_XFRM is boolean)
--- net/ipv4/xfrm4_protocol.c | 1 - 1 file changed, 1 deletion(-)
net/ipv4/xfrm4_protocol.c +0 -1
@@ -297,4 +297,3 @@ void __init xfrm4_protocol_init(void) {xfrm_input_register_afinfo (&xfrm4_input_afinfo); } -EXPORT_SYMBOL (xfrm4_protocol_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 243/287 net: ipv6: unexport __init-annotated seg6_hmac_init()
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit 5801f064e35181c71857a80ff18af4dbec3c5f5c ]
EXPORT_SYMBOL and __init is a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated __init. The access to a freed symbol may end up with kernel panic.
modpost used to detect it, but it has been broken for a decade.
Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds.
There are two ways to fix it:
- Remove __init
- Remove EXPORT_SYMBOL
I chose the latter for this case because the caller (net/ipv6/seg6.c) and the callee (net/ipv6/seg6_hmac.c) belong to the same module. It seems an internal function call in ipv6.ko.
--- net/ipv6/seg6_hmac.c | 1 - 1 file changed, 1 deletion(-)
net/ipv6/seg6_hmac.c +0 -1
@@ -406,7 +406,6 @@ int __init seg6_hmac_init(void) {return seg6_hmac_init_algo (); } -EXPORT_SYMBOL (seg6_hmac_init);int __net_init seg6_hmac_net_init (struct net *net) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 244/287 net/mlx5: Rearm the FW tracer after each tracer event
In reply to Greg Kroah-HartmanFrom: Feras Daoud <[email protected]>
[ Upstream commit 8bf94e6414c9481bfa28269022688ab445d0081d ]
The current design does not arm the tracer if traces are available before the tracer string database is fully loaded, leading to an unfunctional tracer. This fix will rearm the tracer every time the FW triggers tracer event regardless of the tracer strings database status.
--- drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c +5 -2
@@ -637,6 +637,9 @@ static void mlx5_fw_tracer_handle_traces(struct work_struct *work)if (!tracer->owner)return ; +if (unlikely (!tracer->str_db.loaded)) + goto arm; + block_count = tracer->buff.size /TRACER_BLOCK_SIZE_BYTE ; start_offset = tracer->buff.consumer_index *TRACER_BLOCK_SIZE_BYTE ;
@@ -694,6 +697,7 @@ static void mlx5_fw_tracer_handle_traces(struct work_struct *work) &tmp_trace_block[TRACES_PER_BLOCK - 1]); } +arm:mlx5_fw_tracer_arm (dev); }
@@ -935,8 +939,7 @@ void mlx5_fw_tracer_event(struct mlx5_core_dev *dev, struct mlx5_eqe *eqe)queue_work (tracer->work_queue, &tracer->ownership_change_work);break ;case MLX5_TRACER_SUBTYPE_TRACES_AVAILABLE : -if (likely (tracer->str_db.loaded)) -queue_work (tracer->work_queue, &tracer->handle_traces_work); +queue_work (tracer->work_queue, &tracer->handle_traces_work);break ;default : mlx5_core_dbg(dev, "FWTracer: Event with unrecognized subtype: sub_type %d\n",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 245/287 ip_gre: test csum_start instead of transport header
In reply to Greg Kroah-HartmanFrom: Willem de Bruijn <[email protected]>
[ Upstream commit 8d21e9963bec1aad2280cdd034c8993033ef2948 ]
GRE with TUNNEL_CSUM will apply local checksum offload on CHECKSUM_PARTIAL packets.
ipgre_xmit must validate csum_start after an optional skb_pull, else lco_csum may trigger an overflow. The original check was
if (csum && skb_checksum_start(skb) < skb->data) return -EINVAL;
This had false positives when skb_checksum_start is undefined:
when ip_summed is not CHECKSUM_PARTIAL. A discussed refinement was straightforward
if (csum && skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_start(skb) < skb->data) return -EINVAL;
But was eventually revised more thoroughly:
- restrict the check to the only branch where needed, in an uncommon GRE path that uses header_ops and calls skb_pull.
- test skb_transport_header, which is set along with csum_start in skb_partial_csum_set in the normal header_ops datapath.
Turns out skbs can arrive in this branch without the transport header set, e.g., through BPF redirection.
Revise the check back to check csum_start directly, and only if CHECKSUM_PARTIAL. Do leave the check in the updated location. Check field regardless of whether TUNNEL_CSUM is configured.
--- net/ipv4/ip_gre.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
net/ipv4/ip_gre.c +5 -6
@@ -678,21 +678,20 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb, }if (dev->header_ops) { -const int pull_len = tunnel->hlen +sizeof (struct iphdr ); -if (skb_cow_head (skb,0 )) goto free_skb; tnl_params = (const struct iphdr *)skb->data; -if (pull_len >skb_transport_offset (skb)) - goto free_skb; -/* Pull skb since ip_tunnel_xmit() needs skb->data pointing * to gre header. */ -skb_pull (skb, pull_len); +skb_pull (skb, tunnel->hlen +sizeof (struct iphdr ));skb_reset_mac_header (skb); + +if (skb->ip_summed ==CHECKSUM_PARTIAL && +skb_checksum_start (skb) < skb->data) + goto free_skb; }else {if (skb_cow_head (skb, dev->needed_headroom)) goto free_skb;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 246/287 net: altera: Fix refcount leak in altera_tse_mdio_create
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 11ec18b1d8d92b9df307d31950dcba0b3dd7283c ]
Every iteration of for_each_child_of_node() decrements the reference count of the previous node.
When break from a for_each_child_of_node() loop,
we need to explicitly call of_node_put() on the child node when not need anymore.
Add missing of_node_put() to avoid refcount leak.
--- drivers/net/ethernet/altera/altera_tse_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/altera/altera_tse_main.c +5 -1
@@ -174,7 +174,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id) mdio =mdiobus_alloc ();if (mdio ==NULL ) {netdev_err (dev,"Error allocating MDIO bus\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto put_node; } mdio->name =ALTERA_TSE_RESOURCE_NAME ;
@@ -191,6 +192,7 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id) mdio->id); goto out_free_mdio; } +of_node_put (mdio_node);if (netif_msg_drv (priv))netdev_info (dev,"MDIO bus %s: created\n" , mdio->id);
@@ -200,6 +202,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id) out_free_mdio:mdiobus_free (mdio); mdio =NULL ; +put_node: +of_node_put (mdio_node);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 247/287 drm: imx: fix compiler warning with gcc-12
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
[ Upstream commit 7aefd8b53815274f3ef398d370a3c9b27dd9f00c ]
Gcc-12 correctly warned about this code using a non-NULL pointer as a truth value:
drivers/gpu/drm/imx/ipuv3-crtc.c: In function ‘ipu_crtc_disable_planes’:
drivers/gpu/drm/imx/ipuv3-crtc.c:72:21: error: the comparison will always evaluate as ‘true’ for the address of ‘plane’ will never be NULL [-Werror=address]
72 | if (&ipu_crtc->plane[1] && plane == &ipu_crtc->plane[1]->base)
| ^due to the extraneous '&' address-of operator.
Philipp Zabel points out that The mistake had no adverse effect since the following condition doesn't actually dereference the NULL pointer, but the intent of the code was obviously to check for it, not to take the address of the member.
--- drivers/gpu/drm/imx/ipuv3-crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +1 -1
@@ -71,7 +71,7 @@ static void ipu_crtc_disable_planes(struct ipu_crtc *ipu_crtc,drm_atomic_crtc_state_for_each_plane (plane, old_crtc_state) {if (plane == &ipu_crtc->plane[0 ]->base) disable_full = true; -if (&ipu_crtc->plane[1 ] && plane == &ipu_crtc->plane[1 ]->base) +if (ipu_crtc->plane[1 ] && plane == &ipu_crtc->plane[1 ]->base) disable_partial = true; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 248/287 iio: dummy: iio_simple_dummy: check the return value of kstrdup()
In reply to Greg Kroah-HartmanFrom: Xiaoke Wang <[email protected]>
[ Upstream commit ba93642188a6fed754bf7447f638bc410e05a929 ]
kstrdup() is also a memory allocation-related function, it returns NULL when some memory errors happen. So it is better to check the return value of it so to catch the memory error in time. Besides, there should have a kfree() to clear up the allocation if we get a failure later in this function to prevent memory leak.
--- drivers/iio/dummy/iio_simple_dummy.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/iio/dummy/iio_simple_dummy.c +12 -8
@@ -571,10 +571,9 @@ static struct iio_sw_device *iio_dummy_probe(const char *name)struct iio_sw_device *swd; swd =kzalloc (sizeof (*swd),GFP_KERNEL ); -if (!swd) { - ret = -ENOMEM ; - goto error_kzalloc; - } +if (!swd) +return ERR_PTR (-ENOMEM ); +/* * Allocate an IIO device. *
@@ -586,7 +585,7 @@ static struct iio_sw_device *iio_dummy_probe(const char *name) indio_dev =iio_device_alloc (sizeof (*st));if (!indio_dev) { ret = -ENOMEM ; - goto error_ret; + goto error_free_swd; } st =iio_priv (indio_dev);
@@ -617,6 +616,10 @@ static struct iio_sw_device *iio_dummy_probe(const char *name)* indio_dev->name = spi_get_device_id(spi)->name; */ indio_dev->name =kstrdup (name,GFP_KERNEL ); +if (!indio_dev->name) { + ret = -ENOMEM ; + goto error_free_device; + }/* Provide description of available channels */ indio_dev->channels = iio_dummy_channels;
@@ -633,7 +636,7 @@ static struct iio_sw_device *iio_dummy_probe(const char *name) ret =iio_simple_dummy_events_register (indio_dev);if (ret <0 ) - goto error_free_device; + goto error_free_name; ret =iio_simple_dummy_configure_buffer (indio_dev);if (ret <0 )
@@ -650,11 +653,12 @@ static struct iio_sw_device *iio_dummy_probe(const char *name)iio_simple_dummy_unconfigure_buffer (indio_dev); error_unregister_events:iio_simple_dummy_events_unregister (indio_dev); +error_free_name: +kfree (indio_dev->name); error_free_device:iio_device_free (indio_dev); -error_ret: +error_free_swd:kfree (swd); -error_kzalloc:return ERR_PTR (ret); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 249/287 lkdtm/usercopy: Expand size of "out of frame" object
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit f387e86d3a74407bdd9c5815820ac9d060962840 ]
To be sufficiently out of range for the usercopy test to see the lifetime mismatch, expand the size of the "bad" buffer, which will let it be beyond current_stack_pointer regardless of stack growth direction. Paired with the recent addition of stack depth checking under CONFIG_HARDENED_USERCOPY=y, this will correctly start tripping again.
--- drivers/misc/lkdtm/usercopy.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/misc/lkdtm/usercopy.c +14 -3
@@ -30,12 +30,12 @@ static const unsigned char test_text[] = "This is a test.\n";*/ static noinline unsigned char *trick_compiler(unsigned char *stack) { -return stack +0 ; +return stack + unconst; } static noinline unsigned char *do_usercopy_stack_callee(int value) { -unsigned char buf[32 ]; +unsigned char buf[128 ];int i;/* Exercise stack to avoid everything living in registers. */
@@ -43,7 +43,12 @@ static noinline unsigned char *do_usercopy_stack_callee(int value) buf[i] = value &0xff ; } -return trick_compiler (buf); +/* +* Put the target buffer in the middle of stack allocation +* so that we don't step on future stack users regardless +* of stack growth direction. +*/ +return trick_compiler (&buf[(128 /2 )-32 ]); } static noinline void do_usercopy_stack(bool to_user, bool bad_frame)
@@ -66,6 +71,12 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame) bad_stack -=sizeof (unsigned long ); } +#ifdef ARCH_HAS_CURRENT_STACK_POINTER +pr_info ("stack : %px\n" , (void *)current_stack_pointer); +#endif +pr_info ("good_stack: %px-%px\n" , good_stack, good_stack +sizeof (good_stack)); +pr_info ("bad_stack : %px-%px\n" , bad_stack, bad_stack +sizeof (good_stack)); + user_addr =vm_mmap (NULL ,0 ,PAGE_SIZE ,PROT_READ |PROT_WRITE |PROT_EXEC ,MAP_ANONYMOUS |MAP_PRIVATE ,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 250/287 tty: synclink_gt: Fix null-pointer-dereference in slgt_clean()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 689ca31c542687709ba21ec2195c1fbce34fd029 ]
When the driver fails at alloc_hdlcdev(), and then we remove the driver module, we will get the following splat:
[ 25.065966] general protection fault, probably for non-canonical address 0xdffffc0000000182: 0000 [#1] PREEMPT SMP KASAN PTI [ 25.066914] KASAN: null-ptr-deref in range [0x0000000000000c10-0x0000000000000c17] [ 25.069262] RIP: 0010:detach_hdlc_protocol+0x2a/0x3e0 [ 25.077709] Call Trace: [ 25.077924] <TASK> [ 25.078108] unregister_hdlc_device+0x16/0x30 [ 25.078481] slgt_cleanup+0x157/0x9f0 [synclink_gt]
Fix this by checking whether the 'info->netdev' is a null pointer first.
--- drivers/tty/synclink_gt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/synclink_gt.c +2 -0
@@ -1753,6 +1753,8 @@ static int hdlcdev_init(struct slgt_info *info)*/ static void hdlcdev_exit (struct slgt_info *info) { +if (!info->netdev) +return ;unregister_hdlc_device (info->netdev);free_netdev (info->netdev); info->netdev =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 251/287 tty: Fix a possible resource leak in icom_probe
In reply to Greg Kroah-HartmanFrom: Huang Guobin <[email protected]>
[ Upstream commit ee157a79e7c82b01ae4c25de0ac75899801f322c ]
When pci_read_config_dword failed, call pci_release_regions() and pci_disable_device() to recycle the resource previously allocated.
--- drivers/tty/serial/icom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/icom.c +1 -1
@@ -1501,7 +1501,7 @@ static int icom_probe(struct pci_dev *dev, retval =pci_read_config_dword (dev,PCI_COMMAND , &command_reg);if (retval) {dev_err (&dev->dev,"PCI Config read FAILED\n" ); -return retval; + goto probe_exit0; } pci_write_config_dword(dev, PCI_COMMAND,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 252/287 drivers: staging: rtl8192u: Fix deadlock in ieee80211_beacons_stop()
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 806c7b53414934ba2a39449b31fd1a038e500273 ]
There is a deadlock in ieee80211_beacons_stop(), which is shown below:
(Thread 1) | (Thread 2)
| ieee80211_send_beacon()
ieee80211_beacons_stop() | mod_timer()
spin_lock_irqsave() //(1) | (wait a time)
... | ieee80211_send_beacon_cb()
del_timer_sync() | spin_lock_irqsave() //(2)
(wait timer to stop) | ...We hold ieee->beacon_lock in position (1) of thread 1 and use del_timer_sync() to wait timer to stop, but timer handler also need ieee->beacon_lock in position (2) of thread 2. As a result, ieee80211_beacons_stop() will block forever.
This patch extracts del_timer_sync() from the protection of spin_lock_irqsave(), which could let timer handler to obtain the needed lock.
--- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +1 -1
@@ -529,9 +529,9 @@ static void ieee80211_beacons_stop(struct ieee80211_device *ieee)spin_lock_irqsave (&ieee->beacon_lock, flags); ieee->beacon_txing =0 ; -del_timer_sync (&ieee->beacon_timer);spin_unlock_irqrestore (&ieee->beacon_lock, flags); +del_timer_sync (&ieee->beacon_timer); }void ieee80211_stop_send_beacons (struct ieee80211_device *ieee)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 253/287 drivers: staging: rtl8192e: Fix deadlock in rtllib_beacons_stop()
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 9b6bdbd9337de3917945847bde262a34a87a6303 ]
There is a deadlock in rtllib_beacons_stop(), which is shown below:
(Thread 1) | (Thread 2)
| rtllib_send_beacon()
rtllib_beacons_stop() | mod_timer()
spin_lock_irqsave() //(1) | (wait a time)
... | rtllib_send_beacon_cb()
del_timer_sync() | spin_lock_irqsave() //(2)
(wait timer to stop) | ...We hold ieee->beacon_lock in position (1) of thread 1 and use del_timer_sync() to wait timer to stop, but timer handler also need ieee->beacon_lock in position (2) of thread 2. As a result, rtllib_beacons_stop() will block forever.
This patch extracts del_timer_sync() from the protection of spin_lock_irqsave(), which could let timer handler to obtain the needed lock.
--- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_softmac.c +1 -1
@@ -654,9 +654,9 @@ static void rtllib_beacons_stop(struct rtllib_device *ieee)spin_lock_irqsave (&ieee->beacon_lock, flags); ieee->beacon_txing =0 ; -del_timer_sync (&ieee->beacon_timer);spin_unlock_irqrestore (&ieee->beacon_lock, flags); +del_timer_sync (&ieee->beacon_timer); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 254/287 USB: host: isp116x: check return value after calling platform_get_resource()
In reply to Greg Kroah-HartmanFrom: Zhen Ni <[email protected]>
[ Upstream commit 134a3408c2d3f7e23eb0e4556e0a2d9f36c2614e ]
It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value.
--- drivers/usb/host/isp116x-hcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/host/isp116x-hcd.c +4 -2
@@ -1541,10 +1541,12 @@ static int isp116x_remove(struct platform_device *pdev)iounmap (isp116x->data_reg); res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -release_mem_region (res->start,2 ); +if (res) +release_mem_region (res->start,2 );iounmap (isp116x->addr_reg); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -release_mem_region (res->start,2 ); +if (res) +release_mem_region (res->start,2 );usb_put_hcd (hcd);return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 255/287 drivers: tty: serial: Fix deadlock in sa1100_set_termios()
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 62b2caef400c1738b6d22f636c628d9f85cd4c4c ]
There is a deadlock in sa1100_set_termios(), which is shown below:
(Thread 1) | (Thread 2)
| sa1100_enable_ms()
sa1100_set_termios() | mod_timer()
spin_lock_irqsave() //(1) | (wait a time)
... | sa1100_timeout()
del_timer_sync() | spin_lock_irqsave() //(2)
(wait timer to stop) | ...We hold sport->port.lock in position (1) of thread 1 and use del_timer_sync() to wait timer to stop, but timer handler also need sport->port.lock in position (2) of thread 2. As a result, sa1100_set_termios() will block forever.
This patch moves del_timer_sync() before spin_lock_irqsave() in order to prevent the deadlock.
--- drivers/tty/serial/sa1100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/sa1100.c +2 -2
@@ -439,6 +439,8 @@ sa1100_set_termios(struct uart_port *port, struct ktermios *termios, baud =uart_get_baud_rate (port, termios, old,0 , port->uartclk/16 ); quot =uart_get_divisor (port, baud); +del_timer_sync (&sport->timer); +spin_lock_irqsave (&sport->port.lock, flags); sport->port.read_status_mask &=UTSR0_TO_SM (UTSR0_TFS );
@@ -469,8 +471,6 @@ sa1100_set_termios(struct uart_port *port, struct ktermios *termios,UTSR1_TO_SM (UTSR1_ROR ); } -del_timer_sync (&sport->timer); -/* * Update the per-port timeout. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 256/287 drivers: usb: host: Fix deadlock in oxu_bus_suspend()
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 4d378f2ae58138d4c55684e1d274e7dd94aa6524 ]
There is a deadlock in oxu_bus_suspend(), which is shown below:
(Thread 1) | (Thread 2)
| timer_action()
oxu_bus_suspend() | mod_timer()
spin_lock_irq() //(1) | (wait a time)
... | oxu_watchdog()
del_timer_sync() | spin_lock_irq() //(2)
(wait timer to stop) | ...We hold oxu->lock in position (1) of thread 1, and use del_timer_sync() to wait timer to stop, but timer handler also need oxu->lock in position (2) of thread 2. As a result, oxu_bus_suspend() will block forever.
This patch extracts del_timer_sync() from the protection of spin_lock_irq(), which could let timer handler to obtain the needed lock.
--- drivers/usb/host/oxu210hp-hcd.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/oxu210hp-hcd.c +2 -0
@@ -3476,8 +3476,10 @@ static int oxu_bus_suspend(struct usb_hcd *hcd) } } +spin_unlock_irq (&oxu->lock);/* turn off now-idle HC */ del_timer_sync (&oxu->watchdog); +spin_lock_irq (&oxu->lock);ehci_halt (oxu); hcd->state =HC_STATE_SUSPENDED ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 257/287 USB: hcd-pci: Fully suspend across freeze/thaw cycle
In reply to Greg Kroah-HartmanFrom: Evan Green <[email protected]>
[ Upstream commit 63acaa8e9c65dc34dc249440216f8e977f5d2748 ]
The documentation for the freeze() method says that it "should quiesce the device so that it doesn't generate IRQs or DMA". The unspoken consequence of not doing this is that MSIs aimed at non-boot CPUs may get fully lost if they're sent during the period where the target CPU is offline.
The current callbacks for USB HCD do not fully quiesce interrupts, specifically on XHCI. Change to use the full suspend/resume flow for freeze/thaw to ensure interrupts are fully quiesced. This fixes issues where USB devices fail to thaw during hibernation because XHCI misses its interrupt and cannot recover.
--- drivers/usb/core/hcd-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/core/hcd-pci.c +2 -2
@@ -605,10 +605,10 @@ const struct dev_pm_ops usb_hcd_pci_pm_ops = { .suspend_noirq = hcd_pci_suspend_noirq, .resume_noirq = hcd_pci_resume_noirq, .resume = hcd_pci_resume, - .freeze = check_root_hub_suspended, + .freeze = hcd_pci_suspend, .freeze_noirq = check_root_hub_suspended, .thaw_noirq = NULL, - .thaw = NULL, + .thaw = hcd_pci_resume, .poweroff = hcd_pci_suspend, .poweroff_noirq = hcd_pci_suspend_noirq, .restore_noirq = hcd_pci_resume_noirq,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 258/287 usb: dwc2: gadget: dont reset gadgets driver->bus
In reply to Greg Kroah-HartmanFrom: Marek Szyprowski <[email protected]>
[ Upstream commit 3120aac6d0ecd9accf56894aeac0e265f74d3d5a ]
UDC driver should not touch gadget's driver internals, especially it should not reset driver->bus. This wasn't harmful so far, but since commit fc274c1e9973 ("USB: gadget: Add a new bus for gadgets") gadget subsystem got it's own bus and messing with ->bus triggers the following NULL pointer dereference:
dwc2 12480000.hsotg: bound driver g_ether
8<--- cut here ---
Unable to handle kernel NULL pointer dereference at virtual address 00000000 [00000000] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM Modules linked in: ... CPU: 0 PID: 620 Comm: modprobe Not tainted 5.18.0-rc5-next-20220504 #11862 Hardware name: Samsung Exynos (Flattened Device Tree) PC is at module_add_driver+0x44/0xe8 LR is at sysfs_do_create_link_sd+0x84/0xe0
...
Process modprobe (pid: 620, stack limit = 0x(ptrval))
...
module_add_driver from bus_add_driver+0xf4/0x1e4 bus_add_driver from driver_register+0x78/0x10c driver_register from usb_gadget_register_driver_owner+0x40/0xb4 usb_gadget_register_driver_owner from do_one_initcall+0x44/0x1e0 do_one_initcall from do_init_module+0x44/0x1c8 do_init_module from load_module+0x19b8/0x1b9c load_module from sys_finit_module+0xdc/0xfc sys_finit_module from ret_fast_syscall+0x0/0x54
Exception stack(0xf1771fa8 to 0xf1771ff0) ... dwc2 12480000.hsotg: new device is high-speed ---[ end trace 0000000000000000 ]---
Fix this by removing driver->bus entry reset.
--- drivers/usb/dwc2/gadget.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/dwc2/gadget.c +0 -1
@@ -4326,7 +4326,6 @@ static int dwc2_hsotg_udc_start(struct usb_gadget *gadget,WARN_ON (hsotg->driver); - driver->driver.bus =NULL ; hsotg->driver = driver; hsotg->gadget.dev.of_node = hsotg->dev->of_node; hsotg->gadget.speed =USB_SPEED_UNKNOWN ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 259/287 misc: rtsx: set NULL intfdata when probe fails
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit f861d36e021e1ac4a0a2a1f6411d623809975d63 ]
rtsx_usb_probe() doesn't call usb_set_intfdata() to null out the interface pointer when probe fails. This leaves a stale pointer. Noticed the missing usb_set_intfdata() while debugging an unrelated invalid DMA mapping problem.
Fix it with a call to usb_set_intfdata(..., NULL).
--- drivers/misc/cardreader/rtsx_usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/cardreader/rtsx_usb.c +1 -0
@@ -678,6 +678,7 @@ static int rtsx_usb_probe(struct usb_interface *intf,return 0 ; out_init_fail: +usb_set_intfdata (ucr->pusb_intf,NULL );usb_free_coherent (ucr->pusb_dev,IOBUF_SIZE , ucr->iobuf, ucr->iobuf_dma);return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 260/287 extcon: Modify extcon device to be created after driver data is set
In reply to Greg Kroah-HartmanFrom: bumwoo lee <[email protected]>
[ Upstream commit 5dcc2afe716d69f5112ce035cb14f007461ff189 ]
Currently, someone can invoke the sysfs such as state_show() intermittently before dev_set_drvdata() is done.
And it can be a cause of kernel Oops because of edev is Null at that time. So modified the driver registration to after setting drviver data.
- Oops's backtrace.
Backtrace:
[<c067865c>] (state_show) from [<c05222e8>] (dev_attr_show) [<c05222c0>] (dev_attr_show) from [<c02c66e0>] (sysfs_kf_seq_show) [<c02c6648>] (sysfs_kf_seq_show) from [<c02c496c>] (kernfs_seq_show) [<c02c4938>] (kernfs_seq_show) from [<c025e2a0>] (seq_read) [<c025e11c>] (seq_read) from [<c02c50a0>] (kernfs_fop_read) [<c02c5064>] (kernfs_fop_read) from [<c0231cac>] (__vfs_read) [<c0231c5c>] (__vfs_read) from [<c0231ee0>] (vfs_read) [<c0231e34>] (vfs_read) from [<c0232464>] (ksys_read) [<c02323f0>] (ksys_read) from [<c02324fc>] (sys_read) [<c02324e4>] (sys_read) from [<c00091d0>] (__sys_trace_return)
--- drivers/extcon/extcon.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/extcon/extcon.c +17 -12
@@ -1245,19 +1245,14 @@ int extcon_dev_register(struct extcon_dev *edev) edev->dev.type = &edev->extcon_dev_type; } - ret =device_register (&edev->dev); -if (ret) { -put_device (&edev->dev); - goto err_dev; - } -spin_lock_init (&edev->lock); - edev->nh =devm_kcalloc (&edev->dev, edev->max_supported, -sizeof (*edev->nh),GFP_KERNEL ); -if (!edev->nh) { - ret = -ENOMEM ; -device_unregister (&edev->dev); - goto err_dev; +if (edev->max_supported) { + edev->nh =kcalloc (edev->max_supported,sizeof (*edev->nh), +GFP_KERNEL ); +if (!edev->nh) { + ret = -ENOMEM ; + goto err_alloc_nh; + } }for (index =0 ; index < edev->max_supported; index++)
@@ -1268,6 +1263,12 @@ int extcon_dev_register(struct extcon_dev *edev)dev_set_drvdata (&edev->dev, edev); edev->state =0 ; + ret =device_register (&edev->dev); +if (ret) { +put_device (&edev->dev); + goto err_dev; + } +mutex_lock (&extcon_dev_list_lock);list_add (&edev->entry, &extcon_dev_list);mutex_unlock (&extcon_dev_list_lock);
@@ -1275,6 +1276,9 @@ int extcon_dev_register(struct extcon_dev *edev)return 0 ; err_dev: +if (edev->max_supported) +kfree (edev->nh); +err_alloc_nh:if (edev->max_supported)kfree (edev->extcon_dev_type.groups); err_alloc_groups:
@@ -1335,6 +1339,7 @@ void extcon_dev_unregister(struct extcon_dev *edev)if (edev->max_supported) {kfree (edev->extcon_dev_type.groups);kfree (edev->cables); +kfree (edev->nh); }put_device (&edev->dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 261/287 clocksource/drivers/sp804: Avoid error on multiple instances
In reply to Greg Kroah-HartmanFrom: Andre Przywara <[email protected]>
[ Upstream commit a98399cbc1e05f7b977419f03905501d566cf54e ]
When a machine sports more than one SP804 timer instance, we only bring up the first one, since multiple timers of the same kind are not useful to Linux. As this is intentional behaviour, we should not return an error message, as we do today:
===============
[ 0.000800] Failed to initialize '/bus@8000000/motherboard-bus@8000000/iofpga-bus@300000000/timer@120000': -22
===============
Replace the -EINVAL return with a debug message and return 0 instead.
Also we do not reach the init function anymore if the DT node is disabled (as this is now handled by OF_DECLARE), so remove the explicit check for that case.
This fixes a long standing bogus error when booting ARM's fastmodels.
--- drivers/clocksource/timer-sp804.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/clocksource/timer-sp804.c +5 -5
@@ -228,6 +228,11 @@ static int __init sp804_of_init(struct device_node *np)struct clk *clk1, *clk2;const char *name =of_get_property (np,"compatible" ,NULL ); +if (initialized) { +pr_debug ("%pOF: skipping further SP804 timer device\n" , np); +return 0 ; + } + base =of_iomap (np,0 );if (!base)return -ENXIO ;
@@ -236,11 +241,6 @@ static int __init sp804_of_init(struct device_node *np)writel (0 , base +TIMER_CTRL );writel (0 , base +TIMER_2_BASE +TIMER_CTRL ); -if (initialized || !of_device_is_available (np)) { - ret = -EINVAL ; - goto err; - } - clk1 =of_clk_get (np,0 );if (IS_ERR (clk1)) clk1 =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 262/287 staging: rtl8712: fix uninit-value in r871xu_drv_init()
In reply to Greg Kroah-HartmanFrom: Wang Cheng <[email protected]>
[ Upstream commit 0458e5428e5e959d201a40ffe71d762a79ecedc4 ]
When 'tmpU1b' returns from r8712_read8(padapter, EE_9346CR) is 0, 'mac[6]' will not be initialized.
BUG: KMSAN: uninit-value in r871xu_drv_init+0x2d54/0x3070 drivers/staging/rtl8712/usb_intf.c:541 r871xu_drv_init+0x2d54/0x3070 drivers/staging/rtl8712/usb_intf.c:541 usb_probe_interface+0xf19/0x1600 drivers/usb/core/driver.c:396 really_probe+0x653/0x14b0 drivers/base/dd.c:596 __driver_probe_device+0x3e9/0x530 drivers/base/dd.c:752 driver_probe_device drivers/base/dd.c:782 [inline] __device_attach_driver+0x79f/0x1120 drivers/base/dd.c:899 bus_for_each_drv+0x2d6/0x3f0 drivers/base/bus.c:427 __device_attach+0x593/0x8e0 drivers/base/dd.c:970 device_initial_probe+0x4a/0x60 drivers/base/dd.c:1017 bus_probe_device+0x17b/0x3e0 drivers/base/bus.c:487 device_add+0x1fff/0x26e0 drivers/base/core.c:3405 usb_set_configuration+0x37e9/0x3ed0 drivers/usb/core/message.c:2170 usb_generic_driver_probe+0x13c/0x300 drivers/usb/core/generic.c:238 usb_probe_device+0x309/0x570 drivers/usb/core/driver.c:293 really_probe+0x653/0x14b0 drivers/base/dd.c:596 __driver_probe_device+0x3e9/0x530 drivers/base/dd.c:752 driver_probe_device drivers/base/dd.c:782 [inline] __device_attach_driver+0x79f/0x1120 drivers/base/dd.c:899 bus_for_each_drv+0x2d6/0x3f0 drivers/base/bus.c:427 __device_attach+0x593/0x8e0 drivers/base/dd.c:970 device_initial_probe+0x4a/0x60 drivers/base/dd.c:1017 bus_probe_device+0x17b/0x3e0 drivers/base/bus.c:487 device_add+0x1fff/0x26e0 drivers/base/core.c:3405 usb_new_device+0x1b8e/0x2950 drivers/usb/core/hub.c:2566 hub_port_connect drivers/usb/core/hub.c:5358 [inline] hub_port_connect_change drivers/usb/core/hub.c:5502 [inline] port_event drivers/usb/core/hub.c:5660 [inline] hub_event+0x58e3/0x89e0 drivers/usb/core/hub.c:5742 process_one_work+0xdb6/0x1820 kernel/workqueue.c:2307 worker_thread+0x10b3/0x21e0 kernel/workqueue.c:2454 kthread+0x3c7/0x500 kernel/kthread.c:377 ret_from_fork+0x1f/0x30
Local variable mac created at:
r871xu_drv_init+0x1771/0x3070 drivers/staging/rtl8712/usb_intf.c:394 usb_probe_interface+0xf19/0x1600 drivers/usb/core/driver.c:396
KMSAN: uninit-value in r871xu_drv_init
https://syzkaller.appspot.com/bug?id=3cd92b1d85428b128503bfa7a250294c9ae00bd8
--- drivers/staging/rtl8712/usb_intf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rtl8712/usb_intf.c +3 -3
@@ -569,13 +569,13 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, }else { AutoloadFail = false; } -if (((mac[0 ] ==0xff ) && (mac[1 ] ==0xff ) && +if ((!AutoloadFail) || + ((mac[0 ] ==0xff ) && (mac[1 ] ==0xff ) && (mac[2 ] ==0xff ) && (mac[3 ] ==0xff ) && (mac[4 ] ==0xff ) && (mac[5 ] ==0xff )) || ((mac[0 ] ==0x00 ) && (mac[1 ] ==0x00 ) && (mac[2 ] ==0x00 ) && (mac[3 ] ==0x00 ) && - (mac[4 ] ==0x00 ) && (mac[5 ] ==0x00 )) || - (!AutoloadFail)) { + (mac[4 ] ==0x00 ) && (mac[5 ] ==0x00 ))) { mac[0 ] =0x00 ; mac[1 ] =0xe0 ; mac[2 ] =0x4c ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 263/287 serial: msm_serial: disable interrupts in __msm_console_write()
In reply to Greg Kroah-HartmanFrom: John Ogness <[email protected]>
[ Upstream commit aabdbb1b7a5819e18c403334a31fb0cc2c06ad41 ]
__msm_console_write() assumes that interrupts are disabled, but with threaded console printers it is possible that the write() callback of the console is called with interrupts enabled.
Explicitly disable interrupts using local_irq_save() to preserve the assumed context.
--- drivers/tty/serial/msm_serial.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/serial/msm_serial.c +5 -0
@@ -1579,6 +1579,7 @@ static inline struct uart_port *msm_get_port_from_line(unsigned int line)static void __msm_console_write (struct uart_port *port,const char *s,unsigned int count,bool is_uartdm) { +unsigned long flags;int i;int num_newlines =0 ;bool replaced = false;
@@ -1596,6 +1597,8 @@ static void __msm_console_write(struct uart_port *port, const char *s, num_newlines++; count += num_newlines; +local_irq_save (flags); +if (port->sysrq) locked =0 ;else if (oops_in_progress)
@@ -1641,6 +1644,8 @@ static void __msm_console_write(struct uart_port *port, const char *s,if (locked)spin_unlock (&port->lock); + +local_irq_restore (flags); } static void msm_console_write(struct console *co, const char *s,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 264/287 kernfs: Separate kernfs_pr_cont_buf and rename_lock.
In reply to Greg Kroah-HartmanFrom: Hao Luo <[email protected]>
[ Upstream commit 1a702dc88e150487c9c173a249b3d236498b9183 ]
Previously the protection of kernfs_pr_cont_buf was piggy backed by rename_lock, which means that pr_cont() needs to be protected under rename_lock. This can cause potential circular lock dependencies.
If there is an OOM, we have the following call hierarchy:
-> cpuset_print_current_mems_allowed()
-> pr_cont_cgroup_name()
-> pr_cont_kernfs_name()
pr_cont_kernfs_name() will grab rename_lock and call printk. So we have the following lock dependencies:
kernfs_rename_lock -> console_sem
Sometimes, printk does a wakeup before releasing console_sem, which has the dependence chain:
console_sem -> p->pi_lock -> rq->lock
Now, imagine one wants to read cgroup_name under rq->lock, for example, printing cgroup_name in a tracepoint in the scheduler code. They will be holding rq->lock and take rename_lock:
rq->lock -> kernfs_rename_lock
Now they will deadlock.
A prevention to this circular lock dependency is to separate the protection of pr_cont_buf from rename_lock. In principle, rename_lock is to protect the integrity of cgroup name when copying to buf. Once pr_cont_buf has got its content, rename_lock can be dropped. So it's safe to drop rename_lock after kernfs_name_locked (and kernfs_path_from_node_locked) and rely on a dedicated pr_cont_lock to protect pr_cont_buf.
--- fs/kernfs/dir.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
fs/kernfs/dir.c +19 -12
@@ -20,7 +20,15 @@DEFINE_MUTEX (kernfs_mutex);static DEFINE_SPINLOCK (kernfs_rename_lock);/* kn->parent and ->name */ -static char kernfs_pr_cont_buf[PATH_MAX ];/* protected by rename_lock */ +/* +* Don't use rename_lock to piggy back on pr_cont_buf. We don't want to +* call pr_cont() while holding rename_lock. Because sometimes pr_cont() +* will perform wakeups when releasing console_sem. Holding rename_lock +* will introduce deadlock if the scheduler reads the kernfs_name in the +* wakeup path. +*/ +static DEFINE_SPINLOCK (kernfs_pr_cont_lock); +static char kernfs_pr_cont_buf[PATH_MAX ];/* protected by pr_cont_lock */ static DEFINE_SPINLOCK (kernfs_idr_lock);/* root->ino_idr */ #define rb_to_kn (X ) rb_entry((X), struct kernfs_node, rb)
@@ -229,12 +237,12 @@ void pr_cont_kernfs_name(struct kernfs_node *kn) {unsigned long flags; -spin_lock_irqsave (&kernfs_rename_lock, flags); +spin_lock_irqsave (&kernfs_pr_cont_lock, flags); -kernfs_name_locked (kn, kernfs_pr_cont_buf,sizeof (kernfs_pr_cont_buf)); +kernfs_name (kn, kernfs_pr_cont_buf,sizeof (kernfs_pr_cont_buf));pr_cont ("%s" , kernfs_pr_cont_buf); -spin_unlock_irqrestore (&kernfs_rename_lock, flags); +spin_unlock_irqrestore (&kernfs_pr_cont_lock, flags); }/**
@@ -248,10 +256,10 @@ void pr_cont_kernfs_path(struct kernfs_node *kn)unsigned long flags;int sz; -spin_lock_irqsave (&kernfs_rename_lock, flags); +spin_lock_irqsave (&kernfs_pr_cont_lock, flags); - sz =kernfs_path_from_node_locked (kn,NULL , kernfs_pr_cont_buf, -sizeof (kernfs_pr_cont_buf)); + sz =kernfs_path_from_node (kn,NULL , kernfs_pr_cont_buf, +sizeof (kernfs_pr_cont_buf));if (sz <0 ) {pr_cont ("(error)" ); goto out;
@@ -265,7 +273,7 @@ void pr_cont_kernfs_path(struct kernfs_node *kn)pr_cont ("%s" , kernfs_pr_cont_buf); out: -spin_unlock_irqrestore (&kernfs_rename_lock, flags); +spin_unlock_irqrestore (&kernfs_pr_cont_lock, flags); }/**
@@ -867,13 +875,12 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent,lockdep_assert_held (&kernfs_mutex); -/* grab kernfs_rename_lock to piggy back on kernfs_pr_cont_buf */ -spin_lock_irq (&kernfs_rename_lock); +spin_lock_irq (&kernfs_pr_cont_lock); len =strlcpy (kernfs_pr_cont_buf, path,sizeof (kernfs_pr_cont_buf));if (len >=sizeof (kernfs_pr_cont_buf)) { -spin_unlock_irq (&kernfs_rename_lock); +spin_unlock_irq (&kernfs_pr_cont_lock);return NULL ; }
@@ -885,7 +892,7 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent, parent =kernfs_find_ns (parent, name, ns); } -spin_unlock_irq (&kernfs_rename_lock); +spin_unlock_irq (&kernfs_pr_cont_lock);return parent; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 265/287 md: protect md_unregister_thread from reentrancy
In reply to Greg Kroah-HartmanFrom: Guoqing Jiang <[email protected]>
[ Upstream commit 1e267742283a4b5a8ca65755c44166be27e9aa0f ]
Generally, the md_unregister_thread is called with reconfig_mutex, but raid_message in dm-raid doesn't hold reconfig_mutex to unregister thread, so md_unregister_thread can be called simulitaneously from two call sites in theory.
Then after previous commit which remove the protection of reconfig_mutex for md_unregister_thread completely, the potential issue could be worse than before.
Let's take pers_lock at the beginning of function to ensure reentrancy.
--- drivers/md/md.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/md/md.c +10 -5
@@ -7620,17 +7620,22 @@ EXPORT_SYMBOL(md_register_thread);void md_unregister_thread (struct md_thread **threadp) { -struct md_thread *thread = *threadp; -if (!thread) -return ; -pr_debug ("interrupting MD-thread pid %d\n" ,task_pid_nr (thread->tsk)); -/* Locking ensures that mddev_unlock does not wake_up a +struct md_thread *thread; + +/* +* Locking ensures that mddev_unlock does not wake_up a * non-existent thread */ spin_lock (&pers_lock); + thread = *threadp; +if (!thread) { +spin_unlock (&pers_lock); +return ; + } *threadp =NULL ;spin_unlock (&pers_lock); +pr_debug ("interrupting MD-thread pid %d\n" ,task_pid_nr (thread->tsk));kthread_stop (thread->tsk);kfree (thread); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 266/287 Revert "net: af_key: add check for pfkey_broadcast in function pfkey_process"
In reply to Greg Kroah-HartmanFrom: Michal Kubecek <[email protected]>
[ Upstream commit 9c90c9b3e50e16d03c7f87d63e9db373974781e0 ]
This reverts commit 4dc2a5a8f6754492180741facf2a8787f2c415d7.
A non-zero return value from pfkey_broadcast() does not necessarily mean an error occurred as this function returns -ESRCH when no registered listener received the message. In particular, a call with BROADCAST_PROMISC_ONLY flag and null one_sk argument can never return zero so that this commit in fact prevents processing any PF_KEY message. One visible effect is that racoon daemon fails to find encryption algorithms like aes and refuses to start.
Excluding -ESRCH return value would fix this but it's not obvious that we really want to bail out here and most other callers of pfkey_broadcast() also ignore the return value. Also, as pointed out by Steffen Klassert, PF_KEY is kind of deprecated and newer userspace code should use netlink instead so that we should only disturb the code for really important fixes.
v2: add a comment explaining why is the return value ignored
--- net/key/af_key.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/key/af_key.c +6 -4
@@ -2836,10 +2836,12 @@ static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadbvoid *ext_hdrs[SADB_EXT_MAX ];int err; - err =pfkey_broadcast (skb_clone (skb,GFP_KERNEL ),GFP_KERNEL , -BROADCAST_PROMISC_ONLY ,NULL ,sock_net (sk)); -if (err) -return err; +/* Non-zero return value of pfkey_broadcast() does not always signal +* an error and even on an actual error we may still want to process +* the message so rather ignore the return value. +*/ +pfkey_broadcast (skb_clone (skb,GFP_KERNEL ),GFP_KERNEL , +BROADCAST_PROMISC_ONLY ,NULL ,sock_net (sk));memset (ext_hdrs,0 ,sizeof (ext_hdrs)); err =parse_exthdrs (skb, hdr, ext_hdrs);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 267/287 ceph: allow ceph.dir.rctime xattr to be updatable
In reply to Greg Kroah-HartmanFrom: Venky Shankar <[email protected]>
[ Upstream commit d7a2dc523085f8b8c60548ceedc696934aefeb0e ]
`rctime' has been a pain point in cephfs due to its buggy nature - inconsistent values reported and those sorts. Fixing rctime is non-trivial needing an overall redesign of the entire nested statistics infrastructure.
As a workaround, PR
http://github.com/ceph/ceph/pull/37938
allows this extended attribute to be manually set. This allows users to "fixup" inconsistent rctime values. While this sounds messy, its probably the wisest approach allowing users/scripts to workaround buggy rctime values.
The above PR enables Ceph MDS to allow manually setting rctime extended attribute with the corresponding user-land changes. We may as well allow the same to be done via kclient for parity.
--- fs/ceph/xattr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/ceph/xattr.c +9 -1
@@ -273,6 +273,14 @@ static size_t ceph_vxattrcb_quota_max_files(struct ceph_inode_info *ci, }#define XATTR_RSTAT_FIELD (_type, _name) \ XATTR_NAME_CEPH(_type, _name, VXATTR_FLAG_RSTAT) +#define XATTR_RSTAT_FIELD_UPDATABLE (_type, _name) \ + { \ + .name = CEPH_XATTR_NAME(_type, _name), \ + .name_size = sizeof (CEPH_XATTR_NAME(_type, _name)), \ + .getxattr_cb = ceph_vxattrcb_ ## _type ## _ ## _name, \ + .exists_cb = NULL, \ + .flags = VXATTR_FLAG_RSTAT, \ + }#define XATTR_LAYOUT_FIELD (_type, _name, _field) \ { \ .name = CEPH_XATTR_NAME2(_type, _name, _field), \
@@ -310,7 +318,7 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = {XATTR_RSTAT_FIELD (dir, rfiles),XATTR_RSTAT_FIELD (dir, rsubdirs),XATTR_RSTAT_FIELD (dir, rbytes), - XATTR_RSTAT_FIELD(dir, rctime), + XATTR_RSTAT_FIELD_UPDATABLE(dir, rctime), { .name ="ceph.quota" , .name_size = sizeof("ceph.quota"),
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 268/287 drm/radeon: fix a possible null pointer dereference
In reply to Greg Kroah-HartmanFrom: Gong Yuanjun <[email protected]>
[ Upstream commit a2b28708b645c5632dc93669ab06e97874c8244f ]
In radeon_fp_native_mode(), the return value of drm_mode_duplicate() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_mode_duplicate(). Add a check to avoid npd.
The failure status of drm_cvt_mode() on the other path is checked too.
--- drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/radeon/radeon_connectors.c +4 -0
@@ -476,6 +476,8 @@ static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encode native_mode->vdisplay != 0 && native_mode->clock != 0) { mode =drm_mode_duplicate (dev, native_mode); +if (!mode) +return NULL ; mode->type =DRM_MODE_TYPE_PREFERRED |DRM_MODE_TYPE_DRIVER ;drm_mode_set_name (mode);
@@ -490,6 +492,8 @@ static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encode* simpler. */ mode =drm_cvt_mode (dev, native_mode->hdisplay, native_mode->vdisplay,60 , true, false, false); +if (!mode) +return NULL ; mode->type =DRM_MODE_TYPE_PREFERRED |DRM_MODE_TYPE_DRIVER ;DRM_DEBUG_KMS ("Adding cvt approximation of native panel mode %s\n" , mode->name); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 269/287 modpost: fix undefined behavior of is_arm_mapping_symbol()
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit d6b732666a1bae0df3c3ae06925043bba34502b1 ]
The return value of is_arm_mapping_symbol() is unpredictable when "$" is passed in.
strchr(3) says:
The strchr() and strrchr() functions return a pointer to the matched character or NULL if the character is not found. The terminating null byte is considered part of the string, so that if c is specified as '\0', these functions return a pointer to the terminator.
When str[1] is '\0', strchr("axtd", str[1]) is not NULL, and str[2] is referenced (i.e. buffer overrun).
Test code
---------
char str1[] = "abc";
char str2[] = "ab";
strcpy(str1, "$");
strcpy(str2, "$");
printf("test1: %d\n", is_arm_mapping_symbol(str1));
printf("test2: %d\n", is_arm_mapping_symbol(str2));Result
------
test1: 0
test2: 1
--- scripts/mod/modpost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/mod/modpost.c +2 -1
@@ -1218,7 +1218,8 @@ static int secref_whitelist(const struct sectioncheck *mismatch,static inline int is_arm_mapping_symbol (const char *str) { -return str[0 ] =='$' &&strchr ("axtd" , str[1 ]) +return str[0 ] =='$' && + (str[1 ] =='a' || str[1 ] =='d' || str[1 ] =='t' || str[1 ] =='x' ) && (str[2 ] =='\0' || str[2 ] =='.' ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 270/287 nbd: call genl_unregister_family() first in nbd_cleanup()
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit 06c4da89c24e7023ea448cadf8e9daf06a0aae6e ]
Otherwise there may be race between module removal and the handling of netlink command, which can lead to the oops as shown below:
BUG: kernel NULL pointer dereference, address: 0000000000000098 Oops: 0002 [#1] SMP PTI CPU: 1 PID: 31299 Comm: nbd-client Tainted: G E 5.14.0-rc4 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) RIP: 0010:down_write+0x1a/0x50 Call Trace: start_creating+0x89/0x130 debugfs_create_dir+0x1b/0x130 nbd_start_device+0x13d/0x390 [nbd] nbd_genl_connect+0x42f/0x748 [nbd] genl_family_rcv_msg_doit.isra.0+0xec/0x150 genl_rcv_msg+0xe5/0x1e0 netlink_rcv_skb+0x55/0x100 genl_rcv+0x29/0x40 netlink_unicast+0x1a8/0x250 netlink_sendmsg+0x21b/0x430 ____sys_sendmsg+0x2a4/0x2d0 ___sys_sendmsg+0x81/0xc0 __sys_sendmsg+0x62/0xb0 __x64_sys_sendmsg+0x1f/0x30 do_syscall_64+0x3b/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae Modules linked in: nbd(E-)
--- drivers/block/nbd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/block/nbd.c +6 -1
@@ -2337,6 +2337,12 @@ static void __exit nbd_cleanup(void)struct nbd_device *nbd;LIST_HEAD (del_list); +/* +* Unregister netlink interface prior to waiting +* for the completion of netlink commands. +*/ +genl_unregister_family (&nbd_genl_family); +nbd_dbg_close ();mutex_lock (&nbd_index_mutex);
@@ -2352,7 +2358,6 @@ static void __exit nbd_cleanup(void) }idr_destroy (&nbd_index_idr); -genl_unregister_family (&nbd_genl_family);unregister_blkdev (NBD_MAJOR ,"nbd" ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 271/287 nbd: fix race between nbd_alloc_config() and module removal
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit c55b2b983b0fa012942c3eb16384b2b722caa810 ]
When nbd module is being removing, nbd_alloc_config() may be called concurrently by nbd_genl_connect(), although try_module_get() will return false, but nbd_alloc_config() doesn't handle it.
The race may lead to the leak of nbd_config and its related resources (e.g, recv_workq) and oops in nbd_read_stat() due to the unload of nbd module as shown below:
BUG: kernel NULL pointer dereference, address: 0000000000000040 Oops: 0000 [#1] SMP PTI CPU: 5 PID: 13840 Comm: kworker/u17:33 Not tainted 5.14.0+ #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) Workqueue: knbd16-recv recv_work [nbd] RIP: 0010:nbd_read_stat.cold+0x130/0x1a4 [nbd] Call Trace: recv_work+0x3b/0xb0 [nbd] process_one_work+0x1ed/0x390 worker_thread+0x4a/0x3d0 kthread+0x12a/0x150 ret_from_fork+0x22/0x30
Fixing it by checking the return value of try_module_get()
in nbd_alloc_config(). As nbd_alloc_config() may return ERR_PTR(-ENODEV), assign nbd->config only when nbd_alloc_config() succeeds to ensure the value of nbd->config is binary (valid or NULL).
Also adding a debug message to check the reference counter of nbd_config during module removal.
--- drivers/block/nbd.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/block/nbd.c +19 -9
@@ -1395,15 +1395,20 @@ static struct nbd_config *nbd_alloc_config(void) {struct nbd_config *config; +if (!try_module_get (THIS_MODULE )) +return ERR_PTR (-ENODEV ); + config =kzalloc (sizeof (struct nbd_config ),GFP_NOFS ); -if (!config) -return NULL ; +if (!config) { +module_put (THIS_MODULE ); +return ERR_PTR (-ENOMEM ); + } +atomic_set (&config->recv_threads,0 );init_waitqueue_head (&config->recv_wq);init_waitqueue_head (&config->conn_wait); config->blksize =NBD_DEF_BLKSIZE ;atomic_set (&config->live_connections,0 ); -try_module_get (THIS_MODULE );return config; }
@@ -1430,12 +1435,13 @@ static int nbd_open(struct block_device *bdev, fmode_t mode)mutex_unlock (&nbd->config_lock); goto out; } - config = nbd->config =nbd_alloc_config (); -if (!config) { - ret = -ENOMEM ; + config =nbd_alloc_config (); +if (IS_ERR (config)) { + ret =PTR_ERR (config);mutex_unlock (&nbd->config_lock); goto out; } + nbd->config = config;refcount_set (&nbd->config_refs,1 );refcount_inc (&nbd->refs);mutex_unlock (&nbd->config_lock);
@@ -1820,13 +1826,14 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)nbd_put (nbd);return -EINVAL ; } - config = nbd->config =nbd_alloc_config (); -if (!nbd->config) { + config =nbd_alloc_config (); +if (IS_ERR (config)) {mutex_unlock (&nbd->config_lock);nbd_put (nbd);printk (KERN_ERR "nbd: couldn't allocate config\n" ); -return -ENOMEM ; +return PTR_ERR (config); } + nbd->config = config;refcount_set (&nbd->config_refs,1 );set_bit (NBD_BOUND , &config->runtime_flags);
@@ -2352,6 +2359,9 @@ static void __exit nbd_cleanup(void)while (!list_empty (&del_list)) { nbd = list_first_entry(&del_list, struct nbd_device, list);list_del_init (&nbd->list); +if (refcount_read (&nbd->config_refs)) +printk (KERN_ERR "nbd: possibly leaking nbd_config (ref %d)\n" , +refcount_read (&nbd->config_refs));if (refcount_read (&nbd->refs) !=1 )printk (KERN_ERR "nbd: possibly leaking a device\n" );nbd_put (nbd);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 272/287 nbd: fix io hung while disconnecting device
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit 09dadb5985023e27d4740ebd17e6fea4640110e5 ]
In our tests, "qemu-nbd" triggers a io hung:
INFO: task qemu-nbd:11445 blocked for more than 368 seconds.
Not tainted 5.18.0-rc3-next-20220422-00003-g2176915513ca #884
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:qemu-nbd state:D stack: 0 pid:11445 ppid: 1 flags:0x00000000
Call Trace:
<TASK>
__schedule+0x480/0x1050
? _raw_spin_lock_irqsave+0x3e/0xb0
schedule+0x9c/0x1b0
blk_mq_freeze_queue_wait+0x9d/0xf0
? ipi_rseq+0x70/0x70
blk_mq_freeze_queue+0x2b/0x40
nbd_add_socket+0x6b/0x270 [nbd]
nbd_ioctl+0x383/0x510 [nbd]
blkdev_ioctl+0x18e/0x3e0
__x64_sys_ioctl+0xac/0x120
do_syscall_64+0x35/0x80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fd8ff706577
RSP: 002b:00007fd8fcdfebf8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000040000000 RCX: 00007fd8ff706577
RDX: 000000000000000d RSI: 000000000000ab00 RDI: 000000000000000f
RBP: 000000000000000f R08: 000000000000fbe8 R09: 000055fe497c62b0
R10: 00000002aff20000 R11: 0000000000000246 R12: 000000000000006d
R13: 0000000000000000 R14: 00007ffe82dc5e70 R15: 00007fd8fcdff9c0"qemu-ndb -d" will call ioctl 'NBD_DISCONNECT' first, however, following message was found:
block nbd0: Send disconnect failed -32
Which indicate that something is wrong with the server. Then, "qemu-nbd -d" will call ioctl 'NBD_CLEAR_SOCK', however ioctl can't clear requests after commit 2516ab1543fd("nbd: only clear the queue on device teardown"). And in the meantime, request can't complete through timeout because nbd_xmit_timeout() will always return 'BLK_EH_RESET_TIMER', which means such request will never be completed in this situation.
Now that the flag 'NBD_CMD_INFLIGHT' can make sure requests won't complete multiple times, switch back to call nbd_clear_sock() in nbd_clear_sock_ioctl(), so that inflight requests can be cleared.
--- drivers/block/nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
@@ -1288,7 +1288,7 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *bstatic void nbd_clear_sock_ioctl (struct nbd_device *nbd,struct block_device *bdev) { -sock_shutdown (nbd); +nbd_clear_sock (nbd);__invalidate_device (bdev, true);nbd_bdev_reset (bdev); if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 273/287 nodemask: Fix return values to be unsigned
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 0dfe54071d7c828a02917b595456bfde1afdddc9 ]
The nodemask routines had mixed return values that provided potentially signed return values that could never happen. This was leading to the compiler getting confusing about the range of possible return values (it was thinking things could be negative where they could not be). Fix all the nodemask routines that should be returning unsigned (or bool) values. Silences:
mm/swapfile.c: In function ‘setup_swap_info’:
mm/swapfile.c:2291:47: error: array subscript -1 is below array bounds of ‘struct plist_node[]’ [-Werror=array-bounds]
2291 | p->avail_lists[i].prio = 1;
| ~~~~~~~~~~~~~~^~~
In file included from mm/swapfile.c:16:
./include/linux/swap.h:292:27: note: while referencing ‘avail_lists’
292 | struct plist_node avail_lists[]; /*
| ^~~~~~~~~~~--- include/linux/nodemask.h | 38 +++++++++++++++++++------------------- lib/nodemask.c | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-)
include/linux/nodemask.h +19 -19
@@ -42,11 +42,11 @@* void nodes_shift_right(dst, src, n) Shift right * void nodes_shift_left(dst, src, n) Shift left * -* int first_node(mask) Number lowest set bit, or MAX_NUMNODES -* int next_node(node, mask) Next node past 'node', or MAX_NUMNODES -* int next_node_in(node, mask) Next node past 'node', or wrap to first, +* unsigned int first_node(mask) Number lowest set bit, or MAX_NUMNODES +* unsigend int next_node(node, mask) Next node past 'node', or MAX_NUMNODES +* unsigned int next_node_in(node, mask) Next node past 'node', or wrap to first, * or MAX_NUMNODES -* int first_unset_node(mask) First node not set in mask, or +* unsigned int first_unset_node(mask) First node not set in mask, or * MAX_NUMNODES * * nodemask_t nodemask_of_node(node) Return nodemask with bit 'node' set
@@ -153,7 +153,7 @@ static inline void __nodes_clear(nodemask_t *dstp, unsigned int nbits)#define node_test_and_set (node, nodemask) \ __node_test_and_set((node), &(nodemask)) -static inline int __node_test_and_set (int node,nodemask_t *addr) +static inline bool __node_test_and_set (int node,nodemask_t *addr) {return test_and_set_bit (node, addr->bits); }
@@ -200,7 +200,7 @@ static inline void __nodes_complement(nodemask_t *dstp,#define nodes_equal (src1, src2) \ __nodes_equal(&(src1), &(src2), MAX_NUMNODES) -static inline int __nodes_equal (const nodemask_t *src1p, +static inline bool __nodes_equal (const nodemask_t *src1p,const nodemask_t *src2p,unsigned int nbits) {return bitmap_equal (src1p->bits, src2p->bits, nbits);
@@ -208,7 +208,7 @@ static inline int __nodes_equal(const nodemask_t *src1p,#define nodes_intersects (src1, src2) \ __nodes_intersects(&(src1), &(src2), MAX_NUMNODES) -static inline int __nodes_intersects (const nodemask_t *src1p, +static inline bool __nodes_intersects (const nodemask_t *src1p,const nodemask_t *src2p,unsigned int nbits) {return bitmap_intersects (src1p->bits, src2p->bits, nbits);
@@ -216,20 +216,20 @@ static inline int __nodes_intersects(const nodemask_t *src1p,#define nodes_subset (src1, src2) \ __nodes_subset(&(src1), &(src2), MAX_NUMNODES) -static inline int __nodes_subset (const nodemask_t *src1p, +static inline bool __nodes_subset (const nodemask_t *src1p,const nodemask_t *src2p,unsigned int nbits) {return bitmap_subset (src1p->bits, src2p->bits, nbits); }#define nodes_empty (src) __nodes_empty(&(src), MAX_NUMNODES) -static inline int __nodes_empty (const nodemask_t *srcp,unsigned int nbits) +static inline bool __nodes_empty (const nodemask_t *srcp,unsigned int nbits) {return bitmap_empty (srcp->bits, nbits); }#define nodes_full (nodemask) __nodes_full(&(nodemask), MAX_NUMNODES) -static inline int __nodes_full (const nodemask_t *srcp,unsigned int nbits) +static inline bool __nodes_full (const nodemask_t *srcp,unsigned int nbits) {return bitmap_full (srcp->bits, nbits); }
@@ -260,15 +260,15 @@ static inline void __nodes_shift_left(nodemask_t *dstp,> MAX_NUMNODES, then the silly min_ts could be dropped. */ #define first_node (src) __first_node(&(src)) -static inline int __first_node (const nodemask_t *srcp) +static inline unsigned int __first_node (const nodemask_t *srcp) { -return min_t (int,MAX_NUMNODES ,find_first_bit (srcp->bits,MAX_NUMNODES )); + return min_t(unsigned int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES)); }#define next_node (n, src) __next_node((n), &(src)) -static inline int __next_node (int n,const nodemask_t *srcp) +static inline unsigned int __next_node (int n,const nodemask_t *srcp) { -return min_t (int,MAX_NUMNODES ,find_next_bit (srcp->bits,MAX_NUMNODES , n+1 )); + return min_t(unsigned int, MAX_NUMNODES, find_next_bit(srcp->bits, MAX_NUMNODES, n+1)); }/*
@@ -276,7 +276,7 @@ static inline int __next_node(int n, const nodemask_t *srcp)* the first node in src if needed. Returns MAX_NUMNODES if src is empty. */ #define next_node_in (n, src) __next_node_in((n), &(src)) -int __next_node_in (int node,const nodemask_t *srcp); +unsigned int __next_node_in (int node,const nodemask_t *srcp);static inline void init_nodemask_of_node (nodemask_t *mask,int node) {
@@ -296,9 +296,9 @@ static inline void init_nodemask_of_node(nodemask_t *mask, int node) })#define first_unset_node (mask) __first_unset_node(&(mask)) -static inline int __first_unset_node (const nodemask_t *maskp) +static inline unsigned int __first_unset_node (const nodemask_t *maskp) { -return min_t (int,MAX_NUMNODES , + return min_t(unsigned int, MAX_NUMNODES,find_first_zero_bit (maskp->bits,MAX_NUMNODES )); }
@@ -434,11 +434,11 @@ static inline int num_node_state(enum node_states state)#define first_online_node first_node(node_states[N_ONLINE])#define first_memory_node first_node(node_states[N_MEMORY]) -static inline int next_online_node (int nid) +static inline unsigned int next_online_node (int nid) {return next_node (nid, node_states[N_ONLINE ]); } -static inline int next_memory_node (int nid) +static inline unsigned int next_memory_node (int nid) {return next_node (nid, node_states[N_MEMORY ]); }
lib/nodemask.c +2 -2
@@ -3,9 +3,9 @@#include <linux/module.h> #include <linux/random.h> -int __next_node_in (int node,const nodemask_t *srcp) +unsigned int __next_node_in (int node,const nodemask_t *srcp) { -int ret =__next_node (node, srcp); +unsigned int ret =__next_node (node, srcp);if (ret ==MAX_NUMNODES ) ret =__first_node (srcp);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 274/287 vringh: Fix loop descriptors check in the indirect cases
In reply to Greg Kroah-HartmanFrom: Xie Yongji <[email protected]>
[ Upstream commit dbd29e0752286af74243cf891accf472b2f3edd8 ]
We should use size of descriptor chain to test loop condition in the indirect case. And another statistical count is also introduced for indirect descriptors to avoid conflict with the statistical count of direct descriptors.
Message-Id: <[email protected]>
--- drivers/vhost/vringh.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/vhost/vringh.c +8 -2
@@ -263,7 +263,7 @@ __vringh_iov(struct vringh *vrh, u16 i,gfp_t gfp, int (*copy)(void *dst, const void *src, size_t len)) { - int err, count = 0, up_next, desc_max; + int err, count = 0, indirect_count = 0, up_next, desc_max;struct vring_desc desc, *descs;struct vringh_range range = {-1ULL ,0 }, slowrange;bool slow = false;
@@ -320,7 +320,12 @@ __vringh_iov(struct vringh *vrh, u16 i,continue ; } -if (count++ == vrh->vring.num) { +if (up_next ==-1 ) + count++; +else + indirect_count++; + +if (count > vrh->vring.num || indirect_count > desc_max) {vringh_bad ("Descriptor loop in %p" , descs); err = -ELOOP ; goto fail;
@@ -382,6 +387,7 @@ __vringh_iov(struct vringh *vrh, u16 i, i =return_from_indirect (vrh, &up_next, &descs, &desc_max); slow = false; + indirect_count =0 ; }else break ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 275/287 ALSA: hda/conexant - Fix loopback issue with CX20632
In reply to Greg Kroah-HartmanFrom: huangwenhui <[email protected]>
commit d5ea7544c32ba27c2c5826248e4ff58bd50a2518 upstream.
On a machine with CX20632, Alsamixer doesn't have 'Loopback Mixing' and 'Line'.
--- sound/pci/hda/patch_conexant.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/pci/hda/patch_conexant.c +7 -0
@@ -1025,6 +1025,13 @@ static int patch_conexant_auto(struct hdsnd_hda_pick_fixup (codec, cxt5051_fixup_models, cxt5051_fixups, cxt_fixups);break ; +case 0x14f15098 : + codec->pin_amp_workaround =1 ; + spec->gen.mixer_nid =0x22 ; + spec->gen.add_stereo_mix_input =HDA_HINT_STEREO_MIX_AUTO ; +snd_hda_pick_fixup (codec, cxt5066_fixup_models, + cxt5066_fixups, cxt_fixups); +break ;case 0x14f150f2 : codec->power_save_node =1 ;/* Fall through */
Greg Kroah-Hartman
maintainerPATCH 276/287 cifs: return errors during session setup during reconnects
In reply to Greg Kroah-HartmanFrom: Shyam Prasad N <[email protected]>
commit 8ea21823aa584b55ba4b861307093b78054b0c1b upstream.
During reconnects, we check the return value from cifs_negotiate_protocol, and have handlers for both success and failures. But if that passes, and cifs_setup_session returns any errors other than -EACCES, we do not handle that. This fix adds a handler for that, so that we don't go ahead and try a tree_connect on a failed session.
--- fs/cifs/smb2pdu.c | 3 +++ 1 file changed, 3 insertions(+)
fs/cifs/smb2pdu.c +3 -0
@@ -265,6 +265,9 @@ smb2_reconnect(__le16 smb2_command, stru rc = -EHOSTDOWN ;mutex_unlock (&tcon->ses->session_mutex); goto failed; + }else if (rc) { +mutex_unlock (&ses->session_mutex); + goto out; } }if (rc || !tcon->need_reconnect) {
Greg Kroah-Hartman
maintainerPATCH 277/287 ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
commit 72aad489f992871e908ff6d9055b26c6366fb864 upstream.
The {dma|pio}_mode sysfs files are incorrectly documented as having a list of the supported DMA/PIO transfer modes, while the corresponding fields of the *struct* ata_device hold the transfer mode IDs, not masks.
To match these docs, the {dma|pio}_mode (and even xfer_mode!) sysfs files are handled by the ata_bitfield_name_match() macro which leads to reading such kind of nonsense from them:
$ cat /sys/class/ata_device/dev3.0/pio_mode XFER_UDMA_7, XFER_UDMA_6, XFER_UDMA_5, XFER_UDMA_4, XFER_MW_DMA_4, XFER_PIO_6, XFER_PIO_5, XFER_PIO_4, XFER_PIO_3, XFER_PIO_2, XFER_PIO_1, XFER_PIO_0
Using the correct ata_bitfield_name_search() macro fixes that:
$ cat /sys/class/ata_device/dev3.0/pio_mode XFER_PIO_4
While fixing the file documentation, somewhat reword the {dma|pio}_mode file doc and add a note about being mostly useful for PATA devices to the xfer_mode file doc...
--- Documentation/ABI/testing/sysfs-ata | 11 ++++++----- drivers/ata/libata-transport.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-)
Documentation/ABI/testing/sysfs-ata +6 -5
@@ -107,13 +107,14 @@ Description: described in ATA8 7.16 and 7.17. Only valid if the device is not a PM. - pio_mode: (RO) Transfer modes supported by the device when - in PIO mode. Mostly used by PATA device. + pio_mode: (RO) PIO transfer mode used by the device. + Mostly used by PATA devices. - xfer_mode: (RO) Current transfer mode + xfer_mode: (RO) Current transfer mode. Mostly used by + PATA devices. - dma_mode: (RO) Transfer modes supported by the device when - in DMA mode. Mostly used by PATA device. + dma_mode: (RO) DMA transfer mode used by the device. + Mostly used by PATA devices. class: (RO) Device class. Can be "ata" for disk, "atapi" for packet device, "pmp" for PM, or
drivers/ata/libata-transport.c +1 -1
@@ -196,7 +196,7 @@ static struct { { XFER_PIO_0, "XFER_PIO_0" }, { XFER_PIO_SLOW, "XFER_PIO_SLOW" } }; -ata_bitfield_name_match (xfer,ata_xfer_names) +ata_bitfield_name_search (xfer, ata_xfer_names)/* * ATA Port attributes
Greg Kroah-Hartman
maintainerPATCH 278/287 mmc: block: Fix CQE recovery reset success
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit a051246b786af7e4a9d9219cc7038a6e8a411531 upstream.
The intention of the use of mmc_blk_reset_success() in mmc_blk_cqe_recovery() was to prevent repeated resets when retrying and getting the same error. However, that may not be the case - any amount of time and I/O may pass before another recovery is needed, in which case there would be no reason to deny it the opportunity to recover via a reset if necessary. CQE recovery is expected seldom and failure to recover (if the clear tasks command fails), even more seldom, so it is better to allow the reset always, which can be done by calling mmc_blk_reset_success() always.
--- drivers/mmc/core/block.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/core/block.c +1 -2
@@ -1499,8 +1499,7 @@ void mmc_blk_cqe_recovery(struct mmc_que err =mmc_cqe_recovery (host);if (err)mmc_blk_reset (mq->blkdata, host,MMC_BLK_CQE_RECOVERY ); -else -mmc_blk_reset_success (mq->blkdata,MMC_BLK_CQE_RECOVERY ); +mmc_blk_reset_success (mq->blkdata,MMC_BLK_CQE_RECOVERY );pr_debug ("%s: CQE recovery done\n" ,mmc_hostname (host)); }
Greg Kroah-Hartman
maintainerPATCH 279/287 nfc: st21nfca: fix incorrect validating logic in EVT_TRANSACTION
In reply to Greg Kroah-HartmanFrom: Martin Faltesek <[email protected]>
commit 77e5fe8f176a525523ae091d6fd0fbb8834c156d upstream.
The first validation check for EVT_TRANSACTION has two different checks tied together with logical AND. One is a check for minimum packet length, and the other is for a valid aid_tag. If either condition is true (fails), then an error should be triggered. The fix is to change && to ||.
--- drivers/nfc/st21nfca/se.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/st21nfca/se.c +1 -1
@@ -330,7 +330,7 @@ int st21nfca_connectivity_event_received* AID 81 5 to 16 * PARAMETERS 82 0 to 255 */ -if (skb->len <NFC_MIN_AID_LENGTH +2 && +if (skb->len <NFC_MIN_AID_LENGTH +2 || skb->data[0 ] !=NFC_EVT_TRANSACTION_AID_TAG )return -EPROTO ;
Greg Kroah-Hartman
maintainerPATCH 280/287 nfc: st21nfca: fix memory leaks in EVT_TRANSACTION handling
In reply to Greg Kroah-HartmanFrom: Martin Faltesek <[email protected]>
commit 996419e0594abb311fb958553809f24f38e7abbe upstream.
Error paths do not free previously allocated memory. Add devm_kfree() to those failure paths.
--- drivers/nfc/st21nfca/se.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/nfc/st21nfca/se.c +10 -3
@@ -342,22 +342,29 @@ int st21nfca_connectivity_event_received transaction->aid_len = skb->data[1 ];/* Checking if the length of the AID is valid */ -if (transaction->aid_len >sizeof (transaction->aid)) +if (transaction->aid_len >sizeof (transaction->aid)) { +devm_kfree (dev, transaction);return -EINVAL ; + }memcpy (transaction->aid, &skb->data[2 ], transaction->aid_len);/* Check next byte is PARAMETERS tag (82) */ if (skb->data[transaction->aid_len +2 ] != -NFC_EVT_TRANSACTION_PARAMS_TAG ) +NFC_EVT_TRANSACTION_PARAMS_TAG ) { +devm_kfree (dev, transaction);return -EPROTO ; + } transaction->params_len = skb->data[transaction->aid_len +3 ];/* Total size is allocated (skb->len - 2) minus fixed array members */ -if (transaction->params_len > ((skb->len -2 ) -sizeof (struct nfc_evt_transaction ))) +if (transaction->params_len > ((skb->len -2 ) - +sizeof (struct nfc_evt_transaction ))) { +devm_kfree (dev, transaction);return -EINVAL ; + }memcpy (transaction->params, skb->data + transaction->aid_len +4 , transaction->params_len);
Greg Kroah-Hartman
maintainerPATCH 281/287 ixgbe: fix bcast packets Rx on VF after promisc removal
In reply to Greg Kroah-HartmanFrom: Olivier Matz <[email protected]>
commit 803e9895ea2b0fe80bc85980ae2d7a7e44037914 upstream.
After a VF requested to remove the promiscuous flag on an interface, the broadcast packets are not received anymore. This breaks some protocols like ARP.
In ixgbe_update_vf_xcast_mode(), we should keep the IXGBE_VMOLR_BAM bit (Broadcast Accept) on promiscuous removal.
This flag is already set by default in ixgbe_set_vmolr() on VF reset.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +2 -2
@@ -1148,9 +1148,9 @@ static int ixgbe_update_vf_xcast_mode(stswitch (xcast_mode) {case IXGBEVF_XCAST_MODE_NONE : - disable =IXGBE_VMOLR_BAM |IXGBE_VMOLR_ROMPE | + disable =IXGBE_VMOLR_ROMPE |IXGBE_VMOLR_MPE |IXGBE_VMOLR_UPE |IXGBE_VMOLR_VPE ; - enable =0 ; + enable =IXGBE_VMOLR_BAM ;break ;case IXGBEVF_XCAST_MODE_MULTI : disable =IXGBE_VMOLR_MPE |IXGBE_VMOLR_UPE |IXGBE_VMOLR_VPE ;
Greg Kroah-Hartman
maintainerPATCH 282/287 ixgbe: fix unexpected VLAN Rx in promisc mode on VF
In reply to Greg Kroah-HartmanFrom: Olivier Matz <[email protected]>
commit 7bb0fb7c63df95d6027dc50d6af3bc3bbbc25483 upstream.
When the promiscuous mode is enabled on a VF, the IXGBE_VMOLR_VPE bit (VLAN Promiscuous Enable) is set. This means that the VF will receive packets whose VLAN is not the same than the VLAN of the VF.
For instance, in this situation:
┌────────┐ ┌────────┐ ┌────────┐ │ │ │ │ │ │ │ │ │ │ │ │ │ VF0├────┤VF1 VF2├────┤VF3 │ │ │ │ │ │ │ └────────┘ └────────┘ └────────┘ VM1 VM2 VM3
vf 0: vlan 1000 vf 1: vlan 1000 vf 2: vlan 1001 vf 3: vlan 1001
If we tcpdump on VF3, we see all the packets, even those transmitted on vlan 1000.
This behavior prevents to bridge VF1 and VF2 in VM2, because it will create a loop: packets transmitted on VF1 will be received by VF2 and vice-versa, and bridged again through the software bridge.
This patch remove the activation of VLAN Promiscuous when a VF enables the promiscuous mode. However, the IXGBE_VMOLR_UPE bit (Unicast Promiscuous) is kept, so that a VF receives all packets that has the same VLAN, whatever the destination MAC address.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +2 -2
@@ -1172,9 +1172,9 @@ static int ixgbe_update_vf_xcast_mode(streturn -EPERM ; } - disable =0 ; + disable =IXGBE_VMOLR_VPE ; enable =IXGBE_VMOLR_BAM |IXGBE_VMOLR_ROMPE | -IXGBE_VMOLR_MPE |IXGBE_VMOLR_UPE |IXGBE_VMOLR_VPE ; +IXGBE_VMOLR_MPE |IXGBE_VMOLR_UPE ;break ;default :return -EOPNOTSUPP ;
Greg Kroah-Hartman
maintainerPATCH 283/287 Input: bcm5974 - set missing URB_NO_TRANSFER_DMA_MAP urb flag
In reply to Greg Kroah-HartmanFrom: Mathias Nyman <[email protected]>
commit c42e65664390be7c1ef3838cd84956d3a2739d60 upstream.
The bcm5974 driver does the allocation and dma mapping of the usb urb data buffer, but driver does not set the URB_NO_TRANSFER_DMA_MAP flag to let usb core know the buffer is already mapped.
usb core tries to map the already mapped buffer, causing a warning:
"xhci_hcd 0000:00:14.0: rejecting DMA map of vmalloc memory"
Fix this by setting the URB_NO_TRANSFER_DMA_MAP, letting usb core know buffer is already mapped by bcm5974 driver
--- drivers/input/mouse/bcm5974.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/input/mouse/bcm5974.c +6 -1
@@ -956,17 +956,22 @@ static int bcm5974_probe(struct usb_inteif (!dev->tp_data) goto err_free_bt_buffer; -if (dev->bt_urb) +if (dev->bt_urb) {usb_fill_int_urb (dev->bt_urb, udev,usb_rcvintpipe (udev, cfg->bt_ep), dev->bt_data, dev->cfg.bt_datalen, bcm5974_irq_button, dev,1 ); + dev->bt_urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ; + } +usb_fill_int_urb (dev->tp_urb, udev,usb_rcvintpipe (udev, cfg->tp_ep), dev->tp_data, dev->cfg.tp_datalen, bcm5974_irq_trackpad, dev,1 ); + dev->tp_urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ; +/* create bcm5974 device */ usb_make_path (udev, dev->phys,sizeof (dev->phys));strlcat (dev->phys,"/input0" ,sizeof (dev->phys));
Greg Kroah-Hartman
maintainerPATCH 284/287 powerpc/32: Fix overread/overwrite of thread_struct via ptrace
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 8e1278444446fc97778a5e5c99bca1ce0bbc5ec9 upstream.
The ptrace PEEKUSR/POKEUSR (aka PEEKUSER/POKEUSER) API allows a process to read/write registers of another process.
To get/set a register, the API takes an index into an imaginary address space called the "USER area", where the registers of the process are laid out in some fashion.
The kernel then maps that index to a particular register in its own data structures and gets/sets the value.
The API only allows a single machine-word to be read/written at a time. So 4 bytes on 32-bit kernels and 8 bytes on 64-bit kernels.
The way floating point registers (FPRs) are addressed is somewhat complicated, because double precision float values are 64-bit even on 32-bit CPUs. That means on 32-bit kernels each FPR occupies two word-sized locations in the USER area. On 64-bit kernels each FPR occupies one word-sized location in the USER area.
Internally the kernel stores the FPRs in an array of u64s, or if VSX is enabled, an array of pairs of u64s where one half of each pair stores the FPR. Which half of the pair stores the FPR depends on the kernel's endianness.
To handle the different layouts of the FPRs depending on VSX/no-VSX and big/little endian, the TS_FPR() macro was introduced.
Unfortunately the TS_FPR() macro does not take into account the fact that the addressing of each FPR differs between 32-bit and 64-bit kernels. It just takes the index into the "USER area" passed from userspace and indexes into the fp_state.fpr array.
On 32-bit there are 64 indexes that address FPRs, but only 32 entries in the fp_state.fpr array, meaning the user can read/write 256 bytes past the end of the array. Because the fp_state sits in the middle of the thread_struct there are various fields than can be overwritten, including some pointers. As such it may be exploitable.
It has also been observed to cause systems to hang or otherwise misbehave when using gdbserver, and is probably the root cause of this report which could not be easily reproduced:
https://lore.kernel.org/linuxppc-dev/[email protected]/
Rather than trying to make the TS_FPR() macro even more complicated to fix the bug, or add more macros, instead add a special-case for 32-bit kernels. This is more obvious and hopefully avoids a similar bug happening again in future.
Note that because 32-bit kernels never have VSX enabled the code doesn't need to consider TS_FPRWIDTH/OFFSET at all. Add a BUILD_BUG_ON() to ensure that 32-bit && VSX is never enabled.
--- arch/powerpc/kernel/ptrace.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
arch/powerpc/kernel/ptrace.c +14 -4
@@ -3007,8 +3007,13 @@ long arch_ptrace(struct task_struct *chiflush_fp_to_thread (child);if (fpidx < (PT_FPSCR -PT_FPR0 )) -memcpy (&tmp, &child->thread.TS_FPR (fpidx), -sizeof (long )); +if (IS_ENABLED (CONFIG_PPC32 )) { +// On 32-bit the index we are passed refers to 32-bit words + tmp = ((u32 *)child->thread.fp_state.fpr)[fpidx]; + }else { +memcpy (&tmp, &child->thread.TS_FPR (fpidx), +sizeof (long )); + }else tmp = child->thread.fp_state.fpscr; }
@@ -3040,8 +3045,13 @@ long arch_ptrace(struct task_struct *chiflush_fp_to_thread (child);if (fpidx < (PT_FPSCR -PT_FPR0 )) -memcpy (&child->thread.TS_FPR (fpidx), &data, -sizeof (long )); +if (IS_ENABLED (CONFIG_PPC32 )) { +// On 32-bit the index we are passed refers to 32-bit words + ((u32 *)child->thread.fp_state.fpr)[fpidx] = data; + }else { +memcpy (&child->thread.TS_FPR (fpidx), &data, +sizeof (long )); + }else child->thread.fp_state.fpscr = data; ret =0 ;
Greg Kroah-Hartman
maintainerPATCH 285/287 md/raid0: Ignore RAID0 layout if the second zone has only one device
In reply to Greg Kroah-HartmanFrom: Pascal Hambourg <[email protected]>
commit ea23994edc4169bd90d7a9b5908c6ccefd82fa40 upstream.
The RAID0 layout is irrelevant if all members have the same size so the array has only one zone. It is *also* irrelevant if the array has two zones and the second zone has only one device, for example if the array has two members of different sizes.
So in that case it makes sense to allow assembly even when the layout is undefined, like what is done when the array has only one zone.
--- drivers/md/raid0.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/md/raid0.c +16 -15
@@ -150,21 +150,6 @@ static int create_strip_zones(struct mddpr_debug ("md/raid0:%s: FINAL %d zones\n" ,mdname (mddev), conf->nr_strip_zones); -if (conf->nr_strip_zones ==1 ) { - conf->layout =RAID0_ORIG_LAYOUT ; - }else if (mddev->layout ==RAID0_ORIG_LAYOUT || - mddev->layout ==RAID0_ALT_MULTIZONE_LAYOUT ) { - conf->layout = mddev->layout; - }else if (default_layout ==RAID0_ORIG_LAYOUT || - default_layout ==RAID0_ALT_MULTIZONE_LAYOUT ) { - conf->layout = default_layout; - }else { -pr_err ("md/raid0:%s: cannot assemble multi-zone RAID0 with default_layout setting\n" , -mdname (mddev)); -pr_err ("md/raid0: please set raid0.default_layout to 1 or 2\n" ); - err = -ENOTSUPP ; - goto abort; - }/* * now since we have the hard sector sizes, we can make sure * chunk size is a multiple of that sector size
@@ -295,6 +280,22 @@ static int create_strip_zones(struct mdd (unsigned long long)smallest->sectors); } +if (conf->nr_strip_zones ==1 || conf->strip_zone[1 ].nb_dev ==1 ) { + conf->layout =RAID0_ORIG_LAYOUT ; + }else if (mddev->layout ==RAID0_ORIG_LAYOUT || + mddev->layout ==RAID0_ALT_MULTIZONE_LAYOUT ) { + conf->layout = mddev->layout; + }else if (default_layout ==RAID0_ORIG_LAYOUT || + default_layout ==RAID0_ALT_MULTIZONE_LAYOUT ) { + conf->layout = default_layout; + }else { +pr_err ("md/raid0:%s: cannot assemble multi-zone RAID0 with default_layout setting\n" , +mdname (mddev)); +pr_err ("md/raid0: please set raid0.default_layout to 1 or 2\n" ); + err = -EOPNOTSUPP ; + goto abort; + } +pr_debug ("md/raid0:%s: done.\n" ,mdname (mddev)); *private_conf = conf;
Greg Kroah-Hartman
maintainerPATCH 286/287 mtd: cfi_cmdset_0002: Move and rename chip_check/chip_ready/chip_good_for_write
In reply to Greg Kroah-HartmanFrom: Tokunori Ikegami <[email protected]>
commit 083084df578a8bdb18334f69e7b32d690aaa3247 upstream.
This is a preparation patch for the S29GL064N buffer writes fix. There is no functional change.
--- drivers/mtd/chips/cfi_cmdset_0002.c | 77 ++++++++++++++---------------------- 1 file changed, 32 insertions(+), 45 deletions(-)
drivers/mtd/chips/cfi_cmdset_0002.c +32 -45
@@ -731,50 +731,34 @@ static struct mtd_info *cfi_amdstd_setup }/* -* Return true if the chip is ready. +* Return true if the chip is ready and has the correct value. * * Ready is one of: read mode, query mode, erase-suspend-read mode (in any * non-suspended sector) and is indicated by no toggle bits toggling. * +* Error are indicated by toggling bits or bits held with the wrong value, +* or with bits toggling. +* * Note that anything more complicated than checking if no bits are toggling * (including checking DQ5 for an error status) is tricky to get working * correctly and is therefore not done (particularly with interleaved chips * as each chip must be checked independently of the others). */ -static int __xipram chip_ready(struct map_info *map, unsigned long addr) +static int __xipram chip_ready(struct map_info *map, unsigned long addr, +map_word *expected) {map_word d, t; +int ret; d =map_read (map, addr); t =map_read (map, addr); -return map_word_equal (map, d, t); -} + ret =map_word_equal (map, d, t); -/* -* Return true if the chip is ready and has the correct value. -* -* Ready is one of: read mode, query mode, erase-suspend-read mode (in any -* non-suspended sector) and it is indicated by no bits toggling. -* -* Error are indicated by toggling bits or bits held with the wrong value, -* or with bits toggling. -* -* Note that anything more complicated than checking if no bits are toggling -* (including checking DQ5 for an error status) is tricky to get working -* correctly and is therefore not done (particularly with interleaved chips -* as each chip must be checked independently of the others). -* -*/ -static int __xipram chip_good(struct map_info *map, unsigned long addr, map_word expected) -{ -map_word oldd, curd; - - oldd =map_read (map, addr); - curd =map_read (map, addr); +if (!ret || !expected) +return ret; -return map_word_equal (map, oldd, curd) && -map_word_equal (map, curd, expected); +return map_word_equal (map, t, *expected); }static int get_chip (struct map_info *map,struct flchip *chip,unsigned long adr,int mode)
@@ -791,7 +775,7 @@ static int get_chip(struct map_info *mapcase FL_STATUS :for (;;) { -if (chip_ready (map, adr)) +if (chip_ready (map, adr,NULL ))break ;if (time_after (jiffies, timeo)) {
@@ -829,7 +813,7 @@ static int get_chip(struct map_info *map chip->state =FL_ERASE_SUSPENDING ; chip->erase_suspended =1 ;for (;;) { -if (chip_ready (map, adr)) +if (chip_ready (map, adr,NULL ))break ;if (time_after (jiffies, timeo)) {
@@ -1360,7 +1344,7 @@ static int do_otp_lock(struct map_info */* wait for chip to become ready */ timeo = jiffies +msecs_to_jiffies (2 );for (;;) { -if (chip_ready (map, adr)) +if (chip_ready (map, adr,NULL ))break ;if (time_after (jiffies, timeo)) {
@@ -1627,10 +1611,11 @@ static int __xipram do_write_oneword(str }/* -* We check "time_after" and "!chip_good" before checking -* "chip_good" to avoid the failure due to scheduling. +* We check "time_after" and "!chip_ready" before checking +* "chip_ready" to avoid the failure due to scheduling. */ -if (time_after (jiffies, timeo) && !chip_good (map, adr, datum)) { +if (time_after (jiffies, timeo) && + !chip_ready (map, adr, &datum)) {xip_enable (map, chip, adr);printk (KERN_WARNING "MTD %s(): software timeout\n" , __func__);xip_disable (map, chip, adr);
@@ -1638,7 +1623,7 @@ static int __xipram do_write_oneword(strbreak ; } -if (chip_good (map, adr, datum)) +if (chip_ready (map, adr, &datum))break ;/* Latency issues. Drop the lock, wait a while and retry */
@@ -1882,13 +1867,13 @@ static int __xipram do_write_buffer(stru }/* -* We check "time_after" and "!chip_good" before checking "chip_good" to avoid -* the failure due to scheduling. +* We check "time_after" and "!chip_ready" before checking +* "chip_ready" to avoid the failure due to scheduling. */ -if (time_after (jiffies, timeo) && !chip_good (map, adr, datum)) +if (time_after (jiffies, timeo) && !chip_ready (map, adr, &datum))break ; -if (chip_good (map, adr, datum)) { +if (chip_ready (map, adr, &datum)) {xip_enable (map, chip, adr); goto op_done; }
@@ -2022,7 +2007,7 @@ static int cfi_amdstd_panic_wait(struct* If the driver thinks the chip is idle, and no toggle bits * are changing, then the chip is actually idle for sure. */ -if (chip->state ==FL_READY &&chip_ready (map, adr)) +if (chip->state ==FL_READY &&chip_ready (map, adr,NULL ))return 0 ;/*
@@ -2039,7 +2024,7 @@ static int cfi_amdstd_panic_wait(struct/* wait for the chip to become ready */ for (i =0 ; i <jiffies_to_usecs (timeo); i++) { -if (chip_ready (map, adr)) +if (chip_ready (map, adr,NULL ))return 0 ;udelay (1 );
@@ -2103,13 +2088,13 @@ retry:map_write (map, datum, adr);for (i =0 ; i <jiffies_to_usecs (uWriteTimeout); i++) { -if (chip_ready (map, adr)) +if (chip_ready (map, adr,NULL ))break ;udelay (1 ); } -if (!chip_good (map, adr, datum)) { +if (!chip_ready (map, adr, &datum)) {/* reset on all failures. */ map_write (map,CMD (0xF0 ), chip->start);/* FIXME - should have reset delay before continuing */
@@ -2250,6 +2235,7 @@ static int __xipram do_erase_chip(structDECLARE_WAITQUEUE (wait, current);int ret =0 ;int retry_cnt =0 ; +map_word datum =map_word_ff (map); adr = cfi->addr_unlock1;
@@ -2304,7 +2290,7 @@ static int __xipram do_erase_chip(struct chip->erase_suspended =0 ; } -if (chip_good (map, adr,map_word_ff (map))) +if (chip_ready (map, adr, &datum))break ;if (time_after (jiffies, timeo)) {
@@ -2346,6 +2332,7 @@ static int __xipram do_erase_oneblock(stDECLARE_WAITQUEUE (wait, current);int ret =0 ;int retry_cnt =0 ; +map_word datum =map_word_ff (map); adr += chip->start;
@@ -2400,7 +2387,7 @@ static int __xipram do_erase_oneblock(st chip->erase_suspended =0 ; } -if (chip_good (map, adr,map_word_ff (map))) +if (chip_ready (map, adr, &datum))break ;if (time_after (jiffies, timeo)) {
@@ -2593,7 +2580,7 @@ static int __maybe_unused do_ppb_xxlock(*/ timeo = jiffies +msecs_to_jiffies (2000 );/* 2s max (un)locking */ for (;;) { -if (chip_ready (map, adr)) +if (chip_ready (map, adr,NULL ))break ;if (time_after (jiffies, timeo)) {
Greg Kroah-Hartman
maintainerPATCH 287/287 mtd: cfi_cmdset_0002: Use chip_ready() for write on S29GL064N
In reply to Greg Kroah-HartmanFrom: Tokunori Ikegami <[email protected]>
commit 0a8e98305f63deaf0a799d5cf5532cc83af035d1 upstream.
Since commit dfeae1073583("mtd: cfi_cmdset_0002: Change write buffer to check correct value") buffered writes fail on S29GL064N. This is because, on S29GL064N, reads return 0xFF at the end of DQ polling for write completion, where as, chip_good() check expects actual data written to the last location to be returned post DQ polling completion. Fix is to revert to using chip_good() for S29GL064N which only checks for DQ lines to settle down to determine write completion.
--- drivers/mtd/chips/cfi_cmdset_0002.c | 42 +++++++++++++++++++++++++++++------- include/linux/mtd/cfi.h | 1 2 files changed, 35 insertions(+), 8 deletions(-)
drivers/mtd/chips/cfi_cmdset_0002.c +34 -8
@@ -49,6 +49,10 @@#define SST49LF008A 0x005a#define AT49BV6416 0x00d6 +enum cfi_quirks { +CFI_QUIRK_DQ_TRUE_DATA =BIT (0 ), +}; +static int cfi_amdstd_read (struct mtd_info *,loff_t ,size_t ,size_t *,u_char *);static int cfi_amdstd_write_words (struct mtd_info *,loff_t ,size_t ,size_t *,const u_char *);static int cfi_amdstd_write_buffers (struct mtd_info *,loff_t ,size_t ,size_t *,const u_char *);
@@ -365,6 +369,15 @@ static void fixup_s29ns512p_sectors(stru mtd->name); } +static void fixup_quirks (struct mtd_info *mtd) +{ +struct map_info *map = mtd->priv; +struct cfi_private *cfi = map->fldrv_priv; + +if (cfi->mfr ==CFI_MFR_AMD && cfi->id ==0x0c01 ) + cfi->quirks |=CFI_QUIRK_DQ_TRUE_DATA ; +} +/* Used to fix CFI-Tables of chips without Extended Query Tables */ static struct cfi_fixup cfi_nopri_fixup_table[] = { {CFI_MFR_SST ,0x234a , fixup_sst39vf },/* SST39VF1602 */
@@ -403,6 +416,7 @@ static struct cfi_fixup cfi_fixup_table[ #if !FORCE_WORD_WRITE { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers }, #endif + { CFI_MFR_ANY, CFI_ID_ANY, fixup_quirks }, { 0, 0, NULL } }; static struct cfi_fixup jedec_fixup_table[] = {
@@ -761,6 +775,18 @@ static int __xipram chip_ready(struct mareturn map_word_equal (map, t, *expected); } +static int __xipram chip_good(struct map_info *map, unsigned long addr, +map_word *expected) +{ +struct cfi_private *cfi = map->fldrv_priv; +map_word *datum = expected; + +if (cfi->quirks &CFI_QUIRK_DQ_TRUE_DATA ) + datum =NULL ; + +return chip_ready (map, addr, datum); +} +static int get_chip (struct map_info *map,struct flchip *chip,unsigned long adr,int mode) {DECLARE_WAITQUEUE (wait, current);
@@ -1611,11 +1637,11 @@ static int __xipram do_write_oneword(str }/* -* We check "time_after" and "!chip_ready" before checking -* "chip_ready" to avoid the failure due to scheduling. +* We check "time_after" and "!chip_good" before checking +* "chip_good" to avoid the failure due to scheduling. */ if (time_after (jiffies, timeo) && - !chip_ready (map, adr, &datum)) { + !chip_good (map, adr, &datum)) {xip_enable (map, chip, adr);printk (KERN_WARNING "MTD %s(): software timeout\n" , __func__);xip_disable (map, chip, adr);
@@ -1623,7 +1649,7 @@ static int __xipram do_write_oneword(strbreak ; } -if (chip_ready (map, adr, &datum)) +if (chip_good (map, adr, &datum))break ;/* Latency issues. Drop the lock, wait a while and retry */
@@ -1867,13 +1893,13 @@ static int __xipram do_write_buffer(stru }/* -* We check "time_after" and "!chip_ready" before checking -* "chip_ready" to avoid the failure due to scheduling. +* We check "time_after" and "!chip_good" before checking +* "chip_good" to avoid the failure due to scheduling. */ -if (time_after (jiffies, timeo) && !chip_ready (map, adr, &datum)) +if (time_after (jiffies, timeo) && !chip_good (map, adr, &datum))break ; -if (chip_ready (map, adr, &datum)) { +if (chip_good (map, adr, &datum)) {xip_enable (map, chip, adr); goto op_done; }
include/linux/mtd/cfi.h +1 -0
@@ -293,6 +293,7 @@ struct cfi_private {map_word sector_erase_cmd;unsigned long chipshift;/* Because they're of the same type */ const char *im_name;/* inter_module name for cmdset_setup */ +unsigned long quirks;struct flchip chips[0 ];/* per-chip data structure for each chip */ };
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 4.19.247 release. There are 287 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-4.19.y
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.247 release. There are 287 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 15 Jun 2022 09:47:08 +0000. Anything received after that time might be too late.
Build results:
total: 157 pass: 157 fail: 0 Qemu test results: total: 425 pass: 425 fail: 0
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.247 release. There are 287 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 15 Jun 2022 09:47:08 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.247-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.247 release. There are 287 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 15 Jun 2022 09:47:08 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.247-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 4.19.247-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-4.19.y
* git commit: cbdd85f3a5c93a3948c77f3d3016506b65276ca5
* git describe: v4.19.246-288-gcbdd85f3a5c9
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.19.y/build/v4.19.246-288-gcbdd85f3a5c9
## Test Regressions (compared to v4.19.245-31-gfb313cec37d7) No test regressions found.
## Metric Regressions (compared to v4.19.245-31-gfb313cec37d7) No metric regressions found.
## Test Fixes (compared to v4.19.245-31-gfb313cec37d7) No test fixes found.
## Metric Fixes (compared to v4.19.245-31-gfb313cec37d7) No metric fixes found.
## Test result summary
total: 104198, pass: 92268, fail: 261, skip: 10762, xfail: 907
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 298 total, 292 passed, 6 failed
* arm64: 56 total, 54 passed, 2 failed
* i386: 27 total, 23 passed, 4 failed
* mips: 27 total, 27 passed, 0 failed
* parisc: 12 total, 12 passed, 0 failed
* powerpc: 55 total, 54 passed, 1 failed
* s390: 12 total, 12 passed, 0 failed
* sh: 24 total, 24 passed, 0 failed
* sparc: 12 total, 12 passed, 0 failed
* x86_64: 53 total, 51 passed, 2 failed
## Test suites summary
* fwts
* igt-gpu-tools
* kunit
* kvm-unit-tests
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-cap_bounds-tests
* ltp-commands
* ltp-commands-tests
* ltp-containers
* ltp-containers-tests
* ltp-controllers-tests
* ltp-cpuhotplug-tests
* ltp-crypto
* ltp-crypto-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests
* ltp-fcntl-locktests-tests
* ltp-filecaps
* ltp-filecaps-tests
* ltp-fs
* ltp-fs-tests
* ltp-fs_bind
* ltp-fs_bind-tests
* ltp-fs_perms_simple
* ltp-fs_perms_simple-tests
* ltp-fsx
* ltp-fsx-tests
* ltp-hugetlb
* ltp-hugetlb-tests
* ltp-io
* ltp-io-tests
* ltp-ipc
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl
* ltp-nptl-tests
* ltp-open-posix-tests
* ltp-pty
* ltp-pty-tests
* ltp-sched
* ltp-sched-tests
* ltp-securebits
* ltp-securebits-tests
* ltp-smoke
* ltp-syscalls-tests
* ltp-tracing-tests
* network-basic-tests
* packetdrill
* rcutorture
* ssuite
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.247 release. There are 287 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 15 Jun 2022 09:47:08 +0000. Anything received after that time might be too late.
Build test (gcc version 11.3.1 20220612):
mips: 63 configs -> no failure
arm: 115 configs -> no failure
arm64: 2 configs -> no failurex86_64: 4 configs -> no failure
alpha allmodconfig -> no failure
s390 allmodconfig -> no failure
xtensa allmodconfig -> no failure
powerpc allmodconfig and riscv allmodconfig failed to build. backported patches sent separately.
Boot test:x86_64: Booted on my test laptop. No regression.x86_64: Booted on qemu. No regression. [1]
[1]. https://openqa.qa.codethink.co.uk/tests/1315
--
Regards
Sudip