5.14.19-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 416/849 b43legacy: fix a lower bounds test
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit c1c8380b0320ab757e60ed90efc8b1992a943256 ]
The problem is that "channel" is an unsigned int, when it's less 5 the value of "channel - 5" is not a negative number as one would expect but is very high positive value instead.
This means that "start" becomes a very high positive value. The result of that is that we never enter the "for (i = start; i <= end; i++) {" loop. Instead of storing the result from b43legacy_radio_aci_detect() it just uses zero.
--- drivers/net/wireless/broadcom/b43legacy/radio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/b43legacy/radio.c +1 -1
@@ -283,7 +283,7 @@ u8 b43legacy_radio_aci_scan(struct b43legacy_wldev *dev) & 0x7FFF);b43legacy_set_all_gains (dev,3 ,8 ,1 ); - start = (channel -5 >0 ) ? channel -5 :1 ; + start = (channel >5 ) ? channel -5 :1 ; end = (channel +5 <14 ) ? channel +5 :13 ;for (i = start; i <= end; i++) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 417/849 b43: fix a lower bounds test
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 9b793db5fca44d01f72d3564a168171acf7c4076 ]
The problem is that "channel" is an unsigned int, when it's less 5 the value of "channel - 5" is not a negative number as one would expect but is very high positive value instead.
This means that "start" becomes a very high positive value. The result of that is that we never enter the "for (i = start; i <= end; i++) {" loop. Instead of storing the result from b43legacy_radio_aci_detect() it just uses zero.
--- drivers/net/wireless/broadcom/b43/phy_g.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/b43/phy_g.c +1 -1
@@ -2297,7 +2297,7 @@ static u8 b43_gphy_aci_scan(struct b43_wldev *dev)b43_phy_mask (dev,B43_PHY_G_CRS ,0x7FFF );b43_set_all_gains (dev,3 ,8 ,1 ); - start = (channel -5 >0 ) ? channel -5 :1 ; + start = (channel >5 ) ? channel -5 :1 ; end = (channel +5 <14 ) ? channel +5 :13 ;for (i = start; i <= end; i++) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 418/849 gve: Recover from queue stall due to missed IRQ
In reply to Greg Kroah-HartmanFrom: John Fraker <[email protected]>
[ Upstream commit 87a7f321bb6a45e54b7d6c90d032ee5636a6ad97 ]
Don't always reset the driver on a TX timeout. Attempt to recover by kicking the queue in case an IRQ was missed.
--- drivers/net/ethernet/google/gve/gve.h | 4 +- drivers/net/ethernet/google/gve/gve_adminq.h | 1 + drivers/net/ethernet/google/gve/gve_main.c | 48 +++++++++++++++++++- 3 files changed, 51 insertions(+), 2 deletions(-)
drivers/net/ethernet/google/gve/gve.h +3 -1
@@ -30,7 +30,7 @@#define GVE_MIN_MSIX 3/* Numbers of gve tx/rx stats in stats report. */ -#define GVE_TX_STATS_REPORT_NUM 5 +#define GVE_TX_STATS_REPORT_NUM 6#define GVE_RX_STATS_REPORT_NUM 2/* Interval to schedule a stats report update, 20000ms. */
@@ -413,7 +413,9 @@ struct gve_tx_ring {u32 q_num____cacheline_aligned ;/* queue idx */ u32 stop_queue;/* count of queue stops */ u32 wake_queue;/* count of queue wakes */ +u32 queue_timeout;/* count of queue timeouts */ u32 ntfy_id;/* notification block index */ +u32 last_kick_msec;/* Last time the queue was kicked */ dma_addr_t bus;/* dma address of the descr ring */ dma_addr_t q_resources_bus;/* dma address of the queue resources */ dma_addr_t complq_bus_dqo;/* dma address of the dqo.compl_ring */
drivers/net/ethernet/google/gve/gve_adminq.h +1 -0
@@ -270,6 +270,7 @@ enum gve_stat_names {TX_LAST_COMPLETION_PROCESSED =5 ,RX_NEXT_EXPECTED_SEQUENCE =6 ,RX_BUFFERS_POSTED =7 , +TX_TIMEOUT_CNT =8 ,// stats from NIC RX_QUEUE_DROP_CNT =65 , RX_NO_BUFFERS_POSTED = 66,
drivers/net/ethernet/google/gve/gve_main.c +47 -1
68 lines not on this page · raw message
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 419/849 gve: Track RX buffer allocation failures
In reply to Greg Kroah-HartmanFrom: Catherine Sullivan <[email protected]>
[ Upstream commit 1b4d1c9bab091ac6e20a3ff80c30c5cefe192bf4 ]
The rx_buf_alloc_fail counter wasn't getting updated.
--- drivers/net/ethernet/google/gve/gve_rx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_rx.c +6 -1
@@ -514,8 +514,13 @@ static bool gve_rx_refill_buffers(struct gve_priv *priv, struct gve_rx_ring *rx)gve_rx_free_buffer (dev, page_info, data_slot); page_info->page =NULL ; -if (gve_rx_alloc_buffer (priv, dev, page_info, data_slot)) +if (gve_rx_alloc_buffer (priv, dev, page_info, + data_slot)) { +u64_stats_update_begin (&rx->statss); + rx->rx_buf_alloc_fail++; +u64_stats_update_end (&rx->statss);break ; + } } } fill_cnt++;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 420/849 mmc: sdhci-omap: Fix NULL pointer exception if regulator is not configured
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 8e0e7bd38b1ec7f9e5d18725ad41828be4e09859 ]
If sdhci-omap is configured for an unused device instance and the device is not set as disabled, we can get a NULL pointer dereference:
Unable to handle kernel NULL pointer dereference at virtual address
00000045
...
(regulator_set_voltage) from [<c07d7008>] (mmc_regulator_set_ocr+0x44/0xd0) (mmc_regulator_set_ocr) from [<c07e2d80>] (sdhci_set_ios+0xa4/0x490) (sdhci_set_ios) from [<c07ea690>] (sdhci_omap_set_ios+0x124/0x160) (sdhci_omap_set_ios) from [<c07c8e94>] (mmc_power_up.part.0+0x3c/0x154) (mmc_power_up.part.0) from [<c07c9d20>] (mmc_start_host+0x88/0x9c) (mmc_start_host) from [<c07cad34>] (mmc_add_host+0x58/0x7c) (mmc_add_host) from [<c07e2574>] (__sdhci_add_host+0xf0/0x22c) (__sdhci_add_host) from [<c07eaf68>] (sdhci_omap_probe+0x318/0x72c) (sdhci_omap_probe) from [<c06a39d8>] (platform_probe+0x58/0xb8)
AFAIK we are not seeing this with the devices configured in the mainline kernel but this can cause issues for folks bringing up their boards.
--- drivers/mmc/host/sdhci-omap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-omap.c +2 -1
@@ -682,7 +682,8 @@ static void sdhci_omap_set_power(struct sdhci_host *host, unsigned char mode, {struct mmc_host *mmc = host->mmc; -mmc_regulator_set_ocr (mmc, mmc->supply.vmmc, vdd); +if (!IS_ERR (mmc->supply.vmmc)) +mmc_regulator_set_ocr (mmc, mmc->supply.vmmc, vdd); }static int sdhci_omap_enable_dma (struct sdhci_host *host)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 421/849 mmc: sdhci-omap: Fix context restore
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit d806e334d0390502cd2a820ad33d65d7f9bba618 ]
We need to restore context in a specified order with HCTL set in two phases. This is similar to what omap_hsmmc_context_restore() is doing. Otherwise SDIO can stop working on resume.
And for PM runtime and SDIO cards, we need to also save SYSCTL, IE and ISE.
This should not be a problem currently, and these patches can be applied whenever suitable.
--- drivers/mmc/host/sdhci-omap.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-omap.c +14 -1
@@ -62,6 +62,8 @@#define SDHCI_OMAP_IE 0x234#define INT_CC_EN BIT(0) +#define SDHCI_OMAP_ISE 0x238 +#define SDHCI_OMAP_AC12 0x23c#define AC12_V1V8_SIGEN BIT(19)#define AC12_SCLK_SEL BIT(23)
@@ -113,6 +115,8 @@ struct sdhci_omap_host {u32 hctl;u32 sysctl;u32 capa; +u32 ie; +u32 ise; };static void sdhci_omap_start_clock (struct sdhci_omap_host *omap_host);
@@ -1245,14 +1249,23 @@ static void sdhci_omap_context_save(struct sdhci_omap_host *omap_host) { omap_host->con =sdhci_omap_readl (omap_host,SDHCI_OMAP_CON ); omap_host->hctl =sdhci_omap_readl (omap_host,SDHCI_OMAP_HCTL ); + omap_host->sysctl =sdhci_omap_readl (omap_host,SDHCI_OMAP_SYSCTL ); omap_host->capa =sdhci_omap_readl (omap_host,SDHCI_OMAP_CAPA ); + omap_host->ie =sdhci_omap_readl (omap_host,SDHCI_OMAP_IE ); + omap_host->ise =sdhci_omap_readl (omap_host,SDHCI_OMAP_ISE ); } +/* Order matters here, HCTL must be restored in two phases */ static void sdhci_omap_context_restore (struct sdhci_omap_host *omap_host) { -sdhci_omap_writel (omap_host,SDHCI_OMAP_CON , omap_host->con);sdhci_omap_writel (omap_host,SDHCI_OMAP_HCTL , omap_host->hctl);sdhci_omap_writel (omap_host,SDHCI_OMAP_CAPA , omap_host->capa); +sdhci_omap_writel (omap_host,SDHCI_OMAP_HCTL , omap_host->hctl); + +sdhci_omap_writel (omap_host,SDHCI_OMAP_SYSCTL , omap_host->sysctl); +sdhci_omap_writel (omap_host,SDHCI_OMAP_CON , omap_host->con); +sdhci_omap_writel (omap_host,SDHCI_OMAP_IE , omap_host->ie); +sdhci_omap_writel (omap_host,SDHCI_OMAP_ISE , omap_host->ise); }static int __maybe_unused sdhci_omap_suspend (struct device *dev)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 422/849 memstick: avoid out-of-range warning
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 4853396f03c3019eccf5cd113e464231e9ddf0b3 ]
clang-14 complains about a sanity check that always passes when the page size is 64KB or larger:
drivers/memstick/core/ms_block.c:1739:21: error: result of comparison of constant 65536 with expression of type 'unsigned short' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (msb->page_size > PAGE_SIZE) {
~~~~~~~~~~~~~~ ^ ~~~~~~~~~This is fine, it will still work on all architectures, so just shut up that warning with a cast.
--- drivers/memstick/core/ms_block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memstick/core/ms_block.c +1 -1
@@ -1736,7 +1736,7 @@ static int msb_init_card(struct memstick_dev *card) msb->pages_in_block = boot_block->attr.block_size *2 ; msb->block_size = msb->page_size * msb->pages_in_block; -if (msb->page_size >PAGE_SIZE ) { +if ((size_t )msb->page_size >PAGE_SIZE ) {/* this isn't supported by linux at all, anyway*/ dbg ("device page %d size isn't supported" , msb->page_size);return -EINVAL ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 423/849 memstick: jmb38x_ms: use appropriate free function in jmb38x_ms_alloc_host()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit beae4a6258e64af609ad5995cc6b6056eb0d898e ]
The "msh" pointer is device managed, meaning that memstick_alloc_host() calls device_initialize() on it. That means that it can't be free using kfree() but must instead be freed with memstick_free_host(). Otherwise it leads to a tiny memory leak of device resources.
--- drivers/memstick/host/jmb38x_ms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memstick/host/jmb38x_ms.c +1 -1
@@ -882,7 +882,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)iounmap (host->addr); err_out_free: -kfree (msh); +memstick_free_host (msh);return NULL ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 424/849 net, neigh: Fix NTF_EXT_LEARNED in combination with NTF_USE
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
[ Upstream commit e4400bbf5b15750e1b59bf4722d18d99be60c69f ]
The NTF_EXT_LEARNED neigh flag is usually propagated back to user space upon dump of the neighbor table. However, when used in combination with NTF_USE flag this is not the case despite exempting the entry from the garbage collector. This results in inconsistent state since entries are typically marked in neigh->flags with NTF_EXT_LEARNED, but here they are not. Fix it by propagating the creation flag to ___neigh_create().
Before fix:
# ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a REACHABLE [...]
After fix:
# ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a extern_learn REACHABLE [...]
--- net/core/neighbour.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
net/core/neighbour.c +14 -12
@@ -379,7 +379,7 @@ EXPORT_SYMBOL(neigh_ifdown);static struct neighbour *neigh_alloc (struct neigh_table *tbl,struct net_device *dev, -bool exempt_from_gc) +u8 flags,bool exempt_from_gc) {struct neighbour *n =NULL ;unsigned long now = jiffies;
@@ -412,6 +412,7 @@ do_alloc: n->updated = n->used = now; n->nud_state =NUD_NONE ; n->output = neigh_blackhole; + n->flags = flags;seqlock_init (&n->hh.hh_lock); n->parms =neigh_parms_clone (&tbl->parms);timer_setup (&n->timer, neigh_timer_handler,0 );
@@ -575,19 +576,18 @@ struct neighbour *neigh_lookup_nodev(struct neigh_table *tbl, struct net *net, }EXPORT_SYMBOL (neigh_lookup_nodev); -static struct neighbour *___neigh_create (struct neigh_table *tbl, -const void *pkey, -struct net_device *dev, -bool exempt_from_gc,bool want_ref) +static struct neighbour * +___neigh_create (struct neigh_table *tbl,const void *pkey, +struct net_device *dev,u8 flags, +bool exempt_from_gc,bool want_ref) { -struct neighbour *n1, *rc, *n =neigh_alloc (tbl, dev, exempt_from_gc); -u32 hash_val; -unsigned int key_len = tbl->key_len; -int error; +u32 hash_val, key_len = tbl->key_len; +struct neighbour *n1, *rc, *n;struct neigh_hash_table *nht; +int error; + n =neigh_alloc (tbl, dev, flags, exempt_from_gc);trace_neigh_create (tbl, dev, pkey, n, exempt_from_gc); -if (!n) { rc =ERR_PTR (-ENOBUFS ); goto out;
@@ -674,7 +674,7 @@ out_neigh_release:struct neighbour *__neigh_create (struct neigh_table *tbl,const void *pkey,struct net_device *dev,bool want_ref) { -return ___neigh_create (tbl, pkey, dev, false, want_ref); +return ___neigh_create (tbl, pkey, dev,0 , false, want_ref); }EXPORT_SYMBOL (__neigh_create);
@@ -1947,7 +1947,9 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, exempt_from_gc = ndm->ndm_state &NUD_PERMANENT || ndm->ndm_flags &NTF_EXT_LEARNED ; - neigh =___neigh_create (tbl, dst, dev, exempt_from_gc, true); + neigh =___neigh_create (tbl, dst, dev, + ndm->ndm_flags &NTF_EXT_LEARNED , + exempt_from_gc, true);if (IS_ERR (neigh)) { err =PTR_ERR (neigh); goto out;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 425/849 hwmon: Fix possible memleak in __hwmon_device_register()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit ada61aa0b1184a8fda1a89a340c7d6cc4e59aee5 ]
I got memory leak as follows when doing fault injection test:
unreferenced object 0xffff888102740438 (size 8):
comm "27", pid 859, jiffies 4295031351 (age 143.992s) hex dump (first 8 bytes):
68 77 6d 6f 6e 30 00 00 hwmon0..
backtrace:
[<00000000544b5996>] __kmalloc_track_caller+0x1a6/0x300
[<00000000df0d62b9>] kvasprintf+0xad/0x140
[<00000000d3d2a3da>] kvasprintf_const+0x62/0x190
[<000000005f8f0f29>] kobject_set_name_vargs+0x56/0x140
[<00000000b739e4b9>] dev_set_name+0xb0/0xe0
[<0000000095b69c25>] __hwmon_device_register+0xf19/0x1e50 [hwmon]
[<00000000a7e65b52>] hwmon_device_register_with_info+0xcb/0x110 [hwmon]
[<000000006f181e86>] devm_hwmon_device_register_with_info+0x85/0x100 [hwmon]
[<0000000081bdc567>] tmp421_probe+0x2d2/0x465 [tmp421]
[<00000000502cc3f8>] i2c_device_probe+0x4e1/0xbb0
[<00000000f90bda3b>] really_probe+0x285/0xc30
[<000000007eac7b77>] __driver_probe_device+0x35f/0x4f0
[<000000004953d43d>] driver_probe_device+0x4f/0x140
[<000000002ada2d41>] __device_attach_driver+0x24c/0x330
[<00000000b3977977>] bus_for_each_drv+0x15d/0x1e0
[<000000005bf2a8e3>] __device_attach+0x267/0x410When device_register() returns an error, the name allocated in dev_set_name() will be leaked, the put_device() should be used instead of calling hwmon_dev_release() to give up the device reference, then the name will be freed in kobject_cleanup().
--- drivers/hwmon/hwmon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/hwmon.c +4 -2
@@ -796,8 +796,10 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,dev_set_drvdata (hdev, drvdata);dev_set_name (hdev,HWMON_ID_FORMAT , id); err =device_register (hdev); -if (err) - goto free_hwmon; +if (err) { +put_device (hdev); + goto ida_remove; + }INIT_LIST_HEAD (&hwdev->tzdata);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 426/849 hwmon: (pmbus/lm25066) Let compiler determine outer dimension of lm25066_coeff
In reply to Greg Kroah-HartmanFrom: Zev Weiss <[email protected]>
[ Upstream commit b7931a7b0e0df4d2a25fedd895ad32c746b77bc1 ]
Maintaining this manually is error prone (there are currently only five chips supported, not six); gcc can do it for us automatically.
--- drivers/hwmon/pmbus/lm25066.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/lm25066.c +1 -1
@@ -51,7 +51,7 @@ struct __coeff {#define PSC_CURRENT_IN_L (PSC_NUM_CLASSES)#define PSC_POWER_L (PSC_NUM_CLASSES + 1) -static struct __coeff lm25066_coeff[6 ][PSC_NUM_CLASSES +2 ] = { +static struct __coeff lm25066_coeff[][PSC_NUM_CLASSES +2 ] = { [lm25056] = { [PSC_VOLTAGE_IN ] = { .m =16296 ,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 427/849 ath10k: fix max antenna gain unit
In reply to Greg Kroah-HartmanFrom: Sven Eckelmann <[email protected]>
[ Upstream commit 0a491167fe0cf9f26062462de2a8688b96125d48 ]
Most of the txpower for the ath10k firmware is stored as twicepower (0.5 dB steps). This isn't the case for max_antenna_gain - which is still expected by the firmware as dB.
The firmware is converting it from dB to the internal (twicepower) representation when it calculates the limits of a channel. This can be seen in tpc_stats when configuring "12" as max_antenna_gain. Instead of the expected 12 (6 dB), the tpc_stats shows 24 (12 dB).
Tested on QCA9888 and IPQ4019 with firmware 10.4-3.5.3-00057.
--- drivers/net/wireless/ath/ath10k/mac.c | 6 +++--- drivers/net/wireless/ath/ath10k/wmi.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/mac.c +3 -3
@@ -1052,7 +1052,7 @@ static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id) arg.channel.min_power =0 ; arg.channel.max_power = channel->max_power *2 ; arg.channel.max_reg_power = channel->max_reg_power *2 ; - arg.channel.max_antenna_gain = channel->max_antenna_gain *2 ; + arg.channel.max_antenna_gain = channel->max_antenna_gain;reinit_completion (&ar->vdev_setup_done);reinit_completion (&ar->vdev_delete_done);
@@ -1498,7 +1498,7 @@ static int ath10k_vdev_start_restart(struct ath10k_vif *arvif, arg.channel.min_power =0 ; arg.channel.max_power = chandef->chan->max_power *2 ; arg.channel.max_reg_power = chandef->chan->max_reg_power *2 ; - arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain *2 ; + arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain;if (arvif->vdev_type ==WMI_VDEV_TYPE_AP ) { arg.ssid = arvif->u.ap.ssid;
@@ -3426,7 +3426,7 @@ static int ath10k_update_channel_list(struct ath10k *ar) ch->min_power =0 ; ch->max_power = channel->max_power *2 ; ch->max_reg_power = channel->max_reg_power *2 ; - ch->max_antenna_gain = channel->max_antenna_gain *2 ; + ch->max_antenna_gain = channel->max_antenna_gain; ch->reg_class_id =0 ;/* FIXME */ /* FIXME: why use only legacy modes, why not any
drivers/net/wireless/ath/ath10k/wmi.h +3 -0
@@ -2066,7 +2066,9 @@ struct wmi_channel {union {__le32 reginfo1;struct { +/* note: power unit is 1 dBm */ u8 antenna_max; +/* note: power unit is 0.5 dBm */ u8 max_tx_power; } __packed; } __packed;
@@ -2086,6 +2088,7 @@ struct wmi_channel_arg {u32 min_power;u32 max_power;u32 max_reg_power; +/* note: power unit is 1 dBm */ u32 max_antenna_gain;u32 reg_class_id;enum wmi_phy_mode mode;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 428/849 kernel/sched: Fix sched_fork() access an invalid sched_task_group
In reply to Greg Kroah-HartmanFrom: Zhang Qiao <[email protected]>
[ Upstream commit 4ef0c5c6b5ba1f38f0ea1cedad0cad722f00c14a ]
There is a small race between copy_process() and sched_fork() where child->sched_task_group point to an already freed pointer.
parent doing fork() | someone moving the parent
| to another cgroup
-------------------------------+-------------------------------
copy_process()
+ dup_task_struct()<1>
parent move to another cgroup, and free the old cgroup. <2>
+ sched_fork()
+ __set_task_cpu()<3>
+ task_fork_fair()
+ sched_slice()<4>
In the worst case, this bug can lead to "use-after-free" and cause panic as shown above:
(1) parent copy its sched_task_group to child at <1>;
(2) someone move the parent to another cgroup and free the old
cgroup at <2>;
(3) the sched_task_group and cfs_rq that belong to the old cgroup will be accessed at <3> and <4>, which cause a panic:
[] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 [] PGD 8000001fa0a86067 P4D 8000001fa0a86067 PUD 2029955067 PMD 0 [] Oops: 0000 [#1] SMP PTI
[] CPU: 7 PID: 648398 Comm: ebizzy Kdump: loaded Tainted: G OE --------- - - 4.18.0.x86_64+ #1
[] RIP: 0010:sched_slice+0x84/0xc0
[] Call Trace:
[] task_fork_fair+0x81/0x120 [] sched_fork+0x132/0x240 [] copy_process.part.5+0x675/0x20e0 [] ? __handle_mm_fault+0x63f/0x690 [] _do_fork+0xcd/0x3b0 [] do_syscall_64+0x5d/0x1d0 [] entry_SYSCALL_64_after_hwframe+0x65/0xca
[] RIP: 0033:0x7f04418cd7e1
Between cgroup_can_fork() and cgroup_post_fork(), the cgroup membership and thus sched_task_group can't change. So update child's sched_task_group at sched_post_fork() and move task_fork() and __set_task_cpu() (where accees the sched_task_group) from sched_fork() to sched_post_fork().
--- include/linux/sched/task.h | 3 ++- kernel/fork.c | 2 +- kernel/sched/core.c | 43 +++++++++++++++++++------------------- 3 files changed, 25 insertions(+), 23 deletions(-)
include/linux/sched/task.h +2 -1
@@ -54,7 +54,8 @@ extern asmlinkage void schedule_tail(struct task_struct *prev);extern void init_idle (struct task_struct *idle,int cpu);extern int sched_fork (unsigned long clone_flags,struct task_struct *p); -extern void sched_post_fork (struct task_struct *p); +extern void sched_post_fork (struct task_struct *p, +struct kernel_clone_args *kargs);extern void sched_dead (struct task_struct *p);void __noreturn do_task_dead (void );
kernel/fork.c +1 -1
@@ -2331,7 +2331,7 @@ static __latent_entropy struct task_struct *copy_process(write_unlock_irq (&tasklist_lock);proc_fork_connector (p); -sched_post_fork (p); +sched_post_fork (p, args);cgroup_post_fork (p, args);perf_event_fork (p);
kernel/sched/core.c +22 -21
62 lines not on this page · raw message
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 429/849 net: fealnx: fix build for UML
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit cd2621d07d517473611b170c69beb6524c677740 ]
On i386, when builtin (not a loadable module), the fealnx driver inspects boot_cpu_data to see what CPU family it is running on, and then acts on that data. The "family" struct member (x86) does not exist when running on UML, so prevent that test and do the default action.
Prevents this build error on UML + i386:
../drivers/net/ethernet/fealnx.c: In function ‘netdev_open’:../drivers/net/ethernet/fealnx.c:861:19: error: ‘struct cpuinfo_um’ has no member named ‘x86’
--- drivers/net/ethernet/fealnx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/fealnx.c +1 -1
@@ -857,7 +857,7 @@ static int netdev_open(struct net_device *dev) np->bcrvalue |=0x04 ;/* big-endian */ #endif -#if defined(__i386__) && !defined(MODULE ) +#if defined(__i386__) && !defined(MODULE ) && !defined(CONFIG_UML )if (boot_cpu_data.x86 <=4 ) np->crvalue =0xa00 ;else
Signature · 9 lines
2.33.0 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Greg Kroah-Hartman
maintainerPATCH 430/849 net: tulip: winbond-840: fix build for UML
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit a3d708925fcca1a2f7219bc9ce93e6341f85c1e0 ]
On i386, when builtin (not a loadable module), the winbond-840 driver inspects boot_cpu_data to see what CPU family it is running on, and then acts on that data. The "family" struct member (x86) does not exist when running on UML, so prevent that test and do the default action.
Prevents this build error on UML + i386:
../drivers/net/ethernet/dec/tulip/winbond-840.c: In function ‘init_registers’:../drivers/net/ethernet/dec/tulip/winbond-840.c:882:19: error: ‘struct cpuinfo_um’ has no member named ‘x86’
if (boot_cpu_data.x86 <= 4) {
--- drivers/net/ethernet/dec/tulip/winbond-840.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/dec/tulip/winbond-840.c +1 -1
@@ -877,7 +877,7 @@ static void init_registers(struct net_device *dev)8000 16 longwords 0200 2 longwords 2000 32 longwords C000 32 longwords 0400 4 longwords */ -#if defined (__i386__) && !defined(MODULE ) +#if defined (__i386__) && !defined(MODULE ) && !defined(CONFIG_UML )/* When not a module we can work around broken '486 PCI boards. */ if (boot_cpu_data.x86 <=4 ) { i |=0x4800 ;
Signature · 9 lines
2.33.0 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Greg Kroah-Hartman
maintainerPATCH 431/849 x86: Fix get_wchan() to support the ORC unwinder
In reply to Greg Kroah-HartmanFrom: Qi Zheng <[email protected]>
[ Upstream commit bc9bbb81730ea667c31c5b284f95ee312bab466f ]
Currently, the kernel CONFIG_UNWINDER_ORC option is enabled by default on x86, but the implementation of get_wchan() is still based on the frame pointer unwinder, so the /proc/<pid>/wchan usually returned 0 regardless of whether the task <pid> is running.
Reimplement get_wchan() by calling stack_trace_save_tsk(), which is adapted to the ORC and frame pointer unwinders.
--- arch/x86/kernel/process.c | 51 +++------------------------------------ 1 file changed, 3 insertions(+), 48 deletions(-)
arch/x86/kernel/process.c +3 -48
@@ -945,58 +945,13 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)*/ unsigned long get_wchan (struct task_struct *p) { -unsigned long start, bottom, top, sp, fp, ip, ret =0 ; -int count =0 ; +unsigned long entry =0 ;if (p == current ||task_is_running (p))return 0 ; -if (!try_get_task_stack (p)) -return 0 ; - - start = (unsigned long )task_stack_page (p); -if (!start) - goto out; - -/* -* Layout of the stack page: -* -* ----------- topmax = start + THREAD_SIZE - sizeof(unsigned long) -* PADDING -* ----------- top = topmax - TOP_OF_KERNEL_STACK_PADDING -* stack -* ----------- bottom = start -* -* The tasks stack pointer points at the location where the -* framepointer is stored. The data on the stack is: -* ... IP FP ... IP FP -* -* We need to read FP and IP, so we need to adjust the upper -* bound by another unsigned long. -*/ - top = start +THREAD_SIZE -TOP_OF_KERNEL_STACK_PADDING ; - top -=2 *sizeof (unsigned long ); - bottom = start; - - sp =READ_ONCE (p->thread.sp); -if (sp < bottom || sp > top) - goto out; - - fp =READ_ONCE_NOCHECK (((struct inactive_task_frame *)sp)->bp); -do { -if (fp < bottom || fp > top) - goto out; - ip =READ_ONCE_NOCHECK (*(unsigned long *)(fp +sizeof (unsigned long ))); -if (!in_sched_functions (ip)) { - ret = ip; - goto out; - } - fp =READ_ONCE_NOCHECK (*(unsigned long *)fp); - }while (count++ <16 && !task_is_running (p)); - -out: -put_task_stack (p); -return ret; +stack_trace_save_tsk (p, &entry,1 ,0 ); +return entry; } long do_arch_prctl_common(struct task_struct *task, int option,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 432/849 tcp: switch orphan_count to bare per-cpu counters
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 19757cebf0c5016a1f36f7fe9810a9f0b33c0832 ]
Use of percpu_counter structure to track count of orphaned sockets is causing problems on modern hosts with 256 cpus or more.
Stefan Bach reported a serious spinlock contention in real workloads, that I was able to reproduce with a netfilter rule dropping incoming FIN packets.
53.56% server [kernel.kallsyms] [k] queued_spin_lock_slowpath
|
---queued_spin_lock_slowpath
|
--53.51%--_raw_spin_lock_irqsave
|
--53.51%--__percpu_counter_sum
tcp_check_oom
|
|--39.03%--__tcp_close
| tcp_close
| inet_release
| inet6_release
| sock_close
| __fput
| ____fput
| task_work_run
| exit_to_usermode_loop
| do_syscall_64
| entry_SYSCALL_64_after_hwframe
| __GI___libc_close
|
--14.48%--tcp_out_of_resources
tcp_write_timeout
tcp_retransmit_timer
tcp_write_timer_handler
tcp_write_timer
call_timer_fn
expire_timers
__run_timers
run_timer_softirq
__softirqentry_text_startAs explained in commit cf86a086a180 ("net/dst: use a smaller percpu_counter batch for dst entries accounting"), default batch size is too big for the default value of tcp_max_orphans (262144).
But even if we reduce batch sizes, there would still be cases where the estimated count of orphans is beyond the limit, and where tcp_too_many_orphans() has to call the expensive percpu_counter_sum_positive().
One solution is to use plain per-cpu counters, and have a timer to periodically refresh this cache.
Updating this cache every 100ms seems about right, tcp pressure state is not radically changing over shorter periods.
percpu_counter was nice 15 years ago while hosts had less than 16 cpus, not anymore by current standards.
v2: Fix the build issue for CONFIG_CRYPTO_DEV_CHELSIO_TLS=m,
reported by kernel test robot <[email protected]> Remove unused socket argument from tcp_too_many_orphans()
--- .../chelsio/inline_crypto/chtls/chtls_cm.c | 2 +- .../chelsio/inline_crypto/chtls/chtls_cm.h | 2 +- include/net/inet_connection_sock.h | 2 +- include/net/sock.h | 2 +- include/net/tcp.h | 17 ++------- net/dccp/dccp.h | 2 +- net/dccp/proto.c | 14 ++----- net/ipv4/inet_connection_sock.c | 4 +- net/ipv4/inet_hashtables.c | 2 +- net/ipv4/proc.c | 2 +- net/ipv4/tcp.c | 38 ++++++++++++++++--- 11 files changed, 49 insertions(+), 38 deletions(-)
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c +1 -1
@@ -870,7 +870,7 @@ static void do_abort_syn_rcv(struct sock *child, struct sock *parent)* created only after 3 way handshake is done. */ sock_orphan (child); -percpu_counter_inc ((child)->sk_prot->orphan_count); +INC_ORPHAN_COUNT (child);chtls_release_resources (child);chtls_conn_done (child); }else {
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.h +1 -1
@@ -95,7 +95,7 @@ struct deferred_skb_cb {#define WSCALE_OK (tp) ((tp)->rx_opt.wscale_ok)#define TSTAMP_OK (tp) ((tp)->rx_opt.tstamp_ok)#define SACK_OK (tp) ((tp)->rx_opt.sack_ok) -#define INC_ORPHAN_COUNT (sk) percpu_counter_inc((sk)->sk_prot->orphan_count) +#define INC_ORPHAN_COUNT (sk) this_cpu_inc(*(sk)->sk_prot->orphan_count)/* TLS SKB */ #define skb_ulp_tls_inline (skb) (ULP_SKB_CB(skb)->ulp.tls.ofld)
include/net/inet_connection_sock.h +1 -1
@@ -289,7 +289,7 @@ static inline void inet_csk_prepare_for_destroy_sock(struct sock *sk) {/* The below has to be done to allow calling inet_csk_destroy_sock */ sock_set_flag (sk,SOCK_DEAD ); -percpu_counter_inc (sk->sk_prot->orphan_count); +this_cpu_inc (*sk->sk_prot->orphan_count); }void inet_csk_destroy_sock (struct sock *sk);
include/net/sock.h +1 -1
@@ -1235,7 +1235,7 @@ struct proto {unsigned int useroffset;/* Usercopy region offset */ unsigned int usersize;/* Usercopy region size */ -struct percpu_counter *orphan_count; +unsigned int __percpu *orphan_count;struct request_sock_ops *rsk_prot;struct timewait_sock_ops *twsk_prot;
include/net/tcp.h +3 -14
@@ -48,7 +48,9 @@extern struct inet_hashinfo tcp_hashinfo; -extern struct percpu_counter tcp_orphan_count; +DECLARE_PER_CPU(unsigned int, tcp_orphan_count); +int tcp_orphan_count_sum (void ); +void tcp_time_wait (struct sock *sk,int state,int timeo);#define MAX_TCP_HEADER L1_CACHE_ALIGN(128 + MAX_HEADER)
@@ -290,19 +292,6 @@ static inline bool tcp_out_of_memory(struct sock *sk)void sk_forced_mem_schedule (struct sock *sk,int size); -static inline bool tcp_too_many_orphans (struct sock *sk,int shift) -{ -struct percpu_counter *ocp = sk->sk_prot->orphan_count; -int orphans =percpu_counter_read_positive (ocp); - -if (orphans << shift > sysctl_tcp_max_orphans) { - orphans =percpu_counter_sum_positive (ocp); -if (orphans << shift > sysctl_tcp_max_orphans) -return true; - } -return false; -} -bool tcp_check_oom (struct sock *sk,int shift);
net/dccp/dccp.h +1 -1
@@ -48,7 +48,7 @@ extern bool dccp_debug;extern struct inet_hashinfo dccp_hashinfo; -extern struct percpu_counter dccp_orphan_count; +DECLARE_PER_CPU(unsigned int, dccp_orphan_count);void dccp_time_wait (struct sock *sk,int state,int timeo);
net/dccp/proto.c +4 -10
@@ -42,8 +42,8 @@ DEFINE_SNMP_STAT(struct dccp_mib, dccp_statistics) __read_mostly;EXPORT_SYMBOL_GPL (dccp_statistics); -struct percpu_counter dccp_orphan_count; -EXPORT_SYMBOL_GPL (dccp_orphan_count); +DEFINE_PER_CPU(unsigned int, dccp_orphan_count); +EXPORT_PER_CPU_SYMBOL_GPL (dccp_orphan_count);struct inet_hashinfo dccp_hashinfo;EXPORT_SYMBOL_GPL (dccp_hashinfo);
@@ -1055,7 +1055,7 @@ adjudge_to_death:bh_lock_sock (sk);WARN_ON (sock_owned_by_user (sk)); -percpu_counter_inc (sk->sk_prot->orphan_count); +this_cpu_inc (dccp_orphan_count);/* Have we already been destroyed by a softirq or backlog? */ if (state !=DCCP_CLOSED && sk->sk_state ==DCCP_CLOSED )
@@ -1115,13 +1115,10 @@ static int __init dccp_init(void)BUILD_BUG_ON (sizeof (struct dccp_skb_cb ) > sizeof_field(struct sk_buff, cb)); - rc =percpu_counter_init (&dccp_orphan_count,0 ,GFP_KERNEL ); -if (rc) - goto out_fail;inet_hashinfo_init (&dccp_hashinfo); rc =inet_hashinfo2_init_mod (&dccp_hashinfo);if (rc) - goto out_free_percpu; + goto out_fail; rc = -ENOBUFS ; dccp_hashinfo.bind_bucket_cachep = kmem_cache_create("dccp_bind_bucket",
@@ -1226,8 +1223,6 @@ out_free_bind_bucket_cachep:kmem_cache_destroy (dccp_hashinfo.bind_bucket_cachep); out_free_hashinfo2:inet_hashinfo2_free_mod (&dccp_hashinfo); -out_free_percpu: -percpu_counter_destroy (&dccp_orphan_count); out_fail: dccp_hashinfo.bhash =NULL ; dccp_hashinfo.ehash =NULL ;
@@ -1250,7 +1245,6 @@ static void __exit dccp_fini(void)dccp_ackvec_exit ();dccp_sysctl_exit ();inet_hashinfo2_free_mod (&dccp_hashinfo); -percpu_counter_destroy (&dccp_orphan_count); }module_init (dccp_init);
net/ipv4/inet_connection_sock.c +2 -2
@@ -1014,7 +1014,7 @@ void inet_csk_destroy_sock(struct sock *sk)sk_refcnt_debug_release (sk); -percpu_counter_dec (sk->sk_prot->orphan_count); +this_cpu_dec (*sk->sk_prot->orphan_count);sock_put (sk); }
@@ -1073,7 +1073,7 @@ static void inet_child_forget(struct sock *sk, struct request_sock *req,sock_orphan (child); -percpu_counter_inc (sk->sk_prot->orphan_count); +this_cpu_inc (*sk->sk_prot->orphan_count);if (sk->sk_protocol ==IPPROTO_TCP &&tcp_rsk (req)->tfo_listener) {BUG_ON (rcu_access_pointer (tcp_sk (child)->fastopen_rsk) != req);
net/ipv4/inet_hashtables.c +1 -1
@@ -598,7 +598,7 @@ bool inet_ehash_nolisten(struct sock *sk, struct sock *osk, bool *found_dup_sk)if (ok) {sock_prot_inuse_add (sock_net (sk), sk->sk_prot,1 ); }else { -percpu_counter_inc (sk->sk_prot->orphan_count); +this_cpu_inc (*sk->sk_prot->orphan_count);inet_sk_set_state (sk,TCP_CLOSE );sock_set_flag (sk,SOCK_DEAD );inet_csk_destroy_sock (sk);
net/ipv4/proc.c +1 -1
@@ -53,7 +53,7 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)struct net *net = seq->private;int orphans, sockets; - orphans =percpu_counter_sum_positive (&tcp_orphan_count); + orphans =tcp_orphan_count_sum (); sockets =proto_sockets_allocated_sum_positive (&tcp_prot);socket_seq_show (seq);
net/ipv4/tcp.c +33 -5
@@ -287,8 +287,8 @@ enum {TCP_CMSG_TS =2 }; -struct percpu_counter tcp_orphan_count; -EXPORT_SYMBOL_GPL (tcp_orphan_count); +DEFINE_PER_CPU(unsigned int, tcp_orphan_count); +EXPORT_PER_CPU_SYMBOL_GPL (tcp_orphan_count);long sysctl_tcp_mem[3 ]__read_mostly ;EXPORT_SYMBOL (sysctl_tcp_mem);
@@ -2690,11 +2690,36 @@ void tcp_shutdown(struct sock *sk, int how) }EXPORT_SYMBOL (tcp_shutdown); +int tcp_orphan_count_sum (void ) +{ +int i, total =0 ; + +for_each_possible_cpu (i) + total +=per_cpu (tcp_orphan_count, i); + +return max (total,0 ); +} + +static int tcp_orphan_cache; +static struct timer_list tcp_orphan_timer; +#define TCP_ORPHAN_TIMER_PERIOD msecs_to_jiffies(100) + +static void tcp_orphan_update (struct timer_list *unused) +{ +WRITE_ONCE (tcp_orphan_cache,tcp_orphan_count_sum ()); +mod_timer (&tcp_orphan_timer, jiffies +TCP_ORPHAN_TIMER_PERIOD ); +} + +static bool tcp_too_many_orphans (int shift) +{ +return READ_ONCE (tcp_orphan_cache) << shift > sysctl_tcp_max_orphans; +} +bool tcp_check_oom (struct sock *sk,int shift) {bool too_many_orphans, out_of_socket_memory; - too_many_orphans =tcp_too_many_orphans (sk, shift); + too_many_orphans =tcp_too_many_orphans (shift); out_of_socket_memory =tcp_out_of_memory (sk);if (too_many_orphans)
@@ -2803,7 +2828,7 @@ adjudge_to_death:/* remove backlog if any, without releasing ownership. */ __release_sock (sk); -percpu_counter_inc (sk->sk_prot->orphan_count); +this_cpu_inc (tcp_orphan_count);/* Have we already been destroyed by a softirq or backlog? */ if (state !=TCP_CLOSE && sk->sk_state ==TCP_CLOSE )
@@ -4504,7 +4529,10 @@ void __init tcp_init(void) sizeof_field(struct sk_buff, cb));percpu_counter_init (&tcp_sockets_allocated,0 ,GFP_KERNEL ); -percpu_counter_init (&tcp_orphan_count,0 ,GFP_KERNEL ); + +timer_setup (&tcp_orphan_timer, tcp_orphan_update,TIMER_DEFERRABLE ); +mod_timer (&tcp_orphan_timer, jiffies +TCP_ORPHAN_TIMER_PERIOD ); +inet_hashinfo_init (&tcp_hashinfo); inet_hashinfo2_init(&tcp_hashinfo, "tcp_listen_portaddr_hash", thash_entries, 21, /* one slot per 2 MB*/
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 433/849 crypto: octeontx2 - set assoclen in aead_do_fallback()
In reply to Greg Kroah-HartmanFrom: Ovidiu Panait <[email protected]>
[ Upstream commit 06f6e365e2ecf799c249bb464aa9d5f055e88b56 ]
Currently, in case of aead fallback, no associated data info is set in the fallback request. To fix this, call aead_request_set_ad() to pass the assoclen.
--- drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c +1 -0
@@ -1274,6 +1274,7 @@ static int aead_do_fallback(struct aead_request *req, bool is_enc) req->base.complete, req->base.data);aead_request_set_crypt (&rctx->fbk_req, req->src, req->dst, req->cryptlen, req->iv); +aead_request_set_ad (&rctx->fbk_req, req->assoclen); ret = is_enc ?crypto_aead_encrypt (&rctx->fbk_req) :crypto_aead_decrypt (&rctx->fbk_req); }else {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 434/849 thermal/core: fix a UAF bug in __thermal_cooling_device_register()
In reply to Greg Kroah-HartmanFrom: Ziyang Xuan <[email protected]>
[ Upstream commit 0a5c26712f963f0500161a23e0ffff8d29f742ab ]
When device_register() return failed, program will goto out_kfree_type to release 'cdev->device' by put_device(). That will call thermal_release() to free 'cdev'. But the follow-up processes access 'cdev' continually. That trggers the UAF bug.
====================================================================
BUG: KASAN: use-after-free in __thermal_cooling_device_register+0x75b/0xa90 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 Call Trace: dump_stack_lvl+0xe2/0x152 print_address_description.constprop.0+0x21/0x140 ? __thermal_cooling_device_register+0x75b/0xa90 kasan_report.cold+0x7f/0x11b ? __thermal_cooling_device_register+0x75b/0xa90 __thermal_cooling_device_register+0x75b/0xa90 ? memset+0x20/0x40 ? __sanitizer_cov_trace_pc+0x1d/0x50 ? __devres_alloc_node+0x130/0x180 devm_thermal_of_cooling_device_register+0x67/0xf0 max6650_probe.cold+0x557/0x6aa
......
Freed by task 258: kasan_save_stack+0x1b/0x40 kasan_set_track+0x1c/0x30 kasan_set_free_info+0x20/0x30 __kasan_slab_free+0x109/0x140 kfree+0x117/0x4c0 thermal_release+0xa0/0x110 device_release+0xa7/0x240 kobject_put+0x1ce/0x540 put_device+0x20/0x30 __thermal_cooling_device_register+0x731/0xa90 devm_thermal_of_cooling_device_register+0x67/0xf0 max6650_probe.cold+0x557/0x6aa [max6650]
Do not use 'cdev' again after put_device() to fix the problem like doing in thermal_zone_device_register().
[dlezcano]: as requested by Rafael, change the affectation into two statements.
--- drivers/thermal/thermal_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/thermal/thermal_core.c +4 -2
@@ -887,7 +887,7 @@ __thermal_cooling_device_register(struct device_node *np, {struct thermal_cooling_device *cdev;struct thermal_zone_device *pos =NULL ; -int ret; +int id, ret;if (!ops || !ops->get_max_state || !ops->get_cur_state || !ops->set_cur_state)
@@ -901,6 +901,7 @@ __thermal_cooling_device_register(struct device_node *np,if (ret <0 ) goto out_kfree_cdev; cdev->id = ret; + id = ret; ret =dev_set_name (&cdev->device,"cooling_device%d" , cdev->id);if (ret)
@@ -944,8 +945,9 @@ __thermal_cooling_device_register(struct device_node *np, out_kfree_type:kfree (cdev->type);put_device (&cdev->device); + cdev =NULL ; out_ida_remove: -ida_simple_remove (&thermal_cdev_ida, cdev->id); +ida_simple_remove (&thermal_cdev_ida, id); out_kfree_cdev:kfree (cdev);return ERR_PTR (ret);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 435/849 drm/msm: Fix potential Oops in a6xx_gmu_rpmh_init()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 3d91e50ff58364f6572ad268b508175d27800e51 ]
There are two problems here:
1) The "seqptr" is used uninitalized when we free it at the end.
2) The a6xx_gmu_get_mmio() function returns error pointers. It never returns true.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +3 -3
@@ -516,11 +516,11 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;struct platform_device *pdev =to_platform_device (gmu->dev);void __iomem *pdcptr =a6xx_gmu_get_mmio (pdev,"gmu_pdc" ); -void __iomem *seqptr; +void __iomem *seqptr =NULL ;uint32_t pdc_address_offset;bool pdc_in_aop = false; -if (!pdcptr) +if (IS_ERR (pdcptr)) goto err;if (adreno_is_a650 (adreno_gpu) ||adreno_is_a660 (adreno_gpu))
@@ -532,7 +532,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)if (!pdc_in_aop) { seqptr =a6xx_gmu_get_mmio (pdev,"gmu_pdc_seq" ); -if (!seqptr) +if (IS_ERR (seqptr)) goto err; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 436/849 drm/msm: potential error pointer dereference in init()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit b6816441a14bbe356ba8590de79cfea2de6a085c ]
The msm_iommu_new() returns error pointers on failure so check for that to avoid an Oops.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +4 -0
@@ -896,6 +896,10 @@ static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms)return 0 ; mmu =msm_iommu_new (dpu_kms->dev->dev, domain); +if (IS_ERR (mmu)) { +iommu_domain_free (domain); +return PTR_ERR (mmu); + } aspace =msm_gem_address_space_create (mmu,"dpu1" ,0x1000 ,0x100000000 -0x1000 );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 437/849 drm/msm: fix potential NULL dereference in cleanup
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 027d052a36e56789a2134772bacb4fd0860f03a3 ]
The "msm_obj->node" list needs to be initialized earlier so that the list_del() in msm_gem_free_object() doesn't experience a NULL pointer dereference.
--- drivers/gpu/drm/msm/msm_gem.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/msm/msm_gem.c +1 -0
@@ -1184,6 +1184,7 @@ static int msm_gem_new_impl(struct drm_device *dev, msm_obj->madv =MSM_MADV_WILLNEED ;INIT_LIST_HEAD (&msm_obj->submit_entry); +INIT_LIST_HEAD (&msm_obj->node);INIT_LIST_HEAD (&msm_obj->vmas); *obj = &msm_obj->base;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 438/849 drm/msm: uninitialized variable in msm_gem_import()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 2203bd0e5c12ffc53ffdd4fbd7b12d6ba27e0424 ]
The msm_gem_new_impl() function cleans up after itself so there is no need to call drm_gem_object_put(). Conceptually, it does not make sense to call a kref_put() function until after the reference counting has been initialized which happens immediately after this call in the drm_gem_(private_)object_init() functions.
In the msm_gem_import() function the "obj" pointer is uninitialized, so it will lead to a crash.
--- drivers/gpu/drm/msm/msm_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_gem.c +2 -2
@@ -1220,7 +1220,7 @@ static struct drm_gem_object *_msm_gem_new(struct drm_device *dev, ret =msm_gem_new_impl (dev, size, flags, &obj);if (ret) - goto fail; +return ERR_PTR (ret); msm_obj =to_msm_bo (obj);
@@ -1320,7 +1320,7 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev, ret =msm_gem_new_impl (dev, size,MSM_BO_WC , &obj);if (ret) - goto fail; +return ERR_PTR (ret);drm_gem_private_object_init (dev, obj, size);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 439/849 net: stream: dont purge sk_error_queue in sk_stream_kill_queues()
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 24bcbe1cc69fa52dc4f7b5b2456678ed464724d8 ]
sk_stream_kill_queues() can be called on close when there are still outstanding skbs to transmit. Those skbs may try to queue notifications to the error queue (e.g. timestamps). If sk_stream_kill_queues() purges the queue without taking its lock the queue may get corrupted, and skbs leaked.
This shows up as a warning about an rmem leak:
WARNING: CPU: 24 PID: 0 at net/ipv4/af_inet.c:154 inet_sock_destruct+0x...
The leak is always a multiple of 0x300 bytes (the value is in %rax on my builds, so RAX: 0000000000000300). 0x300 is truesize of an empty sk_buff. Indeed if we dump the socket state at the time of the warning the sk_error_queue is often (but not always) corrupted. The ->next pointer points back at the list head, but not the ->prev pointer. Indeed we can find the leaked skb by scanning the kernel memory for something that looks like an skb with ->sk = socket in question, and ->truesize = 0x300. The contents of ->cb[] of the skb confirms the suspicion that it is indeed a timestamp notification (as generated in __skb_complete_tx_timestamp()).
Removing purging of sk_error_queue should be okay, since inet_sock_destruct() does it again once all socket refs are gone. Eric suggests this may cause sockets that go thru disconnect() to maintain notifications from the previous incarnations of the socket, but that should be okay since the race was there anyway, and disconnect() is not exactly dependable.
Thanks to Jonathan Lemon and Omar Sandoval for help at various stages of tracing the issue.
--- net/core/stream.c | 3 --- 1 file changed, 3 deletions(-)
net/core/stream.c +0 -3
@@ -195,9 +195,6 @@ void sk_stream_kill_queues(struct sock *sk)/* First the read buffer. */ __skb_queue_purge (&sk->sk_receive_queue); -/* Next, the error queue. */ -__skb_queue_purge (&sk->sk_error_queue); -/* Next, the write queue. */ WARN_ON (!skb_queue_empty (&sk->sk_write_queue));
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 440/849 mailbox: Remove WARN_ON for async_cb.cb in cmdq_exec_done
In reply to Greg Kroah-HartmanFrom: jason-jh.lin <[email protected]>
[ Upstream commit ce1537fe288469bf68ee0aabdb860a790b4755ef ]
Because mtk_drm_crtc_update_config is not using cmdq_pkt_flush_async, it won't have pkt->async_cb.cb anymore.
So remove the WARN_ON check of pkt->async_cb.cb at cmdq_exec_done.
--- drivers/mailbox/mtk-cmdq-mailbox.c | 1 - 1 file changed, 1 deletion(-)
drivers/mailbox/mtk-cmdq-mailbox.c +0 -1
@@ -186,7 +186,6 @@ static void cmdq_task_exec_done(struct cmdq_task *task, int sta)struct cmdq_task_cb *cb = &task->pkt->async_cb;struct cmdq_cb_data data; -WARN_ON (cb->cb == (cmdq_async_flush_cb )NULL ); data.sta = sta; data.data = cb->data; data.pkt = task->pkt;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 441/849 media: ivtv: fix build for UML
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 6cb67bea945bdf0ad40e633cd2d9fbeb0855675b ]
Prevent the use of page table macros and types from 2 conflicting places. This fixes multiple build errors and warnings, e.g.:
../arch/x86/include/asm/pgtable_64_types.h:21:34: error: conflicting types for ‘pte_t’
typedef struct { pteval_t pte; } pte_t;
^~~~~
In file included from ../include/linux/mm_types_task.h:16:0,
from ../include/linux/mm_types.h:5,
from ../include/linux/buildid.h:5,
from ../include/linux/module.h:14,
from ../drivers/media/pci/ivtv/ivtv-driver.h:40,
from ../drivers/media/pci/ivtv/ivtvfb.c:29:../arch/um/include/asm/page.h:57:39: note: previous declaration of ‘pte_t’ was here
typedef struct { unsigned long pte; } pte_t;
../arch/x86/include/asm/pgtable_types.h:284:43: error: expected ‘)’ before ‘prot’
static inline pgprot_t pgprot_nx(pgprot_t prot)
^
../include/linux/pgtable.h:914:26: note: in definition of macro ‘pgprot_nx’
#define pgprot_nx(prot) (prot)
^~~~
In file included from ../arch/x86/include/asm/memtype.h:6:0,
from ../drivers/media/pci/ivtv/ivtvfb.c:40:../arch/x86/include/asm/pgtable_types.h:288:0: warning: "pgprot_nx" redefined
#define pgprot_nx pgprot_nx
../arch/x86/include/asm/page_types.h:11:0: warning: "PAGE_SIZE" redefined
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
In file included from ../include/linux/mm_types_task.h:16:0,
from ../include/linux/mm_types.h:5,
from ../include/linux/buildid.h:5,
from ../include/linux/module.h:14,
from ../drivers/media/pci/ivtv/ivtv-driver.h:40,
from ../drivers/media/pci/ivtv/ivtvfb.c:29:../arch/um/include/asm/page.h:14:0: note: this is the location of the previous definition
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
--- drivers/media/pci/ivtv/ivtvfb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/pci/ivtv/ivtvfb.c +2 -2
@@ -36,7 +36,7 @@#include <linux/fb.h> #include <linux/ivtvfb.h> -#ifdef CONFIG_X86_64 +#if defined(CONFIG_X86_64 ) && !defined(CONFIG_UML )#include <asm/memtype.h> #endif
@@ -1157,7 +1157,7 @@ static int ivtvfb_init_card(struct ivtv *itv) {int rc; -#ifdef CONFIG_X86_64 +#if defined(CONFIG_X86_64 ) && !defined(CONFIG_UML )if (pat_enabled ()) {if (ivtvfb_force_pat) {pr_info ("PAT is enabled. Write-combined framebuffer caching will be disabled.\n" );
Signature · 9 lines
2.33.0 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Greg Kroah-Hartman
maintainerPATCH 442/849 media: ir_toy: assignment to be16 should be of correct type
In reply to Greg Kroah-HartmanFrom: Sean Young <[email protected]>
[ Upstream commit febfe985fc2ea052a363f6525ff624b8efd5273c ]
commit f0c15b360fb6 ("media: ir_toy: prevent device from hanging during transmit") removed a cpu_to_be16() cast, which causes a sparse warning.
--- drivers/media/rc/ir_toy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/ir_toy.c +1 -1
@@ -310,7 +310,7 @@ static int irtoy_tx(struct rc_dev *rc, uint *txbuf, uint count) buf[i] =cpu_to_be16 (v); } - buf[count] =0xffff ; + buf[count] =cpu_to_be16 (0xffff ); irtoy->tx_buf = buf; irtoy->tx_len = size;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 443/849 mmc: mxs-mmc: disable regulator on error and in the remove function
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit ce5f6c2c9b0fcb4094f8e162cfd37fb4294204f7 ]
The 'reg_vmmc' regulator is enabled in the probe. It is never disabled. Neither in the error handling path of the probe nor in the remove function.
Register a devm_action to disable it when needed.
--- drivers/mmc/host/mxs-mmc.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/mmc/host/mxs-mmc.c +10 -0
@@ -552,6 +552,11 @@ static const struct of_device_id mxs_mmc_dt_ids[] = { };MODULE_DEVICE_TABLE (of, mxs_mmc_dt_ids); +static void mxs_mmc_regulator_disable (void *regulator) +{ +regulator_disable (regulator); +} +static int mxs_mmc_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node;
@@ -591,6 +596,11 @@ static int mxs_mmc_probe(struct platform_device *pdev) "Failed to enable vmmc regulator: %d\n", ret); goto out_mmc_free; } + + ret =devm_add_action_or_reset (&pdev->dev, mxs_mmc_regulator_disable, + reg_vmmc); +if (ret) + goto out_mmc_free; } ssp->clk =devm_clk_get (&pdev->dev,NULL );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 444/849 block: ataflop: fix breakage introduced at blk-mq refactoring
In reply to Greg Kroah-HartmanFrom: Michael Schmitz <[email protected]>
[ Upstream commit 86d46fdaa12ae5befc16b8d73fc85a3ca0399ea6 ]
Refactoring of the Atari floppy driver when converting to blk-mq has broken the state machine in not-so-subtle ways:
finish_fdc() must be called when operations on the floppy device have completed. This is crucial in order to relase the ST-DMA lock, which protects against concurrent access to the ST-DMA controller by other drivers (some DMA related, most just related to device register access - broken beyond compare, I know).
When rewriting the driver's old do_request() function, the fact that finish_fdc() was called only when all queued requests had completed appears to have been overlooked. Instead, the new request function calls finish_fdc() immediately after the last request has been queued. finish_fdc() executes a dummy seek after most requests, and this overwrites the state machine's interrupt hander that was set up to wait for completion of the read/write request just prior. To make matters worse, finish_fdc() is called before device interrupts are re-enabled, making certain that the read/write interupt is missed.
Shifting the finish_fdc() call into the read/write request completion handler ensures the driver waits for the request to actually complete. With a queue depth of 2, we won't see long request sequences, so calling finish_fdc() unconditionally just adds a little overhead for the dummy seeks, and keeps the code simple.
While we're at it, kill ataflop_commit_rqs() which does nothing but run finish_fdc() unconditionally, again likely wiping out an in-flight request.
--- drivers/block/ataflop.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/block/ataflop.c +3 -15
@@ -653,9 +653,6 @@ static inline void copy_buffer(void *from, void *to) *p2++ = *p1++; } - - -/* General Interrupt Handling */ static void (*FloppyIRQHandler)(int status ) =NULL ;
@@ -1228,6 +1225,7 @@ static void fd_rwsec_done1(int status) }else {/* all sectors finished */ +finish_fdc ();fd_end_request_cur (BLK_STS_OK ); }return ;
@@ -1475,15 +1473,6 @@ static void setup_req_params( int drive ) ReqTrack, ReqSector, (unsigned long)ReqData )); } -static void ataflop_commit_rqs (struct blk_mq_hw_ctx *hctx) -{ -spin_lock_irq (&ataflop_lock); -atari_disable_irq (IRQ_MFP_FDC ); -finish_fdc (); -atari_enable_irq (IRQ_MFP_FDC ); -spin_unlock_irq (&ataflop_lock); -} -static blk_status_t ataflop_queue_rq (struct blk_mq_hw_ctx *hctx,const struct blk_mq_queue_data *bd) {
@@ -1491,6 +1480,8 @@ static blk_status_t ataflop_queue_rq(struct blk_mq_hw_ctx *hctx,int drive = floppy - unit;int type = floppy->type; +DPRINT (("Queue request: drive %d type %d last %d\n" , drive, type, bd->last)); +spin_lock_irq (&ataflop_lock);if (fd_request) {spin_unlock_irq (&ataflop_lock);
@@ -1550,8 +1541,6 @@ static blk_status_t ataflop_queue_rq(struct blk_mq_hw_ctx *hctx,setup_req_params ( drive );do_fd_action ( drive ); -if (bd->last) -finish_fdc ();atari_enable_irq (IRQ_MFP_FDC ); out:
@@ -1962,7 +1951,6 @@ static const struct block_device_operations floppy_fops = {static const struct blk_mq_ops ataflop_mq_ops = { .queue_rq = ataflop_queue_rq, - .commit_rqs = ataflop_commit_rqs, };static int ataflop_alloc_disk (unsigned int drive,unsigned int type)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 445/849 platform/x86: thinkpad_acpi: Fix bitwise vs. logical warning
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit fd96e35ea7b95f1e216277805be89d66e4ae962d ]
A new warning in clang points out a use of bitwise OR with boolean expressions in this driver:
drivers/platform/x86/thinkpad_acpi.c:9061:11: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
else if ((strlencmp(cmd, "level disengaged") == 0) |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
||drivers/platform/x86/thinkpad_acpi.c:9061:11: note: cast one or both operands to int to silence this warning 1 error generated.
This should clearly be a logical OR so change it to fix the warning.
--- drivers/platform/x86/thinkpad_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/thinkpad_acpi.c +1 -1
@@ -9145,7 +9145,7 @@ static int fan_write_cmd_level(const char *cmd, int *rc)if (strlencmp (cmd,"level auto" ) ==0 ) level =TP_EC_FAN_AUTO ; -else if ((strlencmp (cmd,"level disengaged" ) ==0 ) | +else if ((strlencmp (cmd,"level disengaged" ) ==0 ) || (strlencmp (cmd,"level full-speed" ) ==0 )) level =TP_EC_FAN_FULLSPEED ;else if (sscanf (cmd,"level %d" , &level) !=1 )
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 446/849 ACPI: PM: Turn off unused wakeup power resources
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 7a63296d6f579a02b2675b4b0fe5b1cd3235e8d3 ]
If an ACPI power resource is found to be "on" during the initialization of the list of wakeup power resources of a device, it is reference counted and its wakeup_enabled flag is set, which is problematic if the deivce in question is the only user of the given power resource, it is never runtime-suspended and it is not allowed to wake up the system from sleep, because in that case the given power resource will stay "on" until the system reboots and energy will be wasted.
It is better to simply turn off wakeup power resources that are "on" during the initialization unless their reference counters are not zero, because that may be the only opportunity to prevent them from staying in the "on" state all the time.
--- drivers/acpi/power.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/acpi/power.c +9 -10
@@ -606,20 +606,19 @@ int acpi_power_wakeup_list_init(struct list_head *list, int *system_level_p)list_for_each_entry (entry, list, node) {struct acpi_power_resource *resource = entry->resource; -int result;u8 state;mutex_lock (&resource->resource_lock); - result =acpi_power_get_state (resource, &state); -if (result) { -mutex_unlock (&resource->resource_lock); -return result; - } -if (state ==ACPI_POWER_RESOURCE_STATE_ON ) { - resource->ref_count++; - resource->wakeup_enabled = true; - } +/* +* Make sure that the power resource state and its reference +* counter value are consistent with each other. +*/ +if (!resource->ref_count && + !acpi_power_get_state (resource, &state) && + state ==ACPI_POWER_RESOURCE_STATE_ON ) +__acpi_power_off (resource); +if (system_level > resource->system_level) system_level = resource->system_level;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 447/849 ACPI: PM: Fix sharing of wakeup power resources
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit a2d7b2e004af6b09f21ac3d10f8f4456c16a8ddf ]
If an ACPI wakeup power resource is shared between multiple devices, it may not be managed correctly.
Suppose, for example, that two devices, A and B, share a wakeup power resource P whose wakeup_enabled flag is 0 initially. Next, suppose that wakeup power is enabled for A and B, in this order, and disabled for B. When wakeup power is enabled for A, P will be turned on and its wakeup_enabled flag will be set. Next, when wakeup power is enabled for B, P will not be touched, because its wakeup_enabled flag is set. Now, when wakeup power is disabled for B, P will be turned off which is incorrect, because A will still need P in order to signal wakeup.
Moreover, if wakeup power is enabled for A and then disabled for B, the latter will cause P to be turned off incorrectly (it will be still needed by A), because acpi_disable_wakeup_device_power() is allowed to manipulate power resources when the wakeup.prepare_count counter of the given device is 0.
While the first issue could be addressed by changing the wakeup_enabled power resource flag into a counter, addressing the second one requires modifying acpi_disable_wakeup_device_power() to do nothing when the target device's wakeup.prepare_count reference counter is zero and that would cause the new counter to be redundant. Namely, if acpi_disable_wakeup_device_power() is modified as per the above, every change of the new counter following a wakeup.prepare_count change would be reflected by the analogous change of the main reference counter of the given power resource.
Accordingly, modify acpi_disable_wakeup_device_power() to do nothing when the target device's wakeup.prepare_count reference counter is zero and drop the power resource wakeup_enabled flag altogether.
While at it, ensure that all of the power resources that can be turned off will be turned off when disabling device wakeup due to a power resource manipulation error, to prevent energy from being wasted.
--- drivers/acpi/power.c | 69 +++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 45 deletions(-)
drivers/acpi/power.c +24 -45
@@ -53,7 +53,6 @@ struct acpi_power_resource {u32 order;unsigned int ref_count;u8 state; -bool wakeup_enabled;struct mutex resource_lock;struct list_head dependents; };
@@ -701,7 +700,6 @@ int acpi_device_sleep_wake(struct acpi_device *dev,*/ int acpi_enable_wakeup_device_power (struct acpi_device *dev,int sleep_state) { -struct acpi_power_resource_entry *entry;int err =0 ;if (!dev || !dev->wakeup.flags.valid)
@@ -712,26 +710,13 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)if (dev->wakeup.prepare_count++) goto out; -list_for_each_entry (entry, &dev->wakeup.resources, node) { -struct acpi_power_resource *resource = entry->resource; - -mutex_lock (&resource->resource_lock); - -if (!resource->wakeup_enabled) { - err =acpi_power_on_unlocked (resource); -if (!err) - resource->wakeup_enabled = true; - } - -mutex_unlock (&resource->resource_lock); - -if (err) { -dev_err (&dev->dev, -"Cannot turn wakeup power resources on\n" ); - dev->wakeup.flags.valid =0 ; - goto out; - } + err =acpi_power_on_list (&dev->wakeup.resources); +if (err) { +dev_err (&dev->dev,"Cannot turn on wakeup power resources\n" ); + dev->wakeup.flags.valid =0 ; + goto out; } +/* * Passing 3 as the third argument below means the device may be * put into arbitrary power state afterward.
@@ -761,39 +746,33 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)mutex_lock (&acpi_device_lock); -if (--dev->wakeup.prepare_count >0 ) +if (dev->wakeup.prepare_count >1 ) { + dev->wakeup.prepare_count--; goto out; + } -/* -* Executing the code below even if prepare_count is already zero when -* the function is called may be useful, for example for initialisation. -*/ -if (dev->wakeup.prepare_count <0 ) - dev->wakeup.prepare_count =0 ; +/* Do nothing if wakeup power has not been enabled for this device. */ +if (!dev->wakeup.prepare_count) + goto out; err =acpi_device_sleep_wake (dev,0 ,0 ,0 );if (err) goto out; +/* +* All of the power resources in the list need to be turned off even if +* there are errors. +*/ list_for_each_entry (entry, &dev->wakeup.resources, node) { -struct acpi_power_resource *resource = entry->resource; - -mutex_lock (&resource->resource_lock); - -if (resource->wakeup_enabled) { - err =acpi_power_off_unlocked (resource); -if (!err) - resource->wakeup_enabled = false; - } - -mutex_unlock (&resource->resource_lock); +int ret; -if (err) { -dev_err (&dev->dev, -"Cannot turn wakeup power resources off\n" ); - dev->wakeup.flags.valid =0 ; -break ; - } + ret =acpi_power_off (entry->resource); +if (ret && !err) + err = ret; + } +if (err) { +dev_err (&dev->dev,"Cannot turn off wakeup power resources\n" ); + dev->wakeup.flags.valid =0 ; } out:
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 448/849 drm/amdkfd: Fix an inappropriate error handling in allloc memory of gpu
In reply to Greg Kroah-HartmanFrom: Lang Yu <[email protected]>
[ Upstream commit 5aeeac6fa38fca450faed9770f75b1470c0e2073 ]
We should unreference a gem object instead of an amdgpu bo here.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
@@ -1490,7 +1490,7 @@ allocate_init_user_pages_failed:remove_kgd_mem_from_kfd_bo_list (*mem, avm->process_info);drm_vma_node_revoke (&gobj->vma_node, drm_priv); err_node_allow: -amdgpu_bo_unref (&bo); +drm_gem_object_put (gobj);/* Don't unreserve system mem limit twice */ goto err_reserve_limit; err_bo_create:
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 449/849 mt76: mt7921: fix endianness in mt7921_mcu_tx_done_event
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit df040215c077de0c13aab12c222bd0360a0d3988 ]
Fix endianness in mt7921_mcu_tx_done_event event reported by the firmware.
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt7921/mcu.h | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +2 -1
@@ -532,7 +532,8 @@ mt7921_mcu_tx_done_event(struct mt7921_dev *dev, struct sk_buff *skb) peer.g8 = !!(sta->vht_cap.cap &IEEE80211_VHT_CAP_SHORT_GI_80 ); peer.g16 = !!(sta->vht_cap.cap &IEEE80211_VHT_CAP_SHORT_GI_160 );mt7921_mcu_tx_rate_parse (mphy->mt76, &peer, - &msta->stats.tx_rate, event->tx_rate); + &msta->stats.tx_rate, +le16_to_cpu (event->tx_rate));spin_lock_bh (&dev->sta_poll_lock);break ;
drivers/net/wireless/mediatek/mt76/mt7921/mcu.h +5 -5
@@ -296,11 +296,11 @@ struct mt7921_txpwr_event {struct mt7921_mcu_tx_done_event {u8 pid;u8 status; -u16 seq; +__le16 seq;u8 wlan_idx;u8 tx_cnt; -u16 tx_rate; +__le16 tx_rate;u8 flag;u8 tid;
@@ -312,9 +312,9 @@ struct mt7921_mcu_tx_done_event {u8 reason;u8 rsv0[1 ]; -u32 delay; -u32 timestamp; -u32 applied_flag; +__le32 delay; +__le32 timestamp; +__le32 applied_flag;u8 txs[28 ];
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 450/849 mt76: mt7915: fix endianness warning in mt7915_mac_add_txs_skb
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 08b3c8da87aed4200dab00906f149d675ca90f23 ]
Fix the following sparse warning in mt7915_mac_add_txs_skb routine:
drivers/net/wireless/mediatek/mt76/mt7915/mac.c:1235:29:
warning: cast to restricted __le32drivers/net/wireless/mediatek/mt76/mt7915/mac.c:1235:23:
warning: restricted __le32 degrades to integer
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +1 -1
@@ -1232,7 +1232,7 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, goto out; info =IEEE80211_SKB_CB (skb); -if (!(txs_data[0 ] &le32_to_cpu (MT_TXS0_ACK_ERROR_MASK ))) +if (!(txs_data[0 ] &cpu_to_le32 (MT_TXS0_ACK_ERROR_MASK ))) info->flags |=IEEE80211_TX_STAT_ACK ; info->status.ampdu_len =1 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 451/849 mt76: mt7921: fix endianness warning in mt7921_update_txs
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 7fc167bbc9296e6aeaaa4063db3639e8a3db75f6 ]
Fix the following sparse warning in mt7921_update_txs routine:drivers/net/wireless/mediatek/mt76/mt7921/mac.c:752:31:
warning: cast to restricted __le32drivers/net/wireless/mediatek/mt76/mt7921/mac.c:752:31:
warning: restricted __le32 degrades to integer
--- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +2 -1
@@ -735,8 +735,9 @@ mt7921_mac_write_txwi_80211(struct mt7921_dev *dev, __le32 *txwi,static void mt7921_update_txs (struct mt76_wcid *wcid,__le32 *txwi) { struct mt7921_sta *msta = container_of(wcid, struct mt7921_sta, wcid); -u32 pid, frame_type =FIELD_GET (MT_TXD2_FRAME_TYPE , txwi[2 ]); +u32 pid, frame_type; + frame_type =FIELD_GET (MT_TXD2_FRAME_TYPE ,le32_to_cpu (txwi[2 ]));if (!(frame_type & (IEEE80211_FTYPE_DATA >>2 )))return ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 452/849 mt76: mt7615: fix endianness warning in mt7615_mac_write_txwi
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit d81bfb41e30c42531536c5d2baa4d275a8309715 ]
Fix the following sparse warning in mt7615_mac_write_txwi routine:drivers/net/wireless/mediatek/mt76/mt7615/mac.c:758:17:
warning: incorrect type in assignment
expected restricted __le32 [usertype]
got unsigned long
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +9 -6
@@ -755,12 +755,15 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,if (info->flags &IEEE80211_TX_CTL_NO_ACK ) txwi[3 ] |=cpu_to_le32 (MT_TXD3_NO_ACK ); - txwi[7 ] =FIELD_PREP (MT_TXD7_TYPE , fc_type) | -FIELD_PREP (MT_TXD7_SUB_TYPE , fc_stype) | -FIELD_PREP (MT_TXD7_SPE_IDX ,0x18 ); -if (!is_mmio) - txwi[8 ] =FIELD_PREP (MT_TXD8_L_TYPE , fc_type) | -FIELD_PREP (MT_TXD8_L_SUB_TYPE , fc_stype); + val =FIELD_PREP (MT_TXD7_TYPE , fc_type) | +FIELD_PREP (MT_TXD7_SUB_TYPE , fc_stype) | +FIELD_PREP (MT_TXD7_SPE_IDX ,0x18 ); + txwi[7 ] =cpu_to_le32 (val); +if (!is_mmio) { + val =FIELD_PREP (MT_TXD8_L_TYPE , fc_type) | +FIELD_PREP (MT_TXD8_L_SUB_TYPE , fc_stype); + txwi[8 ] =cpu_to_le32 (val); + }return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 453/849 mt76: mt7915: fix info leak in mt7915_mcu_set_pre_cal()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 3924715ffe5e064a85f56490f77b7b2084230800 ]
Zero out all the unused members of "req" so that we don't disclose stack information.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -3481,7 +3481,7 @@ static int mt7915_mcu_set_pre_cal(struct mt7915_dev *dev, u8 idx,u8 idx;u8 rsv[4 ];__le32 len; - } req; + } req = {};struct sk_buff *skb; skb =mt76_mcu_msg_alloc (&dev->mt76,NULL ,sizeof (req) + len);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 454/849 mt76: connac: fix mt76_connac_gtk_rekey_tlv usage
In reply to Greg Kroah-HartmanFrom: Leon Yen <[email protected]>
[ Upstream commit d741abeafa47a7331cd4fe526e44db4ad3da0f62 ]
The mistaken structure is introduced since we added the GTK rekey offload to mt7663. The patch fixes mt76_connac_gtk_rekey_tlv structure according to the MT7663 and MT7921 firmware we have submitted into linux-firmware.git.
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +3 -3
@@ -844,14 +844,14 @@ struct mt76_connac_gtk_rekey_tlv {* 2: rekey update */ u8 keyid; -u8 pad[2 ]; +u8 option;/* 1: rekey data update without enabling offload */ +u8 pad[1 ];__le32 proto;/* WPA-RSN-WAPI-OPSN */ __le32 pairwise_cipher;__le32 group_cipher;__le32 key_mgmt;/* NONE-PSK-IEEE802.1X */ __le32 mgmt_group_cipher; -u8 option;/* 1: rekey data update without enabling offload */ -u8 reserverd[3 ]; +u8 reserverd[4 ]; } __packed;#define MT76_CONNAC_WOW_MASK_MAX_LEN 16
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 455/849 mt76: fix build error implicit enumeration conversion
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit adedbc643f02f5a3193b8dcc5cfca97b4c988667 ]
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:114:10: error: implicit conversion from enumeration type 'enum mt76_cipher_type' to different enumeration type 'enum mcu_cipher_type' [-Werror,-Wenum-conversion]
return MT_CIPHER_NONE;
~~~~~~ ^~~~~~~~~~~~~~drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:114:10: error: implicit conversion from enumeration type 'enum mt76_cipher_type' to different enumeration type 'enum mcu_cipher_type' [-Werror,-Wenum-conversion]
return MT_CIPHER_NONE;
~~~~~~ ^~~~~~~~~~~~~~--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -1201,7 +1201,7 @@ mt7915_mcu_sta_key_tlv(struct mt7915_sta *msta, struct sk_buff *skb,u8 cipher; cipher =mt7915_mcu_get_cipher (key->cipher); -if (cipher ==MT_CIPHER_NONE ) +if (cipher ==MCU_CIPHER_NONE )return -EOPNOTSUPP ; sec_key = &sec->key[0 ];
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +1 -1
@@ -620,7 +620,7 @@ mt7921_mcu_sta_key_tlv(struct mt7921_sta *msta, struct sk_buff *skb,u8 cipher; cipher =mt7921_mcu_get_cipher (key->cipher); -if (cipher ==MT_CIPHER_NONE ) +if (cipher ==MCU_CIPHER_NONE )return -EOPNOTSUPP ; sec_key = &sec->key[0 ];
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 456/849 mt76: mt7921: fix survey-dump reporting
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 64ed76d118c656907ec1155f2cdd24de778470a2 ]
Fix MIB tx-rx MIB counters for survey-dump reporting.
--- drivers/net/wireless/mediatek/mt76/mt7921/init.c | 4 ++++ drivers/net/wireless/mediatek/mt76/mt7921/regs.h | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +4 -0
@@ -106,6 +106,10 @@ mt7921_mac_init_band(struct mt7921_dev *dev, u8 band)mt76_set (dev,MT_WF_RMAC_MIB_TIME0 (band),MT_WF_RMAC_MIB_RXTIME_EN );mt76_set (dev,MT_WF_RMAC_MIB_AIRTIME0 (band),MT_WF_RMAC_MIB_RXTIME_EN ); +/* enable MIB tx-rx time reporting */ +mt76_set (dev,MT_MIB_SCR1 (band),MT_MIB_TXDUR_EN ); +mt76_set (dev,MT_MIB_SCR1 (band),MT_MIB_RXDUR_EN ); +mt76_rmw_field (dev,MT_DMA_DCR0 (band),MT_DMA_DCR0_MAX_RX_LEN ,1536 );/* disable rx rate report by default due to hw issues */ mt76_clear (dev,MT_DMA_DCR0 (band),MT_DMA_DCR0_RXD_G5_EN );
drivers/net/wireless/mediatek/mt76/mt7921/regs.h +6 -2
@@ -96,6 +96,10 @@#define MT_WF_MIB_BASE (_band) ((_band) ? 0xa4800 : 0x24800)#define MT_WF_MIB (_band, ofs) (MT_WF_MIB_BASE(_band) + (ofs)) +#define MT_MIB_SCR1 (_band) MT_WF_MIB(_band, 0x004) +#define MT_MIB_TXDUR_EN BIT(8) +#define MT_MIB_RXDUR_EN BIT(9) +#define MT_MIB_SDR3 (_band) MT_WF_MIB(_band, 0x698)#define MT_MIB_SDR3_FCS_ERR_MASK GENMASK(31, 16)
@@ -108,9 +112,9 @@#define MT_MIB_SDR34 (_band) MT_WF_MIB(_band, 0x090)#define MT_MIB_MU_BF_TX_CNT GENMASK(15, 0) -#define MT_MIB_SDR36 (_band) MT_WF_MIB(_band, 0x098) +#define MT_MIB_SDR36 (_band) MT_WF_MIB(_band, 0x054)#define MT_MIB_SDR36_TXTIME_MASK GENMASK(23, 0) -#define MT_MIB_SDR37 (_band) MT_WF_MIB(_band, 0x09c) +#define MT_MIB_SDR37 (_band) MT_WF_MIB(_band, 0x058)#define MT_MIB_SDR37_RXTIME_MASK GENMASK(23, 0)#define MT_MIB_DR8 (_band) MT_WF_MIB(_band, 0x0c0)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 457/849 mt76: mt76x02: fix endianness warnings in mt76x02_mac.c
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit c33edef520213feccebc22c9474c685b9fb60611 ]
Fix the following sparse warning in mt76x02_mac_write_txwi and mt76x02_mac_tx_rate_val routines:drivers/net/wireless/mediatek/mt76/mt76x02_mac.c:237:19:
warning: restricted __le16 degrades to intege
warning: cast from restricted __le16drivers/net/wireless/mediatek/mt76/mt76x02_mac.c:383:28:
warning: incorrect type in assignment (different base types) expected restricted __le16 [usertype] rate
got unsigned long
--- drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +7 -6
@@ -176,7 +176,7 @@ void mt76x02_mac_wcid_set_drop(struct mt76x02_dev *dev, u8 idx, bool drop)mt76_wr (dev,MT_WCID_DROP (idx), (val & ~bit) | (bit * drop)); } -static __le16 +static u16 mt76x02_mac_tx_rate_val (struct mt76x02_dev *dev,const struct ieee80211_tx_rate *rate,u8 *nss_val) {
@@ -222,14 +222,14 @@ mt76x02_mac_tx_rate_val(struct mt76x02_dev *dev, rateval |=MT_RXWI_RATE_SGI ; *nss_val = nss; -return cpu_to_le16 (rateval); +return rateval; }void mt76x02_mac_wcid_set_rate (struct mt76x02_dev *dev,struct mt76_wcid *wcid,const struct ieee80211_tx_rate *rate) {s8 max_txpwr_adj =mt76x02_tx_get_max_txpwr_adj (dev, rate); -__le16 rateval; +u16 rateval;u32 tx_info;s8 nss;
@@ -342,7 +342,7 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,struct ieee80211_key_conf *key = info->control.hw_key;u32 wcid_tx_info;u16 rate_ht_mask =FIELD_PREP (MT_RXWI_RATE_PHY ,BIT (1 ) |BIT (2 )); -u16 txwi_flags =0 ; +u16 txwi_flags =0 , rateval;u8 nss;s8 txpwr_adj, max_txpwr_adj;u8 ccmp_pn[8 ], nstreams = dev->mphy.chainmask &0xf ;
@@ -380,14 +380,15 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,if (wcid && (rate->idx <0 || !rate->count)) { wcid_tx_info = wcid->tx_info; - txwi->rate =FIELD_GET (MT_WCID_TX_INFO_RATE , wcid_tx_info); + rateval =FIELD_GET (MT_WCID_TX_INFO_RATE , wcid_tx_info); max_txpwr_adj =FIELD_GET (MT_WCID_TX_INFO_TXPWR_ADJ , wcid_tx_info); nss =FIELD_GET (MT_WCID_TX_INFO_NSS , wcid_tx_info); }else { - txwi->rate =mt76x02_mac_tx_rate_val (dev, rate, &nss); + rateval =mt76x02_mac_tx_rate_val (dev, rate, &nss); max_txpwr_adj =mt76x02_tx_get_max_txpwr_adj (dev, rate); } + txwi->rate =cpu_to_le16 (rateval); txpwr_adj =mt76x02_tx_get_txpwr_adj (dev, dev->txpower_conf, max_txpwr_adj);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 458/849 mt76: mt7921: Fix out of order process by invalid event pkt
In reply to Greg Kroah-HartmanFrom: Deren Wu <[email protected]>
[ Upstream commit cd3f387371e941e6806b455b4ba5b9f4ca4b77c6 ]
The acceptable event report should inlcude original CMD-ID. Otherwise, drop unexpected result from fw.
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +4 -0
@@ -157,6 +157,7 @@ mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd, struct sk_buff *skb, int seq) {struct mt7921_mcu_rxd *rxd; +int mcu_cmd = cmd &MCU_CMD_MASK ;int ret =0 ;if (!skb) {
@@ -194,6 +195,9 @@ mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd,skb_pull (skb,sizeof (*rxd)); event = (struct mt7921_mcu_uni_event *)skb->data; ret =le32_to_cpu (event->status); +/* skip invalid event */ +if (mcu_cmd != event->cid) + ret = -EAGAIN ;break ; }case MCU_CMD_REG_READ : {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 459/849 mt76: mt7915: fix potential overflow of eeprom page index
In reply to Greg Kroah-HartmanFrom: Shayne Chen <[email protected]>
[ Upstream commit 82a980f82a511ce74ab57eb9f692d02225eb32f4 ]
If total eeprom size is divisible by per-page size, the i in for loop will exceed max page index, which happens in our newer chipset.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +5 -5
@@ -3391,20 +3391,20 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd)static int mt7915_mcu_set_eeprom_flash (struct mt7915_dev *dev) { -#define TOTAL_PAGE_MASK GENMASK(7, 5) +#define MAX_PAGE_IDX_MASK GENMASK(7, 5)#define PAGE_IDX_MASK GENMASK(4, 2)#define PER_PAGE_SIZE 0x400struct mt7915_mcu_eeprom req = { .buffer_mode =EE_MODE_BUFFER }; -u8 total =MT7915_EEPROM_SIZE /PER_PAGE_SIZE ; +u8 total =DIV_ROUND_UP (MT7915_EEPROM_SIZE ,PER_PAGE_SIZE );u8 *eep = (u8 *)dev->mt76.eeprom.data;int eep_len;int i; -for (i =0 ; i <= total; i++, eep += eep_len) { +for (i =0 ; i < total; i++, eep += eep_len) {struct sk_buff *skb;int ret; -if (i == total) +if (i == total -1 && !!(MT7915_EEPROM_SIZE %PER_PAGE_SIZE )) eep_len =MT7915_EEPROM_SIZE %PER_PAGE_SIZE ;else eep_len =PER_PAGE_SIZE ;
@@ -3414,7 +3414,7 @@ static int mt7915_mcu_set_eeprom_flash(struct mt7915_dev *dev)if (!skb)return -ENOMEM ; - req.format =FIELD_PREP (TOTAL_PAGE_MASK , total) | + req.format =FIELD_PREP (MAX_PAGE_IDX_MASK , total -1 ) |FIELD_PREP (PAGE_IDX_MASK , i) |EE_FORMAT_WHOLE ; req.len =cpu_to_le16 (eep_len);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 460/849 mt76: mt7915: fix bit fields for HT rate idx
In reply to Greg Kroah-HartmanFrom: Shayne Chen <[email protected]>
[ Upstream commit 47f1c08db7f3aaa2d13f8e56209375462ace7b8a ]
The bit fields of tx rate idx should be 6 bits, otherwise it might be incorrect in HT mode.
For VHT/HE rates, only 4 bits are actually used by rate idx, the other 2 bits are used for other functions.
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.h +2 -1
@@ -272,7 +272,8 @@ enum tx_mcu_port_q_idx {#define MT_TX_RATE_MODE GENMASK(9, 6)#define MT_TX_RATE_SU_EXT_TONE BIT(5)#define MT_TX_RATE_DCM BIT(4) -#define MT_TX_RATE_IDX GENMASK(3, 0) +/* VHT/HE only use bits 0-3 */ +#define MT_TX_RATE_IDX GENMASK(5, 0)#define MT_TXP_MAX_BUF_NUM 6
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 461/849 mt76: mt7921: fix dma hang in rmmod
In reply to Greg Kroah-HartmanFrom: Deren Wu <[email protected]>
[ Upstream commit a23f80aa9c5e6ad4ec8df88037b7ffd4162b1ec4 ]
The dma would be broken after rmmod flow. There are two different cases causing this issue.
1. dma access without privilege.
2. hw access sequence borken by another context.
This patch handle both cases to avoid hw crash.
--- drivers/net/wireless/mediatek/mt76/mt7921/init.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +9 -0
@@ -251,8 +251,17 @@ int mt7921_register_device(struct mt7921_dev *dev)void mt7921_unregister_device (struct mt7921_dev *dev) { +int i; +struct mt76_connac_pm *pm = &dev->pm; +mt76_unregister_device (&dev->mt76); +mt76_for_each_q_rx (&dev->mt76, i) +napi_disable (&dev->mt76.napi[i]); +cancel_delayed_work_sync (&pm->ps_work); +cancel_work_sync (&pm->wake_work); +mt7921_tx_token_put (dev); +mt7921_mcu_drv_pmctrl (dev);mt7921_dma_cleanup (dev);mt7921_mcu_exit (dev);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 462/849 mt76: connac: fix GTK rekey offload failure on WPA mixed mode
In reply to Greg Kroah-HartmanFrom: Leon Yen <[email protected]>
[ Upstream commit 781f62960c635cfed55a8f8c0f909bdaf8268257 ]
Update the proper firmware programming sequence to fix GTK rekey offload failure on WPA mixed mode.
In the mt76_connac_mcu_key_iter,gtk_tlv->proto should be only set up on pairwise key and gtk_tlk->group_cipher should be only set up on the group key.
Otherwise, those parameters required by firmware would be set incorrectly to cause GTK rekey offload failure on WPA mixed mode and then disconnection follows.
--- .../net/wireless/mediatek/mt76/mt76_connac_mcu.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +9 -6
@@ -1929,19 +1929,22 @@ mt76_connac_mcu_key_iter(struct ieee80211_hw *hw, key->cipher != WLAN_CIPHER_SUITE_TKIP)return ; -if (key->cipher ==WLAN_CIPHER_SUITE_TKIP ) { - gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_1 ); +if (key->cipher ==WLAN_CIPHER_SUITE_TKIP ) cipher =BIT (3 ); - }else { - gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_2 ); +else cipher =BIT (4 ); - }/* we are assuming here to have a single pairwise key */ if (key->flags &IEEE80211_KEY_FLAG_PAIRWISE ) { +if (key->cipher ==WLAN_CIPHER_SUITE_TKIP ) + gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_1 ); +else + gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_2 ); + gtk_tlv->pairwise_cipher =cpu_to_le32 (cipher); - gtk_tlv->group_cipher =cpu_to_le32 (cipher); gtk_tlv->keyid = key->keyidx; + }else { + gtk_tlv->group_cipher =cpu_to_le32 (cipher); } }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 463/849 mt76: overwrite default reg_ops if necessary
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit f6e1f59885dae5a2553f8bbd328be2cb1c80ccb2 ]
Introduce mt76_register_debugfs_fops routine in order to define per-driver regs file operations and make sure the device is up before reading or writing its registers
--- drivers/net/wireless/mediatek/mt76/debugfs.c | 10 ++++--- drivers/net/wireless/mediatek/mt76/mt76.h | 8 ++++- .../wireless/mediatek/mt76/mt7615/debugfs.c | 29 ++++++++++++++++++- .../wireless/mediatek/mt76/mt7921/debugfs.c | 28 +++++++++++++++++- 4 files changed, 68 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/debugfs.c +6 -4
@@ -116,8 +116,11 @@ static int mt76_read_rate_txpower(struct seq_file *s, void *data)return 0 ; } -struct dentry *mt76_register_debugfs (struct mt76_dev *dev) +struct dentry * +mt76_register_debugfs_fops (struct mt76_dev *dev, +const struct file_operations *ops) { +const struct file_operations *fops = ops ? ops : &fops_regval;struct dentry *dir; dir =debugfs_create_dir ("mt76" , dev->hw->wiphy->debugfsdir);
@@ -126,8 +129,7 @@ struct dentry *mt76_register_debugfs(struct mt76_dev *dev)debugfs_create_u8 ("led_pin" ,0600 , dir, &dev->led_pin);debugfs_create_u32 ("regidx" ,0600 , dir, &dev->debugfs_reg); -debugfs_create_file_unsafe ("regval" ,0600 , dir, dev, - &fops_regval); +debugfs_create_file_unsafe ("regval" ,0600 , dir, dev, fops);debugfs_create_file_unsafe ("napi_threaded" ,0600 , dir, dev, &fops_napi_threaded);debugfs_create_blob ("eeprom" ,0400 , dir, &dev->eeprom);
@@ -140,4 +142,4 @@ struct dentry *mt76_register_debugfs(struct mt76_dev *dev)return dir; } -EXPORT_SYMBOL_GPL (mt76_register_debugfs); +EXPORT_SYMBOL_GPL (mt76_register_debugfs_fops);
drivers/net/wireless/mediatek/mt76/mt76.h +7 -1
@@ -869,7 +869,13 @@ struct mt76_phy *mt76_alloc_phy(struct mt76_dev *dev, unsigned int size,int mt76_register_phy (struct mt76_phy *phy,bool vht,struct ieee80211_rate *rates,int n_rates); -struct dentry *mt76_register_debugfs (struct mt76_dev *dev); +struct dentry *mt76_register_debugfs_fops (struct mt76_dev *dev, +const struct file_operations *ops); +static inline struct dentry *mt76_register_debugfs (struct mt76_dev *dev) +{ +return mt76_register_debugfs_fops (dev,NULL ); +} +int mt76_queues_read (struct seq_file *s,void *data);void mt76_seq_puts_array (struct seq_file *file,const char *str,s8 *val,int len);
drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c +28 -1
@@ -2,6 +2,33 @@#include "mt7615.h" +static int +mt7615_reg_set (void *data,u64 val) +{ +struct mt7615_dev *dev = data; + +mt7615_mutex_acquire (dev); +mt76_wr (dev, dev->mt76.debugfs_reg, val); +mt7615_mutex_release (dev); + +return 0 ; +} + +static int +mt7615_reg_get (void *data,u64 *val) +{ +struct mt7615_dev *dev = data; + +mt7615_mutex_acquire (dev); + *val =mt76_rr (dev, dev->mt76.debugfs_reg); +mt7615_mutex_release (dev); + +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_regval, mt7615_reg_get, mt7615_reg_set, +"0x%08llx\n" ); +static int mt7615_radar_pattern_set (void *data,u64 val) {
@@ -506,7 +533,7 @@ int mt7615_init_debugfs(struct mt7615_dev *dev) {struct dentry *dir; - dir =mt76_register_debugfs (&dev->mt76); + dir =mt76_register_debugfs_fops (&dev->mt76, &fops_regval);if (!dir)return -ENOMEM ;
drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +27 -1
@@ -4,6 +4,32 @@#include "mt7921.h" #include "eeprom.h" +static int +mt7921_reg_set (void *data,u64 val) +{ +struct mt7921_dev *dev = data; + +mt7921_mutex_acquire (dev); +mt76_wr (dev, dev->mt76.debugfs_reg, val); +mt7921_mutex_release (dev); + +return 0 ; +} + +static int +mt7921_reg_get (void *data,u64 *val) +{ +struct mt7921_dev *dev = data; + +mt7921_mutex_acquire (dev); + *val =mt76_rr (dev, dev->mt76.debugfs_reg); +mt7921_mutex_release (dev); + +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_regval, mt7921_reg_get, mt7921_reg_set, +"0x%08llx\n" );static int mt7921_fw_debug_set (void *data,u64 val) {
@@ -373,7 +399,7 @@ int mt7921_init_debugfs(struct mt7921_dev *dev) {struct dentry *dir; - dir =mt76_register_debugfs (&dev->mt76); + dir =mt76_register_debugfs_fops (&dev->mt76, &fops_regval);if (!dir)return -ENOMEM ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 464/849 mt76: mt7921: report HE MU radiotap
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 4fee32153ab62356aeea9d152d8f33a5fd3a0086 ]
Report HE MU/BF radiotap.
That fixed HE MU packets dropped by mac80211 because they are missing the ieee80211_radiotap_he_mu header.
--- .../net/wireless/mediatek/mt76/mt7921/mac.c | 65 ++++++++++++++++--- .../net/wireless/mediatek/mt76/mt7921/mac.h | 8 +++ 2 files changed, 65 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +57 -8
@@ -180,12 +180,56 @@ mt7921_mac_decode_he_radiotap_ru(struct mt76_rx_status *status, IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET); } +static void +mt7921_mac_decode_he_mu_radiotap (struct sk_buff *skb, +struct mt76_rx_status *status, +__le32 *rxv) +{ +static const struct ieee80211_radiotap_he_mu mu_known = { + .flags1 =HE_BITS (MU_FLAGS1_SIG_B_MCS_KNOWN ) | +HE_BITS (MU_FLAGS1_SIG_B_DCM_KNOWN ) | +HE_BITS (MU_FLAGS1_CH1_RU_KNOWN ) | +HE_BITS (MU_FLAGS1_SIG_B_SYMS_USERS_KNOWN ) | +HE_BITS (MU_FLAGS1_SIG_B_COMP_KNOWN ), + .flags2 =HE_BITS (MU_FLAGS2_BW_FROM_SIG_A_BW_KNOWN ) | +HE_BITS (MU_FLAGS2_PUNC_FROM_SIG_A_BW_KNOWN ), + }; +struct ieee80211_radiotap_he_mu *he_mu =NULL ; + + he_mu =skb_push (skb,sizeof (mu_known)); +memcpy (he_mu, &mu_known,sizeof (mu_known)); + +#define MU_PREP (f, v) le16_encode_bits(v, IEEE80211_RADIOTAP_HE_MU_##f) + + he_mu->flags1 |=MU_PREP (FLAGS1_SIG_B_MCS , status->rate_idx); +if (status->he_dcm) + he_mu->flags1 |=MU_PREP (FLAGS1_SIG_B_DCM , status->he_dcm); + + he_mu->flags2 |=MU_PREP (FLAGS2_BW_FROM_SIG_A_BW , status->bw) | +MU_PREP (FLAGS2_SIG_B_SYMS_USERS , +le32_get_bits (rxv[2 ],MT_CRXV_HE_NUM_USER )); + + he_mu->ru_ch1[0 ] =FIELD_GET (MT_CRXV_HE_RU0 ,cpu_to_le32 (rxv[3 ])); + +if (status->bw >=RATE_INFO_BW_40 ) { + he_mu->flags1 |=HE_BITS (MU_FLAGS1_CH2_RU_KNOWN ); + he_mu->ru_ch2[0 ] = +FIELD_GET (MT_CRXV_HE_RU1 ,cpu_to_le32 (rxv[3 ])); + } + +if (status->bw >=RATE_INFO_BW_80 ) { + he_mu->ru_ch1[1 ] = +FIELD_GET (MT_CRXV_HE_RU2 ,cpu_to_le32 (rxv[3 ])); + he_mu->ru_ch2[1 ] = +FIELD_GET (MT_CRXV_HE_RU3 ,cpu_to_le32 (rxv[3 ])); + } +} + static void mt7921_mac_decode_he_radiotap(struct sk_buff *skb, struct mt76_rx_status *status, __le32 *rxv, u32 phy) { - /* TODO: struct ieee80211_radiotap_he_mu */ static const struct ieee80211_radiotap_he known = { .data1 = HE_BITS(DATA1_DATA_MCS_KNOWN) | HE_BITS(DATA1_DATA_DCM_KNOWN) |
@@ -193,6 +237,7 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,HE_BITS (DATA1_CODING_KNOWN ) |HE_BITS (DATA1_LDPC_XSYMSEG_KNOWN ) |HE_BITS (DATA1_DOPPLER_KNOWN ) | +HE_BITS (DATA1_SPTL_REUSE_KNOWN ) | HE_BITS(DATA1_BSS_COLOR_KNOWN), .data2 =HE_BITS (DATA2_GI_KNOWN ) | HE_BITS(DATA2_TXBF_KNOWN) |
@@ -207,9 +252,12 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb, he->data3 =HE_PREP (DATA3_BSS_COLOR ,BSS_COLOR , rxv[14 ]) |HE_PREP (DATA3_LDPC_XSYMSEG ,LDPC_EXT_SYM , rxv[2 ]); + he->data4 =HE_PREP (DATA4_SU_MU_SPTL_REUSE ,SR_MASK , rxv[11 ]); he->data5 =HE_PREP (DATA5_PE_DISAMBIG ,PE_DISAMBIG , rxv[2 ]) |le16_encode_bits (ltf_size,IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE ); +if (cpu_to_le32 (rxv[0 ]) &MT_PRXV_TXBF ) + he->data5 |=HE_BITS (DATA5_TXBF ); he->data6 =HE_PREP (DATA6_TXOP ,TXOP_DUR , rxv[14 ]) |HE_PREP (DATA6_DOPPLER ,DOPPLER , rxv[14 ]);
@@ -217,8 +265,7 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,case MT_PHY_TYPE_HE_SU : he->data1 |=HE_BITS (DATA1_FORMAT_SU ) |HE_BITS (DATA1_UL_DL_KNOWN ) | -HE_BITS (DATA1_BEAM_CHANGE_KNOWN ) | -HE_BITS (DATA1_SPTL_REUSE_KNOWN ); +HE_BITS (DATA1_BEAM_CHANGE_KNOWN ); he->data3 |=HE_PREP (DATA3_BEAM_CHANGE ,BEAM_CHNG , rxv[14 ]) |HE_PREP (DATA3_UL_DL ,UPLINK , rxv[2 ]);
@@ -232,17 +279,15 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,break ;case MT_PHY_TYPE_HE_MU : he->data1 |=HE_BITS (DATA1_FORMAT_MU ) | -HE_BITS (DATA1_UL_DL_KNOWN ) | -HE_BITS (DATA1_SPTL_REUSE_KNOWN ); +HE_BITS (DATA1_UL_DL_KNOWN ); he->data3 |=HE_PREP (DATA3_UL_DL ,UPLINK , rxv[2 ]); - he->data4 |=HE_PREP (DATA4_SU_MU_SPTL_REUSE ,SR_MASK , rxv[11 ]); + he->data4 |=HE_PREP (DATA4_MU_STA_ID ,MU_AID , rxv[7 ]);mt7921_mac_decode_he_radiotap_ru (status, he, rxv);break ;case MT_PHY_TYPE_HE_TB : he->data1 |=HE_BITS (DATA1_FORMAT_TRIG ) | -HE_BITS (DATA1_SPTL_REUSE_KNOWN ) |HE_BITS (DATA1_SPTL_REUSE2_KNOWN ) |HE_BITS (DATA1_SPTL_REUSE3_KNOWN ) |HE_BITS (DATA1_SPTL_REUSE4_KNOWN );
@@ -606,9 +651,13 @@ int mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)mt7921_mac_assoc_rssi (dev, skb); -if (rxv && status->flag &RX_FLAG_RADIOTAP_HE ) +if (rxv && status->flag &RX_FLAG_RADIOTAP_HE ) {mt7921_mac_decode_he_radiotap (skb, status, rxv, mode); +if (status->flag &RX_FLAG_RADIOTAP_HE_MU ) +mt7921_mac_decode_he_mu_radiotap (skb, status, rxv); + } +if (!status->wcid || !ieee80211_is_data_qos (fc))return 0 ;
drivers/net/wireless/mediatek/mt76/mt7921/mac.h +8 -0
@@ -116,6 +116,7 @@ enum rx_pkt_type {#define MT_PRXV_TX_DCM BIT(4)#define MT_PRXV_TX_ER_SU_106T BIT(5)#define MT_PRXV_NSTS GENMASK(9, 7) +#define MT_PRXV_TXBF BIT(10)#define MT_PRXV_HT_AD_CODE BIT(11)#define MT_PRXV_FRAME_MODE GENMASK(14, 12)#define MT_PRXV_SGI GENMASK(16, 15)
@@ -138,8 +139,15 @@ enum rx_pkt_type {#define MT_CRXV_HE_LTF_SIZE GENMASK(18, 17)#define MT_CRXV_HE_LDPC_EXT_SYM BIT(20)#define MT_CRXV_HE_PE_DISAMBIG BIT(23) +#define MT_CRXV_HE_NUM_USER GENMASK(30, 24)#define MT_CRXV_HE_UPLINK BIT(31) +#define MT_CRXV_HE_RU0 GENMASK(7, 0) +#define MT_CRXV_HE_RU1 GENMASK(15, 8) +#define MT_CRXV_HE_RU2 GENMASK(23, 16) +#define MT_CRXV_HE_RU3 GENMASK(31, 24) +#define MT_CRXV_HE_MU_AID GENMASK(30, 20) +#define MT_CRXV_HE_SR_MASK GENMASK(11, 8)#define MT_CRXV_HE_SR1_MASK GENMASK(16, 12)#define MT_CRXV_HE_SR2_MASK GENMASK(20, 17)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 465/849 mt76: mt7921: fix firmware usage of RA info using legacy rates
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 99b8e195994d9d77de3bfe0cb403c44a57c2cf79 ]
According to the firmware usage, OFDM rates should fill out bit 6 - 13 while CCK rates should fill out bit 0 - 3 in legacy field of RA info to make the rate adaption runs propertly. Otherwise, a unicast frame might be picking up the unsupported rate to send out.
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 11 ++++++++++- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +10 -1
@@ -719,6 +719,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,struct sta_rec_state *state;struct sta_rec_phy *phy;struct tlv *tlv; +u16 supp_rates;/* starec ht */ if (sta->ht_cap.ht_supported) {
@@ -767,7 +768,15 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb, tlv =mt76_connac_mcu_add_tlv (skb,STA_REC_RA ,sizeof (*ra_info)); ra_info = (struct sta_rec_ra_info *)tlv; - ra_info->legacy =cpu_to_le16 ((u16 )sta->supp_rates[band]); + + supp_rates = sta->supp_rates[band]; +if (band ==NL80211_BAND_2GHZ ) + supp_rates =FIELD_PREP (RA_LEGACY_OFDM , supp_rates >>4 ) | +FIELD_PREP (RA_LEGACY_CCK , supp_rates &0xf ); +else + supp_rates =FIELD_PREP (RA_LEGACY_OFDM , supp_rates); + + ra_info->legacy =cpu_to_le16 (supp_rates);if (sta->ht_cap.ht_supported) memcpy(ra_info->rx_mcs_bitmask, sta->ht_cap.mcs.rx_mask,
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +2 -0
@@ -124,6 +124,8 @@ struct sta_rec_state {u8 rsv[1 ]; } __packed; +#define RA_LEGACY_OFDM GENMASK(13, 6) +#define RA_LEGACY_CCK GENMASK(3, 0)#define HT_MCS_MASK_NUM 10struct sta_rec_ra_info {__le16 tag;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 466/849 mt76: mt7921: fix kernel warning from cfg80211_calculate_bitrate
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 8e695328a1006b7bab2d972e7d0111fa6e6faf51 ]
Fix the kernel warning from cfg80211_calculate_bitrate due to the legacy rate is not parsed well in the current driver.
Also, zeros struct rate_info before we fill it out to avoid the old value is kept such as rate->legacy.
[ 790.921560] WARNING: CPU: 7 PID: 970 at net/wireless/util.c:1298 cfg80211_calculate_bitrate+0x354/0x35c [cfg80211] [ 790.987738] Hardware name: MediaTek Asurada rev1 board (DT) [ 790.993298] pstate: a0400009 (NzCv daif +PAN -UAO) [ 790.998104] pc : cfg80211_calculate_bitrate+0x354/0x35c [cfg80211] [ 791.004295] lr : cfg80211_calculate_bitrate+0x180/0x35c [cfg80211] [ 791.010462] sp : ffffffc0129c3880 [ 791.013765] x29: ffffffc0129c3880 x28: ffffffd38305bea8 [ 791.019065] x27: ffffffc0129c3970 x26: 0000000000000013 [ 791.024364] x25: 00000000000003ca x24: 000000000000002f [ 791.029664] x23: 00000000000000d0 x22: ffffff8d108bc000 [ 791.034964] x21: ffffff8d108bc0d0 x20: ffffffc0129c39a8 [ 791.040264] x19: ffffffc0129c39a8 x18: 00000000ffff0a10 [ 791.045563] x17: 0000000000000050 x16: 00000000000000ec [ 791.050910] x15: ffffffd3f9ebed9c x14: 0000000000000006 [ 791.056211] x13: 00000000000b2eea x12: 0000000000000000 [ 791.061511] x11: 00000000ffffffff x10: 0000000000000000 [ 791.066811] x9 : 0000000000000000 x8 : 0000000000000000 [ 791.072110] x7 : 0000000000000000 x6 : ffffffd3fafa5a7b [ 791.077409] x5 : 0000000000000000 x4 : 0000000000000000 [ 791.082708] x3 : 0000000000000000 x2 : 0000000000000000 [ 791.088008] x1 : ffffff8d3f79c918 x0 : 0000000000000000 [ 791.093308] Call trace: [ 791.095770] cfg80211_calculate_bitrate+0x354/0x35c [cfg80211] [ 791.101615] nl80211_put_sta_rate+0x6c/0x2c0 [cfg80211] [ 791.106853] nl80211_send_station+0x980/0xaa4 [cfg80211] [ 791.112178] nl80211_get_station+0xb4/0x134 [cfg80211] [ 791.117308] genl_rcv_msg+0x3a0/0x440 [ 791.120960] netlink_rcv_skb+0xcc/0x118 [ 791.124785] genl_rcv+0x34/0x48 [ 791.127916] netlink_unicast+0x144/0x1dc
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +9 -2
@@ -320,11 +320,13 @@ mt7921_mcu_tx_rate_parse(struct mt76_phy *mphy, struct rate_info *rate, u16 r) {struct ieee80211_supported_band *sband; -u16 flags =0 ; +u16 flags =0 , rate_idx;u8 txmode =FIELD_GET (MT_WTBL_RATE_TX_MODE , r);u8 gi =0 ;u8 bw =0 ; +bool cck = false; +memset (rate,0 ,sizeof (*rate)); rate->mcs =FIELD_GET (MT_WTBL_RATE_MCS , r); rate->nss =FIELD_GET (MT_WTBL_RATE_NSS , r) +1 ;
@@ -349,13 +351,18 @@ mt7921_mcu_tx_rate_parse(struct mt76_phy *mphy,switch (txmode) {case MT_PHY_TYPE_CCK : + cck = true; + fallthrough;case MT_PHY_TYPE_OFDM :if (mphy->chandef.chan->band ==NL80211_BAND_5GHZ ) sband = &mphy->sband_5g.sband;else sband = &mphy->sband_2g.sband; - rate->legacy = sband->bitrates[rate->mcs].bitrate; + rate_idx =FIELD_GET (MT_TX_RATE_IDX , r); + rate_idx =mt76_get_rate (mphy->dev, sband, rate_idx, + cck); + rate->legacy = sband->bitrates[rate_idx].bitrate;break ;case MT_PHY_TYPE_HT :case MT_PHY_TYPE_HT_GF :
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 467/849 mt76: mt7921: always wake device if necessary in debugfs
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 569008744178b672ea3ad9047fa3098f1b73ca55 ]
Add missing device wakeup in debugfs code if we are accessing chip registers.
--- drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +8 -0
@@ -95,6 +95,8 @@ mt7921_tx_stats_show(struct seq_file *file, void *data)struct mt7921_dev *dev = file->private;int stat[8 ], i, n; +mt7921_mutex_acquire (dev); +mt7921_ampdu_stat_read_phy (&dev->phy, file);/* Tx amsdu info */
@@ -104,6 +106,8 @@ mt7921_tx_stats_show(struct seq_file *file, void *data) n += stat[i]; } +mt7921_mutex_release (dev); +for (i =0 ; i <ARRAY_SIZE (stat); i++) {seq_printf (file,"AMSDU pack count of %d MSDU in TXD: 0x%x " , i +1 , stat[i]);
@@ -124,6 +128,8 @@ mt7921_queues_acq(struct seq_file *s, void *data)struct mt7921_dev *dev =dev_get_drvdata (s->private);int i; +mt7921_mutex_acquire (dev); +for (i =0 ; i <16 ; i++) {int j, acs = i /4 , index = i %4 ;u32 ctrl, val, qlen =0 ;
@@ -143,6 +149,8 @@ mt7921_queues_acq(struct seq_file *s, void *data)seq_printf (s,"AC%d%d: queued=%d\n" , acs, index, qlen); } +mt7921_mutex_release (dev); +return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 468/849 mt76: mt7915: fix hwmon temp sensor mem use-after-free
In reply to Greg Kroah-HartmanFrom: Ben Greear <[email protected]>
[ Upstream commit 0ae3ff5684514d72357240f1033a7494c51f93ed ]
Without this change, garbage is seen in the hwmon name and sensors output for mt7915 is garbled. It appears that the hwmon logic does not make a copy of the incoming string, but instead just copies a char* and expects it to never go away.
--- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/init.c +6 -4
@@ -130,9 +130,12 @@ static int mt7915_thermal_init(struct mt7915_phy *phy)struct wiphy *wiphy = phy->mt76->hw->wiphy;struct thermal_cooling_device *cdev;struct device *hwmon; +const char *name; - cdev =thermal_cooling_device_register (wiphy_name (wiphy), phy, - &mt7915_thermal_ops); + name =devm_kasprintf (&wiphy->dev,GFP_KERNEL ,"mt7915_%s" , +wiphy_name (wiphy)); + + cdev =thermal_cooling_device_register (name, phy, &mt7915_thermal_ops);if (!IS_ERR (cdev)) {if (sysfs_create_link (&wiphy->dev.kobj, &cdev->device.kobj,"cooling_device" ) <0 )
@@ -144,8 +147,7 @@ static int mt7915_thermal_init(struct mt7915_phy *phy)if (!IS_REACHABLE (CONFIG_HWMON ))return 0 ; - hwmon =devm_hwmon_device_register_with_groups (&wiphy->dev, -wiphy_name (wiphy), phy, + hwmon =devm_hwmon_device_register_with_groups (&wiphy->dev, name, phy, mt7915_hwmon_groups);if (IS_ERR (hwmon))return PTR_ERR (hwmon);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 469/849 mt76: mt7615: fix hwmon temp sensor mem use-after-free
In reply to Greg Kroah-HartmanFrom: Ryder Lee <[email protected]>
[ Upstream commit 0bb4e9187ea4a59dc6658a62978deda0c0dc4b28 ]
Without this change, garbage is seen in the hwmon name and sensors output for mt7615 is garbled.
--- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +4 -2
@@ -49,12 +49,14 @@ int mt7615_thermal_init(struct mt7615_dev *dev) {struct wiphy *wiphy =mt76_hw (dev)->wiphy;struct device *hwmon; +const char *name;if (!IS_REACHABLE (CONFIG_HWMON ))return 0 ; - hwmon =devm_hwmon_device_register_with_groups (&wiphy->dev, -wiphy_name (wiphy), dev, + name =devm_kasprintf (&wiphy->dev,GFP_KERNEL ,"mt7615_%s" , +wiphy_name (wiphy)); + hwmon =devm_hwmon_device_register_with_groups (&wiphy->dev, name, dev, mt7615_hwmon_groups);if (IS_ERR (hwmon))return PTR_ERR (hwmon);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 470/849 mt76: mt7915: fix possible infinite loop release semaphore
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit e500c9470e26be66eb2bc6de773ae9091149118a ]
Fix possible infinite loop in mt7915_load_patch if mt7915_mcu_patch_sem_ctrl always returns an error.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -2790,7 +2790,7 @@ out:default : ret = -EAGAIN ;dev_err (dev->mt76.dev,"Failed to release patch semaphore\n" ); - goto out; +break ; }release_firmware (fw);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 471/849 mt76: mt7921: fix retrying release semaphore without end
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 02d1c7d494d8052288bc175e4ff54b56d08a3c5f ]
We should pass the error code to the caller immediately to avoid the possible infinite retry to release the semaphore.
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +1 -1
@@ -827,7 +827,7 @@ out:default : ret = -EAGAIN ;dev_err (dev->mt76.dev,"Failed to release patch semaphore\n" ); - goto out; +break ; }release_firmware (fw);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 472/849 mt76: mt7615: fix monitor mode tear down crash
In reply to Greg Kroah-HartmanFrom: Ryder Lee <[email protected]>
[ Upstream commit a6fdbdd1ac2996a58a84672ef37efb5cbb98fadf ]
[ 103.451600] CPU 3 Unable to handle kernel paging request at virtual address 00000003, epc == 8576591c, ra == 857659f0 [ 103.462226] Oops[#1]: [ 103.464499] CPU: 3 PID: 9247 Comm: ifconfig Tainted: G W 5.4.143 #0 [ 103.472031] $ 0 : 00000000 00000001 83be3854 00000000 [ 103.477239] $ 4 : 8102a374 8102a374 8102f0b0 00000200 [ 103.482444] $ 8 : 0000002d 000001e4 64373765 5d206337 [ 103.487647] $12 : 00000000 00000005 00000000 0006d1df [ 103.492853] $16 : 83be3848 853838a8 8743d600 00010000 [ 103.498059] $20 : 00000000 00000000 8553dec0 0000007f [ 103.503266] $24 : 00000003 80382084 [ 103.508472] $28 : 831d4000 831d5bc0 00000001 857659f0 [ 103.513678] Hi : 00000122 [ 103.516543] Lo : d1768000 [ 103.519452] epc : 8576591c mt7615_mcu_add_bss+0xd0/0x3c0 [mt7615_common] [ 103.526306] ra : 857659f0 mt7615_mcu_add_bss+0x1a4/0x3c0 [mt7615_common] [ 103.533232] Status: 11007c03 KERNEL EXL IE [ 103.537402] Cause : 40800008 (ExcCode 02) [ 103.541389] BadVA : 00000003 [ 103.544253] PrId : 0001992f (MIPS 1004Kc) [ 103.797086] Call Trace: [ 103.799562] [<8576591c>] mt7615_mcu_add_bss+0xd0/0x3c0 [mt7615_common] [ 103.806082] [<85760a14>] mt7615_remove_interface+0x74/0x1e0 [mt7615_common] [ 103.813280] [<85603fcc>] drv_remove_interface+0x2c/0xa0 [mac80211] [ 103.819612] [<8561a8e4>] ieee80211_del_virtual_monitor.part.22+0x74/0xe8 [mac80211] [ 103.827410] [<8561b7f0>] ieee80211_do_stop+0x4a4/0x8a0 [mac80211] [ 103.833671] [<8561bc00>] ieee80211_stop+0x14/0x24 [mac80211] [ 103.839405] [<8045a328>] __dev_close_many+0x9c/0x10c [ 103.844364] [<80463de4>] __dev_change_flags+0x16c/0x1e4 [ 103.849569] [<80463e84>] dev_change_flags+0x28/0x70 [ 103.854440] [<80521e54>] devinet_ioctl+0x280/0x774 [ 103.859222] [<80526248>] inet_ioctl+0xa4/0x1c8 [ 103.863674] [<80436830>] sock_ioctl+0x2d8/0x4bc [ 103.868201] [<801adbb4>] do_vfs_ioctl+0xb8/0x7c0 [ 103.872804] [<801ae30c>] ksys_ioctl+0x50/0xb4 [ 103.877156] [<80014598>] syscall_common+0x34/0x58
--- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +13 -5
@@ -808,7 +808,8 @@ mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int band, int state)static int mt7615_mcu_bss_basic_tlv (struct sk_buff *skb,struct ieee80211_vif *vif, -struct ieee80211_sta *sta,bool enable) +struct ieee80211_sta *sta,struct mt7615_phy *phy, +bool enable) {struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;u32 type = vif->p2p ?NETWORK_P2P :NETWORK_INFRA ;
@@ -821,6 +822,7 @@ mt7615_mcu_bss_basic_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,switch (vif->type) {case NL80211_IFTYPE_MESH_POINT :case NL80211_IFTYPE_AP : +case NL80211_IFTYPE_MONITOR :break ;case NL80211_IFTYPE_STATION :/* TODO: enable BSS_INFO_UAPSD & BSS_INFO_PM */
@@ -840,14 +842,19 @@ mt7615_mcu_bss_basic_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, } bss = (struct bss_info_basic *)tlv; -memcpy (bss->bssid, vif->bss_conf.bssid,ETH_ALEN ); - bss->bcn_interval =cpu_to_le16 (vif->bss_conf.beacon_int); bss->network_type =cpu_to_le32 (type); - bss->dtim_period = vif->bss_conf.dtim_period; bss->bmc_tx_wlan_idx = wlan_idx; bss->wmm_idx = mvif->mt76.wmm_idx; bss->active = enable; +if (vif->type !=NL80211_IFTYPE_MONITOR ) { +memcpy (bss->bssid, vif->bss_conf.bssid,ETH_ALEN ); + bss->bcn_interval =cpu_to_le16 (vif->bss_conf.beacon_int); + bss->dtim_period = vif->bss_conf.dtim_period; + }else { +memcpy (bss->bssid, phy->mt76->macaddr,ETH_ALEN ); + } +return 0 ; }
@@ -863,6 +870,7 @@ mt7615_mcu_bss_omac_tlv(struct sk_buff *skb, struct ieee80211_vif *vif) tlv =mt76_connac_mcu_add_tlv (skb,BSS_INFO_OMAC ,sizeof (*omac));switch (vif->type) { +case NL80211_IFTYPE_MONITOR :case NL80211_IFTYPE_MESH_POINT :case NL80211_IFTYPE_AP :if (vif->p2p)
@@ -929,7 +937,7 @@ mt7615_mcu_add_bss(struct mt7615_phy *phy, struct ieee80211_vif *vif,if (enable)mt7615_mcu_bss_omac_tlv (skb, vif); -mt7615_mcu_bss_basic_tlv (skb, vif, sta, enable); +mt7615_mcu_bss_basic_tlv (skb, vif, sta, phy, enable);if (enable && mvif->mt76.omac_idx >=EXT_BSSID_START && mvif->mt76.omac_idx <REPEATER_BSSID_START )
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 473/849 mt76: connac: fix possible NULL pointer dereference in mt76_connac_get_phy_mode_v2
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit b5f2ba8a4c794e8349c0e30036352b9f685164c4 ]
Fix the following NULL pointer dereference in mt76_connac_get_phy_mode_v2 routine triggered on mt7663s device when sta is NULL
[ 5.490700] mt7663s mmc0:0001:1: N9 Firmware Version: 3.1.1, Build Time: 20200604161656 [ 5.490815] mt7663s mmc0:0001:1: Region number: 0x4 [ 5.490868] mt7663s mmc0:0001:1: Parsing tailer Region: 0 [ 5.496251] mt7663s mmc0:0001:1: Region 0, override_addr = 0x00118000 [ 5.496419] mt7663s mmc0:0001:1: Parsing tailer Region: 1 [ 5.624027] mt7663s mmc0:0001:1: Parsing tailer Region: 2 [ 5.656999] mt7663s mmc0:0001:1: Parsing tailer Region: 3 [ 5.671876] mt7663s mmc0:0001:1: override_addr = 0x00118000, option = 3 [ 9.358658] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 9.358775] #PF: supervisor read access in kernel mode [ 9.358831] #PF: error_code(0x0000) - not-present page [ 9.358886] PGD 0 P4D 0 [ 9.358917] Oops: 0000 [#1] SMP [ 9.358960] CPU: 0 PID: 235 Comm: NetworkManager Not tainted 5.15.0-rc4-kvm-02151-g39e333d657f4-dirty #769 [ 9.359057] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-4.fc34 04/01/2014 [ 9.359150] RIP: 0010:mt76_connac_get_phy_mode_v2+0xc9/0x11c [ 9.359473] RAX: 0000000000000013 RBX: 0000000000000000 RCX: 0000000000000027 [ 9.359546] RDX: ffff8881f9c17358 RSI: 0000000000000001 RDI: ffff8881f9c17350 [ 9.359624] RBP: ffff88810bac1ed4 R08: ffffffff822a4a48 R09: 0000000000000003 [ 9.359697] R10: ffffffff82234a60 R11: ffffffff82234a60 R12: ffff88810bac1eec [ 9.359779] R13: 0000000000000000 R14: ffff88810bad1648 R15: ffff88810bac1eb8 [ 9.359859] FS: 00007f5f1e45bbc0(0000) GS:ffff8881f9c00000(0000) knlGS:0000000000000000 [ 9.359939] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 9.360003] CR2: 0000000000000000 CR3: 0000000105d5d000 CR4: 00000000000006b0 [ 9.360083] Call Trace: [ 9.360116] mt76_connac_mcu_uni_add_bss.cold+0x21/0x250 [ 9.360175] ? schedule_preempt_disabled+0xa/0x10 [ 9.360232] ? __mutex_lock.constprop.0+0x2ab/0x460 [ 9.360286] mt7615_remove_interface+0x63/0x1d0 [ 9.360342] drv_remove_interface+0x32/0xe0 [ 9.360385] ieee80211_do_stop+0x5da/0x800 [ 9.360428] ? dev_reset_queue+0x30/0x90 [ 9.360472] ieee80211_stop+0x3b/0xb0 [ 9.360516] __dev_close_many+0x7a/0xd0 [ 9.360559] __dev_change_flags+0xd6/0x1f0 [ 9.360604] dev_change_flags+0x21/0x60 [ 9.360648] do_setlink+0x259/0xfb0 [ 9.360686] ? __nla_validate_parse+0x51/0xb80 [ 9.360742] __rtnl_newlink+0x5b3/0x960 [ 9.360785] ? inet6_fill_ifla6_attrs+0x41d/0x470 [ 9.360841] ? __kmalloc_track_caller+0x57/0x3c0 [ 9.360905] ? netlink_trim+0x8a/0xb0 [ 9.360949] ? skb_queue_tail+0x1b/0x50
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +2 -2
@@ -689,7 +689,7 @@ mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,if (ht_cap->ht_supported) mode |=PHY_TYPE_BIT_HT ; -if (he_cap->has_he) +if (he_cap && he_cap->has_he) mode |=PHY_TYPE_BIT_HE ; }else if (band ==NL80211_BAND_5GHZ ) { mode |=PHY_TYPE_BIT_OFDM ;
@@ -700,7 +700,7 @@ mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,if (vht_cap->vht_supported) mode |=PHY_TYPE_BIT_VHT ; -if (he_cap->has_he) +if (he_cap && he_cap->has_he) mode |=PHY_TYPE_BIT_HE ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 474/849 mt76: mt7915: fix sta_rec_wtbl tag len
In reply to Greg Kroah-HartmanFrom: Shayne Chen <[email protected]>
[ Upstream commit afa0370f3a3a64af6d368da0bedd72ab2a026cd0 ]
Fix tag len error for sta_rec_wtbl, which causes fw parsing error for the tags placed behind it.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -757,7 +757,7 @@ mt7915_mcu_alloc_wtbl_req(struct mt7915_dev *dev, struct mt7915_sta *msta, }if (sta_hdr) - sta_hdr->len =cpu_to_le16 (sizeof (hdr)); +le16_add_cpu (&sta_hdr->len,sizeof (hdr));return skb_put_data (nskb, &hdr,sizeof (hdr)); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 475/849 mt76: mt7915: fix muar_idx in mt7915_mcu_alloc_sta_req()
In reply to Greg Kroah-HartmanFrom: Shayne Chen <[email protected]>
[ Upstream commit 161cc13912d3c3e8857001988dfba39be842454a ]
For broadcast/multicast wcid, the muar_idx should be 0xe.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -721,7 +721,7 @@ mt7915_mcu_alloc_sta_req(struct mt7915_dev *dev, struct mt7915_vif *mvif, .bss_idx = mvif->idx, .wlan_idx_lo = msta ? to_wcid_lo(msta->wcid.idx) : 0, .wlan_idx_hi = msta ? to_wcid_hi(msta->wcid.idx) : 0, - .muar_idx = msta ? mvif->omac_idx : 0, + .muar_idx = msta && msta->wcid.sta ? mvif->omac_idx : 0xe, .is_tlv_append = 1, };struct sk_buff *skb;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 476/849 rsi: stop thread firstly in rsi_91x_init() error handling
In reply to Greg Kroah-HartmanFrom: Ziyang Xuan <[email protected]>
[ Upstream commit 515e7184bdf0a3ebf1757cc77fb046b4fe282189 ]
When fail to init coex module, free 'common' and 'adapter' directly, but common->tx_thread which will access 'common' and 'adapter' is running at the same time. That will trigger the UAF bug.
==================================================================
BUG: KASAN: use-after-free in rsi_tx_scheduler_thread+0x50f/0x520 [rsi_91x] Read of size 8 at addr ffff8880076dc000 by task Tx-Thread/124777 CPU: 0 PID: 124777 Comm: Tx-Thread Not tainted 5.15.0-rc5+ #19 Call Trace: dump_stack_lvl+0xe2/0x152 print_address_description.constprop.0+0x21/0x140 ? rsi_tx_scheduler_thread+0x50f/0x520 kasan_report.cold+0x7f/0x11b ? rsi_tx_scheduler_thread+0x50f/0x520 rsi_tx_scheduler_thread+0x50f/0x520
...
Freed by task 111873: kasan_save_stack+0x1b/0x40 kasan_set_track+0x1c/0x30 kasan_set_free_info+0x20/0x30 __kasan_slab_free+0x109/0x140 kfree+0x117/0x4c0 rsi_91x_init+0x741/0x8a0 [rsi_91x] rsi_probe+0x9f/0x1750 [rsi_usb]
Stop thread before free 'common' and 'adapter' to fix it.
--- drivers/net/wireless/rsi/rsi_91x_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/rsi/rsi_91x_main.c +1 -0
@@ -369,6 +369,7 @@ struct rsi_hw *rsi_91x_init(u16 oper_mode)if (common->coex_mode >1 ) {if (rsi_coex_attach (common)) {rsi_dbg (ERR_ZONE ,"Failed to init coex module\n" ); +rsi_kill_thread (&common->tx_thread); goto err; } }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 477/849 mwifiex: Send DELBA requests according to spec
In reply to Greg Kroah-HartmanFrom: Jonas Dreßler <[email protected]>
[ Upstream commit cc8a8bc37466f79b24d972555237f3d591150602 ]
While looking at on-air packets using Wireshark, I noticed we're never setting the initiator bit when sending DELBA requests to the AP: While we set the bit on our del_ba_param_set bitmask, we forget to actually copy that bitmask over to the command struct, which means we never actually set the initiator bit.
Fix that and copy the bitmask over to the host_cmd_ds_11n_delba command struct.
--- drivers/net/wireless/marvell/mwifiex/11n.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/marvell/mwifiex/11n.c +3 -2
@@ -657,14 +657,15 @@ int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,uint16_t del_ba_param_set;memset (&delba,0 ,sizeof (delba)); - delba.del_ba_param_set =cpu_to_le16 (tid <<DELBA_TID_POS ); - del_ba_param_set =le16_to_cpu (delba.del_ba_param_set); + del_ba_param_set = tid <<DELBA_TID_POS ; +if (initiator) del_ba_param_set |=IEEE80211_DELBA_PARAM_INITIATOR_MASK ;else del_ba_param_set &= ~IEEE80211_DELBA_PARAM_INITIATOR_MASK ; + delba.del_ba_param_set =cpu_to_le16 (del_ba_param_set);memcpy (&delba.peer_mac_addr, peer_mac,ETH_ALEN );/* We don't wait for the response of this command */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 478/849 iwlwifi: mvm: reset PM state on unsuccessful resume
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 2f629a7772e2a7bdaff25178917a40073f79702c ]
If resume fails for some reason, we need to set the PM state back to normal so we're able to send commands during firmware reset, rather than failing all of them because we're in D3.
--- drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/d3.c +4 -1
@@ -2093,7 +2093,6 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test)iwl_fw_dbg_collect_desc (&mvm->fwrt, &iwl_dump_desc_assert, false,0 ); ret =1 ; - mvm->trans->system_pm_mode =IWL_PLAT_PM_MODE_DISABLED ; goto err; }
@@ -2142,6 +2141,7 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test) } } +/* after the successful handshake, we're out of D3 */ mvm->trans->system_pm_mode =IWL_PLAT_PM_MODE_DISABLED ;/*
@@ -2212,6 +2212,9 @@ out:*/ set_bit (IWL_MVM_STATUS_HW_RESTART_REQUESTED , &mvm->status); +/* regardless of what happened, we're now out of D3 */ + mvm->trans->system_pm_mode =IWL_PLAT_PM_MODE_DISABLED ; +return 1 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 479/849 iwlwifi: pnvm: dont kmemdup() more than we have
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 0f892441d8c353144e3669b7991fa5fe0bd353e9 ]
We shouldn't kmemdup() more data than we have, that might cause the code to crash. Fix that by updating the length before the kmemdup.
--- drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/pnvm.c +3 -4
@@ -284,16 +284,15 @@ int iwl_pnvm_load(struct iwl_trans *trans,/* First attempt to get the PNVM from BIOS */ package =iwl_uefi_get_pnvm (trans, &len);if (!IS_ERR_OR_NULL (package)) { +/* we need only the data */ + len -=sizeof (*package); data =kmemdup (package->data, len,GFP_KERNEL );/* free package regardless of whether kmemdup succeeded */ kfree (package); -if (data) { -/* we need only the data size */ - len -=sizeof (*package); +if (data) goto parse; - } }/* If it's not available, try from the filesystem */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 480/849 iwlwifi: pnvm: read EFI data only if long enough
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit e864a77f51d0d8113b49cf7d030bc9dc911c8176 ]
If the data we get from EFI is not even long enough for the package struct we expect then ignore it entirely.
--- drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/pnvm.c +7 -3
@@ -284,9 +284,13 @@ int iwl_pnvm_load(struct iwl_trans *trans,/* First attempt to get the PNVM from BIOS */ package =iwl_uefi_get_pnvm (trans, &len);if (!IS_ERR_OR_NULL (package)) { -/* we need only the data */ - len -=sizeof (*package); - data =kmemdup (package->data, len,GFP_KERNEL ); +if (len >=sizeof (*package)) { +/* we need only the data */ + len -=sizeof (*package); + data =kmemdup (package->data, len,GFP_KERNEL ); + }else { + data =NULL ; + }/* free package regardless of whether kmemdup succeeded */ kfree (package);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 481/849 net: enetc: unmap DMA in enetc_send_cmd()
In reply to Greg Kroah-HartmanFrom: Tim Gardner <[email protected]>
[ Upstream commit cd4bc63de774eee95e9bac26a565cd80e0fca421 ]
Coverity complains of a possible dereference of a null return value.
5. returned_null: kzalloc returns NULL. [show details]
6. var_assigned: Assigning: si_data = NULL return value from kzalloc.
488 si_data = kzalloc(data_size, __GFP_DMA | GFP_KERNEL);
489 cbd.length = cpu_to_le16(data_size);
490
491 dma = dma_map_single(&priv->si->pdev->dev, si_data,
492 data_size, DMA_FROM_DEVICE);
While this kzalloc() is unlikely to fail, I did notice that the function returned without unmapping si_data.
Fix this by refactoring the error paths and checking for kzalloc() failure.
--- .../net/ethernet/freescale/enetc/enetc_qos.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/net/ethernet/freescale/enetc/enetc_qos.c +11 -7
@@ -486,14 +486,16 @@ static int enetc_streamid_hw_set(struct enetc_ndev_priv *priv, data_size =sizeof (struct streamid_data ); si_data =kzalloc (data_size, __GFP_DMA |GFP_KERNEL ); +if (!si_data) +return -ENOMEM ; cbd.length =cpu_to_le16 (data_size); dma =dma_map_single (&priv->si->pdev->dev, si_data, data_size,DMA_FROM_DEVICE );if (dma_mapping_error (&priv->si->pdev->dev, dma)) {netdev_err (priv->si->ndev,"DMA mapping failed!\n" ); -kfree (si_data); -return -ENOMEM ; + err = -ENOMEM ; + goto out; } cbd.addr[0 ] =cpu_to_le32 (lower_32_bits (dma));
@@ -512,12 +514,10 @@ static int enetc_streamid_hw_set(struct enetc_ndev_priv *priv, err =enetc_send_cmd (priv->si, &cbd);if (err) -return -EINVAL ; + goto out; -if (!enable) { -kfree (si_data); -return 0 ; - } +if (!enable) + goto out;/* Enable the entry overwrite again incase space flushed by hardware */ memset (&cbd,0 ,sizeof (cbd));
@@ -560,6 +560,10 @@ static int enetc_streamid_hw_set(struct enetc_ndev_priv *priv, } err =enetc_send_cmd (priv->si, &cbd); +out: +if (!dma_mapping_error (&priv->si->pdev->dev, dma)) +dma_unmap_single (&priv->si->pdev->dev, dma, data_size,DMA_FROM_DEVICE ); +kfree (si_data);return err;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 482/849 phy: micrel: ksz8041nl: do not use power down mode
In reply to Greg Kroah-HartmanFrom: Stefan Agner <[email protected]>
[ Upstream commit 2641b62d2fab52648e34cdc6994b2eacde2d27c1 ]
Some Micrel KSZ8041NL PHY chips exhibit continuous RX errors after using the power down mode bit (0.11). If the PHY is taken out of power down mode in a certain temperature range, the PHY enters a weird state which leads to continuously reporting RX errors. In that state, the MAC is not able to receive or send any Ethernet frames and the activity LED is constantly blinking. Since Linux is using the suspend callback when the interface is taken down, ending up in that state can easily happen during a normal startup.
Micrel confirmed the issue in errata DS80000700A [*], caused by abnormal clock recovery when using power down mode. Even the latest revision (A4, Revision ID 0x1513) seems to suffer that problem, and according to the errata is not going to be fixed.
Remove the suspend/resume callback to avoid using the power down mode completely.
[*] https://ww1.microchip.com/downloads/en/DeviceDoc/80000700A.pdf
--- drivers/net/phy/micrel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/phy/micrel.c +3 -2
@@ -1593,8 +1593,9 @@ static struct phy_driver ksphy_driver[] = { .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, - .suspend = genphy_suspend, - .resume = genphy_resume, +/* No suspend/resume callbacks because of errata DS80000700A, +* receiver error following software power down. +*/ }, { .phy_id = PHY_ID_KSZ8041RNLI, .phy_id_mask = MICREL_PHY_ID_MASK,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 483/849 nbd: Fix use-after-free in pid_show
In reply to Greg Kroah-HartmanFrom: Ye Bin <[email protected]>
[ Upstream commit 0c98057be9efa32de78dbc4685fc73da9d71faa1 ]
I got issue as follows:
[ 263.886511] BUG: KASAN: use-after-free in pid_show+0x11f/0x13f [ 263.888359] Read of size 4 at addr ffff8880bf0648c0 by task cat/746 [ 263.890479] CPU: 0 PID: 746 Comm: cat Not tainted 4.19.90-dirty #140 [ 263.893162] Call Trace: [ 263.893509] dump_stack+0x108/0x15f [ 263.893999] print_address_description+0xa5/0x372 [ 263.894641] kasan_report.cold+0x236/0x2a8 [ 263.895696] __asan_report_load4_noabort+0x25/0x30 [ 263.896365] pid_show+0x11f/0x13f [ 263.897422] dev_attr_show+0x48/0x90 [ 263.898361] sysfs_kf_seq_show+0x24d/0x4b0 [ 263.899479] kernfs_seq_show+0x14e/0x1b0 [ 263.900029] seq_read+0x43f/0x1150 [ 263.900499] kernfs_fop_read+0xc7/0x5a0 [ 263.903764] vfs_read+0x113/0x350 [ 263.904231] ksys_read+0x103/0x270 [ 263.905230] __x64_sys_read+0x77/0xc0 [ 263.906284] do_syscall_64+0x106/0x360 [ 263.906797] entry_SYSCALL_64_after_hwframe+0x44/0xa9
Reproduce this issue as follows:
1. nbd-server 8000 /tmp/disk
2. nbd-client localhost 8000 /dev/nbd1
3. cat /sys/block/nbd1/pid
Then trigger use-after-free in pid_show.
Reason is after do step '2', nbd-client progress is already exit. So it's task_struct already freed.
To solve this issue, revert part of 6521d39a64b3's modify and remove useless 'recv_task' member of nbd_device.
--- drivers/block/nbd.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/block/nbd.c +9 -9
@@ -122,11 +122,11 @@ struct nbd_device {struct work_struct remove_work;struct list_head list; -struct task_struct *task_recv;struct task_struct *task_setup;struct completion *destroy_complete;unsigned long flags; +pid_t pid;/* pid of nbd-client, if attached */ char *backend; };
@@ -218,7 +218,7 @@ static ssize_t pid_show(struct device *dev,struct gendisk *disk =dev_to_disk (dev);struct nbd_device *nbd = (struct nbd_device *)disk->private_data; -return sprintf (buf,"%d\n" ,task_pid_nr (nbd->task_recv)); +return sprintf (buf,"%d\n" , nbd->pid); }static const struct device_attribute pid_attr = {
@@ -362,7 +362,7 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, nbd->config->bytesize = bytesize; nbd->config->blksize_bits =__ffs (blksize); -if (!nbd->task_recv) +if (!nbd->pid)return 0 ;if (nbd->config->flags &NBD_FLAG_SEND_TRIM ) {
@@ -1274,7 +1274,7 @@ static void nbd_config_put(struct nbd_device *nbd)if (test_and_clear_bit (NBD_RT_HAS_PID_FILE , &config->runtime_flags))device_remove_file (disk_to_dev (nbd->disk), &pid_attr); - nbd->task_recv =NULL ; + nbd->pid =0 ;if (test_and_clear_bit (NBD_RT_HAS_BACKEND_FILE , &config->runtime_flags)) {device_remove_file (disk_to_dev (nbd->disk), &backend_attr);
@@ -1315,7 +1315,7 @@ static int nbd_start_device(struct nbd_device *nbd)int num_connections = config->num_connections;int error =0 , i; -if (nbd->task_recv) +if (nbd->pid)return -EBUSY ;if (!config->socks)return -EINVAL ;
@@ -1334,7 +1334,7 @@ static int nbd_start_device(struct nbd_device *nbd) }blk_mq_update_nr_hw_queues (&nbd->tag_set, config->num_connections); - nbd->task_recv = current; + nbd->pid =task_pid_nr (current);nbd_parse_flags (nbd);
@@ -1590,8 +1590,8 @@ static int nbd_dbg_tasks_show(struct seq_file *s, void *unused) {struct nbd_device *nbd = s->private; -if (nbd->task_recv) -seq_printf (s,"recv: %d\n" ,task_pid_nr (nbd->task_recv)); +if (nbd->pid) +seq_printf (s,"recv: %d\n" , nbd->pid);return 0 ; }
@@ -2177,7 +2177,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)mutex_lock (&nbd->config_lock); config = nbd->config;if (!test_bit (NBD_RT_BOUND , &config->runtime_flags) || - !nbd->task_recv) { + !nbd->pid) {dev_err (nbd_to_dev (nbd),"not configured, cannot reconfigure\n" ); ret = -EINVAL ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 484/849 nvme-rdma: fix error code in nvme_rdma_setup_ctrl
In reply to Greg Kroah-HartmanFrom: Max Gurtovoy <[email protected]>
[ Upstream commit 09748122009aed7bfaa7acc33c10c083a4758322 ]
In case that icdoff is not zero or mandatory keyed sgls are not supported by the NVMe/RDMA target, we'll go to error flow but we'll return 0 to the caller. Fix it by returning an appropriate error code.
--- drivers/nvme/host/rdma.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/rdma.c +2 -0
@@ -1095,11 +1095,13 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new)return ret;if (ctrl->ctrl.icdoff) { + ret = -EOPNOTSUPP ;dev_err (ctrl->ctrl.device,"icdoff is not supported!\n" ); goto destroy_admin; }if (!(ctrl->ctrl.sgls & (1 <<2 ))) { + ret = -EOPNOTSUPP ;dev_err (ctrl->ctrl.device,"Mandatory keyed sgls are not supported!\n" ); goto destroy_admin;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 485/849 PM: hibernate: fix sparse warnings
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
[ Upstream commit 01de5fcd8b1ac0ca28d2bb0921226a54fdd62684 ]
When building the kernel with sparse enabled 'C=1' the following warnings shows up:
kernel/power/swap.c:390:29: warning: incorrect type in assignment (different base types)kernel/power/swap.c:390:29: expected int retkernel/power/swap.c:390:29: got restricted blk_status_t
This is due to function hib_wait_io() returns a 'blk_status_t' which is a bitwise u8. Commit 5416da01ff6e ("PM: hibernate: Remove blk_status_to_errno in hib_wait_io") seemed to have mixed up the return type. However, the 4e4cbee93d56 ("block: switch bios to blk_status_t") actually broke the behaviour by returning the wrong type.
Rework so function hib_wait_io() returns a 'int' instead of 'blk_status_t' and make sure to call function blk_status_to_errno(hb->error)' when returning from function hib_wait_io() a int gets returned.
--- kernel/power/swap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/swap.c +1 -1
@@ -299,7 +299,7 @@ static int hib_submit_io(int op, int op_flags, pgoff_t page_off, void *addr,return error; } -static blk_status_t hib_wait_io (struct hib_bio_batch *hb) +static int hib_wait_io (struct hib_bio_batch *hb) {/* * We are relying on the behavior of blk_plug that a thread with
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 486/849 clocksource/drivers/timer-ti-dm: Select TIMER_OF
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit eda9a4f7af6ee47e9e131f20e4f8a41a97379293 ]
When building OMAP_DM_TIMER without TIMER_OF, there are orphan sections due to the use of TIMER_OF_DELCARE() without CONFIG_TIMER_OF. Select CONFIG_TIMER_OF when enaling OMAP_DM_TIMER:
arm-linux-gnueabi-ld: warning: orphan section __timer_of_table' from drivers/clocksource/timer-ti-dm-systimer.o' being placed in section `__timer_of_table'
--- drivers/clocksource/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/clocksource/Kconfig +1 -0
@@ -24,6 +24,7 @@ config I8253_LOCK config OMAP_DM_TIMER bool + select TIMER_OF config CLKBLD_I8253 def_bool y if CLKSRC_I8253 || CLKEVT_I8253 || I8253_LOCK
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 487/849 x86/sev: Fix stack type check in vc_switch_off_ist()
In reply to Greg Kroah-HartmanFrom: Joerg Roedel <[email protected]>
[ Upstream commit 5681981fb788281b09a4ea14d310d30b2bd89132 ]
The value of STACK_TYPE_EXCEPTION_LAST points to the last _valid_ exception stack. Reflect that in the check done in the vc_switch_off_ist() function.
--- arch/x86/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/traps.c +1 -1
@@ -743,7 +743,7 @@ asmlinkage __visible noinstr struct pt_regs *vc_switch_off_ist(struct pt_regs *r stack = (unsigned long *)sp;if (!get_stack_info_noinstr (stack, current, &info) || info.type ==STACK_TYPE_ENTRY || - info.type >=STACK_TYPE_EXCEPTION_LAST ) + info.type >STACK_TYPE_EXCEPTION_LAST ) sp =__this_cpu_ist_top_va (VC2 ); sync:
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 488/849 drm/msm: Fix potential NULL dereference in DPU SSPP
In reply to Greg Kroah-HartmanFrom: Jessica Zhang <[email protected]>
[ Upstream commit 8bf71a5719b6cc5b6ba358096081e5d50ea23ab6 ]
Move initialization of sblk in _sspp_subblk_offset() after NULL check to avoid potential NULL pointer dereference.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.c +5 -3
@@ -138,11 +138,13 @@ static int _sspp_subblk_offset(struct dpu_hw_pipe *ctx, u32 *idx) {int rc =0 ; -const struct dpu_sspp_sub_blks *sblk = ctx->cap->sblk; +const struct dpu_sspp_sub_blks *sblk; -if (!ctx) +if (!ctx || !ctx->cap || !ctx->cap->sblk)return -EINVAL ; + sblk = ctx->cap->sblk; +switch (s_id) {case DPU_SSPP_SRC : *idx = sblk->src_blk.base;
@@ -419,7 +421,7 @@ static void _dpu_hw_sspp_setup_scaler3(struct dpu_hw_pipe *ctx, (void )pe;if (_sspp_subblk_offset (ctx,DPU_SSPP_SCALER_QSEED3 , &idx) || !sspp - || !scaler3_cfg || !ctx || !ctx->cap || !ctx->cap->sblk) + || !scaler3_cfg)return ; dpu_hw_setup_scaler3(&ctx->hw, scaler3_cfg, idx,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 489/849 crypto: tcrypt - fix skcipher multi-buffer tests for 1420B blocks
In reply to Greg Kroah-HartmanFrom: Horia Geantă <[email protected]>
[ Upstream commit 3ae88f676aa63366ffa9eebb8ae787c7e19f0c57 ]
Commit ad6d66bcac77e ("crypto: tcrypt - include 1420 byte blocks in aead and skcipher benchmarks") mentions:
Quoted 3 lines
power-of-2 block size. So let's add 1420 bytes explicitly, and round it up to the next blocksize multiple of the algo in question if it does not support 1420 byte blocks.
but misses updating skcipher multi-buffer tests.
Fix this by using the proper (rounded) input size.
--- crypto/tcrypt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
crypto/tcrypt.c +2 -3
@@ -1333,7 +1333,7 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,if (bs >XBUFSIZE *PAGE_SIZE ) {pr_err ("template (%u) too big for buffer (%lu)\n" , - *b_size,XBUFSIZE *PAGE_SIZE ); + bs,XBUFSIZE *PAGE_SIZE ); goto out; }
@@ -1386,8 +1386,7 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,memset (cur->xbuf[p],0xff , k);skcipher_request_set_crypt (cur->req, cur->sg, - cur->sg, *b_size, - iv); + cur->sg, bs, iv); }if (secs) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 490/849 smackfs: use netlbl_cfg_cipsov4_del() for deleting cipso_v4_doi
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
[ Upstream commit 0934ad42bb2c5df90a1b9de690f93de735b622fe ]
syzbot is reporting UAF at cipso_v4_doi_search() [1], for smk_cipso_doi() is calling kfree() without removing from the cipso_v4_doi_list list after netlbl_cfg_cipsov4_map_add() returned an error. We need to use netlbl_cfg_cipsov4_del() in order to remove from the list and wait for RCU grace period before kfree().
--- security/smack/smackfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/smack/smackfs.c +1 -1
@@ -712,7 +712,7 @@ static void smk_cipso_doi(void)if (rc !=0 ) {printk (KERN_WARNING "%s:%d map add rc = %d\n" , __func__, __LINE__, rc); -kfree (doip); +netlbl_cfg_cipsov4_del (doip->doi, &nai);return ; } }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 491/849 KVM: selftests: Fix nested SVM tests when built with clang
In reply to Greg Kroah-HartmanFrom: Jim Mattson <[email protected]>
[ Upstream commit ed290e1c20da19fa100a3e0f421aa31b65984960 ]
Though gcc conveniently compiles a simple memset to "rep stos," clang prefers to call the libc version of memset. If a test is dynamically linked, the libc memset isn't available in L1 (nor is the PLT or the GOT, for that matter). Even if the test is statically linked, the libc memset may choose to use some CPU features, like AVX, which may not be enabled in L1. Note that __builtin_memset doesn't solve the problem, because (a) the compiler is free to call memset anyway, and (b) __builtin_memset may also choose to use features like AVX, which may not be available in L1.
To avoid a myriad of problems, use an explicit "rep stos" to clear the VMCB in generic_svm_setup(), which is called both from L0 and L1.
Message-Id: <[email protected]>
--- tools/testing/selftests/kvm/lib/x86_64/svm.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tools/testing/selftests/kvm/lib/x86_64/svm.c +13 -1
@@ -54,6 +54,18 @@ static void vmcb_set_seg(struct vmcb_seg *seg, u16 selector, seg->base = base; } +/* +* Avoid using memset to clear the vmcb, since libc may not be +* available in L1 (and, even if it is, features that libc memset may +* want to use, like AVX, may not be enabled). +*/ +static void clear_vmcb (struct vmcb *vmcb) +{ +int n =sizeof (*vmcb) /sizeof (u32); + + asmvolatile ("rep stosl" :"+c" (n),"+D" (vmcb) :"a" (0 ) :"memory" ); +} +void generic_svm_setup (struct svm_test_data *svm,void *guest_rip,void *guest_rsp) {struct vmcb *vmcb = svm->vmcb;
@@ -70,7 +82,7 @@ void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_rwrmsr (MSR_EFER , efer |EFER_SVME );wrmsr (MSR_VM_HSAVE_PA , svm->save_area_gpa); -memset (vmcb,0 ,sizeof (*vmcb)); +clear_vmcb (vmcb); asmvolatile ("vmsave %0\n\t" : :"a" (vmcb_gpa) :"memory" );vmcb_set_seg (&save->es,get_es (),0 ,-1U , data_seg_attr);vmcb_set_seg (&save->cs,get_cs (),0 ,-1U , code_seg_attr);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 492/849 libbpf: Fix memory leak in btf__dedup()
In reply to Greg Kroah-HartmanFrom: Mauricio Vásquez <[email protected]>
[ Upstream commit 1000298c76830bc291358e98e8fa5baa3baa9b3a ]
Free btf_dedup if btf_ensure_modifiable() returns error.
--- tools/lib/bpf/btf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/lib/bpf/btf.c +4 -2
@@ -2899,8 +2899,10 @@ int btf__dedup(struct btf *btf, struct btf_ext *btf_ext,return libbpf_err (-EINVAL ); } -if (btf_ensure_modifiable (btf)) -return libbpf_err (-ENOMEM ); +if (btf_ensure_modifiable (btf)) { + err = -ENOMEM ; + goto done; + } err =btf_dedup_prep (d);if (err) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 493/849 bpftool: Avoid leaking the JSON writer prepared for program metadata
In reply to Greg Kroah-HartmanFrom: Quentin Monnet <[email protected]>
[ Upstream commit e89ef634f81c9d90e1824ab183721f3b361472e6 ]
Bpftool creates a new JSON object for writing program metadata in plain text mode, regardless of metadata being present or not. Then this writer is freed if any metadata has been found and printed, but it leaks otherwise. We cannot destroy the object unconditionally, because the destructor prints an undesirable line break. Instead, make sure the writer is created only after we have found program metadata to print.
Found with valgrind.
--- tools/bpf/bpftool/prog.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
tools/bpf/bpftool/prog.c +9 -7
@@ -308,18 +308,12 @@ static void show_prog_metadata(int fd, __u32 num_maps)if (printed_header)jsonw_end_object (json_wtr); }else { -json_writer_t *btf_wtr =jsonw_new (stdout); +json_writer_t *btf_wtr;struct btf_dumper d = { .btf = btf, - .jw = btf_wtr, .is_plain_text = true, }; -if (!btf_wtr) { -p_err ("jsonw alloc failed" ); - goto out_free; - } -for (i =0 ; i < vlen; i++, vsi++) { t_var =btf__type_by_id (btf, vsi->type); name =btf__name_by_offset (btf, t_var->name_off);
@@ -329,6 +323,14 @@ static void show_prog_metadata(int fd, __u32 num_maps)if (!printed_header) {printf ("\tmetadata:" ); + + btf_wtr =jsonw_new (stdout); +if (!btf_wtr) { +p_err ("jsonw alloc failed" ); + goto out_free; + } + d.jw = btf_wtr, + printed_header = true; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 494/849 libbpf: Fix overflow in BTF sanity checks
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 5245dafe3d49efba4d3285cf27ee1cc1eeafafc6 ]
btf_header's str_off+str_len or type_off+type_len can overflow as they are u32s. This will lead to bypassing the sanity checks during BTF parsing, resulting in crashes afterwards. Fix by using 64-bit signed integers for comparison.
--- tools/lib/bpf/btf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/btf.c +2 -2
@@ -236,12 +236,12 @@ static int btf_parse_hdr(struct btf *btf) } meta_left = btf->raw_size -sizeof (*hdr); -if (meta_left < hdr->str_off + hdr->str_len) { +if (meta_left < (long long )hdr->str_off + hdr->str_len) {pr_debug ("Invalid BTF total size:%u\n" , btf->raw_size);return -EINVAL ; } -if (hdr->type_off + hdr->type_len > hdr->str_off) { +if ((long long )hdr->type_off + hdr->type_len > hdr->str_off) {pr_debug ("Invalid BTF data sections layout: type data at %u + %u, strings data at %u + %u\n" , hdr->type_off, hdr->type_len, hdr->str_off, hdr->str_len);return -EINVAL ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 495/849 libbpf: Fix BTF header parsing checks
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit c825f5fee19caf301d9821cd79abaa734322de26 ]
Original code assumed fixed and correct BTF header length. That's not always the case, though, so fix this bug with a proper additional check. And use actual header length instead of sizeof(struct btf_header) in sanity checks.
--- tools/lib/bpf/btf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
tools/lib/bpf/btf.c +9 -3
@@ -231,13 +231,19 @@ static int btf_parse_hdr(struct btf *btf) }btf_bswap_hdr (hdr); }else if (hdr->magic !=BTF_MAGIC ) { -pr_debug ("Invalid BTF magic:%x\n" , hdr->magic); +pr_debug ("Invalid BTF magic: %x\n" , hdr->magic);return -EINVAL ; } - meta_left = btf->raw_size -sizeof (*hdr); +if (btf->raw_size < hdr->hdr_len) { +pr_debug ("BTF header len %u larger than data size %u\n" , + hdr->hdr_len, btf->raw_size); +return -EINVAL ; + } + + meta_left = btf->raw_size - hdr->hdr_len;if (meta_left < (long long )hdr->str_off + hdr->str_len) { -pr_debug ("Invalid BTF total size:%u\n" , btf->raw_size); +pr_debug ("Invalid BTF total size: %u\n" , btf->raw_size);return -EINVAL ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 496/849 mt76: mt7615: mt7622: fix ibss and meshpoint
In reply to Greg Kroah-HartmanFrom: Nick Hainke <[email protected]>
[ Upstream commit 753453afacc0243bd45de45e34218a8d17493e8f ]
commit 7f4b7920318b ("mt76: mt7615: add ibss support") introduced IBSS and commit f4ec7fdf7f83 ("mt76: mt7615: enable support for mesh") meshpoint support.
Both used in the "get_omac_idx"-function:
if (~mask & BIT(HW_BSSID_0)) return HW_BSSID_0;
With commit d8d59f66d136 ("mt76: mt7615: support 16 interfaces") the ibss and meshpoint mode should "prefer hw bssid slot 1-3". However, with that change the ibss or meshpoint mode will not send any beacon on the mt7622 wifi anymore. Devices were still able to exchange data but only if a bssid already existed. Two mt7622 devices will never be able to communicate.
This commits reverts the preferation of slot 1-3 for ibss and meshpoint. Only NL80211_IFTYPE_STATION will still prefer slot 1-3.
Tested on Banana Pi R64.
--- drivers/net/wireless/mediatek/mt76/mt7615/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/main.c +2 -2
@@ -135,8 +135,6 @@ static int get_omac_idx(enum nl80211_iftype type, u64 mask)int i;switch (type) { -case NL80211_IFTYPE_MESH_POINT : -case NL80211_IFTYPE_ADHOC :case NL80211_IFTYPE_STATION :/* prefer hw bssid slot 1-3 */ i =get_free_idx (mask,HW_BSSID_1 ,HW_BSSID_3 );
@@ -160,6 +158,8 @@ static int get_omac_idx(enum nl80211_iftype type, u64 mask)return HW_BSSID_0 ;break ; +case NL80211_IFTYPE_ADHOC : +case NL80211_IFTYPE_MESH_POINT :case NL80211_IFTYPE_MONITOR :case NL80211_IFTYPE_AP :/* ap uses hw bssid 0 and ext bssid */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 497/849 s390/gmap: validate VMA in __gmap_zap()
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
[ Upstream commit 2d8fb8f3914b40e3cc12f8cbb74daefd5245349d ]
We should not walk/touch page tables outside of VMA boundaries when holding only the mmap sem in read mode. Evil user space can modify the VMA layout just before this function runs and e.g., trigger races with page table removal code since commit dd2283f2605e ("mm: mmap: zap pages with read mmap_sem in munmap"). The pure prescence in our guest_to_host radix tree does not imply that there is a VMA.
Further, we should not allocate page tables (via get_locked_pte()) outside of VMA boundaries: if evil user space decides to map hugetlbfs to these ranges, bad things will happen because we suddenly have PTE or PMD page tables where we shouldn't have them.
Similarly, we have to check if we suddenly find a hugetlbfs VMA, before calling get_locked_pte().
Note that gmap_discard() is different:
zap_page_range()->unmap_single_vma() makes sure to stay within VMA boundaries.
--- arch/s390/mm/gmap.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/s390/mm/gmap.c +6 -0
@@ -673,6 +673,7 @@ EXPORT_SYMBOL_GPL(gmap_fault);*/ void __gmap_zap (struct gmap *gmap,unsigned long gaddr) { +struct vm_area_struct *vma;unsigned long vmaddr;spinlock_t *ptl;pte_t *ptep;
@@ -682,6 +683,11 @@ void __gmap_zap(struct gmap *gmap, unsigned long gaddr) gaddr >> PMD_SHIFT);if (vmaddr) { vmaddr |= gaddr & ~PMD_MASK ; + + vma =vma_lookup (gmap->mm, vmaddr); +if (!vma ||is_vm_hugetlb_page (vma)) +return ; +/* Get pointer to the page table entry */ ptep =get_locked_pte (gmap->mm, vmaddr, &ptl);if (likely (ptep))
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 498/849 s390/gmap: dont unconditionally call pte_unmap_unlock() in __gmap_zap()
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
[ Upstream commit b159f94c86b43cf7e73e654bc527255b1f4eafc4 ]
... otherwise we will try unlocking a spinlock that was never locked via a garbage pointer.
At the time we reach this code path, we usually successfully looked up a PGSTE already; however, evil user space could have manipulated the VMA layout in the meantime and triggered removal of the page table.
--- arch/s390/mm/gmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/s390/mm/gmap.c +3 -2
@@ -690,9 +690,10 @@ void __gmap_zap(struct gmap *gmap, unsigned long gaddr)/* Get pointer to the page table entry */ ptep =get_locked_pte (gmap->mm, vmaddr, &ptl); -if (likely (ptep)) +if (likely (ptep)) {ptep_zap_unused (gmap->mm, vmaddr, ptep,0 ); -pte_unmap_unlock (ptep, ptl); +pte_unmap_unlock (ptep, ptl); + } } }EXPORT_SYMBOL_GPL (__gmap_zap);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 499/849 s390/mm: validate VMA in PGSTE manipulation functions
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
[ Upstream commit fe3d10024073f06f04c74b9674bd71ccc1d787cf ]
We should not walk/touch page tables outside of VMA boundaries when holding only the mmap sem in read mode. Evil user space can modify the VMA layout just before this function runs and e.g., trigger races with page table removal code since commit dd2283f2605e ("mm: mmap: zap pages with read mmap_sem in munmap"). gfn_to_hva() will only translate using KVM memory regions, but won't validate the VMA.
Further, we should not allocate page tables outside of VMA boundaries: if evil user space decides to map hugetlbfs to these ranges, bad things will happen because we suddenly have PTE or PMD page tables where we shouldn't have them.
Similarly, we have to check if we suddenly find a hugetlbfs VMA, before calling get_locked_pte().
--- arch/s390/mm/pgtable.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/s390/mm/pgtable.c +13 -0
@@ -988,6 +988,7 @@ EXPORT_SYMBOL(get_guest_storage_key);int pgste_perform_essa (struct mm_struct *mm,unsigned long hva,int orc,unsigned long *oldpte,unsigned long *oldpgste) { +struct vm_area_struct *vma;unsigned long pgstev;spinlock_t *ptl;pgste_t pgste;
@@ -997,6 +998,10 @@ int pgste_perform_essa(struct mm_struct *mm, unsigned long hva, int orc,WARN_ON_ONCE (orc >ESSA_MAX );if (unlikely (orc >ESSA_MAX ))return -EINVAL ; + + vma =vma_lookup (mm, hva); +if (!vma ||is_vm_hugetlb_page (vma)) +return -EFAULT ; ptep =get_locked_pte (mm, hva, &ptl);if (unlikely (!ptep))return -EFAULT ;
@@ -1089,10 +1094,14 @@ EXPORT_SYMBOL(pgste_perform_essa);int set_pgste_bits (struct mm_struct *mm,unsigned long hva,unsigned long bits,unsigned long value) { +struct vm_area_struct *vma;spinlock_t *ptl;pgste_t new;pte_t *ptep; + vma =vma_lookup (mm, hva); +if (!vma ||is_vm_hugetlb_page (vma)) +return -EFAULT ; ptep =get_locked_pte (mm, hva, &ptl);if (unlikely (!ptep))return -EFAULT ;
@@ -1117,9 +1126,13 @@ EXPORT_SYMBOL(set_pgste_bits);*/ int get_pgste (struct mm_struct *mm,unsigned long hva,unsigned long *pgstep) { +struct vm_area_struct *vma;spinlock_t *ptl;pte_t *ptep; + vma =vma_lookup (mm, hva); +if (!vma ||is_vm_hugetlb_page (vma)) +return -EFAULT ; ptep =get_locked_pte (mm, hva, &ptl);if (unlikely (!ptep))return -EFAULT ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 500/849 s390/mm: fix VMA and page table handling code in storage key handling functions
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
[ Upstream commit 949f5c1244ee6c36d2e81c588d1200eaa83a3df6 ]
There are multiple things broken about our storage key handling functions:
1. We should not walk/touch page tables outside of VMA boundaries when holding only the mmap sem in read mode. Evil user space can modify the VMA layout just before this function runs and e.g., trigger races with page table removal code since commit dd2283f2605e ("mm: mmap: zap pages with read mmap_sem in munmap"). gfn_to_hva() will only translate using KVM memory regions, but won't validate the VMA.
2. We should not allocate page tables outside of VMA boundaries: if evil user space decides to map hugetlbfs to these ranges, bad things will happen because we suddenly have PTE or PMD page tables where we shouldn't have them.
3. We don't handle large PUDs that might suddenly appeared inside our page table hierarchy.
Don't manually allocate page tables, properly validate that we have VMA and bail out on pud_large().
All callers of page table handling functions, except get_guest_storage_key(), call fixup_user_fault() in case they receive an -EFAULT and retry; this will allocate the necessary page tables if required.
To keep get_guest_storage_key() working as expected and not requiring kvm_s390_get_skeys() to call fixup_user_fault() distinguish between "there is simply no page table or huge page yet and the key is assumed to be 0" and "this is a fault to be reported".
Although commit 637ff9efe5ea ("s390/mm: Add huge pmd storage key handling") introduced most of the affected code, it was actually already broken before when using get_locked_pte() without any VMA checks.
Note: Ever since commit 637ff9efe5ea ("s390/mm: Add huge pmd storage key handling") we can no longer set a guest storage key (for example from QEMU during VM live migration) without actually resolving a fault. Although we would have created most page tables, we would choke on the !pmd_present(), requiring a call to fixup_user_fault(). I would have thought that this is problematic in combination with postcopy life migration ... but nobody noticed and this patch doesn't change the situation. So maybe it's just fine.
--- arch/s390/mm/pgtable.c | 57 +++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 18 deletions(-)
arch/s390/mm/pgtable.c +39 -18
@@ -429,22 +429,36 @@ static inline pmd_t pmdp_flush_lazy(struct mm_struct *mm, }#ifdef CONFIG_PGSTE -static pmd_t *pmd_alloc_map (struct mm_struct *mm,unsigned long addr) +static int pmd_lookup (struct mm_struct *mm,unsigned long addr,pmd_t **pmdp) { +struct vm_area_struct *vma;pgd_t *pgd;p4d_t *p4d;pud_t *pud; -pmd_t *pmd; + +/* We need a valid VMA, otherwise this is clearly a fault. */ + vma =vma_lookup (mm, addr); +if (!vma) +return -EFAULT ; pgd =pgd_offset (mm, addr); - p4d =p4d_alloc (mm, pgd, addr); -if (!p4d) -return NULL ; - pud =pud_alloc (mm, p4d, addr); -if (!pud) -return NULL ; - pmd =pmd_alloc (mm, pud, addr); -return pmd; +if (!pgd_present (*pgd)) +return -ENOENT ; + + p4d =p4d_offset (pgd, addr); +if (!p4d_present (*p4d)) +return -ENOENT ; + + pud =pud_offset (p4d, addr); +if (!pud_present (*pud)) +return -ENOENT ; + +/* Large PUDs are not supported yet. */ +if (pud_large (*pud)) +return -EFAULT ; + + *pmdp =pmd_offset (pud, addr); +return 0 ; }#endif
@@ -778,8 +792,7 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,pmd_t *pmdp;pte_t *ptep; - pmdp =pmd_alloc_map (mm, addr); -if (unlikely (!pmdp)) +if (pmd_lookup (mm, addr, &pmdp))return -EFAULT ; ptl =pmd_lock (mm, pmdp);
@@ -881,8 +894,7 @@ int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr)pte_t *ptep;int cc =0 ; - pmdp =pmd_alloc_map (mm, addr); -if (unlikely (!pmdp)) +if (pmd_lookup (mm, addr, &pmdp))return -EFAULT ; ptl =pmd_lock (mm, pmdp);
@@ -935,15 +947,24 @@ int get_guest_storage_key(struct mm_struct *mm, unsigned long addr,pmd_t *pmdp;pte_t *ptep; - pmdp =pmd_alloc_map (mm, addr); -if (unlikely (!pmdp)) +/* +* If we don't have a PTE table and if there is no huge page mapped, +* the storage key is 0. +*/ + *key =0 ; + +switch (pmd_lookup (mm, addr, &pmdp)) { +case -ENOENT : +return 0 ; +case 0 : +break ; +default :return -EFAULT ; + } ptl =pmd_lock (mm, pmdp);if (!pmd_present (*pmdp)) { -/* Not yet mapped memory has a zero key */ spin_unlock (ptl); - *key =0 ;return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 501/849 s390/uv: fully validate the VMA before calling follow_page()
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
[ Upstream commit 46c22ffd2772201662350bc7b94b9ea9d3ee5ac2 ]
We should not walk/touch page tables outside of VMA boundaries when holding only the mmap sem in read mode. Evil user space can modify the VMA layout just before this function runs and e.g., trigger races with page table removal code since commit dd2283f2605e ("mm: mmap: zap pages with read mmap_sem in munmap").
find_vma() does not check if the address is >= the VMA start address; use vma_lookup() instead.
--- arch/s390/kernel/uv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/uv.c +1 -1
@@ -227,7 +227,7 @@ again: uaddr =__gmap_translate (gmap, gaddr);if (IS_ERR_VALUE (uaddr)) goto out; - vma =find_vma (gmap->mm, uaddr); + vma =vma_lookup (gmap->mm, uaddr);if (!vma) goto out;/*
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 502/849 KVM: s390: pv: avoid double free of sida page
In reply to Greg Kroah-HartmanFrom: Claudio Imbrenda <[email protected]>
[ Upstream commit d4074324b07a94a1fca476d452dfbb3a4e7bf656 ]
If kvm_s390_pv_destroy_cpu is called more than once, we risk calling free_page on a random page, since the sidad field is aliased with the gbea, which is not guaranteed to be zero.
This can happen, for example, if userspace calls the KVM_PV_DISABLE IOCTL, and it fails, and then userspace calls the same IOCTL again. This scenario is only possible if KVM has some serious bug or if the hardware is broken.
The solution is to simply return successfully immediately if the vCPU was already non secure.
Message-Id: <[email protected]>
--- arch/s390/kvm/pv.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
arch/s390/kvm/pv.c +9 -10
@@ -16,18 +16,17 @@int kvm_s390_pv_destroy_cpu (struct kvm_vcpu *vcpu,u16 *rc,u16 *rrc) { -int cc =0 ; +int cc; -if (kvm_s390_pv_cpu_get_handle (vcpu)) { - cc =uv_cmd_nodata (kvm_s390_pv_cpu_get_handle (vcpu), -UVC_CMD_DESTROY_SEC_CPU , rc, rrc); +if (!kvm_s390_pv_cpu_get_handle (vcpu)) +return 0 ; + + cc =uv_cmd_nodata (kvm_s390_pv_cpu_get_handle (vcpu),UVC_CMD_DESTROY_SEC_CPU , rc, rrc); + +KVM_UV_EVENT (vcpu->kvm,3 ,"PROTVIRT DESTROY VCPU %d: rc %x rrc %x" , + vcpu->vcpu_id, *rc, *rrc); +WARN_ONCE (cc,"protvirt destroy cpu failed rc %x rrc %x" , *rc, *rrc); -KVM_UV_EVENT (vcpu->kvm,3 , -"PROTVIRT DESTROY VCPU %d: rc %x rrc %x" , - vcpu->vcpu_id, *rc, *rrc); -WARN_ONCE (cc,"protvirt destroy cpu failed rc %x rrc %x" , - *rc, *rrc); - }/* Intended memory leak for something that should never happen. */ if (!cc) free_pages(vcpu->arch.pv.stor_base,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 503/849 KVM: s390: pv: avoid stalls for kvm_s390_pv_init_vm
In reply to Greg Kroah-HartmanFrom: Claudio Imbrenda <[email protected]>
[ Upstream commit 1e2aa46de526a5adafe580bca4c25856bb06f09e ]
When the system is heavily overcommitted, kvm_s390_pv_init_vm might generate stall notifications.
Fix this by using uv_call_sched instead of just uv_call. This is ok because we are not holding spinlocks.
Message-Id: <[email protected]>
--- arch/s390/kvm/pv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/pv.c +1 -1
@@ -195,7 +195,7 @@ int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc) uvcb.conf_base_stor_origin = (u64 )kvm->arch.pv.stor_base; uvcb.conf_virt_stor_origin = (u64 )kvm->arch.pv.stor_var; - cc =uv_call (0 , (u64)&uvcb); + cc =uv_call_sched (0 , (u64)&uvcb); *rc = uvcb.header.rc; *rrc = uvcb.header.rrc; KVM_UV_EVENT(kvm, 3, "PROTVIRT CREATE VM: handle %llx len %llx rc %x rrc %x",
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 504/849 irq: mips: avoid nested irq_enter()
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
[ Upstream commit c65b52d02f6c1a06ddb20cba175ad49eccd6410d ]
As bcm6345_l1_irq_handle() is a chained irqchip handler, it will be invoked within the context of the root irqchip handler, which must have entered IRQ context already.
When bcm6345_l1_irq_handle() calls arch/mips's do_IRQ() , this will nest another call to irq_enter(), and the resulting nested increment to rcu_data.dynticks_nmi_nesting will cause rcu_is_cpu_rrupt_from_idle() to fail to identify wakeups from idle, resulting in failure to preempt, and RCU stalls.
Chained irqchip handlers must invoke IRQ handlers by way of thee core irqchip code, i.e. generic_handle_irq() or generic_handle_domain_irq() and should not call do_IRQ(), which is intended only for root irqchip handlers.
Fix bcm6345_l1_irq_handle() by calling generic_handle_irq() directly.
--- drivers/irqchip/irq-bcm6345-l1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-bcm6345-l1.c +1 -1
@@ -140,7 +140,7 @@ static void bcm6345_l1_irq_handle(struct irq_desc *desc)for_each_set_bit (hwirq, &pending,IRQS_PER_WORD ) { irq =irq_linear_revmap (intc->domain, base + hwirq);if (irq) -do_IRQ (irq); +generic_handle_irq (irq);else spurious_interrupt (); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 505/849 net: dsa: avoid refcount warnings when ->port_{fdb,mdb}_del returns error
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 232deb3f9567ce37d99b8616a6c07c1fc0436abf ]
At present, when either of ds->ops->port_fdb_del() or ds->ops->port_mdb_del() return a non-zero error code, we attempt to save the day and keep the data structure associated with that switchdev object, as the deletion procedure did not complete.
However, the way in which we do this is suspicious to the checker in lib/refcount.c, who thinks it is buggy to increment a refcount that became zero, and that this is indicative of a use-after-free.
--- net/dsa/switch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/dsa/switch.c +2 -2
@@ -243,7 +243,7 @@ static int dsa_switch_do_mdb_del(struct dsa_switch *ds, int port, err = ds->ops->port_mdb_del (ds, port, mdb);if (err) { -refcount_inc (&a->refcount); +refcount_set (&a->refcount,1 );return err; }
@@ -308,7 +308,7 @@ static int dsa_switch_do_fdb_del(struct dsa_switch *ds, int port, err = ds->ops->port_fdb_del (ds, port, addr, vid);if (err) { -refcount_inc (&a->refcount); +refcount_set (&a->refcount,1 );return err; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 506/849 ARM: 9142/1: kasan: work around LPAE build warning
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit c2e6df3eaaf120cde5e7c3a70590dd82e427458a ]
pgd_page_vaddr() returns an 'unsigned long' address, causing a warning with the memcpy() call in kasan_init():
arch/arm/mm/kasan_init.c: In function 'kasan_init':include/asm-generic/pgtable-nop4d.h:44:50: error: passing argument 2 of '__memcpy' makes pointer from integer without a cast [-Werror=int-conversion]
44 | #define pgd_page_vaddr(pgd) ((unsigned long)(p4d_pgtable((p4d_t){ pgd })))
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| long unsigned intarch/arm/include/asm/string.h:58:45: note: in definition of macro 'memcpy'
58 | #define memcpy(dst, src, len) __memcpy(dst, src, len)
| ^~~arch/arm/mm/kasan_init.c:229:16: note: in expansion of macro 'pgd_page_vaddr'
229 | pgd_page_vaddr(*pgd_offset_k(KASAN_SHADOW_START)),
| ^~~~~~~~~~~~~~
arch/arm/include/asm/string.h:21:47: note: expected 'const void *' but argument is of type 'long unsigned int'
21 | extern void *__memcpy(void *dest, const void *src, __kernel_size_t n);
| ~~~~~~~~~~~~^~~Avoid this by adding an explicit typecast.
--- arch/arm/mm/kasan_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mm/kasan_init.c +1 -1
@@ -226,7 +226,7 @@ void __init kasan_init(void)BUILD_BUG_ON (pgd_index (KASAN_SHADOW_START ) !=pgd_index (KASAN_SHADOW_END ));memcpy (tmp_pmd_table, -pgd_page_vaddr (*pgd_offset_k (KASAN_SHADOW_START )), + (void *)pgd_page_vaddr (*pgd_offset_k (KASAN_SHADOW_START )),sizeof (tmp_pmd_table));set_pgd (&tmp_pgd_table[pgd_index (KASAN_SHADOW_START )],__pgd (__pa (tmp_pmd_table) |PMD_TYPE_TABLE |L_PGD_SWAPPER ));
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 507/849 ath10k: fix module load regression with iram-recovery feature
In reply to Greg Kroah-HartmanFrom: Abinaya Kalaiselvan <[email protected]>
[ Upstream commit 6f8c8bf4c7c9be1c42088689fd4370e06b46608a ]
Commit 9af7c32ceca8 ("ath10k: add target IRAM recovery feature support") introduced a new firmware feature flag ATH10K_FW_FEATURE_IRAM_RECOVERY. But this caused ath10k_pci module load to fail if ATH10K_FW_CRASH_DUMP_RAM_DATA bit was not enabled in the ath10k coredump_mask module parameter:
[ 2209.328190] ath10k_pci 0000:02:00.0: qca9984/qca9994 hw1.0 target 0x01000000 chip_id 0x00000000 sub 168c:cafe [ 2209.434414] ath10k_pci 0000:02:00.0: kconfig debug 1 debugfs 1 tracing 1 dfs 1 testmode 1 [ 2209.547191] ath10k_pci 0000:02:00.0: firmware ver 10.4-3.9.0.2-00099 api 5 features no-p2p,mfp,peer-flow-ctrl,btcoex-param,allows-mesh-bcast,no-ps,peer-fixed-rate,iram-recovery crc32 cbade90a [ 2210.896485] ath10k_pci 0000:02:00.0: board_file api 1 bmi_id 0:1 crc32 a040efc2 [ 2213.603339] ath10k_pci 0000:02:00.0: failed to copy target iram contents: -12 [ 2213.839027] ath10k_pci 0000:02:00.0: could not init core (-12) [ 2213.933910] ath10k_pci 0000:02:00.0: could not probe fw (-12)
And by default coredump_mask does not have ATH10K_FW_CRASH_DUMP_RAM_DATA enabled so anyone using a firmware with iram-recovery feature would fail. To my knowledge only QCA9984 firmwares starting from release 10.4-3.9.0.2-00099 enabled the feature.
The reason for regression was that ath10k_core_copy_target_iram() used ath10k_coredump_get_mem_layout() to get the memory layout, but when ATH10K_FW_CRASH_DUMP_RAM_DATA was disabled it would get just NULL and bail out with an error.
While looking at all this I noticed another bug: if CONFIG_DEV_COREDUMP is disabled but the firmware has iram-recovery enabled the module load fails with similar error messages. I fixed that by returning 0 from ath10k_core_copy_target_iram() when _ath10k_coredump_get_mem_layout() returns NULL.
Tested-on: QCA9984 hw2.0 PCI 10.4-3.9.0.2-00139
--- drivers/net/wireless/ath/ath10k/core.c | 11 +++++++++-- drivers/net/wireless/ath/ath10k/coredump.c | 11 ++++++++--- drivers/net/wireless/ath/ath10k/coredump.h | 7 +++++++ 3 files changed, 24 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +9 -2
@@ -2690,9 +2690,16 @@ static int ath10k_core_copy_target_iram(struct ath10k *ar)int i, ret;u32 len, remaining_len; - hw_mem =ath10k_coredump_get_mem_layout (ar); +/* copy target iram feature must work also when +* ATH10K_FW_CRASH_DUMP_RAM_DATA is disabled, so +* _ath10k_coredump_get_mem_layout() to accomplist that +*/ + hw_mem =_ath10k_coredump_get_mem_layout (ar);if (!hw_mem) -return -ENOMEM ; +/* if CONFIG_DEV_COREDUMP is disabled we get NULL, then +* just silently disable the feature by doing nothing +*/ +return 0 ;for (i =0 ; i < hw_mem->region_table.size; i++) { tmp = &hw_mem->region_table.regions[i];
drivers/net/wireless/ath/ath10k/coredump.c +8 -3
@@ -1447,11 +1447,17 @@ static u32 ath10k_coredump_get_ramdump_size(struct ath10k *ar)const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout (struct ath10k *ar) { -int i; -if (!test_bit (ATH10K_FW_CRASH_DUMP_RAM_DATA , &ath10k_coredump_mask))return NULL ; +return _ath10k_coredump_get_mem_layout (ar); +} +EXPORT_SYMBOL (ath10k_coredump_get_mem_layout); + +const struct ath10k_hw_mem_layout *_ath10k_coredump_get_mem_layout (struct ath10k *ar) +{ +int i; +if (WARN_ON (ar->target_version ==0 ))return NULL ;
@@ -1464,7 +1470,6 @@ const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout(struct ath10kreturn NULL ; } -EXPORT_SYMBOL (ath10k_coredump_get_mem_layout);struct ath10k_fw_crash_data *ath10k_coredump_new (struct ath10k *ar) {
drivers/net/wireless/ath/ath10k/coredump.h +7 -0
@@ -176,6 +176,7 @@ int ath10k_coredump_register(struct ath10k *ar);void ath10k_coredump_unregister (struct ath10k *ar);void ath10k_coredump_destroy (struct ath10k *ar); +const struct ath10k_hw_mem_layout *_ath10k_coredump_get_mem_layout (struct ath10k *ar);const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout (struct ath10k *ar);#else /* CONFIG_DEV_COREDUMP */
@@ -214,6 +215,12 @@ ath10k_coredump_get_mem_layout(struct ath10k *ar)return NULL ; } +static inline const struct ath10k_hw_mem_layout * +_ath10k_coredump_get_mem_layout (struct ath10k *ar) +{ +return NULL ; +} +#endif /* CONFIG_DEV_COREDUMP */ #endif /* _COREDUMP_H_ */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 508/849 block: ataflop: more blk-mq refactoring fixes
In reply to Greg Kroah-HartmanFrom: Michael Schmitz <[email protected]>
[ Upstream commit d28e4dff085c5a87025c9a0a85fb798bd8e9ca17 ]
As it turns out, my earlier patch in commit 86d46fdaa12a (block:
ataflop: fix breakage introduced at blk-mq refactoring) was incomplete. This patch fixes any remaining issues found during more testing and code review.
Requests exceeding 4 k are handled in 4k segments but __blk_mq_end_request() is never called on these (still sectors outstanding on the request). With redo_fd_request() removed, there is no provision to kick off processing of the next segment, causing requests exceeding 4k to hang. (By setting /sys/block/fd0/queue/max_sectors_k <= 4 as workaround, this behaviour can be avoided).
Instead of reintroducing redo_fd_request(), requeue the remainder of the request by calling blk_mq_requeue_request() on incomplete requests (i.e. when blk_update_request() still returns true), and rely on the block layer to queue the residual as new request.
Both error handling and formatting needs to release the ST-DMA lock, so call finish_fdc() on these (this was previously handled by redo_fd_request()). finish_fdc() may be called legitimately without the ST-DMA lock held - make sure we only release the lock if we actually held it. In a similar way, early exit due to errors in ataflop_queue_rq() must release the lock.
After minor errors, fd_error sets up to recalibrate the drive but never re-runs the current operation (another task handled by redo_fd_request() before). Call do_fd_action() to get the next steps (seek, retry read/write) underway.
--- drivers/block/ataflop.c | 45 +++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-)
drivers/block/ataflop.c +39 -6
@@ -456,10 +456,20 @@ static DEFINE_TIMER(fd_timer, check_change);static void fd_end_request_cur (blk_status_t err) { +DPRINT (("fd_end_request_cur(), bytes %d of %d\n" , +blk_rq_cur_bytes (fd_request), +blk_rq_bytes (fd_request))); +if (!blk_update_request (fd_request, err,blk_rq_cur_bytes (fd_request))) { +DPRINT (("calling __blk_mq_end_request()\n" ));__blk_mq_end_request (fd_request, err); fd_request =NULL ; + }else { +/* requeue rest of request */ +DPRINT (("calling blk_mq_requeue_request()\n" )); +blk_mq_requeue_request (fd_request, true); + fd_request =NULL ; } }
@@ -697,12 +707,21 @@ static void fd_error( void )if (fd_request->error_count >=MAX_ERRORS ) {printk (KERN_ERR "fd%d: too many errors.\n" , SelectedDrive );fd_end_request_cur (BLK_STS_IOERR ); +finish_fdc (); +return ; }else if (fd_request->error_count ==RECALIBRATE_ERRORS ) {printk (KERN_WARNING "fd%d: recalibrating\n" , SelectedDrive );if (SelectedDrive !=-1 )SUD .track =-1 ; } +/* need to re-run request to recalibrate */ +atari_disable_irq (IRQ_MFP_FDC ); + +setup_req_params ( SelectedDrive ); +do_fd_action ( SelectedDrive ); + +atari_enable_irq (IRQ_MFP_FDC ); }
@@ -729,8 +748,10 @@ static int do_format(int drive, int type, struct atari_format_descr *desc)if (type) { type--;if (type >=NUM_DISK_MINORS || - minor2disktype[type].drive_types > DriveType) + minor2disktype[type].drive_types > DriveType) { +finish_fdc ();return -EINVAL ; + } } q = unit[drive].disk[type]->queue;
@@ -748,6 +769,7 @@ static int do_format(int drive, int type, struct atari_format_descr *desc) }if (!UDT || desc->track >=UDT ->blocks/UDT ->spt/2 || desc->head >=2 ) { +finish_fdc (); ret = -EINVAL ; goto out; }
@@ -788,6 +810,7 @@ static int do_format(int drive, int type, struct atari_format_descr *desc)wait_for_completion (&format_wait); +finish_fdc (); ret = FormatError ? -EIO :0 ; out:blk_mq_unquiesce_queue (q);
@@ -822,6 +845,7 @@ static void do_fd_action( int drive )else {/* all sectors finished */ fd_end_request_cur (BLK_STS_OK ); +finish_fdc ();return ; } }
@@ -1225,8 +1249,8 @@ static void fd_rwsec_done1(int status) }else {/* all sectors finished */ -finish_fdc ();fd_end_request_cur (BLK_STS_OK ); +finish_fdc (); }return ;
@@ -1348,7 +1372,7 @@ static void fd_times_out(struct timer_list *unused)static void finish_fdc (void ) { -if (!NeedSeek) { +if (!NeedSeek || !stdma_is_locked_by (floppy_irq)) {finish_fdc_done (0 ); }else {
@@ -1383,7 +1407,8 @@ static void finish_fdc_done( int dummy )start_motor_off_timer ();local_irq_save (flags); -stdma_release (); +if (stdma_is_locked_by (floppy_irq)) +stdma_release ();local_irq_restore (flags);DPRINT (("finish_fdc() finished\n" ));
@@ -1480,7 +1505,9 @@ static blk_status_t ataflop_queue_rq(struct blk_mq_hw_ctx *hctx,int drive = floppy - unit;int type = floppy->type; -DPRINT (("Queue request: drive %d type %d last %d\n" , drive, type, bd->last)); +DPRINT (("Queue request: drive %d type %d sectors %d of %d last %d\n" , + drive, type,blk_rq_cur_sectors (bd->rq), +blk_rq_sectors (bd->rq), bd->last));spin_lock_irq (&ataflop_lock);if (fd_request) {
@@ -1502,6 +1529,7 @@ static blk_status_t ataflop_queue_rq(struct blk_mq_hw_ctx *hctx,/* drive not connected */ printk (KERN_ERR "Unknown Device: fd%d\n" , drive );fd_end_request_cur (BLK_STS_IOERR ); +stdma_release (); goto out; }
@@ -1518,11 +1546,13 @@ static blk_status_t ataflop_queue_rq(struct blk_mq_hw_ctx *hctx,if (--type >=NUM_DISK_MINORS ) {printk (KERN_WARNING "fd%d: invalid disk format" , drive );fd_end_request_cur (BLK_STS_IOERR ); +stdma_release (); goto out; }if (minor2disktype[type].drive_types > DriveType) {printk (KERN_WARNING "fd%d: unsupported disk format" , drive );fd_end_request_cur (BLK_STS_IOERR ); +stdma_release (); goto out; } type = minor2disktype[type].index;
@@ -1623,6 +1653,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,/* what if type > 0 here? Overwrite specified entry ? */ if (type) {/* refuse to re-set a predefined type for now */ +finish_fdc ();return -EINVAL ; }
@@ -1690,8 +1721,10 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,/* sanity check */ if (setprm.track != dtp->blocks/dtp->spt/2 || - setprm.head !=2 ) + setprm.head !=2 ) { +finish_fdc ();return -EINVAL ; + }UDT = dtp;set_capacity (disk,UDT ->blocks);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 509/849 blk-cgroup: synchronize blkg creation against policy deactivation
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit 0c9d338c8443b06da8e8d3bfce824c5ea6d3488f ]
Our test reports a null pointer dereference:
[ 168.534653] ================================================================== [ 168.535614] Disabling lock debugging due to kernel taint [ 168.536346] BUG: kernel NULL pointer dereference, address: 0000000000000008 [ 168.537274] #PF: supervisor read access in kernel mode [ 168.537964] #PF: error_code(0x0000) - not-present page [ 168.538667] PGD 0 P4D 0 [ 168.539025] Oops: 0000 [#1] PREEMPT SMP KASAN [ 168.539656] CPU: 13 PID: 759 Comm: bash Tainted: G B 5.15.0-rc2-next-202100 [ 168.540954] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_0738364 [ 168.542736] RIP: 0010:bfq_pd_init+0x88/0x1e0 [ 168.543318] Code: 98 00 00 00 e8 c9 e4 5b ff 4c 8b 65 00 49 8d 7c 24 08 e8 bb e4 5b ff 4d0 [ 168.545803] RSP: 0018:ffff88817095f9c0 EFLAGS: 00010002 [ 168.546497] RAX: 0000000000000001 RBX: ffff888101a1c000 RCX: 0000000000000000 [ 168.547438] RDX: 0000000000000003 RSI: 0000000000000002 RDI: ffff888106553428 [ 168.548402] RBP: ffff888106553400 R08: ffffffff961bcaf4 R09: 0000000000000001 [ 168.549365] R10: ffffffffa2e16c27 R11: fffffbfff45c2d84 R12: 0000000000000000 [ 168.550291] R13: ffff888101a1c098 R14: ffff88810c7a08c8 R15: ffffffffa55541a0 [ 168.551221] FS: 00007fac75227700(0000) GS:ffff88839ba80000(0000) knlGS:0000000000000000 [ 168.552278] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 168.553040] CR2: 0000000000000008 CR3: 0000000165ce7000 CR4: 00000000000006e0 [ 168.554000] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 168.554929] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 168.555888] Call Trace: [ 168.556221] <TASK> [ 168.556510] blkg_create+0x1c0/0x8c0 [ 168.556989] blkg_conf_prep+0x574/0x650 [ 168.557502] ? stack_trace_save+0x99/0xd0 [ 168.558033] ? blkcg_conf_open_bdev+0x1b0/0x1b0 [ 168.558629] tg_set_conf.constprop.0+0xb9/0x280 [ 168.559231] ? kasan_set_track+0x29/0x40 [ 168.559758] ? kasan_set_free_info+0x30/0x60 [ 168.560344] ? tg_set_limit+0xae0/0xae0 [ 168.560853] ? do_sys_openat2+0x33b/0x640 [ 168.561383] ? do_sys_open+0xa2/0x100 [ 168.561877] ? __x64_sys_open+0x4e/0x60 [ 168.562383] ? __kasan_check_write+0x20/0x30 [ 168.562951] ? copyin+0x48/0x70 [ 168.563390] ? _copy_from_iter+0x234/0x9e0 [ 168.563948] tg_set_conf_u64+0x17/0x20 [ 168.564467] cgroup_file_write+0x1ad/0x380 [ 168.565014] ? cgroup_file_poll+0x80/0x80 [ 168.565568] ? __mutex_lock_slowpath+0x30/0x30 [ 168.566165] ? pgd_free+0x100/0x160 [ 168.566649] kernfs_fop_write_iter+0x21d/0x340 [ 168.567246] ? cgroup_file_poll+0x80/0x80 [ 168.567796] new_sync_write+0x29f/0x3c0 [ 168.568314] ? new_sync_read+0x410/0x410 [ 168.568840] ? __handle_mm_fault+0x1c97/0x2d80 [ 168.569425] ? copy_page_range+0x2b10/0x2b10 [ 168.570007] ? _raw_read_lock_bh+0xa0/0xa0 [ 168.570622] vfs_write+0x46e/0x630 [ 168.571091] ksys_write+0xcd/0x1e0 [ 168.571563] ? __x64_sys_read+0x60/0x60 [ 168.572081] ? __kasan_check_write+0x20/0x30 [ 168.572659] ? do_user_addr_fault+0x446/0xff0 [ 168.573264] __x64_sys_write+0x46/0x60 [ 168.573774] do_syscall_64+0x35/0x80 [ 168.574264] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 168.574960] RIP: 0033:0x7fac74915130 [ 168.575456] Code: 73 01 c3 48 8b 0d 58 ed 2c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 444 [ 168.577969] RSP: 002b:00007ffc3080e288 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 168.578986] RAX: ffffffffffffffda RBX: 0000000000000009 RCX: 00007fac74915130 [ 168.579937] RDX: 0000000000000009 RSI: 000056007669f080 RDI: 0000000000000001 [ 168.580884] RBP: 000056007669f080 R08: 000000000000000a R09: 00007fac75227700 [ 168.581841] R10: 000056007655c8f0 R11: 0000000000000246 R12: 0000000000000009 [ 168.582796] R13: 0000000000000001 R14: 00007fac74be55e0 R15: 00007fac74be08c0 [ 168.583757] </TASK> [ 168.584063] Modules linked in: [ 168.584494] CR2: 0000000000000008 [ 168.584964] ---[ end trace 2475611ad0f77a1a ]---
This is because blkg_alloc() is called from blkg_conf_prep() without holding 'q->queue_lock', and elevator is exited before blkg_create():
thread 1 thread 2blkg_conf_prep
spin_lock_irq(&q->queue_lock);
blkg_lookup_check -> return NULL
spin_unlock_irq(&q->queue_lock);
blkg_alloc
blkcg_policy_enabled -> true
pd = ->pd_alloc_fn
blkg->pd[i] = pd
blk_mq_exit_sched
bfq_exit_queue
blkcg_deactivate_policy
spin_lock_irq(&q->queue_lock);
__clear_bit(pol->plid, q->blkcg_pols);
spin_unlock_irq(&q->queue_lock);
q->elevator = NULL;
spin_lock_irq(&q->queue_lock);
blkg_create
if (blkg->pd[i])
->pd_init_fn -> q->elevator is NULL spin_unlock_irq(&q->queue_lock);
Because blkcg_deactivate_policy() requires queue to be frozen, we can grab q_usage_counter to synchoronize blkg_conf_prep() against blkcg_deactivate_policy().
--- block/blk-cgroup.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
block/blk-cgroup.c +10 -0
@@ -634,6 +634,14 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, q = bdev->bd_disk->queue; +/* +* blkcg_deactivate_policy() requires queue to be frozen, we can grab +* q_usage_counter to prevent concurrent with blkcg_deactivate_policy(). +*/ + ret =blk_queue_enter (q,0 ); +if (ret) +return ret; +rcu_read_lock ();spin_lock_irq (&q->queue_lock);
@@ -703,6 +711,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, goto success; } success: +blk_queue_exit (q); ctx->bdev = bdev; ctx->blkg = blkg; ctx->body = input;
@@ -715,6 +724,7 @@ fail_unlock:rcu_read_unlock (); fail:blkdev_put_no_open (bdev); +blk_queue_exit (q);/* * If queue was bypassing, we should retry. Do so after a * short msleep(). It isn't strictly necessary but queue
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 510/849 tpm: fix Atmel TPM crash caused by too frequent queries
In reply to Greg Kroah-HartmanFrom: Hao Wu <[email protected]>
[ Upstream commit 79ca6f74dae067681a779fd573c2eb59649989bc ]
The Atmel TPM 1.2 chips crash with error tpm_try_transmit: send(): error -62 since kernel 4.14. It is observed from the kernel log after running tpm_sealdata -z. The error thrown from the command is as follows
``` $ tpm_sealdata -z Tspi_Key_LoadKey failed: 0x00001087 - layer=tddl, code=0087 (135), I/O error ```
The issue was reproduced with the following Atmel TPM chip:
``` $ tpm_version T0 TPM 1.2 Version Info: Chip Version: 1.2.66.1 Spec Level: 2 Errata Revision: 3 TPM Vendor ID: ATML TPM Version: 01010000 Manufacturer Info: 41544d4c ```
The root cause of the issue is due to the TPM calls to msleep() were replaced with usleep_range() [1], which reduces the actual timeout. Via experiments, it is observed that the original msleep(5) actually sleeps for 15ms. Because of a known timeout issue in Atmel TPM 1.2 chip, the shorter timeout than 15ms can cause the error described above.
A few further changes in kernel 4.16 [2] and 4.18 [3, 4] further reduced the timeout to less than 1ms. With experiments, the problematic timeout in the latest kernel is the one for wait_for_tpm_stat.
To fix it, the patch reverts the timeout of wait_for_tpm_stat to 15ms for all Atmel TPM 1.2 chips, but leave it untouched for Ateml TPM 2.0 chip, and chips from other vendors.
As explained above, the chosen 15ms timeout is
the actual timeout before this issue introduced,
thus the old value is used here.
Particularly, TPM_ATML_TIMEOUT_WAIT_STAT_MIN is set to 14700us, TPM_ATML_TIMEOUT_WAIT_STAT_MIN is set to 15000us according to the existing TPM_TIMEOUT_RANGE_US (300us).
The fixed has been tested in the system with the affected Atmel chip with no issues observed after boot up.
[1] 9f3fc7bcddcb tpm: replace msleep() with usleep_range() in TPM 1.2/2.0 generic drivers
[2] cf151a9a44d5 tpm: reduce tpm polling delay in tpm_tis_core
[3] 59f5a6b07f64 tpm: reduce poll sleep time in tpm_transmit()
[4] 424eaf910c32 tpm: reduce polling time to usecs for even finer granularity
--- drivers/char/tpm/tpm_tis_core.c | 26 ++++++++++++++++++-------- drivers/char/tpm/tpm_tis_core.h | 4 ++++ include/linux/tpm.h | 1 + 3 files changed, 23 insertions(+), 8 deletions(-)
drivers/char/tpm/tpm_tis_core.c +18 -8
@@ -48,6 +48,7 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, wait_queue_head_t *queue, bool check_cancel) { + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);unsigned long stop;long rc;u8 status;
@@ -80,8 +81,8 @@ again: } }else { do { - usleep_range(TPM_TIMEOUT_USECS_MIN, - TPM_TIMEOUT_USECS_MAX); + usleep_range(priv->timeout_min, + priv->timeout_max); status = chip->ops->status(chip); if ((status & mask) == mask) return 0;
@@ -945,7 +946,22 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, chip->timeout_b =msecs_to_jiffies (TIS_TIMEOUT_B_MAX ); chip->timeout_c =msecs_to_jiffies (TIS_TIMEOUT_C_MAX ); chip->timeout_d =msecs_to_jiffies (TIS_TIMEOUT_D_MAX ); + priv->timeout_min =TPM_TIMEOUT_USECS_MIN ; + priv->timeout_max =TPM_TIMEOUT_USECS_MAX ; priv->phy_ops = phy_ops; + + rc =tpm_tis_read32 (priv,TPM_DID_VID (0 ), &vendor); +if (rc <0 ) + goto out_err; + + priv->manufacturer_id = vendor; + +if (priv->manufacturer_id ==TPM_VID_ATML && + !(chip->flags &TPM_CHIP_FLAG_TPM2 )) { + priv->timeout_min =TIS_TIMEOUT_MIN_ATML ; + priv->timeout_max =TIS_TIMEOUT_MAX_ATML ; + } +dev_set_drvdata (&chip->dev, priv);if (is_bsw ()) {
@@ -988,12 +1004,6 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,if (rc) goto out_err; - rc =tpm_tis_read32 (priv,TPM_DID_VID (0 ), &vendor); -if (rc <0 ) - goto out_err; - - priv->manufacturer_id = vendor; - rc =tpm_tis_read8 (priv,TPM_RID (0 ), &rid);if (rc <0 ) goto out_err;
drivers/char/tpm/tpm_tis_core.h +4 -0
@@ -54,6 +54,8 @@ enum tis_defaults {TIS_MEM_LEN =0x5000 ,TIS_SHORT_TIMEOUT =750 ,/* ms */ TIS_LONG_TIMEOUT =2000 ,/* 2 sec */ +TIS_TIMEOUT_MIN_ATML =14700 ,/* usecs */ + TIS_TIMEOUT_MAX_ATML = 15000, /* usecs */ };/* Some timeout values are needed before it is known whether the chip is
@@ -98,6 +100,8 @@ struct tpm_tis_data {wait_queue_head_t read_queue;const struct tpm_tis_phy_ops *phy_ops;unsigned short rng_quality; +unsigned int timeout_min;/* usecs */ +unsigned int timeout_max;/* usecs */ };struct tpm_tis_phy_ops {
include/linux/tpm.h +1 -0
@@ -269,6 +269,7 @@ enum tpm2_cc_attrs {#define TPM_VID_INTEL 0x8086#define TPM_VID_WINBOND 0x1050#define TPM_VID_STM 0x104A +#define TPM_VID_ATML 0x1114enum tpm_chip_flags {TPM_CHIP_FLAG_TPM2 =BIT (1 ),
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 511/849 tpm_tis_spi: Add missing SPI ID
In reply to Greg Kroah-HartmanFrom: Mark Brown <[email protected]>
[ Upstream commit 7eba41fe8c7bb01ff3d4b757bd622375792bc720 ]
In commit c46ed2281bbe ("tpm_tis_spi: add missing SPI device ID entries") we added SPI IDs for all the DT aliases to handle the fact that we always use SPI modaliases to load modules even when probed via DT however the mentioned commit missed that the SPI and OF device ID entries did not match and were different and so DT nodes with compatible "tcg,tpm_tis-spi" will not match. Add an extra ID for tpm_tis-spi rather than just fix the existing one since what's currently there is going to be better for anyone actually using SPI IDs to instantiate.
--- drivers/char/tpm/tpm_tis_spi_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/tpm/tpm_tis_spi_main.c +1 -0
@@ -267,6 +267,7 @@ static const struct spi_device_id tpm_tis_spi_id[] = { { "st33htpm-spi", (unsigned long)tpm_tis_spi_probe }, { "slb9670", (unsigned long)tpm_tis_spi_probe }, { "tpm_tis_spi", (unsigned long)tpm_tis_spi_probe }, + { "tpm_tis-spi", (unsigned long)tpm_tis_spi_probe }, { "cr50", (unsigned long)cr50_spi_probe }, {} };
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 512/849 libbpf: Fix endianness detection in BPF_CORE_READ_BITFIELD_PROBED()
In reply to Greg Kroah-HartmanFrom: Ilya Leoshkevich <[email protected]>
[ Upstream commit 45f2bebc8079788f62f22d9e8b2819afb1789d7b ]
__BYTE_ORDER is supposed to be defined by a libc, and __BYTE_ORDER__ - by a compiler. bpf_core_read.h checks __BYTE_ORDER == __LITTLE_ENDIAN, which is true if neither are defined, leading to incorrect behavior on big-endian hosts if libc headers are not included, which is often the case.
--- tools/lib/bpf/bpf_core_read.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/bpf_core_read.h +1 -1
@@ -40,7 +40,7 @@ enum bpf_enum_value_kind {#define __CORE_RELO (src, field, info) \ __builtin_preserve_field_info((src)->field, BPF_FIELD_##info) -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__#define __CORE_BITFIELD_PROBE_READ (dst, src, fld) \ bpf_probe_read_kernel( \ (void *)dst, \
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 513/849 tcp: dont free a FIN sk_buff in tcp_remove_empty_skb()
In reply to Greg Kroah-HartmanFrom: Jon Maxwell <[email protected]>
[ Upstream commit cf12e6f9124629b18a6182deefc0315f0a73a199 ]
v1: Implement a more general statement as recommended by Eric Dumazet. The sequence number will be advanced, so this check will fix the FIN case and other cases.
A customer reported sockets stuck in the CLOSING state. A Vmcore revealed that the write_queue was not empty as determined by tcp_write_queue_empty() but the sk_buff containing the FIN flag had been freed and the socket was zombied in that state. Corresponding pcaps show no FIN from the Linux kernel on the wire.
Some instrumentation was added to the kernel and it was found that there is a timing window where tcp_sendmsg() can run after tcp_send_fin().
tcp_sendmsg() will hit an error, for example:
1269 ▹ if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))↩
1270 ▹ ▹ goto do_error;↩
tcp_remove_empty_skb() will then free the FIN sk_buff as "skb->len == 0". The TCP socket is now wedged in the FIN-WAIT-1 state because the FIN is never sent.
If the other side sends a FIN packet the socket will transition to CLOSING and remain that way until the system is rebooted.
Fix this by checking for the FIN flag in the sk_buff and don't free it if that is the case. Testing confirmed that fixed the issue.
--- net/ipv4/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp.c +1 -1
@@ -955,7 +955,7 @@ int tcp_send_mss(struct sock *sk, int *size_goal, int flags)*/ void tcp_remove_empty_skb (struct sock *sk,struct sk_buff *skb) { -if (skb && !skb->len) { +if (skb &&TCP_SKB_CB (skb)->seq ==TCP_SKB_CB (skb)->end_seq) {tcp_unlink_write_queue (skb, sk);if (tcp_write_queue_empty (sk))tcp_chrono_stop (sk,TCP_CHRONO_BUSY );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 514/849 cpufreq: intel_pstate: Fix cpu->pstate.turbo_freq initialization
In reply to Greg Kroah-HartmanFrom: Zhang Rui <[email protected]>
[ Upstream commit c72bcf0ab87a92634e58af62e89af0f40dfd0b88 ]
Fix a problem in active mode that cpu->pstate.turbo_freq is initialized only if HWP-to-frequency scaling factor is refined.
In passive mode, this problem is not exposed, because cpu->pstate.turbo_freq is set again, later in intel_cpufreq_cpu_init()->intel_pstate_get_hwp_cap().
--- drivers/cpufreq/intel_pstate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/cpufreq/intel_pstate.c +2 -3
@@ -615,9 +615,8 @@ static void intel_pstate_hybrid_hwp_calibrate(struct cpudata *cpu)* the scaling factor is too high, so recompute it so that the HWP_CAP * highest performance corresponds to the maximum turbo frequency. */ -if (turbo_freq < cpu->pstate.turbo_pstate * scaling) { -pr_debug ("CPU%d: scaling too high (%d)\n" , cpu->cpu, scaling); - + cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * scaling; +if (turbo_freq < cpu->pstate.turbo_freq) { cpu->pstate.turbo_freq = turbo_freq; scaling =DIV_ROUND_UP (turbo_freq, cpu->pstate.turbo_pstate); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 515/849 spi: spi-rpc-if: Check return value of rpcif_sw_init()
In reply to Greg Kroah-HartmanFrom: Lad Prabhakar <[email protected]>
[ Upstream commit 0b0a281ed7001d4c4f4c47bdc84680c4997761ca ]
rpcif_sw_init() can fail so make sure we check the return value of it and on error exit rpcif_spi_probe() callback with error code.
--- drivers/spi/spi-rpc-if.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-rpc-if.c +3 -1
@@ -139,7 +139,9 @@ static int rpcif_spi_probe(struct platform_device *pdev)return -ENOMEM ; rpc =spi_controller_get_devdata (ctlr); -rpcif_sw_init (rpc, parent); + error =rpcif_sw_init (rpc, parent); +if (error) +return error;platform_set_drvdata (pdev, ctlr);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 516/849 sched: Add wrapper for get_wchan() to keep task blocked
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 42a20f86dc19f9282d974df0ba4d226c865ab9dd ]
Having a stable wchan means the process must be blocked and for it to stay that way while performing stack unwinding.
--- arch/alpha/include/asm/processor.h | 2 +- arch/alpha/kernel/process.c | 5 ++--- arch/arc/include/asm/processor.h | 2 +- arch/arc/kernel/stacktrace.c | 4 ++-- arch/arm/include/asm/processor.h | 2 +- arch/arm/kernel/process.c | 4 +--- arch/arm64/include/asm/processor.h | 2 +- arch/arm64/kernel/process.c | 4 +--- arch/csky/include/asm/processor.h | 2 +- arch/csky/kernel/stacktrace.c | 5 ++--- arch/h8300/include/asm/processor.h | 2 +- arch/h8300/kernel/process.c | 5 +---- arch/hexagon/include/asm/processor.h | 2 +- arch/hexagon/kernel/process.c | 4 +--- arch/ia64/include/asm/processor.h | 2 +- arch/ia64/kernel/process.c | 5 +---- arch/m68k/include/asm/processor.h | 2 +- arch/m68k/kernel/process.c | 4 +--- arch/microblaze/include/asm/processor.h | 2 +- arch/microblaze/kernel/process.c | 2 +- arch/mips/include/asm/processor.h | 2 +- arch/mips/kernel/process.c | 8 +++----- arch/nds32/include/asm/processor.h | 2 +- arch/nds32/kernel/process.c | 7 +------ arch/nios2/include/asm/processor.h | 2 +- arch/nios2/kernel/process.c | 5 +---- arch/openrisc/include/asm/processor.h | 2 +- arch/openrisc/kernel/process.c | 2 +- arch/parisc/include/asm/processor.h | 2 +- arch/parisc/kernel/process.c | 5 +---- arch/powerpc/include/asm/processor.h | 2 +- arch/powerpc/kernel/process.c | 9 +++------ arch/riscv/include/asm/processor.h | 2 +- arch/riscv/kernel/stacktrace.c | 12 +++++------- arch/s390/include/asm/processor.h | 2 +- arch/s390/kernel/process.c | 4 ++-- arch/sh/include/asm/processor_32.h | 2 +- arch/sh/kernel/process_32.c | 5 +---- arch/sparc/include/asm/processor_32.h | 2 +- arch/sparc/include/asm/processor_64.h | 2 +- arch/sparc/kernel/process_32.c | 5 +---- arch/sparc/kernel/process_64.c | 5 +---- arch/um/include/asm/processor-generic.h | 2 +- arch/um/kernel/process.c | 5 +---- arch/x86/include/asm/processor.h | 2 +- arch/x86/kernel/process.c | 5 +---- arch/xtensa/include/asm/processor.h | 2 +- arch/xtensa/kernel/process.c | 5 +---- include/linux/sched.h | 1 + kernel/sched/core.c | 19 +++++++++++++++++++ 50 files changed, 80 insertions(+), 112 deletions(-)
arch/alpha/include/asm/processor.h +1 -1
@@ -42,7 +42,7 @@ extern void start_thread(struct pt_regs *, unsigned long, unsigned long);struct task_struct ;extern void release_thread (struct task_struct *); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) (task_pt_regs(tsk)->pc)
arch/alpha/kernel/process.c +2 -3
@@ -376,12 +376,11 @@ thread_saved_pc(struct task_struct *t) }unsigned long -get_wchan (struct task_struct *p) +__get_wchan (struct task_struct *p) {unsigned long schedule_frame;unsigned long pc; -if (!p || p == current ||task_is_running (p)) -return 0 ; +/* * This one depends on the frame size of schedule(). Do a * "disass schedule" in gdb to find the frame size. Also, the
arch/arc/include/asm/processor.h +1 -1
@@ -70,7 +70,7 @@ struct task_struct;extern void start_thread (struct pt_regs * regs,unsigned long pc,unsigned long usp); -extern unsigned int get_wchan (struct task_struct *p); +extern unsigned int __get_wchan (struct task_struct *p);#endif /* !__ASSEMBLY__ */
arch/arc/kernel/stacktrace.c +2 -2
@@ -15,7 +15,7 @@* = specifics of data structs where trace is saved(CONFIG_STACKTRACE etc) * * vineetg: March 2009 -* -Implemented correct versions of thread_saved_pc() and get_wchan() +* -Implemented correct versions of thread_saved_pc() and __get_wchan() * * rajeshwarr: 2008 * -Initial implementation
@@ -248,7 +248,7 @@ void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)* Of course just returning schedule( ) would be pointless so unwind until * the function is not in schedular code */ -unsigned int get_wchan (struct task_struct *tsk) +unsigned int __get_wchan (struct task_struct *tsk) {return arc_unwind_core (tsk,NULL , __get_first_nonsched,NULL ); }
arch/arm/include/asm/processor.h +1 -1
@@ -84,7 +84,7 @@ struct task_struct;/* Free all resources held by a thread. */ extern void release_thread (struct task_struct *); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define task_pt_regs (p) \ ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
arch/arm/kernel/process.c +1 -3
@@ -283,13 +283,11 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,return 0 ; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {struct stackframe frame;unsigned long stack_page;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; frame.fp =thread_saved_fp (p); frame.sp =thread_saved_sp (p);
arch/arm64/include/asm/processor.h +1 -1
@@ -251,7 +251,7 @@ struct task_struct;/* Free all resources held by a thread. */ extern void release_thread (struct task_struct *); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);void set_task_sctlr_el1 (u64 sctlr);
arch/arm64/kernel/process.c +1 -3
@@ -544,13 +544,11 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,return last; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {struct stackframe frame;unsigned long stack_page, ret =0 ;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; stack_page = (unsigned long )try_get_task_stack (p);if (!stack_page)
arch/csky/include/asm/processor.h +1 -1
@@ -81,7 +81,7 @@ static inline void release_thread(struct task_struct *dead_task)extern int kernel_thread (int (*fn)(void *),void *arg,unsigned long flags); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) (task_pt_regs(tsk)->pc)#define KSTK_ESP (tsk) (task_pt_regs(tsk)->usp)
arch/csky/kernel/stacktrace.c +2 -3
@@ -111,12 +111,11 @@ static bool save_wchan(unsigned long pc, void *arg)return false; } -unsigned long get_wchan (struct task_struct *task) +unsigned long __get_wchan (struct task_struct *task) {unsigned long pc =0 ; -if (likely (task && task != current && !task_is_running (task))) -walk_stackframe (task,NULL , save_wchan, &pc); +walk_stackframe (task,NULL , save_wchan, &pc);return pc; }
arch/h8300/include/asm/processor.h +1 -1
@@ -105,7 +105,7 @@ static inline void release_thread(struct task_struct *dead_task) { } -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) \ ({ \
arch/h8300/kernel/process.c +1 -4
@@ -128,15 +128,12 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,return 0 ; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long fp, pc;unsigned long stack_page;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; - stack_page = (unsigned long )p; fp = ((struct pt_regs *)p->thread.ksp)->er6; do {
arch/hexagon/include/asm/processor.h +1 -1
@@ -64,7 +64,7 @@ struct thread_struct {extern void release_thread (struct task_struct *dead_task);/* Get wait channel for task P. */ -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);/* The following stuff is pretty HEXAGON specific. */
arch/hexagon/kernel/process.c +1 -3
@@ -130,13 +130,11 @@ void flush_thread(void)* is an identification of the point at which the scheduler * was invoked by a blocked thread. */ -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long fp, pc;unsigned long stack_page;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; stack_page = (unsigned long )task_stack_page (p); fp = ((struct hexagon_switch_stack *)p->thread.switch_sp)->fp;
arch/ia64/include/asm/processor.h +1 -1
@@ -330,7 +330,7 @@ struct task_struct;#define release_thread (dead_task)/* Get wait channel for task P. */ -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);/* Return instruction pointer of blocked task TSK. */ #define KSTK_EIP (tsk) \
arch/ia64/kernel/process.c +1 -4
@@ -523,15 +523,12 @@ exit_thread (struct task_struct *tsk) }unsigned long -get_wchan (struct task_struct *p) +__get_wchan (struct task_struct *p) {struct unw_frame_info info;unsigned long ip;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; -/* * Note: p may not be a blocked task (it could be current or * another process running on some other CPU. Rather than
arch/m68k/include/asm/processor.h +1 -1
@@ -125,7 +125,7 @@ static inline void release_thread(struct task_struct *dead_task) { } -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) \ ({ \
arch/m68k/kernel/process.c +1 -3
@@ -263,13 +263,11 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu) }EXPORT_SYMBOL (dump_fpu); -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long fp, pc;unsigned long stack_page;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; stack_page = (unsigned long )task_stack_page (p); fp = ((struct switch_stack *)p->thread.ksp)->a6;
arch/microblaze/include/asm/processor.h +1 -1
@@ -68,7 +68,7 @@ static inline void release_thread(struct task_struct *dead_task) { } -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);/* The size allocated for kernel stacks. This _must_ be a power of two! */ # define KERNEL_STACK_SIZE 0x2000
arch/microblaze/kernel/process.c +1 -1
@@ -112,7 +112,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,return 0 ; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {/* TBD (used by procfs) */ return 0 ;
arch/mips/include/asm/processor.h +1 -1
@@ -369,7 +369,7 @@ static inline void flush_thread(void) { } -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define __KSTK_TOS (tsk) ((unsigned long)task_stack_page(tsk) + \ THREAD_SIZE - 32 - sizeof(struct pt_regs))
arch/mips/kernel/process.c +3 -5
@@ -511,7 +511,7 @@ static int __init frame_info_init(void)/* * Without schedule() frame info, result given by -* thread_saved_pc() and get_wchan() are not reliable. +* thread_saved_pc() and __get_wchan() are not reliable. */ if (schedule_mfi.pc_offset <0 )printk ("Can't analyze schedule() prologue at %p\n" , schedule);
@@ -652,9 +652,9 @@ unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,#endif /* -* get_wchan - a maintenance nightmare^W^Wpain in the ass ... +* __get_wchan - a maintenance nightmare^W^Wpain in the ass ... */ -unsigned long get_wchan (struct task_struct *task) +unsigned long __get_wchan (struct task_struct *task) {unsigned long pc =0 ;#ifdef CONFIG_KALLSYMS
@@ -662,8 +662,6 @@ unsigned long get_wchan(struct task_struct *task)unsigned long ra =0 ;#endif -if (!task || task == current ||task_is_running (task)) - goto out;if (!task_stack_page (task)) goto out;
arch/nds32/include/asm/processor.h +1 -1
@@ -83,7 +83,7 @@ extern struct task_struct *last_task_used_math;/* Prepare to copy thread state - unlazy all lazy status */ #define prepare_to_copy (tsk) do { } while (0) -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define cpu_relax () barrier()
arch/nds32/kernel/process.c +1 -6
@@ -233,15 +233,12 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t * fpu)EXPORT_SYMBOL (dump_fpu); -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long fp, lr;unsigned long stack_start, stack_end;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; -if (IS_ENABLED (CONFIG_FRAME_POINTER )) { stack_start = (unsigned long )end_of_stack (p); stack_end = (unsigned long )task_stack_page (p) +THREAD_SIZE ;
@@ -258,5 +255,3 @@ unsigned long get_wchan(struct task_struct *p) }return 0 ; } - -EXPORT_SYMBOL (get_wchan);
arch/nios2/include/asm/processor.h +1 -1
@@ -69,7 +69,7 @@ static inline void release_thread(struct task_struct *dead_task) { } -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);#define task_pt_regs (p) \ ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
arch/nios2/kernel/process.c +1 -4
@@ -217,15 +217,12 @@ void dump(struct pt_regs *fp)pr_emerg ("\n\n" ); } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long fp, pc;unsigned long stack_page;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; - stack_page = (unsigned long )p; fp = ((struct switch_stack *)p->thread.ksp)->fp;/* ;dgt2 */ do {
arch/openrisc/include/asm/processor.h +1 -1
@@ -73,7 +73,7 @@ struct thread_struct {void start_thread (struct pt_regs *regs,unsigned long nip,unsigned long sp);void release_thread (struct task_struct *); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define cpu_relax () barrier()
arch/openrisc/kernel/process.c +1 -1
@@ -265,7 +265,7 @@ void dump_elf_thread(elf_greg_t *dest, struct pt_regs* regs) dest[35 ] =0 ; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {/* TODO */
arch/parisc/include/asm/processor.h +1 -1
@@ -277,7 +277,7 @@ struct mm_struct;/* Free all resources held by a thread. */ extern void release_thread (struct task_struct *); -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) ((tsk)->thread.regs.iaoq[0])#define KSTK_ESP (tsk) ((tsk)->thread.regs.gr[30])
arch/parisc/kernel/process.c +1 -4
@@ -243,15 +243,12 @@ copy_thread(unsigned long clone_flags, unsigned long usp, }unsigned long -get_wchan (struct task_struct *p) +__get_wchan (struct task_struct *p) {struct unwind_frame_info info;unsigned long ip;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; -/* * These bracket the sleeping functions.. */
arch/powerpc/include/asm/processor.h +1 -1
@@ -300,7 +300,7 @@ struct thread_struct {#define task_pt_regs (tsk) ((tsk)->thread.regs) -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)#define KSTK_ESP (tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
arch/powerpc/kernel/process.c +3 -6
@@ -2111,14 +2111,11 @@ int validate_sp(unsigned long sp, struct task_struct *p,EXPORT_SYMBOL (validate_sp); -static unsigned long __get_wchan (struct task_struct *p) +static unsigned long ___get_wchan (struct task_struct *p) {unsigned long ip, sp;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; - sp = p->thread.ksp;if (!validate_sp (sp, p,STACK_FRAME_OVERHEAD ))return 0 ;
@@ -2137,14 +2134,14 @@ static unsigned long __get_wchan(struct task_struct *p)return 0 ; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long ret;if (!try_get_task_stack (p))return 0 ; - ret =__get_wchan (p); + ret =___get_wchan (p);put_task_stack (p);
arch/riscv/include/asm/processor.h +1 -1
@@ -58,7 +58,7 @@ static inline void release_thread(struct task_struct *dead_task) { } -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);static inline void wait_for_interrupt (void )
arch/riscv/kernel/stacktrace.c +5 -7
@@ -128,16 +128,14 @@ static bool save_wchan(void *arg, unsigned long pc)return true; } -unsigned long get_wchan (struct task_struct *task) +unsigned long __get_wchan (struct task_struct *task) {unsigned long pc =0 ; -if (likely (task && task != current && !task_is_running (task))) { -if (!try_get_task_stack (task)) -return 0 ; -walk_stackframe (task,NULL , save_wchan, &pc); -put_task_stack (task); - } +if (!try_get_task_stack (task)) +return 0 ; +walk_stackframe (task,NULL , save_wchan, &pc); +put_task_stack (task);return pc; }
arch/s390/include/asm/processor.h +1 -1
@@ -192,7 +192,7 @@ static inline void release_thread(struct task_struct *tsk) { }void guarded_storage_release (struct task_struct *tsk);void gs_load_bc_cb (struct pt_regs *regs); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define task_pt_regs (tsk) ((struct pt_regs *) \ (task_stack_page(tsk) + THREAD_SIZE) - 1)#define KSTK_EIP (tsk) (task_pt_regs(tsk)->psw.addr)
arch/s390/kernel/process.c +2 -2
@@ -181,12 +181,12 @@ void execve_tail(void) asmvolatile ("sfpc %0" : :"d" (0 )); } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {struct unwind_state state;unsigned long ip =0 ; -if (!p || p == current ||task_is_running (p) || !task_stack_page (p)) +if (!task_stack_page (p))return 0 ;if (!try_get_task_stack (p))
arch/sh/include/asm/processor_32.h +1 -1
@@ -180,7 +180,7 @@ static inline void show_code(struct pt_regs *regs) }#endif -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) (task_pt_regs(tsk)->pc)#define KSTK_ESP (tsk) (task_pt_regs(tsk)->regs[15])
arch/sh/kernel/process_32.c +1 -4
@@ -182,13 +182,10 @@ __switch_to(struct task_struct *prev, struct task_struct *next)return prev; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long pc; -if (!p || p == current ||task_is_running (p)) -return 0 ; -/* * The same comment as on the Alpha applies here, too ... */
arch/sparc/include/asm/processor_32.h +1 -1
@@ -89,7 +89,7 @@ static inline void start_thread(struct pt_regs * regs, unsigned long pc,/* Free all resources held by a thread. */ #define release_thread (tsk) do { } while(0) -unsigned long get_wchan (struct task_struct *); +unsigned long __get_wchan (struct task_struct *);#define task_pt_regs (tsk) ((tsk)->thread.kregs)#define KSTK_EIP (tsk) ((tsk)->thread.kregs->pc)
arch/sparc/include/asm/processor_64.h +1 -1
@@ -183,7 +183,7 @@ do { \/* Free all resources held by a thread. */ #define release_thread (tsk) do { } while (0) -unsigned long get_wchan (struct task_struct *task); +unsigned long __get_wchan (struct task_struct *task);#define task_pt_regs (tsk) (task_thread_info(tsk)->kregs)#define KSTK_EIP (tsk) (task_pt_regs(tsk)->tpc)
arch/sparc/kernel/process_32.c +1 -4
@@ -368,7 +368,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, unsigned long arg,return 0 ; } -unsigned long get_wchan (struct task_struct *task) +unsigned long __get_wchan (struct task_struct *task) {unsigned long pc, fp, bias =0 ;unsigned long task_base = (unsigned long ) task;
@@ -376,9 +376,6 @@ unsigned long get_wchan(struct task_struct *task)struct reg_window32 *rw;int count =0 ; -if (!task || task == current ||task_is_running (task)) - goto out; - fp =task_thread_info (task)->ksp + bias; do { /* Bogus frame pointer? */
arch/sparc/kernel/process_64.c +1 -4
@@ -666,7 +666,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)return 0 ; } -unsigned long get_wchan (struct task_struct *task) +unsigned long __get_wchan (struct task_struct *task) {unsigned long pc, fp, bias =0 ;struct thread_info *tp;
@@ -674,9 +674,6 @@ unsigned long get_wchan(struct task_struct *task)unsigned long ret =0 ;int count =0 ; -if (!task || task == current ||task_is_running (task)) - goto out; - tp =task_thread_info (task); bias =STACK_BIAS ; fp =task_thread_info (task)->ksp + bias;
arch/um/include/asm/processor-generic.h +1 -1
@@ -106,6 +106,6 @@ extern struct cpuinfo_um boot_cpu_data;#define cache_line_size () (boot_cpu_data.cache_alignment)#define KSTK_REG (tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf) -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);#endif
arch/um/kernel/process.c +1 -4
@@ -364,14 +364,11 @@ unsigned long arch_align_stack(unsigned long sp) }#endif -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long stack_page, sp, ip;bool seen_sched =0 ; -if ((p ==NULL ) || (p == current) ||task_is_running (p)) -return 0 ; - stack_page = (unsigned long )task_stack_page (p);/* Bail if the process has no kernel stack for some reason */ if (stack_page ==0 )
arch/x86/include/asm/processor.h +1 -1
@@ -588,7 +588,7 @@ static inline void load_sp0(unsigned long sp0)/* Free all resources held by a thread. */ extern void release_thread (struct task_struct *); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);/* * Generic CPUID function
arch/x86/kernel/process.c +1 -4
@@ -943,13 +943,10 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)* because the task might wake up and we might look at a stack * changing under us. */ -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long entry =0 ; -if (p == current ||task_is_running (p)) -return 0 ; -stack_trace_save_tsk (p, &entry,1 ,0 );return entry; }
arch/xtensa/include/asm/processor.h +1 -1
@@ -215,7 +215,7 @@ struct mm_struct;/* Free all resources held by a thread. */ #define release_thread (thread) do { } while(0) -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) (task_pt_regs(tsk)->pc)#define KSTK_ESP (tsk) (task_pt_regs(tsk)->areg[1])
arch/xtensa/kernel/process.c +1 -4
@@ -298,15 +298,12 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn,* These bracket the sleeping functions.. */ -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long sp, pc;unsigned long stack_page = (unsigned long )task_stack_page (p);int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; - sp = p->thread.sp; pc =MAKE_PC_FROM_RA (p->thread.ra, p->thread.sp);
include/linux/sched.h +1 -0
@@ -2030,6 +2030,7 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)#endif /* CONFIG_SMP */ extern bool sched_task_on_rq (struct task_struct *p); +extern unsigned long get_wchan (struct task_struct *p);/* * In order to reduce various lock holder preemption latencies provide an
kernel/sched/core.c +19 -0
@@ -1960,6 +1960,25 @@ bool sched_task_on_rq(struct task_struct *p)return task_on_rq_queued (p); } +unsigned long get_wchan (struct task_struct *p) +{ +unsigned long ip =0 ; +unsigned int state; + +if (!p || p == current) +return 0 ; + +/* Only get wchan if task is blocked and we can keep it that way. */ +raw_spin_lock_irq (&p->pi_lock); + state =READ_ONCE (p->__state); +smp_rmb ();/* see try_to_wake_up() */ +if (state !=TASK_RUNNING && state !=TASK_WAKING && !p->on_rq) + ip =__get_wchan (p); +raw_spin_unlock_irq (&p->pi_lock); + +return ip; +} +static inline void enqueue_task (struct rq *rq,struct task_struct *p,int flags) {if (!(flags &ENQUEUE_NOCLOCK ))
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 517/849 x86: Fix __get_wchan() for !STACKTRACE
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 5d1ceb3969b6b2e47e2df6d17790a7c5a20fcbb4 ]
Use asm/unwind.h to implement wchan, since we cannot always rely on STACKTRACE=y.
--- arch/x86/kernel/process.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
arch/x86/kernel/process.c +14 -3
@@ -43,6 +43,7 @@#include <asm/io_bitmap.h> #include <asm/proto.h> #include <asm/frame.h> +#include <asm/unwind.h> #include "process.h"
@@ -945,10 +946,20 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)*/ unsigned long __get_wchan (struct task_struct *p) { -unsigned long entry =0 ; +struct unwind_state state; +unsigned long addr =0 ; -stack_trace_save_tsk (p, &entry,1 ,0 ); -return entry; +for (unwind_start (&state, p,NULL ,NULL ); !unwind_done (&state); +unwind_next_frame (&state)) { + addr =unwind_get_return_address (&state); +if (!addr) +break ; +if (in_sched_functions (addr)) +continue ; +break ; + } + +return addr; } long do_arch_prctl_common(struct task_struct *task, int option,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 518/849 samples/kretprobes: Fix return value if register_kretprobe() failed
In reply to Greg Kroah-HartmanFrom: Tiezhu Yang <[email protected]>
[ Upstream commit f76fbbbb5061fe14824ba5807c44bd7400a6b4e1 ]
Use the actual return value instead of always -1 if register_kretprobe() failed.
E.g. without this patch:
# insmod samples/kprobes/kretprobe_example.ko func=no_such_func insmod: ERROR: could not insert module samples/kprobes/kretprobe_example.ko: Operation not permitted
With this patch:
# insmod samples/kprobes/kretprobe_example.ko func=no_such_func insmod: ERROR: could not insert module samples/kprobes/kretprobe_example.ko: Unknown symbol in module
--- samples/kprobes/kretprobe_example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/kprobes/kretprobe_example.c +1 -1
@@ -86,7 +86,7 @@ static int __init kretprobe_init(void) ret =register_kretprobe (&my_kretprobe);if (ret <0 ) {pr_err ("register_kretprobe failed, returned %d\n" , ret); -return -1 ; +return ret; }pr_info ("Planted return probe at %s: %p\n" , my_kretprobe.kp.symbol_name, my_kretprobe.kp.addr);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 519/849 KVM: s390: Fix handle_sske page fault handling
In reply to Greg Kroah-HartmanFrom: Janis Schoetterl-Glausch <[email protected]>
[ Upstream commit 85f517b29418158d3e6e90c3f0fc01b306d2f1a1 ]
If handle_sske cannot set the storage key, because there is no page table entry or no present large page entry, it calls fixup_user_fault.
However, currently, if the call succeeds, handle_sske returns -EAGAIN, without having set the storage key.
Instead, retry by continue'ing the loop without incrementing the address.
The same issue in handle_pfmf was fixed bya11bdb1a6b78 ("KVM: s390: Fix pfmf and conditional skey emulation").
--- arch/s390/kvm/priv.c | 2 ++ 1 file changed, 2 insertions(+)
arch/s390/kvm/priv.c +2 -0
@@ -397,6 +397,8 @@ static int handle_sske(struct kvm_vcpu *vcpu)mmap_read_unlock (current->mm);if (rc == -EFAULT )return kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING ); +if (rc == -EAGAIN ) +continue ;if (rc <0 )return rc; start +=PAGE_SIZE ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 520/849 libertas_tf: Fix possible memory leak in probe and disconnect
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit d549107305b4634c81223a853701c06bcf657bc3 ]
I got memory leak as follows when doing fault injection test:
unreferenced object 0xffff88810a2ddc00 (size 512):
comm "kworker/6:1", pid 176, jiffies 4295009893 (age 757.220s) hex dump (first 32 bytes):
00 50 05 18 81 88 ff ff 00 00 00 00 00 00 00 00 .P..............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8167939c>] slab_post_alloc_hook+0x9c/0x490
[<ffffffff8167f627>] kmem_cache_alloc_trace+0x1f7/0x470
[<ffffffffa02a1530>] if_usb_probe+0x60/0x37c [libertas_tf_usb]
[<ffffffffa022668a>] usb_probe_interface+0x1aa/0x3c0 [usbcore]
[<ffffffff82b59630>] really_probe+0x190/0x480
[<ffffffff82b59a19>] __driver_probe_device+0xf9/0x180
[<ffffffff82b59af3>] driver_probe_device+0x53/0x130
[<ffffffff82b5a075>] __device_attach_driver+0x105/0x130
[<ffffffff82b55949>] bus_for_each_drv+0x129/0x190
[<ffffffff82b593c9>] __device_attach+0x1c9/0x270
[<ffffffff82b5a250>] device_initial_probe+0x20/0x30
[<ffffffff82b579c2>] bus_probe_device+0x142/0x160
[<ffffffff82b52e49>] device_add+0x829/0x1300
[<ffffffffa02229b1>] usb_set_configuration+0xb01/0xcc0 [usbcore]
[<ffffffffa0235c4e>] usb_generic_driver_probe+0x6e/0x90 [usbcore]
[<ffffffffa022641f>] usb_probe_device+0x6f/0x130 [usbcore]cardp is missing being freed in the error handling path of the probe and the path of the disconnect, which will cause memory leak.
This patch adds the missing kfree().
--- drivers/net/wireless/marvell/libertas_tf/if_usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/marvell/libertas_tf/if_usb.c +2 -0
@@ -230,6 +230,7 @@ static int if_usb_probe(struct usb_interface *intf, dealloc:if_usb_free (cardp); +kfree (cardp); error:lbtf_deb_leave (LBTF_DEB_MAIN );return -ENOMEM ;
@@ -254,6 +255,7 @@ static void if_usb_disconnect(struct usb_interface *intf)/* Unlink and free urb */ if_usb_free (cardp); +kfree (cardp);usb_set_intfdata (intf,NULL );usb_put_dev (interface_to_usbdev (intf));
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 521/849 libertas: Fix possible memory leak in probe and disconnect
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit 9692151e2fe7a326bafe99836fd1f20a2cc3a049 ]
I got memory leak as follows when doing fault injection test:
unreferenced object 0xffff88812c7d7400 (size 512):
comm "kworker/6:1", pid 176, jiffies 4295003332 (age 822.830s) hex dump (first 32 bytes):
00 68 1e 04 81 88 ff ff 01 00 00 00 00 00 00 00 .h..............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8167939c>] slab_post_alloc_hook+0x9c/0x490
[<ffffffff8167f627>] kmem_cache_alloc_trace+0x1f7/0x470
[<ffffffffa02c9873>] if_usb_probe+0x63/0x446 [usb8xxx]
[<ffffffffa022668a>] usb_probe_interface+0x1aa/0x3c0 [usbcore]
[<ffffffff82b59630>] really_probe+0x190/0x480
[<ffffffff82b59a19>] __driver_probe_device+0xf9/0x180
[<ffffffff82b59af3>] driver_probe_device+0x53/0x130
[<ffffffff82b5a075>] __device_attach_driver+0x105/0x130
[<ffffffff82b55949>] bus_for_each_drv+0x129/0x190
[<ffffffff82b593c9>] __device_attach+0x1c9/0x270
[<ffffffff82b5a250>] device_initial_probe+0x20/0x30
[<ffffffff82b579c2>] bus_probe_device+0x142/0x160
[<ffffffff82b52e49>] device_add+0x829/0x1300
[<ffffffffa02229b1>] usb_set_configuration+0xb01/0xcc0 [usbcore]
[<ffffffffa0235c4e>] usb_generic_driver_probe+0x6e/0x90 [usbcore]
[<ffffffffa022641f>] usb_probe_device+0x6f/0x130 [usbcore]cardp is missing being freed in the error handling path of the probe and the path of the disconnect, which will cause memory leak.
This patch adds the missing kfree().
--- drivers/net/wireless/marvell/libertas/if_usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/marvell/libertas/if_usb.c +2 -0
@@ -292,6 +292,7 @@ err_add_card:if_usb_reset_device (cardp); dealloc:if_usb_free (cardp); +kfree (cardp); error:return r;
@@ -316,6 +317,7 @@ static void if_usb_disconnect(struct usb_interface *intf)/* Unlink and free urb */ if_usb_free (cardp); +kfree (cardp);usb_set_intfdata (intf,NULL );usb_put_dev (interface_to_usbdev (intf));
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 522/849 wcn36xx: add proper DMA memory barriers in rx path
In reply to Greg Kroah-HartmanFrom: Benjamin Li <[email protected]>
[ Upstream commit 9bfe38e064af5decba2ffce66a2958ab8b10eaa4 ]
This is essentially exactly following the dma_wmb()/dma_rmb() usage instructions in Documentation/memory-barriers.txt.
The theoretical races here are:
1. DXE (the DMA Transfer Engine in the Wi-Fi subsystem) seeing the dxe->ctrl & WCN36xx_DXE_CTRL_VLD write before the dxe->dst_addr_l write, thus performing DMA into the wrong address.
2. CPU reading dxe->dst_addr_l before DXE unsets dxe->ctrl & WCN36xx_DXE_CTRL_VLD. This should generally be harmless since DXE doesn't write dxe->dst_addr_l (no risk of freeing the wrong skb).
--- drivers/net/wireless/ath/wcn36xx/dxe.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/dxe.c +11 -1
@@ -606,6 +606,10 @@ static int wcn36xx_rx_handle_packets(struct wcn36xx *wcn, dxe = ctl->desc;while (!(READ_ONCE (dxe->ctrl) & WCN36xx_DXE_CTRL_VLD)) { +/* do not read until we own DMA descriptor */ +dma_rmb (); + +/* read/modify DMA descriptor */ skb = ctl->skb; dma_addr = dxe->dst_addr_l; ret =wcn36xx_dxe_fill_skb (wcn->dev, ctl,GFP_ATOMIC );
@@ -616,9 +620,15 @@ static int wcn36xx_rx_handle_packets(struct wcn36xx *wcn,dma_unmap_single (wcn->dev, dma_addr,WCN36XX_PKT_SIZE ,DMA_FROM_DEVICE );wcn36xx_rx_skb (wcn, skb); - }/* else keep old skb not submitted and use it for rx DMA */ + } +/* else keep old skb not submitted and reuse it for rx DMA +* (dropping the packet that it contained) +*/ +/* flush descriptor changes before re-marking as valid */ +dma_wmb (); dxe->ctrl = ctrl; + ctl = ctl->next; dxe = ctl->desc; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 523/849 wcn36xx: Fix discarded frames due to wrong sequence number
In reply to Greg Kroah-HartmanFrom: Loic Poulain <[email protected]>
[ Upstream commit 113f304dbc1627c6ec9d5329d839964095768980 ]
The firmware is offering features such as ARP offload, for which firmware crafts its own (QoS)packets without waking up the host. Point is that the sequence numbers generated by the firmware are not in sync with the host mac80211 layer and can cause packets such as firmware ARP reponses to be dropped by the AP (too old SN).
To fix this we need to let the firmware manages the sequence numbers by its own (except for QoS null frames). There is a SN counter for each QoS queue and one global/baseline counter for Non-QoS.
--- drivers/net/wireless/ath/wcn36xx/txrx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/wcn36xx/txrx.c +7 -2
@@ -344,8 +344,6 @@ static void wcn36xx_set_tx_pdu(struct wcn36xx_tx_bd *bd, bd->pdu.mpdu_header_off; bd->pdu.mpdu_len = len; bd->pdu.tid = tid; -/* Use seq number generated by mac80211 */ - bd->pdu.bd_ssn =WCN36XX_TXBD_SSN_FILL_HOST ; } static inline struct wcn36xx_vif *get_vif_by_addr(struct wcn36xx *wcn,
@@ -442,6 +440,9 @@ static void wcn36xx_set_tx_data(struct wcn36xx_tx_bd *bd, tid =ieee80211_get_tid (hdr);/* TID->QID is one-to-one mapping */ bd->queue_id = tid; + bd->pdu.bd_ssn =WCN36XX_TXBD_SSN_FILL_DPU_QOS ; + }else { + bd->pdu.bd_ssn =WCN36XX_TXBD_SSN_FILL_DPU_NON_QOS ; } if (info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT ||
@@ -453,6 +454,8 @@ static void wcn36xx_set_tx_data(struct wcn36xx_tx_bd *bd,/* Don't use a regular queue for null packet (no ampdu) */ bd->queue_id =WCN36XX_TX_U_WQ_ID ; bd->bd_rate =WCN36XX_BD_RATE_CTRL ; +if (ieee80211_is_qos_nullfunc (hdr->frame_control)) + bd->pdu.bd_ssn =WCN36XX_TXBD_SSN_FILL_HOST ; }if (bcast) {
@@ -512,6 +515,8 @@ static void wcn36xx_set_tx_mgmt(struct wcn36xx_tx_bd *bd, bd->queue_id =WCN36XX_TX_U_WQ_ID ; *vif_priv = __vif_priv; + bd->pdu.bd_ssn =WCN36XX_TXBD_SSN_FILL_DPU_NON_QOS ; + wcn36xx_set_tx_pdu(bd, ieee80211_is_data_qos(hdr->frame_control) ? sizeof(struct ieee80211_qos_hdr) :
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 524/849 bpf: Fixes possible race in update_prog_stats() for 32bit arches
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit d979617aa84d96acca44c2f5778892b4565e322f ]
It seems update_prog_stats() suffers from same issue fixed in the prior patch:
As it can run while interrupts are enabled, it could be re-entered and the u64_stats syncp could be mangled.
--- kernel/bpf/trampoline.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/bpf/trampoline.c +4 -2
@@ -579,11 +579,13 @@ static void notrace update_prog_stats(struct bpf_prog *prog,* Hence check that 'start' is valid. */ start > NO_START_TIME) { +unsigned long flags; + stats =this_cpu_ptr (prog->stats); -u64_stats_update_begin (&stats->syncp); + flags =u64_stats_update_begin_irqsave (&stats->syncp); stats->cnt++; stats->nsecs +=sched_clock () - start; -u64_stats_update_end (&stats->syncp); +u64_stats_update_end_irqrestore (&stats->syncp, flags); } }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 525/849 wcn36xx: Channel list update before hardware scan
In reply to Greg Kroah-HartmanFrom: Loic Poulain <[email protected]>
[ Upstream commit d707f812bb0513ea0030d0c9fe2a456bae5a4583 ]
The channel scan list must be updated before triggering a hardware scan so that firmware takes into account the regulatory info for each single channel such as active/passive config, power, DFS, etc... Without this the firmware uses its own internal default channel configuration, which is not aligned with mac80211 regulatory rules, and misses several channels (e.g. 144).
--- drivers/net/wireless/ath/wcn36xx/hal.h | 32 ++++++++++ drivers/net/wireless/ath/wcn36xx/main.c | 1 + drivers/net/wireless/ath/wcn36xx/smd.c | 82 +++++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/smd.h | 1 + 4 files changed, 116 insertions(+)
drivers/net/wireless/ath/wcn36xx/hal.h +32 -0
@@ -359,6 +359,8 @@ enum wcn36xx_hal_host_msg_type {WCN36XX_HAL_START_SCAN_OFFLOAD_RSP =205 ,WCN36XX_HAL_STOP_SCAN_OFFLOAD_REQ =206 ,WCN36XX_HAL_STOP_SCAN_OFFLOAD_RSP =207 , +WCN36XX_HAL_UPDATE_CHANNEL_LIST_REQ =208 , +WCN36XX_HAL_UPDATE_CHANNEL_LIST_RSP =209 ,WCN36XX_HAL_SCAN_OFFLOAD_IND =210 , WCN36XX_HAL_AVOID_FREQ_RANGE_IND = 233,
@@ -1353,6 +1355,36 @@ struct wcn36xx_hal_stop_scan_offload_rsp_msg {u32 status; } __packed; +#define WCN36XX_HAL_CHAN_REG1_MIN_PWR_MASK 0x000000ff +#define WCN36XX_HAL_CHAN_REG1_MAX_PWR_MASK 0x0000ff00 +#define WCN36XX_HAL_CHAN_REG1_REG_PWR_MASK 0x00ff0000 +#define WCN36XX_HAL_CHAN_REG1_CLASS_ID_MASK 0xff000000 +#define WCN36XX_HAL_CHAN_REG2_ANT_GAIN_MASK 0x000000ff +#define WCN36XX_HAL_CHAN_INFO_FLAG_PASSIVE BIT(7) +#define WCN36XX_HAL_CHAN_INFO_FLAG_DFS BIT(10) +#define WCN36XX_HAL_CHAN_INFO_FLAG_HT BIT(11) +#define WCN36XX_HAL_CHAN_INFO_FLAG_VHT BIT(12) +#define WCN36XX_HAL_CHAN_INFO_PHY_11A 0 +#define WCN36XX_HAL_CHAN_INFO_PHY_11BG 1 +#define WCN36XX_HAL_DEFAULT_ANT_GAIN 6 +#define WCN36XX_HAL_DEFAULT_MIN_POWER 6 + +struct wcn36xx_hal_channel_param { +u32 mhz; +u32 band_center_freq1; +u32 band_center_freq2; +u32 channel_info; +u32 reg_info_1; +u32 reg_info_2; +} __packed; + +struct wcn36xx_hal_update_channel_list_req_msg { +struct wcn36xx_hal_msg_header header; + +u8 num_channel; +struct wcn36xx_hal_channel_param channels[80 ]; +} __packed; +enum wcn36xx_hal_rate_index {HW_RATE_INDEX_1MBPS =0x82 ,HW_RATE_INDEX_2MBPS =0x84 ,
drivers/net/wireless/ath/wcn36xx/main.c +1 -0
@@ -671,6 +671,7 @@ static int wcn36xx_hw_scan(struct ieee80211_hw *hw,mutex_unlock (&wcn->scan_lock); +wcn36xx_smd_update_channel_list (wcn, &hw_req->req);return wcn36xx_smd_start_hw_scan (wcn, vif, &hw_req->req); }
drivers/net/wireless/ath/wcn36xx/smd.c +82 -0
100 lines not on this page · raw message
drivers/net/wireless/ath/wcn36xx/smd.h +1 -0
@@ -70,6 +70,7 @@ int wcn36xx_smd_update_scan_params(struct wcn36xx *wcn, u8 *channels, size_t chaint wcn36xx_smd_start_hw_scan (struct wcn36xx *wcn,struct ieee80211_vif *vif,struct cfg80211_scan_request *req);int wcn36xx_smd_stop_hw_scan (struct wcn36xx *wcn); +int wcn36xx_smd_update_channel_list (struct wcn36xx *wcn,struct cfg80211_scan_request *req);int wcn36xx_smd_add_sta_self (struct wcn36xx *wcn,struct ieee80211_vif *vif);int wcn36xx_smd_delete_sta_self (struct wcn36xx *wcn,u8 *addr);int wcn36xx_smd_delete_sta (struct wcn36xx *wcn,u8 sta_index);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 526/849 drm/amdgpu: fix a potential memory leak in amdgpu_device_fini_sw()
In reply to Greg Kroah-HartmanFrom: Lang Yu <[email protected]>
[ Upstream commit a5c5d8d50ecf5874be90a76e1557279ff8a30c9e ]
amdgpu_fence_driver_sw_fini() should be executed before amdgpu_device_ip_fini(), otherwise fence driver resource won't be properly freed as adev->rings have been tore down.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -3818,8 +3818,8 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)void amdgpu_device_fini_sw (struct amdgpu_device *adev) { -amdgpu_device_ip_fini (adev);amdgpu_fence_driver_sw_fini (adev); +amdgpu_device_ip_fini (adev);release_firmware (adev->firmware.gpu_info_fw); adev->firmware.gpu_info_fw =NULL ; adev->accel_working = false;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 527/849 drm/amdgpu/gmc6: fix DMA mask from 44 to 40 bits
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
[ Upstream commit 403475be6d8b122c3e6b8a47e075926d7299e5ef ]
The DMA mask on SI parts is 40 bits not 44. Copy paste typo.
--- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -2
@@ -841,12 +841,12 @@ static int gmc_v6_0_sw_init(void *handle) adev->gmc.mc_mask =0xffffffffffULL ; - r =dma_set_mask_and_coherent (adev->dev,DMA_BIT_MASK (44 )); + r =dma_set_mask_and_coherent (adev->dev,DMA_BIT_MASK (40 ));if (r) {dev_warn (adev->dev,"No suitable DMA available.\n" );return r; } - adev->need_swiotlb =drm_need_swiotlb (44 ); + adev->need_swiotlb =drm_need_swiotlb (40 ); r =gmc_v6_0_init_microcode (adev);if (r) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 528/849 selftests/bpf: Fix fd cleanup in sk_lookup test
In reply to Greg Kroah-HartmanFrom: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit c3fc706e94f5653def2783ffcd809a38676b7551 ]
Similar to the fix in commit:e31eec77e4ab ("bpf: selftests: Fix fd cleanup in get_branch_snapshot")
We use designated initializer to set fds to -1 without breaking on future changes to MAX_SERVER constant denoting the array size.
The particular close(0) occurs on non-reuseport tests, so it can be seen with -n 115/{2,3} but not 115/4. This can cause problems with future tests if they depend on BTF fd never being acquired as fd 0, breaking internal libbpf assumptions.
--- tools/testing/selftests/bpf/prog_tests/sk_lookup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/sk_lookup.c +2 -2
@@ -598,7 +598,7 @@ close:static void run_lookup_prog (const struct test *t) { -int server_fds[MAX_SERVERS ] = {-1 }; +int server_fds[] = { [0 ...MAX_SERVERS -1 ] =-1 };int client_fd, reuse_conn_fd =-1 ;struct bpf_link *lookup_link;int i, err;
@@ -1053,7 +1053,7 @@ static void run_sk_assign(struct test_sk_lookup *skel,struct bpf_program *lookup_prog, const char *remote_ip, const char *local_ip) { - int server_fds[MAX_SERVERS] = { -1 }; + int server_fds[] = { [0 ... MAX_SERVERS - 1] = -1 };struct bpf_sk_lookup ctx;__u64 server_cookie;int i, err;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 529/849 selftests/bpf: Fix memory leak in test_ima
In reply to Greg Kroah-HartmanFrom: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit efadf2ad17a2d5dc90bda4e6e8b2f96af4c62dae ]
The allocated ring buffer is never freed, do so in the cleanup path.
--- tools/testing/selftests/bpf/prog_tests/test_ima.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/test_ima.c +2 -1
@@ -43,7 +43,7 @@ static int process_sample(void *ctx, void *data, size_t len)void test_test_ima (void ) {char measured_dir_template[] ="/tmp/ima_measuredXXXXXX" ; -struct ring_buffer *ringbuf; +struct ring_buffer *ringbuf =NULL ;const char *measured_dir;char cmd[256 ];
@@ -85,5 +85,6 @@ close_clean: err =system (cmd);CHECK (err,"failed to run command" ,"%s, errno = %d\n" , cmd, errno); close_prog: +ring_buffer__free (ringbuf);ima__destroy (skel); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 530/849 sctp: allow IP fragmentation when PLPMTUD enters Error state
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit 40171248bb8934537fec8fbaf718e57c8add187c ]
Currently when PLPMTUD enters Error state, transport pathmtu will be set to MIN_PLPMTU(512) while probe is continuing with BASE_PLPMTU(1200). It will cause pathmtu to stay in a very small value, even if the real pmtu is some value like 1000.
RFC8899 doesn't clearly say how to set the value in Error state. But one possibility could be keep using BASE_PLPMTU for the real pmtu, but allow to do IP fragmentation when it's in Error state.
As it says in rfc8899#section-5.4:
Some paths could be unable to sustain packets of the BASE_PLPMTU size. The Error State could be implemented to provide robustness to such paths. This allows fallback to a smaller than desired PLPMTU rather than suffer connectivity failure. This could utilize methods such as endpoint IP fragmentation to enable the PL sender to communicate using packets smaller than the BASE_PLPMTU.
This patch is to set pmtu to BASE_PLPMTU instead of MIN_PLPMTU for Error state in sctp_transport_pl_send/toobig(), and set packet ipfragok for non-probe packets when it's in Error state.
--- net/sctp/output.c | 13 ++++++++----- net/sctp/transport.c | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-)
net/sctp/output.c +8 -5
@@ -581,13 +581,16 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp) chunk = list_entry(packet->chunk_list.next, struct sctp_chunk, list); sk = chunk->skb->sk; -/* check gso */ if (packet->size > tp->pathmtu && !packet->ipfragok && !chunk->pmtu_probe) { -if (!sk_can_gso (sk)) { -pr_err_once ("Trying to GSO but underlying device doesn't support it." ); - goto out; +if (tp->pl.state ==SCTP_PL_ERROR ) {/* do IP fragmentation if in Error state */ + packet->ipfragok =1 ; + }else { +if (!sk_can_gso (sk)) {/* check gso */ +pr_err_once ("Trying to GSO but underlying device doesn't support it." ); + goto out; + } + gso =1 ; } - gso =1 ; }/* alloc head skb */
net/sctp/transport.c +2 -2
@@ -269,7 +269,7 @@ bool sctp_transport_pl_send(struct sctp_transport *t)if (t->pl.probe_size ==SCTP_BASE_PLPMTU ) {/* BASE_PLPMTU Confirmation Failed */ t->pl.state =SCTP_PL_ERROR ;/* Base -> Error */ - t->pl.pmtu =SCTP_MIN_PLPMTU ; + t->pl.pmtu =SCTP_BASE_PLPMTU ; t->pathmtu = t->pl.pmtu +sctp_transport_pl_hlen (t);sctp_assoc_sync_pmtu (t->asoc); }
@@ -366,7 +366,7 @@ static bool sctp_transport_pl_toobig(struct sctp_transport *t, u32 pmtu)if (pmtu >=SCTP_MIN_PLPMTU && pmtu <SCTP_BASE_PLPMTU ) { t->pl.state =SCTP_PL_ERROR ;/* Base -> Error */ - t->pl.pmtu =SCTP_MIN_PLPMTU ; + t->pl.pmtu =SCTP_BASE_PLPMTU ; t->pathmtu = t->pl.pmtu +sctp_transport_pl_hlen (t); } }else if (t->pl.state ==SCTP_PL_SEARCH ) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 531/849 sctp: reset probe_timer in sctp_transport_pl_update
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit c6ea04ea692fa0d8e7faeb133fcd28e3acf470a0 ]
sctp_transport_pl_update() is called when transport update its dst and pathmtu, instead of stopping the PLPMTUD probe timer, PLPMTUD should start over and reset the probe timer. Otherwise, the PLPMTUD service would stop.
--- include/net/sctp/sctp.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
include/net/sctp/sctp.h +1 -3
@@ -653,12 +653,10 @@ static inline void sctp_transport_pl_update(struct sctp_transport *t)if (t->pl.state ==SCTP_PL_DISABLED )return ; -if (del_timer (&t->probe_timer)) -sctp_transport_put (t); - t->pl.state =SCTP_PL_BASE ; t->pl.pmtu =SCTP_BASE_PLPMTU ; t->pl.probe_size =SCTP_BASE_PLPMTU ; +sctp_transport_reset_probe_timer (t); }static inline bool sctp_transport_pl_enabled (struct sctp_transport *t)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 532/849 sctp: subtract sctphdr len in sctp_transport_pl_hlen
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit cc4665ca646c96181a7c00198aa72c59e0c576e8 ]
sctp_transport_pl_hlen() is called to calculate the outer header length for PL. However, as the Figure in rfc8899#section-4.4:
Any additional
headers .--- MPS -----.
| | |
v v v
+------------------------------+
| IP | ** | PL | protocol data |
+------------------------------+ <----- PLPMTU ----->
<---------- PMTU -------------->Outer header are IP + Any additional headers, which doesn't include Packetization Layer itself header, namely sctphdr, whereas sctphdr is counted by __sctp_mtu_payload().
The incorrect calculation caused the link pathmtu to be set larger than expected by t->pl.pmtu + sctp_transport_pl_hlen(). This patch is to fix it by subtracting sctphdr len in sctp_transport_pl_hlen().
--- include/net/sctp/sctp.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/net/sctp/sctp.h +2 -1
@@ -626,7 +626,8 @@ static inline __u32 sctp_min_frag_point(struct sctp_sock *sp, __u16 datasize)static inline int sctp_transport_pl_hlen (struct sctp_transport *t) { -return __sctp_mtu_payload (sctp_sk (t->asoc->base.sk), t,0 ,0 ); +return __sctp_mtu_payload (sctp_sk (t->asoc->base.sk), t,0 ,0 ) - +sizeof (struct sctphdr ); }static inline void sctp_transport_pl_reset (struct sctp_transport *t)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 533/849 sctp: return true only for pathmtu update in sctp_transport_pl_toobig
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit 75cf662c64dd8543f56c329c69eba18141c8fd9f ]
sctp_transport_pl_toobig() supposes to return true only if there's pathmtu update, so that in sctp_icmp_frag_needed() it would call sctp_assoc_sync_pmtu() and sctp_retransmit(). This patch is to fix these return places in sctp_transport_pl_toobig().
--- net/sctp/transport.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/sctp/transport.c +4 -3
@@ -368,6 +368,7 @@ static bool sctp_transport_pl_toobig(struct sctp_transport *t, u32 pmtu) t->pl.pmtu =SCTP_BASE_PLPMTU ; t->pathmtu = t->pl.pmtu +sctp_transport_pl_hlen (t); +return true; } }else if (t->pl.state ==SCTP_PL_SEARCH ) {if (pmtu >=SCTP_BASE_PLPMTU && pmtu < t->pl.pmtu) {
@@ -378,11 +379,10 @@ static bool sctp_transport_pl_toobig(struct sctp_transport *t, u32 pmtu) t->pl.probe_high =0 ; t->pl.pmtu =SCTP_BASE_PLPMTU ; t->pathmtu = t->pl.pmtu +sctp_transport_pl_hlen (t); +return true; }else if (pmtu > t->pl.pmtu && pmtu < t->pl.probe_size) { t->pl.probe_size = pmtu; t->pl.probe_count =0 ; - -return false; } }else if (t->pl.state ==SCTP_PL_COMPLETE ) {if (pmtu >=SCTP_BASE_PLPMTU && pmtu < t->pl.pmtu) {
@@ -393,10 +393,11 @@ static bool sctp_transport_pl_toobig(struct sctp_transport *t, u32 pmtu) t->pl.probe_high =0 ; t->pl.pmtu =SCTP_BASE_PLPMTU ; t->pathmtu = t->pl.pmtu +sctp_transport_pl_hlen (t); +return true; } } -return true; +return false; }bool sctp_transport_update_pmtu (struct sctp_transport *t,u32 pmtu)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 534/849 net: amd-xgbe: Toggle PLL settings during rate change
In reply to Greg Kroah-HartmanFrom: Shyam Sundar S K <[email protected]>
[ Upstream commit daf182d360e509a494db18666799f4e85d83dda0 ]
For each rate change command submission, the FW has to do a phy power off sequence internally. For this to happen correctly, the PLL re-initialization control setting has to be turned off before sending mailbox commands and re-enabled once the command submission is complete.
Without the PLL control setting, the link up takes longer time in a fixed phy configuration.
--- drivers/net/ethernet/amd/xgbe/xgbe-common.h | 8 ++++++++ drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-)
drivers/net/ethernet/amd/xgbe/xgbe-common.h +8 -0
@@ -1331,6 +1331,10 @@#define MDIO_VEND2_PMA_CDR_CONTROL 0x8056#endif +#ifndef MDIO_VEND2_PMA_MISC_CTRL0 +#define MDIO_VEND2_PMA_MISC_CTRL0 0x8090 +#endif +#ifndef MDIO_CTRL1_SPEED1G #define MDIO_CTRL1_SPEED1G (MDIO_CTRL1_SPEED10G & ~BMCR_SPEED100)#endif
@@ -1389,6 +1393,10 @@#define XGBE_PMA_RX_RST_0_RESET_ON 0x10#define XGBE_PMA_RX_RST_0_RESET_OFF 0x00 +#define XGBE_PMA_PLL_CTRL_MASK BIT(15) +#define XGBE_PMA_PLL_CTRL_ENABLE BIT(15) +#define XGBE_PMA_PLL_CTRL_DISABLE 0x0000 +/* Bit setting and getting macros * The get macro will extract the current bit field value from within * the variable
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c +19 -1
@@ -1977,12 +1977,26 @@ static void xgbe_phy_rx_reset(struct xgbe_prv_data *pdata) } } +static void xgbe_phy_pll_ctrl (struct xgbe_prv_data *pdata,bool enable) +{ +XMDIO_WRITE_BITS (pdata,MDIO_MMD_PMAPMD ,MDIO_VEND2_PMA_MISC_CTRL0 , +XGBE_PMA_PLL_CTRL_MASK , + enable ?XGBE_PMA_PLL_CTRL_ENABLE + :XGBE_PMA_PLL_CTRL_DISABLE ); + +/* Wait for command to complete */ +usleep_range (100 ,200 ); +} +static void xgbe_phy_perform_ratechange (struct xgbe_prv_data *pdata,unsigned int cmd,unsigned int sub_cmd) {unsigned int s0 =0 ;unsigned int wait; +/* Disable PLL re-initialization during FW command processing */ +xgbe_phy_pll_ctrl (pdata, false); +/* Log if a previous command did not complete */ if (XP_IOREAD_BITS (pdata,XP_DRIVER_INT_RO ,STATUS )) { netif_dbg(pdata, link, pdata->netdev,
@@ -2003,7 +2017,7 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, wait =XGBE_RATECHANGE_COUNT ;while (wait--) {if (!XP_IOREAD_BITS (pdata,XP_DRIVER_INT_RO ,STATUS )) -return ; + goto reenable_pll;usleep_range (1000 ,2000 ); }
@@ -2013,6 +2027,10 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata,/* Reset on error */ xgbe_phy_rx_reset (pdata); + +reenable_pll: +/* Enable PLL re-initialization */ +xgbe_phy_pll_ctrl (pdata, true); }static void xgbe_phy_rrc (struct xgbe_prv_data *pdata)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 535/849 ipmi: kcs_bmc: Fix a memory leak in the error handling path of kcs_bmc_serio_add_device()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit f281d010b87454e72475b668ad66e34961f744e0 ]
In the unlikely event where 'devm_kzalloc()' fails and 'kzalloc()' succeeds, 'port' would be leaking.
Test each allocation separately to avoid the leak.
Message-Id: <ecbfa15e94e64f4b878ecab1541ea46c74807670.1631048724.git.christophe.jaillet@wanadoo.fr>
--- drivers/char/ipmi/kcs_bmc_serio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/ipmi/kcs_bmc_serio.c +3 -1
@@ -73,10 +73,12 @@ static int kcs_bmc_serio_add_device(struct kcs_bmc_device *kcs_bmc)struct serio *port; priv =devm_kzalloc (kcs_bmc->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ;/* Use kzalloc() as the allocation is cleaned up with kfree() via serio_unregister_port() */ port =kzalloc (sizeof (*port),GFP_KERNEL ); -if (!(priv && port)) +if (!port)return -ENOMEM ; port->id.type =SERIO_8042 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 536/849 net: phylink: avoid mvneta warning when setting pause parameters
In reply to Greg Kroah-HartmanFrom: Russell King (Oracle) <[email protected]>
[ Upstream commit fd8d9731bcdfb22d28e45bce789bcb211c868c78 ]
mvneta does not support asymetric pause modes, and it flags this by the lack of AsymPause in the supported field. When setting pause modes, we check that pause->rx_pause == pause->tx_pause, but only when pause autoneg is enabled. When pause autoneg is disabled, we still allow pause->rx_pause != pause->tx_pause, which is incorrect when the MAC does not support asymetric pause, and causes mvneta to issue a warning.
Fix this by removing the test for pause->autoneg, so we always check that pause->rx_pause == pause->tx_pause for network devices that do not support AsymPause.
--- drivers/net/phy/phylink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phylink.c +1 -1
@@ -1724,7 +1724,7 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,return -EOPNOTSUPP ;if (!phylink_test (pl->supported, Asym_Pause) && - !pause->autoneg && pause->rx_pause != pause->tx_pause) + pause->rx_pause != pause->tx_pause)return -EINVAL ; pause_state =0 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 537/849 net: bridge: fix uninitialized variables when BRIDGE_CFM is disabled
In reply to Greg Kroah-HartmanFrom: Ivan Vecera <[email protected]>
[ Upstream commit 829e050eea69c7442441b714b6f5b339b5b8c367 ]
Function br_get_link_af_size_filtered() calls br_cfm_{,peer}_mep_count() that return a count. When BRIDGE_CFM is not enabled these functions simply return -EOPNOTSUPP but do not modify count parameter and calling function then works with uninitialized variables. Modify these inline functions to return zero in count parameter.
--- net/bridge/br_private.h | 2 ++ 1 file changed, 2 insertions(+)
net/bridge/br_private.h +2 -0
@@ -1594,11 +1594,13 @@ static inline int br_cfm_status_fill_info(struct sk_buff *skb,static inline int br_cfm_mep_count (struct net_bridge *br,u32 *count) { + *count =0 ;return -EOPNOTSUPP ; }static inline int br_cfm_peer_mep_count (struct net_bridge *br,u32 *count) { + *count =0 ;return -EOPNOTSUPP ; }#endif
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 538/849 selftests: net: bridge: update IGMP/MLD membership interval value
In reply to Greg Kroah-HartmanFrom: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 34d7ecb3d4f772eb00ce1f7195ae30886ddf4d2e ]
When I fixed IGMPv3/MLDv2 to use the bridge's multicast_membership_interval value which is chosen by user-space instead of calculating it based on multicast_query_interval and multicast_query_response_interval I forgot to update the selftests relying on that behaviour. Now we have to manually set the expected GMI value to perform the tests correctly and get proper results (similar to IGMPv2 behaviour).
--- .../testing/selftests/net/forwarding/bridge_igmp.sh | 12 +++++++++--- tools/testing/selftests/net/forwarding/bridge_mld.sh | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-)
tools/testing/selftests/net/forwarding/bridge_igmp.sh +9 -3
@@ -482,10 +482,15 @@ v3exc_timeout_test() local X=("192.0.2.20" "192.0.2.30") # GMI should be 3 seconds - ip link set dev br0 type bridge mcast_query_interval 100 mcast_query_response_interval 100 + ip link set dev br0 type bridge mcast_query_interval 100 \ + mcast_query_response_interval 100 \ + mcast_membership_interval 300 v3exclude_prepare $h1 $ALL_MAC $ALL_GROUP - ip link set dev br0 type bridge mcast_query_interval 500 mcast_query_response_interval 500 + ip link set dev br0 type bridge mcast_query_interval 500 \ + mcast_query_response_interval 500 \ + mcast_membership_interval 1500 + $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip "proto=2,p=$MZPKT_ALLOW2" -q sleep 3 bridge -j -d -s mdb show dev br0 \
@@ -517,7 +522,8 @@ v3exc_timeout_test() log_test "IGMPv3 group $TEST_GROUP exclude timeout" ip link set dev br0 type bridge mcast_query_interval 12500 \ - mcast_query_response_interval 1000 + mcast_query_response_interval 1000 \ + mcast_membership_interval 26000 v3cleanup $swp1 $TEST_GROUP }
tools/testing/selftests/net/forwarding/bridge_mld.sh +9 -3
@@ -479,10 +479,15 @@ mldv2exc_timeout_test() local X=("2001:db8:1::20" "2001:db8:1::30") # GMI should be 3 seconds - ip link set dev br0 type bridge mcast_query_interval 100 mcast_query_response_interval 100 + ip link set dev br0 type bridge mcast_query_interval 100 \ + mcast_query_response_interval 100 \ + mcast_membership_interval 300 mldv2exclude_prepare $h1 - ip link set dev br0 type bridge mcast_query_interval 500 mcast_query_response_interval 500 + ip link set dev br0 type bridge mcast_query_interval 500 \ + mcast_query_response_interval 500 \ + mcast_membership_interval 1500 + $MZ $h1 -c 1 $MZPKT_ALLOW2 -q sleep 3 bridge -j -d -s mdb show dev br0 \
@@ -514,7 +519,8 @@ mldv2exc_timeout_test() log_test "MLDv2 group $TEST_GROUP exclude timeout" ip link set dev br0 type bridge mcast_query_interval 12500 \ - mcast_query_response_interval 1000 + mcast_query_response_interval 1000 \ + mcast_membership_interval 26000 mldv2cleanup $swp1 }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 539/849 crypto: pcrypt - Delay write to padata->info
In reply to Greg Kroah-HartmanFrom: Daniel Jordan <[email protected]>
[ Upstream commit 68b6dea802cea0dbdd8bd7ccc60716b5a32a5d8a ]
These three events can race when pcrypt is used multiple times in a template ("pcrypt(pcrypt(...))"):
1. [taskA] The caller makes the crypto request via crypto_aead_encrypt() 2. [kworkerB] padata serializes the inner pcrypt request 3. [kworkerC] padata serializes the outer pcrypt request
3 might finish before the call to crypto_aead_encrypt() returns in 1, resulting in two possible issues.
First, a use-after-free of the crypto request's memory when, for example, taskA writes to the outer pcrypt request's padata->info in pcrypt_aead_enc() after kworkerC completes the request.
Second, the outer pcrypt request overwrites the inner pcrypt request's return code with -EINPROGRESS, making a successful request appear to fail. For instance, kworkerB writes the outer pcrypt request's padata->info in pcrypt_aead_done() and then taskA overwrites it in pcrypt_aead_enc().
Avoid both situations by delaying the write of padata->info until after the inner crypto request's return code is checked. This prevents the use-after-free by not touching the crypto request's memory after the next-inner crypto request is made, and stops padata->info from being overwritten.
--- crypto/pcrypt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
crypto/pcrypt.c +8 -4
@@ -78,12 +78,14 @@ static void pcrypt_aead_enc(struct padata_priv *padata) {struct pcrypt_request *preq =pcrypt_padata_request (padata);struct aead_request *req =pcrypt_request_ctx (preq); +int ret; - padata->info =crypto_aead_encrypt (req); + ret =crypto_aead_encrypt (req); -if (padata->info == -EINPROGRESS ) +if (ret == -EINPROGRESS )return ; + padata->info = ret;padata_do_serial (padata); }
@@ -123,12 +125,14 @@ static void pcrypt_aead_dec(struct padata_priv *padata) {struct pcrypt_request *preq =pcrypt_padata_request (padata);struct aead_request *req =pcrypt_request_ctx (preq); +int ret; - padata->info =crypto_aead_decrypt (req); + ret =crypto_aead_decrypt (req); -if (padata->info == -EINPROGRESS ) +if (ret == -EINPROGRESS )return ; + padata->info = ret;padata_do_serial (padata); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 540/849 selftests/bpf: Fix fclose/pclose mismatch in test_progs
In reply to Greg Kroah-HartmanFrom: Andrea Righi <[email protected]>
[ Upstream commit f48ad69097fe79d1de13c4d8fef556d4c11c5e68 ]
Make sure to use pclose() to properly close the pipe opened by popen().
--- tools/testing/selftests/bpf/test_progs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/test_progs.c +2 -2
@@ -348,7 +348,7 @@ int extract_build_id(char *build_id, size_t size)if (getline (&line, &len, fp) ==-1 ) goto err; -fclose (fp); +pclose (fp);if (len > size) len = size;
@@ -357,7 +357,7 @@ int extract_build_id(char *build_id, size_t size)free (line);return 0 ; err: -fclose (fp); +pclose (fp);return -1 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 541/849 udp6: allow SO_MARK ctrl msg to affect routing
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 42dcfd850e514b229d616a53dec06d0f2533217c ]
Commit c6af0c227a22 ("ip: support SO_MARK cmsg") added propagation of SO_MARK from cmsg to skb->mark. For IPv4 and raw sockets the mark also affects route lookup, but in case of IPv6 the flow info is initialized before cmsg is parsed.
--- net/ipv6/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/udp.c +1 -1
@@ -1435,7 +1435,6 @@ do_udp_sendmsg:if (!fl6.flowi6_oif) fl6.flowi6_oif = np->sticky_pktinfo.ipi6_ifindex; - fl6.flowi6_mark = ipc6.sockc.mark; fl6.flowi6_uid = sk->sk_uid;if (msg->msg_controllen) {
@@ -1471,6 +1470,7 @@ do_udp_sendmsg: ipc6.opt = opt; fl6.flowi6_proto = sk->sk_protocol; + fl6.flowi6_mark = ipc6.sockc.mark; fl6.daddr = *daddr;if (ipv6_addr_any (&fl6.saddr) && !ipv6_addr_any (&np->saddr)) fl6.saddr = np->saddr;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 542/849 ibmvnic: dont stop queue in xmit
In reply to Greg Kroah-HartmanFrom: Sukadev Bhattiprolu <[email protected]>
[ Upstream commit 8878e46fcfd46b19964bd90e13b25dd94cbfc9be ]
If adapter's resetting bit is on, discard the packet but don't stop the transmit queue - instead leave that to the reset code. With this change, it is possible that we may get several calls to ibmvnic_xmit() that simply discard packets and return.
But if we stop the queue here, we might end up doing so just after __ibmvnic_open() started the queues (during a hard/soft reset) and before the ->resetting bit was cleared. If that happens, there will be no one to restart queue and transmissions will be blocked indefinitely.
This can cause a TIMEOUT reset and with auto priority failover enabled, an unnecessary FAILOVER reset to less favored backing device and then a FAILOVER back to the most favored backing device. If we hit the window repeatedly, we can get stuck in a loop of TIMEOUT, FAILOVER, FAILOVER resets leaving the adapter unusable for extended periods of time.
--- drivers/net/ethernet/ibm/ibmvnic.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +0 -2
@@ -1724,8 +1724,6 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev) ind_bufp = &tx_scrq->ind_buf;if (test_bit (0 , &adapter->resetting)) { -if (!netif_subqueue_stopped (netdev, skb)) -netif_stop_subqueue (netdev, queue_num);dev_kfree_skb_any (skb); tx_send_failed++;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 543/849 ibmvnic: Process crqs after enabling interrupts
In reply to Greg Kroah-HartmanFrom: Sukadev Bhattiprolu <[email protected]>
[ Upstream commit 6e20d00158f31f7631d68b86996b7e951c4451c8 ]
Soon after registering a CRQ it is possible that we get a fail over or maybe a CRQ_INIT from the VIOS while interrupts were disabled.
Look for any such CRQs after enabling interrupts.
Otherwise we can intermittently fail to bring up ibmvnic adapters during boot, specially in kexec/kdump kernels.
--- drivers/net/ethernet/ibm/ibmvnic.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/ibm/ibmvnic.c +3 -0
@@ -5412,6 +5412,9 @@ static int init_crq_queue(struct ibmvnic_adapter *adapter) crq->cur =0 ;spin_lock_init (&crq->lock); +/* process any CRQs that were queued before we enabled interrupts */ +tasklet_schedule (&adapter->tasklet); +return retrc; req_irq_failed:
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 544/849 ibmvnic: delay complete()
In reply to Greg Kroah-HartmanFrom: Sukadev Bhattiprolu <[email protected]>
[ Upstream commit 6b278c0cb378079f3c0c61ae4a369c09ff1a4188 ]
If we get CRQ_INIT, we set errno to -EIO and first call complete() to notify the waiter. Then we try to schedule a FAILOVER reset. If this occurs while adapter is in PROBING state, ibmvnic_reset() changes the error code to EAGAIN and returns without scheduling the FAILOVER. The purpose of setting error code to EAGAIN is to ask the waiter to retry.
But due to the earlier complete() call, the waiter may already have seen the -EIO response and decided not to retry. This can cause intermittent failures when bringing up ibmvnic adapters during boot, specially in in kexec/kdump kernels.
Defer the complete() call until after scheduling the reset.
Also streamline the error code to EAGAIN. Don't see why we need EIO sometimes. All 3 callers of ibmvnic_reset_init() can handle EAGAIN.
--- drivers/net/ethernet/ibm/ibmvnic.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +9 -7
@@ -2565,7 +2565,7 @@ static int ibmvnic_reset(struct ibmvnic_adapter *adapter,if (adapter->state ==VNIC_PROBING ) {netdev_warn (netdev,"Adapter reset during probe\n" ); - adapter->init_done_rc =EAGAIN ; + adapter->init_done_rc = -EAGAIN ; ret =EAGAIN ; goto err; }
@@ -5067,11 +5067,6 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,*/ adapter->login_pending = false; -if (!completion_done (&adapter->init_done)) { -complete (&adapter->init_done); - adapter->init_done_rc = -EIO ; - } -if (adapter->state ==VNIC_DOWN ) rc =ibmvnic_reset (adapter,VNIC_RESET_PASSIVE_INIT );else
@@ -5092,6 +5087,13 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq, rc); adapter->failover_pending = false; } + +if (!completion_done (&adapter->init_done)) { +complete (&adapter->init_done); +if (!adapter->init_done_rc) + adapter->init_done_rc = -EAGAIN ; + } +break ;case IBMVNIC_CRQ_INIT_COMPLETE :dev_info (dev,"Partner initialization complete\n" );
@@ -5559,7 +5561,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) } rc =ibmvnic_reset_init (adapter, false); - }while (rc ==EAGAIN ); + }while (rc == -EAGAIN );/* We are ignoring the error from ibmvnic_reset_init() assuming that the * partner is not ready. CRQ is not active. When the partner becomes
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 545/849 skmsg: Lose offset info in sk_psock_skb_ingress
In reply to Greg Kroah-HartmanFrom: Liu Jian <[email protected]>
[ Upstream commit 7303524e04af49a47991e19f895c3b8cdc3796c7 ]
If sockmap enable strparser, there are lose offset info in sk_psock_skb_ingress(). If the length determined by parse_msg function is not skb->len, the skb will be converted to sk_msg multiple times, and userspace app will get the data multiple times.
Fix this by get the offset and length from strp_msg. And as Cong suggested, add one bit in skb->_sk_redir to distinguish enable or disable strparser.
--- include/linux/skmsg.h | 18 ++++++++++++++++-- net/core/skmsg.c | 43 +++++++++++++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 12 deletions(-)
include/linux/skmsg.h +16 -2
@@ -508,8 +508,22 @@ static inline bool sk_psock_strp_enabled(struct sk_psock *psock)#if IS_ENABLED (CONFIG_NET_SOCK_MSG ) -/* We only have one bit so far. */ -#define BPF_F_PTR_MASK ~(BPF_F_INGRESS) +#define BPF_F_STRPARSER (1UL << 1) + +/* We only have two bits so far. */ +#define BPF_F_PTR_MASK ~(BPF_F_INGRESS | BPF_F_STRPARSER) + +static inline bool skb_bpf_strparser (const struct sk_buff *skb) +{ +unsigned long sk_redir = skb->_sk_redir; + +return sk_redir &BPF_F_STRPARSER ; +} + +static inline void skb_bpf_set_strparser (struct sk_buff *skb) +{ + skb->_sk_redir |=BPF_F_STRPARSER ; +}static inline bool skb_bpf_ingress (const struct sk_buff *skb) {
net/core/skmsg.c +33 -10
131 lines not on this page · raw message
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 546/849 cgroup: Fix rootcg cpu.stat guest double counting
In reply to Greg Kroah-HartmanFrom: Dan Schatzberg <[email protected]>
[ Upstream commit 81c49d39aea8a10e6d05d3aa1cb65ceb721e19b0 ]
In account_guest_time in kernel/sched/cputime.c guest time is attributed to both CPUTIME_NICE and CPUTIME_USER in addition to CPUTIME_GUEST_NICE and CPUTIME_GUEST respectively. Therefore, adding both to calculate usage results in double counting any guest time at the rootcg.
--- kernel/cgroup/rstat.c | 2 -- 1 file changed, 2 deletions(-)
kernel/cgroup/rstat.c +0 -2
@@ -433,8 +433,6 @@ static void root_cgroup_cputime(struct task_cputime *cputime) cputime->sum_exec_runtime += user; cputime->sum_exec_runtime += sys; cputime->sum_exec_runtime += cpustat[CPUTIME_STEAL ]; - cputime->sum_exec_runtime += cpustat[CPUTIME_GUEST ]; - cputime->sum_exec_runtime += cpustat[CPUTIME_GUEST_NICE ]; } }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 547/849 bpf: Fix propagation of bounds from 64-bit min/max into 32-bit and var_off.
In reply to Greg Kroah-HartmanFrom: Alexei Starovoitov <[email protected]>
[ Upstream commit b9979db8340154526d9ab38a1883d6f6ba9b6d47 ]
Before this fix:
166: (b5) if r2 <= 0x1 goto pc+22
from 166 to 189: R2=invP(id=1,umax_value=1,var_off=(0x0; 0xffffffff))
After this fix:
166: (b5) if r2 <= 0x1 goto pc+22
from 166 to 189: R2=invP(id=1,umax_value=1,var_off=(0x0; 0x1))
While processing BPF_JLE the reg_set_min_max() would set true_reg->umax_value = 1 and call __reg_combine_64_into_32(true_reg).
Without the fix it would not pass the condition:
if (__reg64_bound_u32(reg->umin_value) && __reg64_bound_u32(reg->umax_value))
since umin_value == 0 at this point.
Before commit 10bf4e83167c the umin was incorrectly ingored.
The commit 10bf4e83167c fixed the correctness issue, but pessimized propagation of 64-bit min max into 32-bit min max and corresponding var_off.
--- kernel/bpf/verifier.c | 2 +- tools/testing/selftests/bpf/verifier/array_access.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/verifier.c +1 -1
@@ -1402,7 +1402,7 @@ static bool __reg64_bound_s32(s64 a)static bool __reg64_bound_u32 (u64 a) { -return a >U32_MIN && a <U32_MAX ; +return a >=U32_MIN && a <=U32_MAX ; }static void __reg_combine_64_into_32 (struct bpf_reg_state *reg)
tools/testing/selftests/bpf/verifier/array_access.c +1 -1
@@ -186,7 +186,7 @@ }, .fixup_map_hash_48b = { 3 }, .errstr_unpriv = "R0 leaks addr", - .errstr = "R0 unbounded memory access", + .errstr = "invalid access to map value, value_size=48 off=44 size=8", .result_unpriv = REJECT, .result = REJECT, .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 548/849 bpf: Fix propagation of signed bounds from 64-bit min/max into 32-bit.
In reply to Greg Kroah-HartmanFrom: Alexei Starovoitov <[email protected]>
[ Upstream commit 388e2c0b978339dee9b0a81a2e546f8979e021e2 ]
Similar to unsigned bounds propagation fix signed bounds. The 'Fixes' tag is a hint. There is no security bug here. The verifier was too conservative.
--- kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +1 -1
@@ -1397,7 +1397,7 @@ static void __reg_combine_32_into_64(struct bpf_reg_state *reg)static bool __reg64_bound_s32 (s64 a) { -return a >S32_MIN && a <S32_MAX ; +return a >=S32_MIN && a <=S32_MAX ; }static bool __reg64_bound_u32 (u64 a)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 549/849 of: unittest: fix EXPECT text for gpio hog errors
In reply to Greg Kroah-HartmanFrom: Frank Rowand <[email protected]>
[ Upstream commit e85860e5bc077865a04f0a88d0b0335d3200484a ]
The console message text for gpio hog errors does not match what unittest expects.
--- drivers/of/unittest.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/of/unittest.c +8 -8
@@ -1688,19 +1688,19 @@ static void __init of_unittest_overlay_gpio(void)*/ EXPECT_BEGIN (KERN_INFO , -"GPIO line <<int>> (line-B-input) hogged as input\n" ); +"gpio-<<int>> (line-B-input): hogged as input\n" );EXPECT_BEGIN (KERN_INFO , -"GPIO line <<int>> (line-A-input) hogged as input\n" ); +"gpio-<<int>> (line-A-input): hogged as input\n" ); ret =platform_driver_register (&unittest_gpio_driver);if (unittest (ret ==0 ,"could not register unittest gpio driver\n" ))return ;EXPECT_END (KERN_INFO , -"GPIO line <<int>> (line-A-input) hogged as input\n" ); +"gpio-<<int>> (line-A-input): hogged as input\n" );EXPECT_END (KERN_INFO , -"GPIO line <<int>> (line-B-input) hogged as input\n" ); +"gpio-<<int>> (line-B-input): hogged as input\n" );unittest (probe_pass_count +2 == unittest_gpio_probe_pass_count,"unittest_gpio_probe() failed or not called\n" );
@@ -1727,7 +1727,7 @@ static void __init of_unittest_overlay_gpio(void) chip_request_count = unittest_gpio_chip_request_count;EXPECT_BEGIN (KERN_INFO , -"GPIO line <<int>> (line-D-input) hogged as input\n" ); +"gpio-<<int>> (line-D-input): hogged as input\n" );/* overlay_gpio_03 contains gpio node and child gpio hog node */
@@ -1735,7 +1735,7 @@ static void __init of_unittest_overlay_gpio(void) "Adding overlay 'overlay_gpio_03' failed\n");EXPECT_END (KERN_INFO , -"GPIO line <<int>> (line-D-input) hogged as input\n" ); +"gpio-<<int>> (line-D-input): hogged as input\n" );unittest (probe_pass_count +1 == unittest_gpio_probe_pass_count,"unittest_gpio_probe() failed or not called\n" );
@@ -1774,7 +1774,7 @@ static void __init of_unittest_overlay_gpio(void)*/ EXPECT_BEGIN (KERN_INFO , -"GPIO line <<int>> (line-C-input) hogged as input\n" ); +"gpio-<<int>> (line-C-input): hogged as input\n" );/* overlay_gpio_04b contains child gpio hog node */
@@ -1782,7 +1782,7 @@ static void __init of_unittest_overlay_gpio(void) "Adding overlay 'overlay_gpio_04b' failed\n");EXPECT_END (KERN_INFO , -"GPIO line <<int>> (line-C-input) hogged as input\n" ); +"gpio-<<int>> (line-C-input): hogged as input\n" ); unittest(chip_request_count + 1 == unittest_gpio_chip_request_count, "unittest_gpio_chip_request() called %d times (expected 1 time)\n",
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 550/849 arm64: dts: meson: sm1: add Ethernet PHY reset line for ODROID-C4/HC4
In reply to Greg Kroah-HartmanFrom: Dongjin Kim <[email protected]>
[ Upstream commit 9d02214f8332d5dbbcce3d6c5c915e54d43a0c46 ]
This patch is to fix an issue that the ethernet link doesn't come up when using ip link set down/up:
[ 11.428114] meson8b-dwmac ff3f0000.ethernet eth0: Link is Down [ 14.428595] meson8b-dwmac ff3f0000.ethernet eth0: PHY [0.0:00] driver [RTL8211F Gigabit Ethernet] (irq=31) [ 14.428610] meson8b-dwmac ff3f0000.ethernet: Failed to reset the dma [ 14.428974] meson8b-dwmac ff3f0000.ethernet eth0: stmmac_hw_setup: DMA engine initialization failed [ 14.711185] meson8b-dwmac ff3f0000.ethernet eth0: stmmac_open: Hw setup failed
This fix refers to two commits applied for ODROID-N2 (G12B).
commit 658e4129bb81 ("arm64: dts: meson: g12b: odroid-n2: add the Ethernet PHY reset line")
commit 1c7412530d5d0 ("arm64: dts: meson: g12b: odroid-n2: fix PHY deassert timing requirements")--- arch/arm64/boot/dts/amlogic/meson-sm1-odroid.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/amlogic/meson-sm1-odroid.dtsi +4 -0
@@ -263,6 +263,10 @@ reg = <0>; max-speed = <1000>; + reset-assert-us = <10000>; + reset-deassert-us = <80000>; + reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>; + interrupt-parent = <&gpio_intc>; /* MAC_INTR on GPIOZ_14 */ interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 551/849 iio: st_sensors: disable regulators after device unregistration
In reply to Greg Kroah-HartmanFrom: Alexandru Ardelean <[email protected]>
[ Upstream commit 9f0b3e0cc0c88618aa9e5cecef747b1337ae0a5d ]
Up until commit ea7e586bdd331 ("iio: st_sensors: move regulator retrieveal to core") only the ST pressure driver seems to have had any regulator disable. After that commit, the regulator handling was moved into the common st_sensors logic.
In all instances of this regulator handling, the regulators were disabled before unregistering the IIO device.
This can cause issues where the device would be powered down and still be available to userspace, allowing it to send invalid/garbage data.
This change moves the st_sensors_power_disable() after the common probe functions. These common probe functions also handle unregistering the IIO device.
--- drivers/iio/accel/st_accel_i2c.c | 4 ++-- drivers/iio/accel/st_accel_spi.c | 4 ++-- drivers/iio/gyro/st_gyro_i2c.c | 4 ++-- drivers/iio/gyro/st_gyro_spi.c | 4 ++-- drivers/iio/magnetometer/st_magn_i2c.c | 4 ++-- drivers/iio/magnetometer/st_magn_spi.c | 4 ++-- drivers/iio/pressure/st_pressure_i2c.c | 4 ++-- drivers/iio/pressure/st_pressure_spi.c | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-)
drivers/iio/accel/st_accel_i2c.c +2 -2
@@ -194,10 +194,10 @@ static int st_accel_i2c_remove(struct i2c_client *client) {struct iio_dev *indio_dev =i2c_get_clientdata (client); -st_sensors_power_disable (indio_dev); -st_accel_common_remove (indio_dev); +st_sensors_power_disable (indio_dev); +return 0 ; }
drivers/iio/accel/st_accel_spi.c +2 -2
@@ -143,10 +143,10 @@ static int st_accel_spi_remove(struct spi_device *spi) {struct iio_dev *indio_dev =spi_get_drvdata (spi); -st_sensors_power_disable (indio_dev); -st_accel_common_remove (indio_dev); +st_sensors_power_disable (indio_dev); +return 0 ; }
drivers/iio/gyro/st_gyro_i2c.c +2 -2
@@ -106,10 +106,10 @@ static int st_gyro_i2c_remove(struct i2c_client *client) {struct iio_dev *indio_dev =i2c_get_clientdata (client); -st_sensors_power_disable (indio_dev); -st_gyro_common_remove (indio_dev); +st_sensors_power_disable (indio_dev); +return 0 ; }
drivers/iio/gyro/st_gyro_spi.c +2 -2
@@ -110,10 +110,10 @@ static int st_gyro_spi_remove(struct spi_device *spi) {struct iio_dev *indio_dev =spi_get_drvdata (spi); -st_sensors_power_disable (indio_dev); -st_gyro_common_remove (indio_dev); +st_sensors_power_disable (indio_dev); +return 0 ; }
drivers/iio/magnetometer/st_magn_i2c.c +2 -2
@@ -102,10 +102,10 @@ static int st_magn_i2c_remove(struct i2c_client *client) {struct iio_dev *indio_dev =i2c_get_clientdata (client); -st_sensors_power_disable (indio_dev); -st_magn_common_remove (indio_dev); +st_sensors_power_disable (indio_dev); +return 0 ; }
drivers/iio/magnetometer/st_magn_spi.c +2 -2
@@ -96,10 +96,10 @@ static int st_magn_spi_remove(struct spi_device *spi) {struct iio_dev *indio_dev =spi_get_drvdata (spi); -st_sensors_power_disable (indio_dev); -st_magn_common_remove (indio_dev); +st_sensors_power_disable (indio_dev); +return 0 ; }
drivers/iio/pressure/st_pressure_i2c.c +2 -2
@@ -118,10 +118,10 @@ static int st_press_i2c_remove(struct i2c_client *client) {struct iio_dev *indio_dev =i2c_get_clientdata (client); -st_sensors_power_disable (indio_dev); -st_press_common_remove (indio_dev); +st_sensors_power_disable (indio_dev); +return 0 ; }
drivers/iio/pressure/st_pressure_spi.c +2 -2
@@ -102,10 +102,10 @@ static int st_press_spi_remove(struct spi_device *spi) {struct iio_dev *indio_dev =spi_get_drvdata (spi); -st_sensors_power_disable (indio_dev); -st_press_common_remove (indio_dev); +st_sensors_power_disable (indio_dev); +return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 552/849 RDMA/rxe: Fix wrong port_cap_flags
In reply to Greg Kroah-HartmanFrom: Junji Wei <[email protected]>
[ Upstream commit dcd3f985b20ffcc375f82ca0ca9f241c7025eb5e ]
The port->attr.port_cap_flags should be set to enum ib_port_capability_mask_bits in ib_mad.h, not RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP.
--- drivers/infiniband/sw/rxe/rxe_param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_param.h +1 -1
@@ -113,7 +113,7 @@ enum rxe_device_param {/* default/initial rxe port parameters */ enum rxe_port_param {RXE_PORT_GID_TBL_LEN =1024 , -RXE_PORT_PORT_CAP_FLAGS =RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP , +RXE_PORT_PORT_CAP_FLAGS =IB_PORT_CM_SUP ,RXE_PORT_MAX_MSG_SZ =0x800000 ,RXE_PORT_BAD_PKEY_CNTR =0 ,RXE_PORT_QKEY_VIOL_CNTR =0 ,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 553/849 ARM: dts: BCM5301X: Fix memory nodes names
In reply to Greg Kroah-HartmanFrom: Rafał Miłecki <[email protected]>
[ Upstream commit c5e1df3276d7a500678da9453be31a66ad115150 ]
Thix fixes:arch/arm/boot/dts/bcm4708-netgear-r6250.dt.yaml: /: memory: False schema does not allow {'device_type': ['memory'], 'reg': [[0, 134217728], [2281701376, 134217728]]} arch/arm/boot/dts/bcm4709-asus-rt-ac87u.dt.yaml: /: memory: False schema does not allow {'device_type': ['memory'], 'reg': [[0, 134217728], [2281701376, 134217728]]} arch/arm/boot/dts/bcm4709-buffalo-wxr-1900dhp.dt.yaml: /: memory: False schema does not allow {'device_type': ['memory'], 'reg': [[0, 134217728], [2281701376, 402653184]]} arch/arm/boot/dts/bcm4709-linksys-ea9200.dt.yaml: /: memory: False schema does not allow {'device_type': ['memory'], 'reg': [[0, 134217728], [2281701376, 134217728]]} arch/arm/boot/dts/bcm4709-netgear-r7000.dt.yaml: /: memory: False schema does not allow {'device_type': ['memory'], 'reg': [[0, 134217728], [2281701376, 134217728]]} arch/arm/boot/dts/bcm4709-netgear-r8000.dt.yaml: /: memory: False schema does not allow {'device_type': ['memory'], 'reg': [[0, 134217728], [2281701376, 134217728]]} arch/arm/boot/dts/bcm4709-tplink-archer-c9-v1.dt.yaml: /: memory: False schema does not allow {'device_type': ['memory'], 'reg': [[0, 134217728]]} arch/arm/boot/dts/bcm47094-luxul-xwc-2000.dt.yaml: /: memory: False schema does not allow {'device_type': ['memory'], 'reg': [[0, 134217728], [2281701376, 402653184]]} arch/arm/boot/dts/bcm53016-meraki-mr32.dt.yaml: /: memory: False schema does not allow {'reg': [[0, 134217728]], 'device_type': ['memory']} arch/arm/boot/dts/bcm94708.dt.yaml: /: memory: False schema does not allow {'device_type': ['memory'], 'reg': [[0, 134217728]]} arch/arm/boot/dts/bcm94709.dt.yaml: /: memory: False schema does not allow {'device_type': ['memory'], 'reg': [[0, 134217728]]}
--- arch/arm/boot/dts/bcm4708-netgear-r6250.dts | 2 +- arch/arm/boot/dts/bcm4709-asus-rt-ac87u.dts | 2 +- arch/arm/boot/dts/bcm4709-buffalo-wxr-1900dhp.dts | 2 +- arch/arm/boot/dts/bcm4709-linksys-ea9200.dts | 2 +- arch/arm/boot/dts/bcm4709-netgear-r7000.dts | 2 +- arch/arm/boot/dts/bcm4709-netgear-r8000.dts | 2 +- arch/arm/boot/dts/bcm4709-tplink-archer-c9-v1.dts | 2 +- arch/arm/boot/dts/bcm47094-luxul-xwc-2000.dts | 2 +- arch/arm/boot/dts/bcm53016-meraki-mr32.dts | 2 +- arch/arm/boot/dts/bcm94708.dts | 2 +- arch/arm/boot/dts/bcm94709.dts | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-)
arch/arm/boot/dts/bcm4708-netgear-r6250.dts +1 -1
@@ -20,7 +20,7 @@ bootargs = "console=ttyS0,115200 earlycon"; }; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x08000000>, <0x88000000 0x08000000>;
arch/arm/boot/dts/bcm4709-asus-rt-ac87u.dts +1 -1
@@ -19,7 +19,7 @@ bootargs = "console=ttyS0,115200"; }; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x08000000>, <0x88000000 0x08000000>;
arch/arm/boot/dts/bcm4709-buffalo-wxr-1900dhp.dts +1 -1
@@ -19,7 +19,7 @@ bootargs = "console=ttyS0,115200"; }; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x08000000>, <0x88000000 0x18000000>;
arch/arm/boot/dts/bcm4709-linksys-ea9200.dts +1 -1
@@ -16,7 +16,7 @@ bootargs = "console=ttyS0,115200"; }; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x08000000>, <0x88000000 0x08000000>;
arch/arm/boot/dts/bcm4709-netgear-r7000.dts +1 -1
@@ -19,7 +19,7 @@ bootargs = "console=ttyS0,115200"; }; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x08000000>, <0x88000000 0x08000000>;
arch/arm/boot/dts/bcm4709-netgear-r8000.dts +1 -1
@@ -30,7 +30,7 @@ bootargs = "console=ttyS0,115200"; }; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x08000000>, <0x88000000 0x08000000>;
arch/arm/boot/dts/bcm4709-tplink-archer-c9-v1.dts +1 -1
@@ -15,7 +15,7 @@ bootargs = "console=ttyS0,115200 earlycon"; }; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x08000000>; };
arch/arm/boot/dts/bcm47094-luxul-xwc-2000.dts +1 -1
@@ -16,7 +16,7 @@ bootargs = "earlycon"; }; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x08000000>, <0x88000000 0x18000000>;
arch/arm/boot/dts/bcm53016-meraki-mr32.dts +1 -1
@@ -20,7 +20,7 @@ bootargs = " console=ttyS0,115200n8 earlycon"; }; - memory { + memory@0 { reg = <0x00000000 0x08000000>; device_type = "memory"; };
arch/arm/boot/dts/bcm94708.dts +1 -1
@@ -38,7 +38,7 @@ model = "NorthStar SVK (BCM94708)"; compatible = "brcm,bcm94708", "brcm,bcm4708"; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x08000000>; };
arch/arm/boot/dts/bcm94709.dts +1 -1
@@ -38,7 +38,7 @@ model = "NorthStar SVK (BCM94709)"; compatible = "brcm,bcm94709", "brcm,bcm4709", "brcm,bcm4708"; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x08000000>; };
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 554/849 arm64: dts: broadcom: bcm4908: Fix UART clock name
In reply to Greg Kroah-HartmanFrom: Rafał Miłecki <[email protected]>
[ Upstream commit 6c38c39ab2141f53786d73e706675e8819a3f2cb ]
According to the binding the correct clock name is "refclk".
--- arch/arm64/boot/dts/broadcom/bcm4908/bcm4908.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/broadcom/bcm4908/bcm4908.dtsi +1 -1
@@ -292,7 +292,7 @@ reg = <0x640 0x18>; interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>; clocks = <&periph_clk>; - clock-names = "periph"; + clock-names = "refclk"; status = "okay"; };
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 555/849 clk: mvebu: ap-cpu-clk: Fix a memory leak in error handling paths
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit af9617b419f77cf0b99702a7b2b0519da0d27715 ]
If we exit the for_each_of_cpu_node loop early, the reference on the current node must be decremented, otherwise there is a leak.
--- drivers/clk/mvebu/ap-cpu-clk.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/clk/mvebu/ap-cpu-clk.c +11 -3
@@ -256,12 +256,15 @@ static int ap_cpu_clock_probe(struct platform_device *pdev)int cpu, err; err =of_property_read_u32 (dn,"reg" , &cpu); -if (WARN_ON (err)) +if (WARN_ON (err)) { +of_node_put (dn);return err; + }/* If cpu2 or cpu3 is enabled */ if (cpu &APN806_CLUSTER_NUM_MASK ) { nclusters =2 ; +of_node_put (dn);break ; } }
@@ -288,8 +291,10 @@ static int ap_cpu_clock_probe(struct platform_device *pdev)int cpu, err; err =of_property_read_u32 (dn,"reg" , &cpu); -if (WARN_ON (err)) +if (WARN_ON (err)) { +of_node_put (dn);return err; + } cluster_index = cpu &APN806_CLUSTER_NUM_MASK ; cluster_index >>=APN806_CLUSTER_NUM_OFFSET ;
@@ -301,6 +306,7 @@ static int ap_cpu_clock_probe(struct platform_device *pdev) parent =of_clk_get (np, cluster_index);if (IS_ERR (parent)) {dev_err (dev,"Could not get the clock parent\n" ); +of_node_put (dn);return -EINVAL ; } parent_name =__clk_get_name (parent);
@@ -319,8 +325,10 @@ static int ap_cpu_clock_probe(struct platform_device *pdev) init.parent_names = &parent_name; ret =devm_clk_hw_register (dev, &ap_cpu_clk[cluster_index].hw); -if (ret) +if (ret) { +of_node_put (dn);return ret; + } ap_cpu_data->hws[cluster_index] = &ap_cpu_clk[cluster_index].hw; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 556/849 scsi: pm80xx: Fix lockup in outbound queue management
In reply to Greg Kroah-HartmanFrom: Ajish Koshy <[email protected]>
[ Upstream commit b27a40534ef76a22628a5c12f98ea489823a8ba5 ]
Commit 1f02beff224e ("scsi: pm80xx: Remove global lock from outbound queue processing") introduced a lock per outbound queue. Prior to that change the driver was using a global lock for all outbound queues.
While processing the I/O responses and events the driver takes the outbound queue spinlock and is supposed to release it in pm8001_ccb_task_free_done() before calling command done(). Since the older code was using a global lock, pm8001_ccb_task_free_done() was releasing the global spin lock. The change that split the lock per outbound queue did not consider this and pm8001_ccb_task_free_done() was still releasing the global lock.
--- drivers/scsi/pm8001/pm8001_sas.h | 3 +- drivers/scsi/pm8001/pm80xx_hwi.c | 53 ++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 11 deletions(-)
drivers/scsi/pm8001/pm8001_sas.h +1 -2
@@ -457,6 +457,7 @@ struct outbound_queue_table {__le32 producer_index;u32 consumer_idx;spinlock_t oq_lock; +unsigned long lock_flags; };struct pm8001_hba_memspace {void __iomem *memvirtaddr;
@@ -738,9 +739,7 @@ pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, {pm8001_ccb_task_free (pm8001_ha, task, ccb, ccb_idx);smp_mb ();/*in order to force CPU ordering*/ -spin_unlock (&pm8001_ha->lock); task->task_done (task); -spin_lock (&pm8001_ha->lock); }#endif
drivers/scsi/pm8001/pm80xx_hwi.c +44 -9
158 lines not on this page · raw message
Signature · 1 line
2.33.0