5.10.275-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 1498/1848 dmaengine: ste_dma40: Fix memcpy channel parsing
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit f2baf04a695de4f952513cb00ccf0338c6db2e00 ]
d40_of_probe() validates the memcpy-channels property against D40_MEMCPY_MAX_CHANS, but reads the property directly into a smaller global array. A long property can therefore overwrite adjacent data. The mutable global also lets a later DMA40 instance replace the memcpy channel mapping used for future allocations on an earlier instance.
Store the mapping in the per-device platform data, validate the property against that storage, and check the property read result. The property is required and d40_probe() always populates the platform data, so remove the obsolete global mapping and fallback.
--- drivers/dma/ste_dma40.c | 45 +++++++++++++---------------------------- 1 file changed, 14 insertions(+), 31 deletions(-)
drivers/dma/ste_dma40.c +14 -31
@@ -28,6 +28,8 @@#include "ste_dma40.h" #include "ste_dma40_ll.h" +#define D40_MEMCPY_MAX_CHANS 8 +/** * struct stedma40_platform_data - Configuration struct for the dma device. *
@@ -43,6 +45,7 @@* to use SoftLLI. * @use_esram_lcla: flag for mapping the lcla into esram region * @num_of_memcpy_chans: The number of channels reserved for memcpy. +* @memcpy_channels: The event lines used for memcpy. * @num_of_phy_chans: The number of physical channels implemented in HW. * 0 means reading the number of channels from DMA HW but this is only valid * for 'multiple of 4' channels, like 8.
@@ -53,6 +56,7 @@ struct stedma40_platform_data {int num_of_soft_lli_chans;bool use_esram_lcla;int num_of_memcpy_chans; +u32 memcpy_channels[D40_MEMCPY_MAX_CHANS ];int num_of_phy_chans; };
@@ -88,25 +92,6 @@ struct stedma40_platform_data {#define D40_ALLOC_PHY BIT(30)#define D40_ALLOC_LOG_FREE 0 -#define D40_MEMCPY_MAX_CHANS 8 - -/* Reserved event lines for memcpy only. */ -#define DB8500_DMA_MEMCPY_EV_0 51 -#define DB8500_DMA_MEMCPY_EV_1 56 -#define DB8500_DMA_MEMCPY_EV_2 57 -#define DB8500_DMA_MEMCPY_EV_3 58 -#define DB8500_DMA_MEMCPY_EV_4 59 -#define DB8500_DMA_MEMCPY_EV_5 60 - -static int dma40_memcpy_channels[] = { -DB8500_DMA_MEMCPY_EV_0 , -DB8500_DMA_MEMCPY_EV_1 , -DB8500_DMA_MEMCPY_EV_2 , -DB8500_DMA_MEMCPY_EV_3 , -DB8500_DMA_MEMCPY_EV_4 , -DB8500_DMA_MEMCPY_EV_5 , -}; -/* Default configuration for physical memcpy */ static const struct stedma40_chan_cfg dma40_memcpy_conf_phy = { .mode =STEDMA40_MODE_PHYSICAL ,
@@ -2026,7 +2011,8 @@ static int d40_config_memcpy(struct d40_chan *d40c)if (dma_has_cap (DMA_MEMCPY , cap) && !dma_has_cap (DMA_SLAVE , cap)) { d40c->dma_cfg = dma40_memcpy_conf_log; - d40c->dma_cfg.dev_type = dma40_memcpy_channels[d40c->chan.chan_id]; + d40c->dma_cfg.dev_type = + d40c->base->plat_data->memcpy_channels[d40c->chan.chan_id];d40_log_cfg (&d40c->dma_cfg, &d40c->log_def.lcsp1, &d40c->log_def.lcsp3);
@@ -3247,12 +3233,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) num_phy_chans =min (num_phy_chans,STEDMA40_MAX_PHYS );/* The number of channels used for memcpy */ -if (plat_data->num_of_memcpy_chans) - num_memcpy_chans = plat_data->num_of_memcpy_chans; -else - num_memcpy_chans =ARRAY_SIZE (dma40_memcpy_channels); - - num_memcpy_chans =min (num_memcpy_chans,D40_MEMCPY_MAX_CHANS ); + num_memcpy_chans = plat_data->num_of_memcpy_chans; num_log_chans = num_phy_chans *D40_MAX_LOG_CHAN_PER_PHY ; dev_info(dev,
@@ -3499,6 +3480,7 @@ static int __init d40_of_probe(struct device *dev,struct stedma40_platform_data *pdata;int num_phy =0 , num_memcpy =0 , num_disabled =0 ;const __be32 *list; +int ret; pdata =devm_kzalloc (dev,sizeof (*pdata),GFP_KERNEL );if (!pdata)
@@ -3512,18 +3494,19 @@ static int __init d40_of_probe(struct device *dev, list =of_get_property (np,"memcpy-channels" , &num_memcpy); num_memcpy /=sizeof (*list); -if (num_memcpy >D40_MEMCPY_MAX_CHANS || num_memcpy <=0 ) { +if (num_memcpy >ARRAY_SIZE (pdata->memcpy_channels) || + num_memcpy <=0 ) {d40_err (dev,"Invalid number of memcpy channels specified (%d)\n" , num_memcpy);return -EINVAL ; } + ret =of_property_read_u32_array (np,"memcpy-channels" , + pdata->memcpy_channels, num_memcpy); +if (ret) +return ret; pdata->num_of_memcpy_chans = num_memcpy; -of_property_read_u32_array (np,"memcpy-channels" , - dma40_memcpy_channels, - num_memcpy); - list =of_get_property (np,"disabled-channels" , &num_disabled); num_disabled /=sizeof (*list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1499/1848 dmaengine: ste_dma40: Validate disabled channel indexes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit c96e9f056095825b5f8d4a11f4107fc174892f92 ]
d40_of_probe() checks how many entries disabled-channels contains, but not the channel numbers themselves. d40_phy_res_init() later uses every value as an index into base->phy_res, whose size is the number of channels found in this DMA40 instance. An out-of-range value can therefore write beyond the allocation.
Validate each disabled channel against the detected hardware channel count before allocating and initializing the channel resources.
--- drivers/dma/ste_dma40.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/dma/ste_dma40.c +9 -0
@@ -3232,6 +3232,15 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) num_phy_chans =min (num_phy_chans,STEDMA40_MAX_PHYS ); +for (i =0 ; plat_data->disabled_channels[i] !=-1 ; i++) { +int chan = plat_data->disabled_channels[i]; + +if (chan <0 || chan >= num_phy_chans) { +dev_err (dev,"Invalid disabled channel %d\n" , chan); +return -EINVAL ; + } + } +/* The number of channels used for memcpy */ num_memcpy_chans = plat_data->num_of_memcpy_chans; num_log_chans = num_phy_chans *D40_MAX_LOG_CHAN_PER_PHY ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1500/1848 dmaengine: ste_dma40: Validate DMA specifier length
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 9f1064ebe17cf3ab65ac6eb166398e02678aea33 ]
The DMA40 binding requires three cells, but d40_xlate() reads args[0], args[1], and args[2] without checking args_count. A malformed provider node can specify fewer cells, leaving some of these values uninitialized when the OF DMA core invokes the translation callback.
Reject specifiers that do not contain exactly three cells before reading the argument array.
--- drivers/dma/ste_dma40.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/dma/ste_dma40.c +3 -0
@@ -2398,6 +2398,9 @@ static struct dma_chan *d40_xlate(struct of_phandle_args *dma_spec,dma_cap_mask_t cap;u32 flags; +if (dma_spec->args_count !=3 ) +return NULL ; +memset (&cfg,0 ,sizeof (struct stedma40_chan_cfg ));dma_cap_zero (cap);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1501/1848 dmaengine: ste_dma40: Reject direction changes after allocation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 77ebc64f40717b8501793b5f5ee717a141e62e8e ]
Logical channel allocation uses the configured direction to select the source or destination allocation mask, derive the logical channel number, and choose the LCPA location.
d40_set_runtime_config_write() nevertheless overwrites the configured direction when a transfer is prepared for the opposite direction. d40_free_dma() then clears the wrong allocation mask, leaking the original resource and potentially releasing one used by another client.
Reject directions that differ from the direction used during allocation and propagate runtime configuration errors to callers. Skip slave runtime configuration for memcpy transfers, which also use d40_prep_sg() but do not require it.
--- drivers/dma/ste_dma40.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/dma/ste_dma40.c +14 -15
@@ -2271,7 +2271,13 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,return NULL ; } -d40_set_runtime_config_write (dchan, &chan->slave_config, direction); +if (direction !=DMA_MEM_TO_MEM ) { + ret =d40_set_runtime_config_write (dchan, + &chan->slave_config, + direction); +if (ret) +return NULL ; + }spin_lock_irqsave (&chan->lock, flags);
@@ -2726,6 +2732,13 @@ static int d40_set_runtime_config_write(struct dma_chan *chan,return -EINVAL ; } +if (direction != cfg->dir) { +chan_err (d40c, +"transfer direction %d differs from allocated direction %d\n" , + direction, cfg->dir); +return -EINVAL ; + } + src_addr_width = config->src_addr_width; src_maxburst = config->src_maxburst; dst_addr_width = config->dst_addr_width;
@@ -2734,13 +2747,6 @@ static int d40_set_runtime_config_write(struct dma_chan *chan,if (direction ==DMA_DEV_TO_MEM ) { config_addr = config->src_addr; -if (cfg->dir !=DMA_DEV_TO_MEM ) -dev_dbg (d40c->base->dev, -"channel was not configured for peripheral " -"to memory transfer (%d) overriding\n" , - cfg->dir); - cfg->dir =DMA_DEV_TO_MEM ; -/* Configure the memory side */ if (dst_addr_width ==DMA_SLAVE_BUSWIDTH_UNDEFINED ) dst_addr_width = src_addr_width;
@@ -2750,13 +2756,6 @@ static int d40_set_runtime_config_write(struct dma_chan *chan, }else if (direction ==DMA_MEM_TO_DEV ) { config_addr = config->dst_addr; -if (cfg->dir !=DMA_MEM_TO_DEV ) -dev_dbg (d40c->base->dev, -"channel was not configured for memory " -"to peripheral transfer (%d) overriding\n" , - cfg->dir); - cfg->dir =DMA_MEM_TO_DEV ; -/* Configure the memory side */ if (src_addr_width ==DMA_SLAVE_BUSWIDTH_UNDEFINED ) src_addr_width = dst_addr_width;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1502/1848 dmaengine: ste_dma40: Fix logical channel bounds check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 57938e0c2a24f9f792fe9f611391ef6b58d1aa21 ]
d40_validate_conf() checks the raw dev_type against num_log_chans, but d40_allocate_channel() derives the lookup_log_chans index as either 2 * dev_type or 2 * dev_type + 1.
Validate the dev_type against the derived logical channel index limit so channel allocation cannot write past lookup_log_chans.
--- drivers/dma/ste_dma40.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/dma/ste_dma40.c +14 -3
@@ -1753,15 +1753,26 @@ static int d40_validate_conf(struct d40_chan *d40c, {int res =0 ;bool is_log = conf->mode ==STEDMA40_MODE_LOGICAL ; +bool invalid_dev_type = conf->dev_type <0 ;if (!conf->dir) {chan_err (d40c,"Invalid direction.\n" ); res = -EINVAL ; } -if ((is_log && conf->dev_type > d40c->base->num_log_chans) || - (!is_log && conf->dev_type > d40c->base->num_phy_chans) || - (conf->dev_type <0 )) { +if (!invalid_dev_type && is_log) { +int max_dev_type; + +if (conf->dir ==DMA_DEV_TO_MEM ) + max_dev_type =DIV_ROUND_UP (d40c->base->num_log_chans,2 ); +else + max_dev_type = d40c->base->num_log_chans /2 ; + + invalid_dev_type = conf->dev_type >= max_dev_type; + } + +if (invalid_dev_type || + (!is_log && conf->dev_type > d40c->base->num_phy_chans)) {chan_err (d40c,"Invalid device type (%d)\n" , conf->dev_type); res = -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1503/1848 dmaengine: ste_dma40: Fix event group bounds
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit e66a9dbe04c71249cfb2a544c9c25d1b3b761fba ]
The dev_type validation can allow values whose derived event group has no matching physical channel pair. d40_allocate_channel() then indexes phy_res with j + event_group * 2, and __d40_set_prio_rt() uses the same group to select priority and realtime registers.
The physical-mode validation also compares dev_type with the number of physical channels. However, dev_type identifies an event line: DB8500 has eight physical channels but 64 source and 64 destination event lines. The event group determines which physical channel pair can serve an event, so the physical channel count is not a valid dev_type limit.
Reject dev_type values outside the hardware event-group range, remove the incorrect physical channel count limit, and stop the physical-channel search before a partial final channel group can index past phy_res.
--- drivers/dma/ste_dma40.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/dma/ste_dma40.c +22 -4
@@ -81,6 +81,10 @@ struct stedma40_platform_data {#define D40_LCLA_LINK_PER_EVENT_GRP 128#define D40_LCLA_END D40_LCLA_LINK_PER_EVENT_GRP +/* Number of event groups per hardware register layout */ +#define D40_EVENT_GROUPS_V4A 4 +#define D40_EVENT_GROUPS_V4B 5 +/* Max number of logical channels per physical channel */ #define D40_MAX_LOG_CHAN_PER_PHY 32
@@ -509,6 +513,7 @@ struct d40_chan {* @high_prio_clear: the high priority clear register * @interrupt_en: the interrupt enable register * @interrupt_clear: the interrupt clear register +* @num_event_groups: number of supported event groups * @il: the pointer to struct d40_interrupt_lookup * @il_size: the size of d40_interrupt_lookup array * @init_reg: the pointer to the struct d40_reg_val
@@ -523,6 +528,7 @@ struct d40_gen_dmac {u32 high_prio_clear;u32 interrupt_en;u32 interrupt_clear; +u32 num_event_groups;struct d40_interrupt_lookup *il;u32 il_size;struct d40_reg_val *init_reg;
@@ -1755,6 +1761,11 @@ static int d40_validate_conf(struct d40_chan *d40c,bool is_log = conf->mode ==STEDMA40_MODE_LOGICAL ;bool invalid_dev_type = conf->dev_type <0 ; +if (!invalid_dev_type && +D40_TYPE_TO_GROUP (conf->dev_type) >= + d40c->base->gen_dmac.num_event_groups) + invalid_dev_type = true; +if (!conf->dir) {chan_err (d40c,"Invalid direction.\n" ); res = -EINVAL ;
@@ -1771,8 +1782,7 @@ static int d40_validate_conf(struct d40_chan *d40c, invalid_dev_type = conf->dev_type >= max_dev_type; } -if (invalid_dev_type || - (!is_log && conf->dev_type > d40c->base->num_phy_chans)) { +if (invalid_dev_type) {chan_err (d40c,"Invalid device type (%d)\n" , conf->dev_type); res = -EINVAL ; }
@@ -1937,8 +1947,12 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user) } } }else -for (j =0 ; j < d40c->base->num_phy_chans; j +=8 ) { +for (j =0 ; j < d40c->base->num_phy_chans; + j +=D40_GROUP_SIZE ) {int phy_num = j + event_group *2 ; +if (phy_num +1 >= num_phy_chans) +break ; +for (i = phy_num; i < phy_num +2 ; i++) { if (d40_alloc_mask_set(&phys[i], is_src,
@@ -1958,8 +1972,10 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)return -EINVAL ;/* Find logical channel */ -for (j =0 ; j < d40c->base->num_phy_chans; j +=8 ) { +for (j =0 ; j < d40c->base->num_phy_chans; j +=D40_GROUP_SIZE ) {int phy_num = j + event_group *2 ; +if (phy_num +1 >= num_phy_chans) +break ;if (d40c->dma_cfg.use_fixed_channel) { i = d40c->dma_cfg.phy_channel;
@@ -3280,6 +3296,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) base->log_chans = &base->phy_chans[num_phy_chans];if (base->plat_data->num_of_phy_chans ==14 ) { + base->gen_dmac.num_event_groups =D40_EVENT_GROUPS_V4B ; base->gen_dmac.backup = d40_backup_regs_v4b; base->gen_dmac.backup_size =BACKUP_REGS_SZ_V4B ; base->gen_dmac.interrupt_en =D40_DREG_CPCMIS ;
@@ -3293,6 +3310,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) base->gen_dmac.init_reg = dma_init_reg_v4b; base->gen_dmac.init_reg_size =ARRAY_SIZE (dma_init_reg_v4b); }else { + base->gen_dmac.num_event_groups =D40_EVENT_GROUPS_V4A ;if (base->rev >=3 ) { base->gen_dmac.backup = d40_backup_regs_v4a; base->gen_dmac.backup_size =BACKUP_REGS_SZ_V4A ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1504/1848 dmaengine: ste_dma40: Fix V4B event group mapping
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit b36f8fce7314fed53563c60e683ff86deb8a51ae ]
DMA40 physical resources are connected in pairs to event groups. The mapping repeats after each complete set of groups.
D40_GROUP_SIZE and D40_PHYS_TO_GROUP() encode the four-group V4A layout. On V4B, which has five groups, resources 8 and 9 are consequently offered both to event groups 0 and 4. The GCC clock bookkeeping also treats these resources as group 0 instead of group 4.
Derive the physical-resource stride and reverse mapping from the variant-specific number of event groups. This preserves the V4A mapping and gives V4B a ten-resource stride: resources 8 and 9 belong only to group 4, while resources 10 and 11 repeat group 0.
--- drivers/dma/ste_dma40.c | 47 ++++++++++++++++++++++++++------------ drivers/dma/ste_dma40_ll.h | 2 -- 2 files changed, 33 insertions(+), 16 deletions(-)
drivers/dma/ste_dma40.c +33 -14
@@ -84,6 +84,7 @@ struct stedma40_platform_data {/* Number of event groups per hardware register layout */ #define D40_EVENT_GROUPS_V4A 4#define D40_EVENT_GROUPS_V4B 5 +#define D40_PHYS_PER_EVENT_GROUP 2/* Max number of logical channels per physical channel */ #define D40_MAX_LOG_CHAN_PER_PHY 32
@@ -1899,6 +1900,12 @@ static bool d40_alloc_mask_free(struct d40_phy_res *phy, bool is_src,return is_free; } +static int d40_phy_to_group (struct d40_base *base,int phy) +{ +return (phy /D40_PHYS_PER_EVENT_GROUP ) % + base->gen_dmac.num_event_groups; +} +static int d40_allocate_channel (struct d40_chan *d40c,bool *first_phy_user) {int dev_type = d40c->dma_cfg.dev_type;
@@ -1909,11 +1916,14 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)int j;int log_num;int num_phy_chans; +int phy_group_stride;bool is_src;bool is_log = d40c->dma_cfg.mode ==STEDMA40_MODE_LOGICAL ; phys = d40c->base->phy_res; num_phy_chans = d40c->base->num_phy_chans; + phy_group_stride =D40_PHYS_PER_EVENT_GROUP * + d40c->base->gen_dmac.num_event_groups;if (d40c->dma_cfg.dir ==DMA_DEV_TO_MEM ) { log_num =2 * dev_type;
@@ -1947,13 +1957,18 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user) } } }else -for (j =0 ; j < d40c->base->num_phy_chans; - j +=D40_GROUP_SIZE ) { -int phy_num = j + event_group *2 ; -if (phy_num +1 >= num_phy_chans) +for (j =0 ; j < num_phy_chans; + j += phy_group_stride) { +int phy_num = j + event_group * +D40_PHYS_PER_EVENT_GROUP ; + +if (phy_num +D40_PHYS_PER_EVENT_GROUP > + num_phy_chans)break ; -for (i = phy_num; i < phy_num +2 ; i++) { +for (i = phy_num; + i < phy_num +D40_PHYS_PER_EVENT_GROUP ; + i++) { if (d40_alloc_mask_set(&phys[i], is_src, 0,
@@ -1972,9 +1987,10 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)return -EINVAL ;/* Find logical channel */ -for (j =0 ; j < d40c->base->num_phy_chans; j +=D40_GROUP_SIZE ) { -int phy_num = j + event_group *2 ; -if (phy_num +1 >= num_phy_chans) +for (j =0 ; j < num_phy_chans; j += phy_group_stride) { +int phy_num = j + event_group *D40_PHYS_PER_EVENT_GROUP ; + +if (phy_num +D40_PHYS_PER_EVENT_GROUP > num_phy_chans)break ;if (d40c->dma_cfg.use_fixed_channel) {
@@ -2001,14 +2017,17 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)* channels. */ if (is_src) { -for (i = phy_num; i < phy_num +2 ; i++) { +for (i = phy_num; + i < phy_num +D40_PHYS_PER_EVENT_GROUP ; + i++) {if (d40_alloc_mask_set (&phys[i], is_src, event_line, is_log, first_phy_user)) goto found_log; } }else { -for (i = phy_num +1 ; i >= phy_num; i--) { +for (i = phy_num +D40_PHYS_PER_EVENT_GROUP -1 ; + i >= phy_num; i--) {if (d40_alloc_mask_set (&phys[i], is_src, event_line, is_log, first_phy_user))
@@ -3119,9 +3138,9 @@ static int __init d40_phy_res_init(struct d40_base *base) base->phy_res[i].allocated_src =D40_ALLOC_PHY ; base->phy_res[i].allocated_dst =D40_ALLOC_PHY ; base->phy_res[i].reserved = true; - gcc |=D40_DREG_GCC_EVTGRP_ENA (D40_PHYS_TO_GROUP (i), + gcc |=D40_DREG_GCC_EVTGRP_ENA (d40_phy_to_group (base, i),D40_DREG_GCC_SRC ); - gcc |=D40_DREG_GCC_EVTGRP_ENA (D40_PHYS_TO_GROUP (i), + gcc |=D40_DREG_GCC_EVTGRP_ENA (d40_phy_to_group (base, i),D40_DREG_GCC_DST );
@@ -3141,9 +3160,9 @@ static int __init d40_phy_res_init(struct d40_base *base) base->phy_res[chan].allocated_src =D40_ALLOC_PHY ; base->phy_res[chan].allocated_dst =D40_ALLOC_PHY ; base->phy_res[chan].reserved = true; - gcc |=D40_DREG_GCC_EVTGRP_ENA (D40_PHYS_TO_GROUP (chan), + gcc |=D40_DREG_GCC_EVTGRP_ENA (d40_phy_to_group (base, chan),D40_DREG_GCC_SRC ); - gcc |=D40_DREG_GCC_EVTGRP_ENA (D40_PHYS_TO_GROUP (chan), + gcc |=D40_DREG_GCC_EVTGRP_ENA (d40_phy_to_group (base, chan),D40_DREG_GCC_DST ); num_phy_chans_avail--; }
drivers/dma/ste_dma40_ll.h +0 -2
@@ -16,8 +16,6 @@#define D40_TYPE_TO_GROUP (type) (type / 16)#define D40_TYPE_TO_EVENT (type) (type % 16) -#define D40_GROUP_SIZE 8 -#define D40_PHYS_TO_GROUP (phys) ((phys & (D40_GROUP_SIZE - 1)) / 2)/* Most bits of the CFG register are the same in log as in phy mode */ #define D40_SREG_CFG_MST_POS 15
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1505/1848 dmaengine: ste_dma40: Validate fixed physical channel indexes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 884e01160bc727509b4fdf04e763a86b936df464 ]
Fixed physical memcpy allocation uses dma_cfg.phy_channel directly as an index into phy_res when use_fixed_channel is set. d40_validate_conf() validates dev_type but not the fixed physical channel, allowing an invalid configuration to access memory outside the array.
Validate the fixed physical channel centrally before accepting the channel configuration.
--- drivers/dma/ste_dma40.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/dma/ste_dma40.c +8 -0
@@ -1788,6 +1788,14 @@ static int d40_validate_conf(struct d40_chan *d40c, res = -EINVAL ; } +if (conf->use_fixed_channel && + (conf->phy_channel <0 || + conf->phy_channel >= d40c->base->num_phy_chans)) { +chan_err (d40c,"Invalid physical channel (%d)\n" , + conf->phy_channel); + res = -EINVAL ; + } +if (conf->dir ==DMA_DEV_TO_DEV ) {/* * DMAC HW supports it. Will be added to this driver,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1506/1848 dmaengine: ste_dma40: fix typo in comment
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julia Lawall <[email protected]>
[ Upstream commit a71da24ce1f8f6844c6378ae394b5c4b31ff5725 ]
Spelling mistake (triple letters) in comment.
Detected with the help of Coccinelle.
Stable-dep-of: 0ac4a90c4805 ("dmaengine: ste_dma40: Validate memcpy configuration")
--- drivers/dma/ste_dma40.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ste_dma40.c +1 -1
@@ -2075,7 +2075,7 @@ static int d40_config_memcpy(struct d40_chan *d40c) dma_has_cap(DMA_SLAVE, cap)) { d40c->dma_cfg = dma40_memcpy_conf_phy; -/* Generate interrrupt at end of transfer or relink. */ +/* Generate interrupt at end of transfer or relink. */ d40c->dst_def_cfg |=BIT (D40_SREG_CFG_TIM_POS );/* Generate interrupt on error. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1507/1848 dmaengine: ste_dma40: Validate memcpy configuration
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 0ac4a90c4805b41013044fdefff051ae59a54302 ]
d40_config_memcpy() builds a default memcpy configuration without passing it through d40_validate_conf(). A dev_type supplied through the memcpy-channels device tree property can therefore bypass the bounds checks added for client configurations.
The generic DMA direction enum assigns zero to DMA_MEM_TO_MEM, unlike DMA40's old private enum. Allow memory-to-memory directions in the validator so checking the generated configuration does not reject all memcpy channels.
Validate the generated memcpy configuration before deriving logical channel registers or allocating the channel.
--- drivers/dma/ste_dma40.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/dma/ste_dma40.c +11 -1
@@ -1767,7 +1767,8 @@ static int d40_validate_conf(struct d40_chan *d40c, d40c->base->gen_dmac.num_event_groups) invalid_dev_type = true; -if (!conf->dir) { +if (conf->dir !=DMA_MEM_TO_MEM && + !is_slave_direction (conf->dir)) {chan_err (d40c,"Invalid direction.\n" ); res = -EINVAL ; }
@@ -2062,12 +2063,17 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)static int d40_config_memcpy (struct d40_chan *d40c) {dma_cap_mask_t cap = d40c->chan.device->cap_mask; +int ret;if (dma_has_cap (DMA_MEMCPY , cap) && !dma_has_cap (DMA_SLAVE , cap)) { d40c->dma_cfg = dma40_memcpy_conf_log; d40c->dma_cfg.dev_type = d40c->base->plat_data->memcpy_channels[d40c->chan.chan_id]; + ret =d40_validate_conf (d40c, &d40c->dma_cfg); +if (ret) +return ret; +d40_log_cfg (&d40c->dma_cfg, &d40c->log_def.lcsp1, &d40c->log_def.lcsp3);
@@ -2075,6 +2081,10 @@ static int d40_config_memcpy(struct d40_chan *d40c) dma_has_cap(DMA_SLAVE, cap)) { d40c->dma_cfg = dma40_memcpy_conf_phy; + ret =d40_validate_conf (d40c, &d40c->dma_cfg); +if (ret) +return ret; +/* Generate interrupt at end of transfer or relink. */ d40c->dst_def_cfg |=BIT (D40_SREG_CFG_TIM_POS );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1508/1848 arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video engine
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit d7287d940f3cd8d5945009076058a8120281744b ]
The SRAM C region contains a partial alias to the VE SRAM already referenced by the video engine. To avoid access through this alias window, the region should also be claimed by the video engine.
Add a reference to the SRAM C region to the video engine node.
--- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +1 -1
@@ -161,7 +161,7 @@ video-codec@1c0e000 { clock-names = "ahb", "mod", "ram"; resets = <&ccu RST_BUS_VE>; interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; - allwinner,sram = <&ve_sram 1>; + allwinner,sram = <&ve_sram 1>, <&de2_sram 1>; iommus = <&iommu 3>; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1509/1848 arm64: dts: allwinner: sun50i-h6: Add missing IOMMU for video engine
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit 965a49fc413d996eba9bae2a3132f03f45a2ea1b ]
The video engine on the H6 actually has two IOMMU ports. The one already listed is simply named "VE" in the user manual. The missing one is named "VE_R" and is probably either read-only or used for reference frames. Either way, it should be listed.
Add a reference to the "VE_R" IOMMU port to the video engine node.
--- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +1 -1
@@ -162,7 +162,7 @@ video-codec@1c0e000 { resets = <&ccu RST_BUS_VE>; interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; allwinner,sram = <&ve_sram 1>, <&de2_sram 1>; - iommus = <&iommu 3>; + iommus = <&iommu 3>, <&iommu 1>; }; gpu: gpu@1800000 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1510/1848 sh: uaccess: Require offsettable operands for 64-bit user access
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fuchs <[email protected]>
[ Upstream commit 8b5dba9ea4a3f5ed994f03d6ca7686c49491b426 ]
The 64-bit __get_user_u64()/__put_user_u64() paths address the memory operand as %T2 (base+4). This base+4 requires an offsettable address, but "m" also allows the indexed mode @(R0,Rn) (e.g. for a variable- indexed array element), which has no displacement field for the +4. Depending on optimization this build fails with "invalid 'asm'" or an ICE in GCC's change_address_1.
Require an offsettable memory operand, allowing GCC to reload an unsuitable indexed address into an appropriate form.
--- arch/sh/include/asm/uaccess_32.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/sh/include/asm/uaccess_32.h +4 -4
@@ -92,7 +92,7 @@ __asm__ __volatile__( \ ".long 1b + 2, 3b\n\t" \ ".previous" \ :"=&r" (err), "=&r" (x) \ - :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); }) + :"o" (__m(addr)), "i" (-EFAULT), "0" (err)); })#else #define __get_user_u64 (x, addr, err) \ ({ \
@@ -116,7 +116,7 @@ __asm__ __volatile__( \ ".long 1b + 2, 3b\n\t" \ ".previous" \ :"=&r" (err), "=&r" (x) \ - :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); }) + :"o" (__m(addr)), "i" (-EFAULT), "0" (err)); })#endif #define __put_user_size (x,ptr,size,retval) \
@@ -196,7 +196,7 @@ __asm__ __volatile__( \ ".long 1b, 3b\n\t" \ ".previous" \ : "=r" (retval) \ - : "r" (val), "m" (__m(addr)), "i" (-EFAULT), "0" (retval) \ + : "r" (val), "o" (__m(addr)), "i" (-EFAULT), "0" (retval) \ : "memory"); }) #else #define __put_user_u64(val,addr,retval) \
@@ -218,7 +218,7 @@ __asm__ __volatile__( \ ".long 1b, 3b\n\t" \ ".previous" \ : "=r" (retval) \ - : "r" (val), "m" (__m(addr)), "i" (-EFAULT), "0" (retval) \ + : "r" (val), "o" (__m(addr)), "i" (-EFAULT), "0" (retval) \ : "memory"); }) #endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1511/1848 sh: defconfig: Enable the current M66592 UDC symbol
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 9b65dcd94222c37febf98127b1ac5452c94a16d0 ]
The M66592 UDC provider is built under CONFIG_USB_M66592. Several SuperH defconfigs still enable the removed CONFIG_USB_GADGET_M66592 symbol.
Replace the stale entries with the current provider symbol.
--- arch/sh/configs/migor_defconfig | 2 +- arch/sh/configs/sdk7786_defconfig | 2 +- arch/sh/configs/shx3_defconfig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/sh/configs/migor_defconfig +1 -1
@@ -76,7 +76,7 @@ CONFIG_LOGO=y # CONFIG_LOGO_SUPERH_MONO is not set # CONFIG_LOGO_SUPERH_CLUT224 is not set CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_M66592=y +CONFIG_USB_M66592=y CONFIG_USB_G_SERIAL=m CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_RS5C372=y
arch/sh/configs/sdk7786_defconfig +1 -1
@@ -156,7 +156,7 @@ CONFIG_USB_MON=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_STORAGE=y CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_M66592=y +CONFIG_USB_M66592=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_MAX6900=y CONFIG_RTC_DRV_SH=y
arch/sh/configs/shx3_defconfig +1 -1
@@ -81,7 +81,7 @@ CONFIG_USB=y CONFIG_USB_MON=y CONFIG_USB_R8A66597_HCD=m CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_M66592=y +CONFIG_USB_M66592=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_SH=y CONFIG_UIO=m
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1512/1848 spi: spi-sun4i: sun4i_spi_transfer_one(): fix transfers for SUN4I_FIFO_DEPTH
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit f3ce7a3ca82bd9cda9ef61250aeff65fe6b44809 ]
In commit 6d9fe44bd73d ("spi: sun4i: fix FIFO limit"), the TX-FIFO is filled max to SUN4I_FIFO_DEPTH - 1 (= 63) bytes to work around timeouts observed on A10s SoCs.
Commit 196737912da5 ("spi: sun4i: Allow transfers larger than FIFO size") added support for transfers larger than the FIFO size. But this commit only enabled the TX-FIFO empty interrupt for transfers larger than the FIFO (= 64) bytes.
This breaks transfers with exactly 64 bytes: the TX-FIFO is only filled with 63 bytes but the interrupt to refill the FIFO is not triggered. The problem can be reproduced with the following command:
| spidev_test -D /dev/spidev0.1 -S 64 -s 20000000 -I 1 | | [ 7797.548745] spi_master spi0: spi0.1: timeout transferring 64 bytes@20000000Hz for 110(100)ms | [ 7797.557237] spidev spi0.1: SPI transfer failed: -110 | [ 7797.562308] spi_master spi0: failed to transfer one message from queue | [ 7797.568936] spi_master spi0: noqueue transfer failed
To fix the problem enable the TX-FIFO interrupt if the total TX length is larger than SUN4I_FIFO_DEPTH - 1 (= 63) bytes.
--- drivers/spi/spi-sun4i.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-sun4i.c +1 -1
@@ -321,7 +321,7 @@ static int sun4i_spi_transfer_one(struct spi_master *master,sun4i_spi_enable_interrupt (sspi,SUN4I_INT_CTL_TC |SUN4I_INT_CTL_RF_F34 );/* Only enable Tx FIFO interrupt if we really need it */ -if (tx_len >SUN4I_FIFO_DEPTH ) +if (tx_len >SUN4I_FIFO_DEPTH -1 )sun4i_spi_enable_interrupt (sspi,SUN4I_INT_CTL_TF_E34 );/* Start the transfer */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1513/1848 spi: spi-sun4i: sun4i_spi_fill_fifo(): always apply A10 FIFO fill level workaround
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit ee109e2bbea0986f6ad34bfbcba90fce36f17538 ]
In commit 6d9fe44bd73d ("spi: sun4i: fix FIFO limit"), the TX FIFO is filled max to SUN4I_FIFO_DEPTH - 1 (= 63) bytes to work around timeouts observed on A10s SoCs.
Commit 196737912da5 ("spi: sun4i: Allow transfers larger than FIFO size") added support for transfers larger than the FIFO size. This commit did not consider the A10 workaround (limit the TX FIFO fill size to SUN4I_FIFO_DEPTH - 1 (= 63) bytes) for refilling the TX FIFO in the IRQ handler.
To apply the workaround independent from where sun4i_spi_fill_fifo() is called, remove the length argument from the function and directly take the max fill level of SUN4I_FIFO_DEPTH - 1 into account when calculating the free space in the FIFO.
Due to the lack of HW this patch has not been tested on an A10 SoC, but on an A20 SoC. It was not possible to reproduce the timeout on the A20.
--- drivers/spi/spi-sun4i.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/spi/spi-sun4i.c +13 -11
@@ -142,15 +142,21 @@ static inline void sun4i_spi_drain_fifo(struct sun4i_spi *sspi, int len) } } -static inline void sun4i_spi_fill_fifo (struct sun4i_spi *sspi,int len) +static inline void sun4i_spi_fill_fifo (struct sun4i_spi *sspi) {u32 cnt; +int len;u8 byte; -/* See how much data we can fit */ - cnt =SUN4I_FIFO_DEPTH -sun4i_spi_get_tx_fifo_count (sspi); +/* +* See how much data we can fit +* +* Filling the FIFO fully causes timeout for some reason +* at least on spi2 on A10s +*/ + cnt =SUN4I_FIFO_DEPTH -1 -sun4i_spi_get_tx_fifo_count (sspi); - len =min3 (len, (int )cnt, sspi->len); + len =min_t (int, cnt, sspi->len);while (len--) { byte = sspi->tx_buf ? *sspi->tx_buf++ :0 ;
@@ -310,12 +316,8 @@ static int sun4i_spi_transfer_one(struct spi_master *master,sun4i_spi_write (sspi,SUN4I_BURST_CNT_REG ,SUN4I_BURST_CNT (tfr->len));sun4i_spi_write (sspi,SUN4I_XMIT_CNT_REG ,SUN4I_XMIT_CNT (tx_len)); -/* -* Fill the TX FIFO -* Filling the FIFO fully causes timeout for some reason -* at least on spi2 on A10s -*/ -sun4i_spi_fill_fifo (sspi,SUN4I_FIFO_DEPTH -1 ); +/* Fill the TX FIFO */ +sun4i_spi_fill_fifo (sspi);/* Enable the interrupts */ sun4i_spi_enable_interrupt(sspi, SUN4I_INT_CTL_TC |
@@ -372,7 +374,7 @@ static irqreturn_t sun4i_spi_handler(int irq, void *dev_id)/* Transmit FIFO 3/4 empty */ if (status &SUN4I_INT_CTL_TF_E34 ) { -sun4i_spi_fill_fifo (sspi,SUN4I_FIFO_DEPTH ); +sun4i_spi_fill_fifo (sspi);if (!sspi->len)/* nothing left to transmit */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1514/1848 nilfs2: fix link count underflow when removing corrupted directory
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 814f5a53b4724798795b15690ff3d1c1d9ac1eb6 ]
When removing an empty directory with a corrupted link count (e.g., i_nlink is 1 due to filesystem corruption), nilfs_rmdir() calls drop_nlink() via nilfs_do_unlink() and then calls drop_nlink() again on the directory inode. This second call causes an underflow of i_nlink, triggering a kernel WARNING in drop_nlink().
Fix this issue by using clear_nlink() instead of drop_nlink() to finalize the link count reset for the target directory in nilfs_rmdir(). Additionally, log a warning message when i_nlink is not 2 before removing an empty directory to notify about the link count inconsistency.
--- fs/nilfs2/namei.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/nilfs2/namei.c +7 -1
@@ -339,10 +339,16 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry) err = -ENOTEMPTY ;if (nilfs_empty_dir (inode)) { +if (unlikely (inode->i_nlink !=2 )) +nilfs_warn (dir->i_sb, +"inconsistent empty directory link count %u (ino=%llu)" , + inode->i_nlink, + (unsigned long long )inode->i_ino); + err =nilfs_do_unlink (dir, dentry);if (!err) { inode->i_size =0 ; -drop_nlink (inode); +clear_nlink (inode);nilfs_mark_inode_dirty (inode);drop_nlink (dir);nilfs_mark_inode_dirty (dir);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1515/1848 checkpatch: skip CamelCase cache for --no-tree without root
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Vorel <[email protected]>
[ Upstream commit d41ebc7f9e2cc80cb57139c05e71415a79582ab0 ]
Running outside tree (--no-tree) without git root (--root DIR) is not doable because we have no include/ directory which could be cached. But 3445686af721 expected that we are always in Linux tree (w/a git). But --no-tree does not require --root. Therefore skip whole caching in that case.
This fixes perl and find errors when running checkpatch.pl *with* --no-tree --strict and *without* --root:
No structs that should be const will be found - file 'scripts/const_structs.checkpatch': No such file or directory Use of uninitialized value $root in concatenation (.) or string at scripts/checkpatch.pl line 1213.
find: `/include': No such file or directory
--- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+)
scripts/checkpatch.pl +2 -0
@@ -933,6 +933,8 @@ sub seed_camelcase_includes { my $git_last_include_commit = `${git_command} log --no-merges --pretty=format:"%h%n" -1 -- include`; chomp $git_last_include_commit; $camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit"; + } elsif (not defined $root) { + return; } else { my $last_mod_date = 0; $files = `find $root/include -name "*.h"`;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1516/1848 ocfs2: fix deadlock in inline-data truncate transactions
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit c204bf5ac3eeb66648904d0374d6f7b84d843aac ]
Updating an inode xattr can cause an ABBA deadlock with inline file truncation:
ocfs2_truncate_file()
down_write(&oi->ip_alloc_sem)
ocfs2_truncate_inline()
ocfs2_start_trans() ocfs2_xattr_set()
ocfs2_start_trans()
ocfs2_xattr_ibody_set()
down_write(&oi->ip_alloc_sem)The xattr set path starts the merged transaction before the inode-body xattr helper acquires ip_alloc_sem, reversing the ip_alloc_sem -> transaction order used by the allocation and truncate paths. The transaction merge in commit 85db90e77806 ("ocfs2/xattr: Merge xattr set transaction.") introduced this ordering.
Fix it by acquiring ip_alloc_sem once in ocfs2_xattr_set(), before xattr preparation, allocation reservations and ocfs2_start_trans(), and removing the per-helper acquisition from ocfs2_xattr_ibody_find(), ocfs2_xattr_ibody_set() and ocfs2_xattr_create_index_block(). These helpers now assert via lockdep that the caller holds ip_alloc_sem.
ocfs2_xattr_set_handle(), which only sets initial ACL or security xattrs on unpublished inodes inside the create transaction, takes ip_alloc_sem under a dedicated lockdep subclass so that the assertions hold without creating a transaction -> ip_alloc_sem cycle against the ip_alloc_sem -> transaction order. The inode is unpublished, so the acquisition can never contend.
This keeps the established ip_alloc_sem -> transaction order and makes the locking unconditional, so lockdep can verify a single plain ordering instead of conditional acquisitions.
--- fs/ocfs2/xattr.c | 79 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 26 deletions(-)
fs/ocfs2/xattr.c +53 -26
@@ -2685,6 +2685,9 @@ static int ocfs2_xattr_has_space_inline(struct inode *inode,* * Find extended attribute in inode block and * fill search info into struct ocfs2_xattr_search. +* +* The inline free-space check races with truncate and allocation, so +* callers must hold ip_alloc_sem for writing. */ static int ocfs2_xattr_ibody_find(struct inode *inode, int name_index,
@@ -2696,13 +2699,13 @@ static int ocfs2_xattr_ibody_find(struct inode *inode,int ret;int has_space =0 ; +lockdep_assert_held_write (&oi->ip_alloc_sem); +if (inode->i_sb->s_blocksize ==OCFS2_MIN_BLOCKSIZE )return 0 ;if (!(oi->ip_dyn_features &OCFS2_INLINE_XATTR_FL )) { -down_read (&oi->ip_alloc_sem); has_space =ocfs2_xattr_has_space_inline (inode, di); -up_read (&oi->ip_alloc_sem);if (!has_space)return 0 ; }
@@ -2781,6 +2784,7 @@ static int ocfs2_xattr_ibody_init(struct inode *inode,* * Set, replace or remove an extended attribute into inode block. * +* Callers must hold ip_alloc_sem for writing. */ static int ocfs2_xattr_ibody_set(struct inode *inode, struct ocfs2_xattr_info *xi,
@@ -2791,16 +2795,17 @@ static int ocfs2_xattr_ibody_set(struct inode *inode,struct ocfs2_inode_info *oi =OCFS2_I (inode);struct ocfs2_xa_loc loc; +lockdep_assert_held_write (&oi->ip_alloc_sem); +if (inode->i_sb->s_blocksize ==OCFS2_MIN_BLOCKSIZE )return -ENOSPC ; -down_write (&oi->ip_alloc_sem);if (!(oi->ip_dyn_features &OCFS2_INLINE_XATTR_FL )) { ret =ocfs2_xattr_ibody_init (inode, xs->inode_bh, ctxt);if (ret) {if (ret != -ENOSPC )mlog_errno (ret); - goto out; +return ret; } }
@@ -2810,13 +2815,10 @@ static int ocfs2_xattr_ibody_set(struct inode *inode,if (ret) {if (ret != -ENOSPC )mlog_errno (ret); - goto out; +return ret; } xs->here = loc.xl_entry; -out: -up_write (&oi->ip_alloc_sem); -return ret; }
@@ -3474,6 +3476,18 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,return ret; } +/* +* ip_alloc_sem subclass for inodes being initialized before publication. +* ocfs2_xattr_set_handle() runs inside the create transaction, so taking +* ip_alloc_sem there adds a transaction -> ip_alloc_sem order that would +* form a lockdep cycle with the ip_alloc_sem -> transaction order used +* elsewhere, if not for this separate subclass. The inode is unpublished +* so the acquisition can never contend. +*/ +enum { +OCFS2_IP_ALLOC_SEM_UNPUBLISHED =1 , +}; +/* * This helper is only for setting initial ACL or security xattrs on an inode * that is still unpublished, unhashed, and unattached to a dentry.
@@ -3535,6 +3549,13 @@ int ocfs2_xattr_set_handle(handle_t *handle, xis.inode_bh = xbs.inode_bh = di_bh; di = (struct ocfs2_dinode *)di_bh->b_data; +/* +* The inode is unpublished and cannot contend, but take the +* semaphore anyway so the helpers' lockdep assertions hold. +*/ +down_write_nested (&OCFS2_I (inode)->ip_alloc_sem, +OCFS2_IP_ALLOC_SEM_UNPUBLISHED ); + ret =ocfs2_xattr_ibody_find (inode, name_index, name, &xis);if (ret) goto cleanup;
@@ -3547,6 +3568,7 @@ int ocfs2_xattr_set_handle(handle_t *handle, ret =__ocfs2_xattr_set_handle (inode, di, &xi, &xis, &xbs, &ctxt); cleanup: +up_write (&OCFS2_I (inode)->ip_alloc_sem);brelse (xbs.xattr_bh);ocfs2_xattr_bucket_free (xbs.bucket);
@@ -3615,30 +3637,38 @@ int ocfs2_xattr_set(struct inode *inode, di = (struct ocfs2_dinode *)di_bh->b_data;down_write (&OCFS2_I (inode)->ip_xattr_sem); +/* +* The allocation and truncate paths take ip_alloc_sem before +* starting a transaction, so take it here before xattr +* preparation, allocation reservations and ocfs2_start_trans() +* to keep that order. The xattr helpers below no longer take +* it themselves. +*/ +down_write (&OCFS2_I (inode)->ip_alloc_sem);/* * Scan inode and external block to find the same name * extended attribute and collect search information. */ ret =ocfs2_xattr_ibody_find (inode, name_index, name, &xis);if (ret) - goto cleanup; + goto out_free_ac;if (xis.not_found) { ret =ocfs2_xattr_block_find (inode, name_index, name, &xbs);if (ret) - goto cleanup; + goto out_free_ac; }if (xis.not_found && xbs.not_found) { ret = -ENODATA ;if (flags &XATTR_REPLACE ) - goto cleanup; + goto out_free_ac; ret =0 ;if (!value) - goto cleanup; + goto out_free_ac; }else { ret = -EEXIST ;if (flags &XATTR_CREATE ) - goto cleanup; + goto out_free_ac; }/* Check whether the value is refcounted and do some preparation. */
@@ -3649,7 +3679,7 @@ int ocfs2_xattr_set(struct inode *inode, &ref_meta, &ref_credits);if (ret) {mlog_errno (ret); - goto cleanup; + goto out_free_ac; } }
@@ -3660,7 +3690,7 @@ int ocfs2_xattr_set(struct inode *inode,if (ret <0 ) {inode_unlock (tl_inode);mlog_errno (ret); - goto cleanup; + goto out_free_ac; } }inode_unlock (tl_inode);
@@ -3669,7 +3699,7 @@ int ocfs2_xattr_set(struct inode *inode, &xbs, &ctxt, ref_meta, &credits);if (ret) {mlog_errno (ret); - goto cleanup; + goto out_free_ac; }/* we need to update inode's ctime field, so add credit for it. */
@@ -3687,6 +3717,7 @@ int ocfs2_xattr_set(struct inode *inode,ocfs2_commit_trans (osb, ctxt.handle); out_free_ac: +up_write (&OCFS2_I (inode)->ip_alloc_sem);if (ctxt.data_ac)ocfs2_free_alloc_context (ctxt.data_ac);if (ctxt.meta_ac)
@@ -3695,7 +3726,6 @@ int ocfs2_xattr_set(struct inode *inode,ocfs2_schedule_truncate_log_flush (osb,1 );ocfs2_run_deallocs (osb, &ctxt.dealloc); -cleanup:if (ref_tree)ocfs2_unlock_refcount_tree (osb, ref_tree,1 );up_write (&OCFS2_I (inode)->ip_xattr_sem);
@@ -4352,6 +4382,10 @@ static void ocfs2_xattr_update_xattr_search(struct inode *inode, xs->here = xs->header->xh_entries; } +/* +* Caller must hold ip_alloc_sem for writing, since a new xattr block +* is allocated and the xattr block header is rewritten. +*/ static int ocfs2_xattr_create_index_block(struct inode *inode, struct ocfs2_xattr_info *xi, struct ocfs2_xattr_search *xs,
@@ -4368,19 +4402,14 @@ static int ocfs2_xattr_create_index_block(struct inode *inode,struct ocfs2_xattr_tree_root *xr;u16 xb_flags =le16_to_cpu (xb->xb_flags); +lockdep_assert_held_write (&oi->ip_alloc_sem); +trace_ocfs2_xattr_create_index_block_begin ( (unsigned long long )xb_bh->b_blocknr);BUG_ON (xb_flags &OCFS2_XATTR_INDEXED );BUG_ON (!xs->bucket); -/* -* XXX: -* We can use this lock for now, and maybe move to a dedicated mutex -* if performance becomes a problem later. -*/ -down_write (&oi->ip_alloc_sem); - ret =ocfs2_journal_access_xb (handle,INODE_CACHE (inode), xb_bh,OCFS2_JOURNAL_ACCESS_WRITE );if (ret) {
@@ -4442,8 +4471,6 @@ static int ocfs2_xattr_create_index_block(struct inode *inode,ocfs2_journal_dirty (handle, xb_bh); out: -up_write (&oi->ip_alloc_sem); -return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1517/1848 selftests/epoll: fix race condition in multi-waiter wakeup tests
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Schmaus <[email protected]>
[ Upstream commit 4238e66c82b6ee888a768cb298c85083b4566726 ]
In tests with multiple concurrent waiters on edge-triggered epoll instances where an emitter writes to multiple sockets (epoll16, epoll56, epoll58):
When the emitter performs its first write(), ep_poll_callback() fires and wakes up both waiters because one waiter uses epoll_wait() and the other one uses poll(). This translates to different wait queues, ep->wq for epoll and ep->poll_wait for poll/select, which are both awoken by the kernel because of that single write. Next, both waiter threads invoke epoll_wait(), but since there is only one event, only one epoll_wait() will return non-zero because of the edge-triggered mode being used (in level-triggered mode, the kernel would re-queue the event because of remaining unread data).
Since the second waiter sees an empty ready list, it does not increment ctx.count and the test fails spuriously with ctx.count == 1 instead of 2.
Emitter (CPU 0) Thread 0 (CPU 1) Thread 1 (CPU 2)
=============== ================ ================
epoll_wait(e0, -1) poll(e0, -1)
[on e0->wq] [on e0->poll_wait] write(sfd[1])
|
+--(Kernel wakes BOTH e0->wq and e0->poll_wait via callback)--+
| |
| wakes up wakes up |
| epoll_wait() reaps e1 poll() returns 1 |
| (e1 removed via ET) (wants event) |
| e0->rdllist is EMPTY | |
| count++ (count = 1) v |
| epoll_wait(e0, 0) |
| sees EMPTY list! |
| returns 0! |
| thread exits |
v |
write(sfd[3]) |
(event arrives too late!) v
EXPECT_EQ(count, 2) <-- SPURIOUS FAILURE!
Introduce waiter_entry1ap_loop() to retry poll() if the initial epoll_wait(..., 0) yielded no events. This ensures the thread waits for the subsequent write rather than failing immediately. Apply this helper in epoll16, epoll56, and for both waiter threads in epoll58.
--- .../filesystems/epoll/epoll_wakeup_test.c | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-)
tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c +22 -10
@@ -59,6 +59,24 @@ static void *waiter_entry1ap(void *data)return NULL ; } +static void *waiter_entry1ap_loop (void *data) +{ +struct pollfd pfd; +struct epoll_event e; +struct epoll_mtcontext *ctx = data; + + pfd.fd = ctx->efd[0 ]; + pfd.events =POLLIN ; +while (poll (&pfd,1 ,2000 ) >0 ) { +if (epoll_wait (ctx->efd[0 ], &e,1 ,0 ) >0 ) { +__sync_fetch_and_add (&ctx->count,1 ); +break ; + } + } + +return NULL ; +} +static void *waiter_entry1o (void *data) {struct epoll_event e;
@@ -794,7 +812,7 @@ TEST(epoll16)ASSERT_EQ (epoll_ctl (ctx.efd[0 ],EPOLL_CTL_ADD , ctx.sfd[2 ], events),0 ); ctx.main =pthread_self (); -ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap, &ctx),0 ); +ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap_loop, &ctx),0 );ASSERT_EQ (pthread_create (&emitter,NULL , emitter_entry2, &ctx),0 );if (epoll_wait (ctx.efd[0 ], events,1 ,-1 ) >0 )
@@ -2910,7 +2928,7 @@ TEST(epoll56)ASSERT_EQ (epoll_ctl (ctx.efd[0 ],EPOLL_CTL_ADD , ctx.efd[2 ], &e),0 ); ctx.main =pthread_self (); -ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap, &ctx),0 ); +ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap_loop, &ctx),0 );ASSERT_EQ (pthread_create (&emitter,NULL , emitter_entry2, &ctx),0 );if (epoll_wait (ctx.efd[0 ], &e,1 ,-1 ) >0 )
@@ -3015,7 +3033,6 @@ TEST(epoll57)TEST (epoll58) {pthread_t emitter; -struct pollfd pfd;struct epoll_event e;struct epoll_mtcontext ctx = {0 };
@@ -3046,15 +3063,10 @@ TEST(epoll58)ASSERT_EQ (epoll_ctl (ctx.efd[0 ],EPOLL_CTL_ADD , ctx.efd[2 ], &e),0 ); ctx.main =pthread_self (); -ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap, &ctx),0 ); +ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap_loop, &ctx),0 );ASSERT_EQ (pthread_create (&emitter,NULL , emitter_entry2, &ctx),0 ); - pfd.fd = ctx.efd[0 ]; - pfd.events =POLLIN ; -if (poll (&pfd,1 ,-1 ) >0 ) { -if (epoll_wait (ctx.efd[0 ], &e,1 ,0 ) >0 ) -__sync_fetch_and_add (&ctx.count,1 ); - } +waiter_entry1ap_loop (&ctx);ASSERT_EQ (pthread_join (ctx.waiter,NULL ),0 );EXPECT_EQ (ctx.count,2 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1518/1848 init/main: fix off-by-one in argv_init cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wilson Felipe Pereira <[email protected]>
[ Upstream commit b82ed0e3a1dafe41577b095318a3ea6c0eec6f46 ]
Patch series "init: fix array boundary bugs in boot parameter parsing".
This series fixes two distinct boundary logic edge-case bugs in init/main.c related to parsing boot command-line arguments and environment variables. Both bugs have been present since the early git history (Linux-2.6.12-rc2).
1. The first patch fixes an off-by-one error in init_setup() where the final slot of the argv_init array was left uncleared. This allowed a stale kernel parameter to leak into the init process's user-space command line if exactly MAX_INIT_ARGS unknown parameters were passed.
2. The second patch fixes a false-positive kernel panic in unknown_bootoption(). If a user filled the environment variable array up to its exact limit (32) and then attempted to overwrite the final variable, the kernel would panic before evaluating whether it was a harmless duplicate.
Exact QEMU reproduction steps for both edge cases are documented inside their respective commit descriptions.
This patch (of 2):
When cleaning up argv_init in init_setup() and rdinit_setup(), the loop terminates one element early due to using '<' instead of '<='. Since argv_init is sized MAX_INIT_ARGS+2, index MAX_INIT_ARGS is a valid element that should be cleared to NULL.
If exactly MAX_INIT_ARGS unknown arguments are passed before 'init=', the uncleared argv_init[MAX_INIT_ARGS] can act as a ghost argument to /sbin/init or cause a spurious kernel panic when later appended to.
To verify the argument leak, boot a VM into a shell with 32 unknown kernel arguments, the init parameter, and 31 user arguments:
STALE_ARGS=$(for i in {1..32}; do echo -n "stale$i "; done)
USER_ARGS=$(for i in {1..31}; do echo -n "user$i "; done)
qemu-system-x86_64 -kernel bzImage \
-append "$STALE_ARGS init=/bin/sh $USER_ARGS"Running cat /proc/1/cmdline inside the shell reveals that the 32nd kernel argument ('stale32') incorrectly leaked into the init process's command line. This patch zeroes the final slot, cleanly terminating the array.
--- init/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
init/main.c +2 -2
@@ -557,7 +557,7 @@ static int __init init_setup(char *str)* the shell think it should execute a script with such name. * So we ignore all arguments entered _before_ init=... [MJ] */ -for (i =1 ; i <MAX_INIT_ARGS ; i++) +for (i =1 ; i <=MAX_INIT_ARGS ; i++) argv_init[i] =NULL ;return 1 ; }
@@ -569,7 +569,7 @@ static int __init rdinit_setup(char *str) ramdisk_execute_command = str;/* See "auto" comment in init_setup */ -for (i =1 ; i <MAX_INIT_ARGS ; i++) +for (i =1 ; i <=MAX_INIT_ARGS ; i++) argv_init[i] =NULL ;return 1 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1519/1848 init/main: fix false-positive kernel panic on environment variable overwrite
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wilson Felipe Pereira <[email protected]>
[ Upstream commit 51e766bcd35e706d8df29dd0fac98871fdced261 ]
In unknown_bootoption(), the limit checking for environment variables sets panic_later *before* checking if the variable already exists in envp_init.
If a user passes exactly MAX_INIT_ENVS custom variables and then overwrites the final variable by matching its key, it causes a false-positive hard panic on boot despite not actually exceeding the array bounds or increasing the total variable count.
Swapping the order of these checks allows the duplicate check to break out of the loop before the panic flag is erroneously latched.
To verify, boot a VM with 31 custom variables (filling the array up to its limit of 32) and then overwrite the very last variable:
ENV_VARS=$(for i in {1..31}; do echo -n "var$i=$i "; done)
qemu-system-x86_64 -kernel bzImage -append "$ENV_VARS var31=overwrite"Without this patch, the kernel crashes instantly with:
Kernel panic - not syncing: Too many boot env vars at 'var31=overwrite'
With this patch, the kernel safely overwrites the variable and boots.
--- init/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
init/main.c +2 -2
@@ -524,12 +524,12 @@ static int __init unknown_bootoption(char *param, char *val,/* Environment option */ unsigned int i;for (i =0 ; envp_init[i]; i++) { +if (!strncmp (param, envp_init[i], len+1 )) +break ;if (i ==MAX_INIT_ENVS ) { panic_later ="env" ; panic_param = param; } -if (!strncmp (param, envp_init[i], len+1 )) -break ; } envp_init[i] = param; }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1520/1848 ocfs2: reject inconsistent xattr bucket during defrag
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit bd40b997f04542869afeabe94f2cf1a016fc9bfa ]
ocfs2_defrag_xattr_bucket() has two mlog_bug_on_msg() checks that assume the name/value pairs in a bucket are disjoint and that xh_free_start is not below the compacted region.
ocfs2_validate_xattr_bucket() only checks each entry in isolation, so a corrupt bucket holding overlapping entries, or one with an inflated xh_free_start, passes validation and then hits BUG() in defrag when a setxattr triggers it.
Defrag works on a linear copy of the bucket and does not touch the real blocks before the copy back, so the checks can return an error instead of calling BUG().
--- fs/ocfs2/xattr.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
fs/ocfs2/xattr.c +11 -5
@@ -4566,16 +4566,22 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,memmove (bucket_buf + end - len, bucket_buf + offset, len); xe->xe_name_offset =cpu_to_le16 (end - len); + }else if (end < offset + len) { + ret =ocfs2_error (inode->i_sb, +"Defrag check failed for bucket %llu\n" , + (unsigned long long )blkno); + goto out; } -mlog_bug_on_msg (end < offset + len,"Defrag check failed for " -"bucket %llu\n" , (unsigned long long )blkno); - end -= len; } -mlog_bug_on_msg (xh_free_start > end,"Defrag check failed for " -"bucket %llu\n" , (unsigned long long )blkno); +if (xh_free_start > end) { + ret =ocfs2_error (inode->i_sb, +"Defrag check failed for bucket %llu\n" , + (unsigned long long )blkno); + goto out; + }if (xh_free_start == end) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1521/1848 PCI/AER: Add optional logging callback for correctable error
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 361187e04733eee19778ea9b01cb95a977c14c10 ]
Some new devices such as CXL devices may want to record additional error information on a corrected error. Add a callback to allow the PCI device driver to do additional logging such as providing additional stats for user space RAS monitoring.
For CXL device, this is actually a need due to CXL needing to write to the CXL RAS capability structure correctable error status register in order to clear the unmasked correctable errors. See CXL spec rev3.0 8.2.4.16.
Stable-dep-of: e86ac10110d0 ("PCI/AER: Fix struct pci_dev reference leak in aer_process_err_devices()")
--- Documentation/PCI/pci-error-recovery.rst | 7 +++++++ drivers/pci/pcie/aer.c | 8 +++++++- include/linux/pci.h | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-)
Documentation/PCI/pci-error-recovery.rst +7 -0
@@ -83,6 +83,7 @@ This structure has the form:: int (*mmio_enabled)(struct pci_dev *dev); int (*slot_reset)(struct pci_dev *dev); void (*resume)(struct pci_dev *dev); + void (*cor_error_detected)(struct pci_dev *dev); }; The possible channel states are::
@@ -422,5 +423,11 @@ That is, the recovery API only requires that: - drivers/net/cxgb3 - drivers/net/s2io.c + The cor_error_detected() callback is invoked in handle_error_source() when + the error severity is "correctable". The callback is optional and allows + additional logging to be done if desired. See example: + + - drivers/cxl/pci.c + The End -------
drivers/pci/pcie/aer.c +7 -1
@@ -954,8 +954,14 @@ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)if (aer)pci_write_config_dword (dev, aer +PCI_ERR_COR_STATUS , info->status); -if (pcie_aer_is_native (dev)) +if (pcie_aer_is_native (dev)) { +struct pci_driver *pdrv = dev->driver; + +if (pdrv && pdrv->err_handler && + pdrv->err_handler->cor_error_detected) + pdrv->err_handler->cor_error_detected (dev);pcie_clear_device_status (dev); + } }else if (info->severity ==AER_NONFATAL )pcie_do_recovery (dev, pci_channel_io_normal, aer_root_reset);else if (info->severity ==AER_FATAL )
include/linux/pci.h +3 -0
@@ -840,6 +840,9 @@ struct pci_error_handlers {/* Device driver may resume normal operations */ void (*resume)(struct pci_dev *dev); + +/* Allow device driver to record more details of a correctable error */ +void (*cor_error_detected)(struct pci_dev *dev); };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1522/1848 PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Richter <[email protected]>
[ Upstream commit 0a867568bb0d203ca3d28634a611a1367d7c892d ]
In Restricted CXL Device (RCD) mode a CXL device is exposed as an RCiEP, but CXL downstream and upstream ports are not enumerated and not visible in the PCIe hierarchy. [1] Protocol and link errors from these non-enumerated ports are signaled as internal AER errors, either Uncorrectable Internal Error (UIE) or Corrected Internal Errors (CIE) via an RCEC.
Restricted CXL host (RCH) downstream port-detected errors have the Requester ID of the RCEC set in the RCEC's AER Error Source ID register. A CXL handler must then inspect the error status in various CXL registers residing in the dport's component register space (CXL RAS capability) or the dport's RCRB (PCIe AER extended capability). [2]
Errors showing up in the RCEC's error handler must be handled and connected to the CXL subsystem. Implement this by forwarding the error to all CXL devices below the RCEC. Since the entire CXL device is controlled only using PCIe Configuration Space of device 0, function 0, only pass it there [3]. The error handling is limited to currently supported devices with the Memory Device class code set (CXL Type 3 Device, PCI_CLASS_MEMORY_CXL, 502h), handle downstream port errors in the device's cxl_pci driver. Support for other CXL Device Types (e.g. a CXL.cache Device) can be added later.
To handle downstream port errors in addition to errors directed to the CXL endpoint device, a handler must also inspect the CXL RAS and PCIe AER capabilities of the CXL downstream port the device is connected to.
Since CXL downstream port errors are signaled using internal errors, the handler requires those errors to be unmasked. This is subject of a follow-on patch.
The reason for choosing this implementation is that the AER service driver claims the RCEC device, but does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time. The alternative to add an implementation to the portdrv to allow the registration of a custom RCEC error handler isn't worth doing it as CXL would be its only user. Instead, just check for an CXL RCEC and pass it down to the connected CXL device's error handler. With this approach the code can entirely be implemented in the PCIe AER driver and is independent of the CXL subsystem. The CXL driver only provides the handler.
[1] CXL 3.0 spec: 9.11.8 CXL Devices Attached to an RCH
[2] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors
[3] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL Devices
Stable-dep-of: e86ac10110d0 ("PCI/AER: Fix struct pci_dev reference leak in aer_process_err_devices()")
--- drivers/pci/pcie/Kconfig | 9 ++++ drivers/pci/pcie/aer.c | 93 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 100 insertions(+), 2 deletions(-)
drivers/pci/pcie/Kconfig +9 -0
@@ -45,6 +45,15 @@ config PCIEAER_INJECT gotten from: https://www.kernel.org/pub/linux/utils/pci/aer-inject/ +config PCIEAER_CXL + bool "PCI Express CXL RAS support" + default y + depends on PCIEAER && CXL_PCI + help + Enables CXL error handling. + + If unsure, say Y. + # # PCI Express ECRC #
drivers/pci/pcie/aer.c +91 -2
111 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1523/1848 PCI/AER: Fix struct pci_dev reference leak in aer_process_err_devices()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Priyank Rathod <[email protected]>
[ Upstream commit e86ac10110d00e6c3801f38bde1863951315222b ]
When an AER error occurs, candidate error-source devices are added to e_info->dev[] by add_error_device(), which takes a reference with pci_dev_get().
A device can be recorded without any error status being present: the Requester ID fast path in is_error_source(),
if (e_info->id == pci_dev_id(dev))
return true;
matches purely on the ID reported by the Root Port and returns true without reading the device's AER status registers.
In aer_process_err_devices(), handle_error_source() is called only if aer_get_device_error_info() returns non-zero, i.e. only if an unmasked error status bit is actually set. It returns 0 if the device has become inaccessible (status and mask both read as all ones, so status & ~mask == 0) or if no unmasked status bit is set.
Because handle_error_source() was responsible for calling pci_dev_put(), skipping it permanently leaks the reference taken in add_error_device().
Decouple reference lifetime from error handling by moving pci_dev_put() out of handle_error_source() and into the aer_process_err_devices() loop, so every recorded device is put exactly once.
handle_error_source() is static and aer_process_err_devices() is its only caller, so no other path is affected.
--- drivers/pci/pcie/aer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/aer.c +1 -1
@@ -1055,7 +1055,6 @@ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) {cxl_rch_handle_error (dev, info);pci_aer_handle_error (dev, info); -pci_dev_put (dev); }#ifdef CONFIG_ACPI_APEI_PCIEAER
@@ -1202,6 +1201,7 @@ static inline void aer_process_err_devices(struct aer_err_info *e_info)for (i =0 ; i < e_info->error_dev_num && e_info->dev[i]; i++) {if (aer_get_device_error_info (e_info->dev[i], e_info))handle_error_source (e_info->dev[i], e_info); +pci_dev_put (e_info->dev[i]); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1524/1848 ALSA: caiaq: Allow zero-length packet handling for EP1
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit ccfe6ab672c020fca56988e634088bfb7764e2a7 ]
The recent fix to avoid OOB access for malformed packets added a packet length check and returns immediately if it's too short. However, this can be lead to a regression because the completion handler doesn't resubmit the packet, while a zero-length packet itself is valid, per se.
For addressing the potential regression above, change the handling for a zero-length packet to just resubmit without processing the incoming contents.
--- sound/usb/caiaq/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/usb/caiaq/device.c +2 -1
@@ -156,7 +156,7 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb)return ; }if (urb->actual_length <1 ) -return ; + goto resubmit; payload_len = urb->actual_length -1 ;
@@ -206,6 +206,7 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb)break ; } + resubmit: cdev->ep1_in_urb->actual_length =0 ; ret =usb_submit_urb (cdev->ep1_in_urb,GFP_ATOMIC );if (ret <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1525/1848 gen_init_cpio: stop parsing on lines with a missing argument list
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leizhen Zhang <[email protected]>
[ Upstream commit c8dd1aa0274d8ad3df82ec1b064065f410ce99ed ]
When a line in the cpio list consists of a file type followed only by whitespace and no newline (e.g. "slink " as the last line of the file), strtok(NULL, "\n") returns NULL. main() prints an error and sets ec, but then carries on and passes the NULL args pointer to the type handler, which hands it to sscanf() and crashes:
AddressSanitizer: SEGV on unknown address 0x000000000000
#4 __isoc99_sscanf
#5 cpio_mkslink_line usr/gen_init_cpio.c:169Break out of the loop as is already done for the other format error, so that the error is reported and gen_init_cpio exits with a failure status.
Found by fuzzing gen_init_cpio built with ASan/UBSan.
Reproducer:
printf 'slink ' > list && usr/gen_init_cpio list
--- usr/gen_init_cpio.c | 1 + 1 file changed, 1 insertion(+)
usr/gen_init_cpio.c +1 -0
@@ -599,6 +599,7 @@ int main (int argc, char *argv[])"ERROR: incorrect format, newline required line %d: '%s'\n" , line_nr, line); ec =-1 ; +break ; }for (type_idx =0 ; file_handler_table[type_idx].type; type_idx++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1526/1848 pinctrl: sprd: free maps on DT map failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit e873c665e503ebfb6dafaf9346c3956695686226 ]
sprd_dt_node_to_map() reserves map storage before adding mux and configuration entries. If a later operation fails, the error path only frees the temporary configurations and leaves the map allocation reachable through the output pointer.
Free the partially built map on failure. The caller ignores the output parameters when the mapping callback returns an error, so they do not need to be reset after freeing the map.
--- drivers/pinctrl/sprd/pinctrl-sprd.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pinctrl/sprd/pinctrl-sprd.c +3 -0
@@ -327,6 +327,9 @@ static int sprd_dt_node_to_map(struct pinctrl_dev *pctldev, out:kfree (configs); +if (ret <0 ) +pinctrl_utils_free_map (pctldev, *map, *num_maps); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1527/1848 wifi: mt76: mt76x02: validate RX padding before use
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit baf375ca58eaa24503f9febac75c056852694c3a ]
The RX descriptor provides L2 and PN padding lengths that are used to locate the CCMP IV and determine how many bytes to remove from the packet. These lengths are not checked against the received skb length before the IV is read or mt76x02_remove_hdr_pad() is called.
Reject frames whose IV does not fit within the skb or whose header padding would extend past the end of the skb.
--- drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +9 -2
@@ -814,9 +814,13 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb, len =FIELD_GET (MT_RXWI_CTL_MPDU_LEN , ctl); pn_len =FIELD_GET (MT_RXINFO_PN_LEN , rxinfo);if (pn_len) { -int offset =ieee80211_get_hdrlen_from_skb (skb) + pad_len; -u8 *data = skb->data + offset; +unsigned int offset =ieee80211_get_hdrlen_from_skb (skb) + pad_len; +u8 *data; +if (offset +8 > skb->len) +return -EINVAL ; + + data = skb->data + offset; status->iv[0 ] = data[7 ]; status->iv[1 ] = data[6 ]; status->iv[2 ] = data[5 ];
@@ -836,6 +840,9 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb, } } +if (pad_len +ieee80211_get_hdrlen_from_skb (skb) > skb->len) +return -EINVAL ; +mt76x02_remove_hdr_pad (skb, pad_len);if ((rxinfo &MT_RXINFO_BA ) && !(rxinfo &MT_RXINFO_NULL ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1528/1848 wifi: mt76: usb: fix source overread in mt76u_copy
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit d435130cdd064b901d8ce5ada0322298e6a86a49 ]
mt76u_copy() rounds up len to a multiple of four and uses the rounded length as the bound for memcpy() from the source buffer. When the caller's length is not four-byte aligned, the final copy reads up to three bytes past the source buffer.
Keep the original length for the source copy and zero the remaining bytes in the transmit buffer so that the hardware access width remains four-byte aligned.
--- drivers/net/wireless/mediatek/mt76/usb.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/usb.c +11 -5
@@ -189,8 +189,10 @@ static void mt76u_copy(struct mt76_dev *dev, u32 offset, {struct mt76_usb *usb = &dev->usb;const u8 *val = data; -int ret;int current_batch_size; +int len_aligned; +int copy_len; +int ret;int i =0 ;/* Assure that always a multiple of 4 bytes are copied,
@@ -198,12 +200,16 @@ static void mt76u_copy(struct mt76_dev *dev, u32 offset,* See: "mt76: round up length on mt76_wr_copy" * Commit 850e8f6fbd5d0003b0 */ - len =round_up (len,4 ); + len_aligned =round_up (len,4 );mutex_lock (&usb->usb_ctrl_mtx); -while (i < len) { - current_batch_size =min_t (int, usb->data_len, len - i); -memcpy (usb->data, val + i, current_batch_size); +while (i < len_aligned) { + current_batch_size =min_t (int, usb->data_len, len_aligned - i); + copy_len =min_t (int, current_batch_size, len - i); +memcpy (usb->data, val + i, copy_len); +if (copy_len < current_batch_size) +memset (usb->data + copy_len,0 , + current_batch_size - copy_len); ret = __mt76u_vendor_request(dev, MT_VEND_MULTI_WRITE, USB_DIR_OUT | USB_TYPE_VENDOR, 0, offset + i, usb->data,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1529/1848 mt76: implement .mcu_parse_response in struct mt76_mcu_ops
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit f320d812b7bbd30abb5699971051e8b494df6278 ]
Do not free skb inside that function
Preparation for further cleanup
Stable-dep-of: 40217d8e6cba ("wifi: mt76: mt7615: read MT7663 temperature from the correct offset")
--- drivers/net/wireless/mediatek/mt76/mt76.h | 2 ++ .../net/wireless/mediatek/mt76/mt7603/mcu.c | 24 ++++++++++++------- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 18 +++++++------- .../wireless/mediatek/mt76/mt7615/mt7615.h | 2 ++ .../wireless/mediatek/mt76/mt7615/sdio_mcu.c | 1 + .../wireless/mediatek/mt76/mt7615/usb_mcu.c | 1 + .../wireless/mediatek/mt76/mt76x0/pci_mcu.c | 1 + .../net/wireless/mediatek/mt76/mt76x02_mcu.c | 23 +++++++++++------- .../net/wireless/mediatek/mt76/mt76x02_mcu.h | 2 ++ .../wireless/mediatek/mt76/mt76x02_usb_mcu.c | 1 + .../wireless/mediatek/mt76/mt76x2/pci_mcu.c | 1 + .../net/wireless/mediatek/mt76/mt7915/mcu.c | 15 ++++++------ 12 files changed, 55 insertions(+), 36 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +2 -0
@@ -148,6 +148,8 @@ struct mt76_mcu_ops { int len, bool wait_resp);int (*mcu_skb_send_msg)(struct mt76_dev *dev,struct sk_buff *skb,int cmd,bool wait_resp); +int (*mcu_parse_response)(struct mt76_dev *dev,int cmd, +struct sk_buff *skb,int seq);u32 (*mcu_rr)(struct mt76_dev *dev,u32 offset);void (*mcu_wr)(struct mt76_dev *dev,u32 offset,u32 val); int (*mcu_wr_rp)(struct mt76_dev *dev, u32 base,
drivers/net/wireless/mediatek/mt76/mt7603/mcu.c +15 -9
@@ -13,6 +13,18 @@ struct mt7603_fw_trailer {__le32 dl_len; } __packed; +static int +mt7603_mcu_parse_response (struct mt76_dev *mdev,int cmd, +struct sk_buff *skb,int seq) +{ +struct mt7603_mcu_rxd *rxd = (struct mt7603_mcu_rxd *)skb->data; + +if (seq != rxd->seq) +return -EAGAIN ; + +return 0 ; +} +static int __mt7603_mcu_msg_send (struct mt7603_dev *dev,struct sk_buff *skb,int cmd,int *wait_seq)
@@ -58,7 +70,6 @@ mt7603_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, { struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);unsigned long expires = jiffies +3 *HZ ; -struct mt7603_mcu_rxd *rxd;struct sk_buff *skb;int ret, seq;
@@ -73,8 +84,6 @@ mt7603_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, goto out;while (wait_resp) { -bool check_seq = false; - skb =mt76_mcu_get_response (&dev->mt76, expires);if (!skb) { dev_err(mdev->dev,
@@ -85,13 +94,9 @@ mt7603_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,break ; } - rxd = (struct mt7603_mcu_rxd *)skb->data; -if (seq == rxd->seq) - check_seq = true; - + ret =mt7603_mcu_parse_response (mdev, cmd, skb, seq);dev_kfree_skb (skb); - -if (check_seq) +if (ret != -EAGAIN )break ; }
@@ -267,6 +272,7 @@ int mt7603_mcu_init(struct mt7603_dev *dev)static const struct mt76_mcu_ops mt7603_mcu_ops = { .headroom =sizeof (struct mt7603_mcu_txd ), .mcu_send_msg = mt7603_mcu_msg_send, + .mcu_parse_response = mt7603_mcu_parse_response, .mcu_restart = mt7603_mcu_restart, };
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +8 -10
@@ -179,17 +179,14 @@ static int __mt7615_mcu_msg_send(struct mt7615_dev *dev, struct sk_buff *skb,return mt76_tx_queue_skb_raw (dev, qid, skb,0 ); } -static int -mt7615_mcu_parse_response (struct mt7615_dev *dev,int cmd, -struct sk_buff *skb,int seq) +int mt7615_mcu_parse_response (struct mt76_dev *mdev,int cmd, +struct sk_buff *skb,int seq) {struct mt7615_mcu_rxd *rxd = (struct mt7615_mcu_rxd *)skb->data;int ret =0 ; -if (seq != rxd->seq) { - ret = -EAGAIN ; - goto out; - } +if (seq != rxd->seq) +return -EAGAIN ;switch (cmd) {case MCU_CMD_PATCH_SEM_CONTROL :
@@ -228,11 +225,10 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd,default :break ; } -out: -dev_kfree_skb (skb);return ret; } +EXPORT_SYMBOL_GPL (mt7615_mcu_parse_response);int mt7615_mcu_wait_response (struct mt7615_dev *dev,int cmd,int seq) {
@@ -248,7 +244,8 @@ int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq)return -ETIMEDOUT ; } - ret =mt7615_mcu_parse_response (dev, cmd, skb, seq); + ret =mt7615_mcu_parse_response (&dev->mt76, cmd, skb, seq); +dev_kfree_skb (skb);if (ret != -EAGAIN )break ; }
@@ -2476,6 +2473,7 @@ int mt7615_mcu_init(struct mt7615_dev *dev) .headroom = sizeof(struct mt7615_mcu_txd), .mcu_skb_send_msg = mt7615_mcu_send_message, .mcu_send_msg = mt7615_mcu_msg_send, + .mcu_parse_response = mt7615_mcu_parse_response, .mcu_restart = mt7615_mcu_restart, };int ret;
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +2 -0
@@ -590,6 +590,8 @@ u32 mt7615_mac_get_sta_tid_sn(struct mt7615_dev *dev, int wcid, u8 tid);int mt7615_mcu_wait_response (struct mt7615_dev *dev,int cmd,int seq);int mt7615_mcu_msg_send (struct mt76_dev *mdev,int cmd,const void *data,int len,bool wait_resp); +int mt7615_mcu_parse_response (struct mt76_dev *mdev,int cmd, +struct sk_buff *skb,int seq);u32 mt7615_rf_rr (struct mt7615_dev *dev,u32 wf,u32 reg);int mt7615_rf_wr (struct mt7615_dev *dev,u32 wf,u32 reg,u32 val);int mt7615_mcu_set_dbdc (struct mt7615_dev *dev);
drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c +1 -0
@@ -128,6 +128,7 @@ int mt7663s_mcu_init(struct mt7615_dev *dev) .tailroom = MT_USB_TAIL_SIZE, .mcu_skb_send_msg = mt7663s_mcu_send_message, .mcu_send_msg = mt7615_mcu_msg_send, + .mcu_parse_response = mt7615_mcu_parse_response, .mcu_restart = mt7615_mcu_restart, .mcu_rr = mt7615_mcu_reg_rr, .mcu_wr = mt7615_mcu_reg_wr,
drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c +1 -0
@@ -57,6 +57,7 @@ int mt7663u_mcu_init(struct mt7615_dev *dev) .tailroom = MT_USB_TAIL_SIZE, .mcu_skb_send_msg = mt7663u_mcu_send_message, .mcu_send_msg = mt7615_mcu_msg_send, + .mcu_parse_response = mt7615_mcu_parse_response, .mcu_restart = mt7615_mcu_restart, };int ret;
drivers/net/wireless/mediatek/mt76/mt76x0/pci_mcu.c +1 -0
@@ -117,6 +117,7 @@ int mt76x0e_mcu_init(struct mt76x02_dev *dev) {static const struct mt76_mcu_ops mt76x0e_mcu_ops = { .mcu_send_msg = mt76x02_mcu_msg_send, + .mcu_parse_response = mt76x02_mcu_parse_response, };int err;
drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c +14 -9
@@ -10,6 +10,18 @@#include "mt76x02_mcu.h" +int mt76x02_mcu_parse_response (struct mt76_dev *mdev,int cmd, +struct sk_buff *skb,int seq) +{ +u32 *rxfce = (u32 *)skb->cb; + +if (seq !=FIELD_GET (MT_RX_FCE_INFO_CMD_SEQ , *rxfce)) +return -EAGAIN ; + +return 0 ; +} +EXPORT_SYMBOL_GPL (mt76x02_mcu_parse_response); +int mt76x02_mcu_msg_send (struct mt76_dev *mdev,int cmd,const void *data,int len,bool wait_resp) {
@@ -44,9 +56,6 @@ int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, goto out;while (wait_resp) { -u32 *rxfce; -bool check_seq = false; - skb =mt76_mcu_get_response (&dev->mt76, expires);if (!skb) { dev_err(mdev->dev,
@@ -57,13 +66,9 @@ int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,break ; } - rxfce = (u32 *)skb->cb; - -if (seq ==FIELD_GET (MT_RX_FCE_INFO_CMD_SEQ , *rxfce)) - check_seq = true; - + ret =mt76x02_mcu_parse_response (mdev, cmd, skb, seq);dev_kfree_skb (skb); -if (check_seq) +if (ret != -EAGAIN )break ; }
drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h +2 -0
@@ -89,6 +89,8 @@ int mt76x02_mcu_cleanup(struct mt76x02_dev *dev);int mt76x02_mcu_calibrate (struct mt76x02_dev *dev,int type,u32 param);int mt76x02_mcu_msg_send (struct mt76_dev *mdev,int cmd,const void *data,int len,bool wait_resp); +int mt76x02_mcu_parse_response (struct mt76_dev *mdev,int cmd, +struct sk_buff *skb,int seq);int mt76x02_mcu_function_select (struct mt76x02_dev *dev,enum mcu_function func,u32 val);int mt76x02_mcu_set_radio_state (struct mt76x02_dev *dev,bool on);
drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c +1 -0
@@ -297,6 +297,7 @@ void mt76x02u_init_mcu(struct mt76_dev *dev) .headroom = MT_CMD_HDR_LEN, .tailroom = 8, .mcu_send_msg = mt76x02u_mcu_send_msg, + .mcu_parse_response = mt76x02_mcu_parse_response, .mcu_wr_rp = mt76x02u_mcu_wr_rp, .mcu_rd_rp = mt76x02u_mcu_rd_rp, };
drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c +1 -0
@@ -179,6 +179,7 @@ int mt76x2_mcu_init(struct mt76x02_dev *dev)static const struct mt76_mcu_ops mt76x2_mcu_ops = { .mcu_restart = mt76pci_mcu_restart, .mcu_send_msg = mt76x02_mcu_msg_send, + .mcu_parse_response = mt76x02_mcu_parse_response, };int ret;
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +7 -8
@@ -306,16 +306,15 @@ mt7915_mcu_parse_eeprom(struct mt7915_dev *dev, struct sk_buff *skb) }static int -mt7915_mcu_parse_response (struct mt7915_dev *dev,int cmd, +mt7915_mcu_parse_response (struct mt76_dev *mdev,int cmd,struct sk_buff *skb,int seq) { + struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76);struct mt7915_mcu_rxd *rxd = (struct mt7915_mcu_rxd *)skb->data;int ret =0 ; -if (seq != rxd->seq) { - ret = -EAGAIN ; - goto out; - } +if (seq != rxd->seq) +return -EAGAIN ;switch (cmd) {case -MCU_CMD_PATCH_SEM_CONTROL :
@@ -332,8 +331,6 @@ mt7915_mcu_parse_response(struct mt7915_dev *dev, int cmd,default :break ; } -out: -dev_kfree_skb (skb);return ret; }
@@ -353,7 +350,8 @@ mt7915_mcu_wait_response(struct mt7915_dev *dev, int cmd, int seq)return -ETIMEDOUT ; } - ret =mt7915_mcu_parse_response (dev, cmd, skb, seq); + ret =mt7915_mcu_parse_response (&dev->mt76, cmd, skb, seq); +dev_kfree_skb (skb);if (ret != -EAGAIN )break ; }
@@ -2859,6 +2857,7 @@ int mt7915_mcu_init(struct mt7915_dev *dev) .headroom = sizeof(struct mt7915_mcu_txd), .mcu_skb_send_msg = mt7915_mcu_send_message, .mcu_send_msg = mt7915_mcu_msg_send, + .mcu_parse_response = mt7915_mcu_parse_response, .mcu_restart = mt7915_mcu_restart, };int ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1530/1848 wifi: mt76: mt7615: read MT7663 temperature from the correct offset
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmed Naseef <[email protected]>
[ Upstream commit 40217d8e6cba433a6ccb8c73737dd38b54dcc26f ]
On MT7663 the hwmon temp1_input attribute always reads 0.
mt7615_mcu_parse_response() takes the temperature from the first dword of the THERMAL_CTRL response payload, but MT7663 firmware reports it in the second one. On a DASAN H660GM-A (MT7663E, N9 firmware 7663mp1827) the request and its response are:
request: 00 00 00 00
response: 00 00 00 00 2a 00 00 00
0x2a is the reading, 42 degrees, while the driver returns the leading zero. mt7915 and mt7921 already pull sizeof(*rxd) + 4 for this command.
Restrict the extra pull to MT7663, as no MT7615 or MT7622 hardware was available to check whether their firmware uses the same layout.
--- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +2 -0
@@ -195,6 +195,8 @@ int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,break ;case MCU_EXT_CMD_GET_TEMP :skb_pull (skb,sizeof (*rxd)); +if (is_mt7663 (mdev)) +skb_pull (skb,4 ); ret =le32_to_cpu (*(__le32 *)skb->data);break ;case MCU_EXT_CMD_RF_REG_ACCESS |MCU_QUERY_PREFIX :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1531/1848 ASoC: rockchip: rockchip_i2s: Handle runtime PM resume failures in set_fmt
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit e9eb1854d16136006c6fe94c927b54b2b264b429 ]
rockchip_i2s_set_fmt() calls pm_runtime_get_sync() before accessing hardware registers, but ignores its return value.
If the runtime resume fails, the function continues to perform register accesses while the device state is undefined.
Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() and return early on failure to avoid unpowered register accesses.
--- sound/soc/rockchip/rockchip_i2s.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/rockchip/rockchip_i2s.c +3 -1
@@ -188,7 +188,9 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,unsigned int mask =0 , val =0 ;int ret =0 ; -pm_runtime_get_sync (cpu_dai->dev); + ret =pm_runtime_resume_and_get (cpu_dai->dev); +if (ret) +return ret; mask =I2S_CKR_MSS_MASK ;switch (fmt &SND_SOC_DAIFMT_MASTER_MASK ) {case SND_SOC_DAIFMT_CBS_CFS :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1532/1848 checkkconfigsymbols.py: Parse Git status output line by line
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ting-Han Hou <[email protected]>
[ Upstream commit 72a61a7fef954152abd9df9def4f94816eb344ca ]
tree_is_dirty() iterates over the string returned by execute() one character at a time. Its status check therefore examines filenames as well as the two status columns.
An otherwise clean tree containing an untracked README is reported as dirty because its name contains letters matched by [URMADC]. This prevents --commit and --diff from running, whereas an untracked notes.txt does not trigger the check.
Split the output into lines before examining the two status columns so that filenames do not affect the dirty-tree check.
--- scripts/checkkconfigsymbols.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkkconfigsymbols.py +1 -1
@@ -243,7 +243,7 @@ def tree_is_dirty(): """Return true if the current working tree is dirty (i.e., if any file has been added, deleted, modified, renamed or copied but not committed).""" stdout = execute(["git", "status", "--porcelain"]) - for line in stdout: + for line in stdout.splitlines(): if re.findall(r"[URMADC]{1}", line[:2]): return True return False
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1533/1848 drm/amd/display: use right type for amdgpu_dc_performance event entries
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Melissa Wen <[email protected]>
[ Upstream commit 99858eda764364bae733448c7eb79145d3d043ec ]
Some amdgpu_dc_performance trace event params are passed as unsigned long but stored as uint32_t, cutting them off on 64-bit. Use the right type on entry fields and on printk use unsigned format accordingly.
--- .../drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h +7 -10
@@ -72,10 +72,10 @@ TRACE_EVENT(amdgpu_dc_performance, const char *func, unsigned int line),TP_ARGS (read_count ,write_count ,last_read ,last_write ,func ,line ),TP_STRUCT__entry ( - __field(uint32_t, reads) -__field (uint32_t ,writes ) -__field (uint32_t, read_delta) -__field (uint32_t, write_delta) + __field(unsigned long, reads) +__field (unsigned long ,writes ) + __field(unsigned long, read_delta) + __field(unsigned long, write_delta)__string (func, func)__field (uint32_t, line) ),
@@ -89,12 +89,9 @@ TRACE_EVENT(amdgpu_dc_performance, *last_read = read_count; *last_write = write_count; ), -TP_printk ("%s:%d reads=%08ld (%08ld total), writes=%08ld (%08ld total)" , -__get_str (func), __entry->line, - (unsigned long )__entry->read_delta, - (unsigned long )__entry->reads, - (unsigned long )__entry->write_delta, - (unsigned long )__entry->writes) +TP_printk ("%s:%u reads=%08lu (%08lu total), writes=%08lu (%08lu total)" , +__get_str (func), __entry->line, __entry->read_delta, + __entry->reads, __entry->write_delta, __entry->writes) );#endif /* _AMDGPU_DM_TRACE_H_ */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1534/1848 ASoC: mediatek: common: Handle constraint return value in FE startup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 5fcdb40a4776cc6f8d3179aa9cf9663fc18c7861 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from mtk_afe_fe_startup(). ASoC only treats 0 as success when marking the DAI as started, so .shutdown() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/soc/mediatek/common/mtk-afe-fe-dai.c +5 -3
@@ -75,8 +75,10 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream, ret =snd_pcm_hw_constraint_integer (runtime,SNDRV_PCM_HW_PARAM_PERIODS ); -if (ret <0 ) +if (ret <0 ) {dev_err (afe->dev,"snd_pcm_hw_constraint_integer failed\n" ); +return ret; + }/* dynamic allocate irq to memif */ if (memif->irq_usage <0 ) {
@@ -88,10 +90,10 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream, }else {dev_err (afe->dev,"%s() error: no more asys irq\n" , __func__); - ret = -EBUSY ; +return -EBUSY ; } } -return ret; +return 0 ; }EXPORT_SYMBOL_GPL (mtk_afe_fe_startup);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1535/1848 PCI/sysfs: Rely on lengths from scnprintf(), dsm_label_utf16s_to_utf8s()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Wilczyński <[email protected]>
[ Upstream commit 316ae33051215f92c72fe13bc1bfc4e513a26700 ]
scnprintf() returns the number of bytes written into the buffer. Change dsm_label_utf16s_to_utf8s() to do the same. Rely on those values instead of using strlen() to compute the buffer length.
No functional change intended.
[bhelgaas: reorder patch in series, len++ to include newline added by dsm_label_utf16s_to_utf8s(), commit log]
Stable-dep-of: 36f9bd09920e ("PCI/sysfs: Stop reporting _DSM failures as -EPERM")
--- drivers/pci/pci-label.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/pci/pci-label.c +10 -8
@@ -154,14 +154,17 @@ enum acpi_attr_enum { ACPI_ATTR_INDEX_SHOW, }; -static void dsm_label_utf16s_to_utf8s (union acpi_object *obj,char *buf) +static int dsm_label_utf16s_to_utf8s (union acpi_object *obj,char *buf) {int len; + len =utf16s_to_utf8s ((const wchar_t *)obj->buffer.pointer, obj->buffer.length /sizeof (wchar_t),UTF16_LITTLE_ENDIAN , buf,PAGE_SIZE -1 ); - buf[len] ='\n' ; + buf[len++] ='\n' ; + +return len; } static int dsm_get_label(struct device *dev, char *buf,
@@ -169,7 +172,7 @@ static int dsm_get_label(struct device *dev, char *buf, {acpi_handle handle;union acpi_object *obj, *tmp; -int len =-1 ; +int len =0 ; handle =ACPI_HANDLE (dev);if (!handle)
@@ -191,20 +194,19 @@ static int dsm_get_label(struct device *dev, char *buf,* this entry must return a null string. */ if (attr ==ACPI_ATTR_INDEX_SHOW ) { -scnprintf (buf,PAGE_SIZE ,"%llu\n" , tmp->integer.value); + len =scnprintf (buf,PAGE_SIZE ,"%llu\n" , tmp->integer.value); }else if (attr ==ACPI_ATTR_LABEL_SHOW ) {if (tmp[1 ].type ==ACPI_TYPE_STRING ) -scnprintf (buf,PAGE_SIZE ,"%s\n" , + len =scnprintf (buf,PAGE_SIZE ,"%s\n" , tmp[1 ].string.pointer);else if (tmp[1 ].type ==ACPI_TYPE_BUFFER ) -dsm_label_utf16s_to_utf8s (tmp +1 , buf); + len =dsm_label_utf16s_to_utf8s (tmp +1 , buf); } - len =strlen (buf) >0 ?strlen (buf) :-1 ; }ACPI_FREE (obj); -return len; +return len >0 ? len :-1 ; }static bool device_has_dsm (struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1536/1848 PCI/sysfs: Stop reporting _DSM failures as -EPERM
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Wilczyński <[email protected]>
[ Upstream commit 36f9bd09920ed71c1b79db397170412b2de22319 ]
Currently, dsm_get_label() returns the literal -1 on every failure path. The sysfs read path passes that value to userspace as -EPERM. Reading the "label" or "acpi_index" attribute on a platform where the Device Name _DSM returns a malformed result then fails with:
$ cat /sys/bus/pci/devices/0000:00:08.3/label cat: /sys/bus/pci/devices/0000:00:08.3/label: Operation not permitted
Nothing in that path performs a permission check, and the read fails the same way for a privileged reader. The error code points at a cause that does not exist, and tools such as lspci report it on every invocation.
Return -ENODEV when the device has no ACPI companion, and -EIO when the _DSM evaluation fails or returns an object that cannot be parsed. Other _DSM users in the tree report such failures the same way.
The set of reads that succeed, and the bytes they return, stay the same. Only the error code of reads that already fail differs.
--- drivers/pci/pci-label.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/pci-label.c +3 -3
@@ -176,12 +176,12 @@ static int dsm_get_label(struct device *dev, char *buf, handle =ACPI_HANDLE (dev);if (!handle) -return -1 ; +return -ENODEV ; obj =acpi_evaluate_dsm (handle, &pci_acpi_dsm_guid,0x2 ,DSM_PCI_DEVICE_NAME ,NULL );if (!obj) -return -1 ; +return -EIO ; tmp = obj->package.elements; if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 &&
@@ -206,7 +206,7 @@ static int dsm_get_label(struct device *dev, char *buf,ACPI_FREE (obj); -return len >0 ? len :-1 ; +return len >0 ? len : -EIO ; }static bool device_has_dsm (struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1537/1848 ALSA: hda: Fix potential UAF for gating jack
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 27cee4141c8de82cf051104ca830c3a209816033 ]
snd_hda_jack_set_gating_jack() assigns gated and gating variables from the succeeding calls of snd_hda_jack_tbl_get(). This works normally, but the second call might kick off the reallocation of the jack table, hence the first pointer might become invalid, which leads to a UAF.
For avoiding that pitfall, this patch changes the code to two phases:
the first to only create two entries, and the second phase to get the pointers from the table, so that no relocation can happen any longer.
--- sound/pci/hda/hda_jack.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/pci/hda/hda_jack.c +6 -3
@@ -372,12 +372,15 @@ EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable);int snd_hda_jack_set_gating_jack (struct hda_codec *codec,hda_nid_t gated_nid,hda_nid_t gating_nid) { -struct hda_jack_tbl *gated =snd_hda_jack_tbl_new (codec, gated_nid,0 ); -struct hda_jack_tbl *gating = -snd_hda_jack_tbl_new (codec, gating_nid,0 ); +struct hda_jack_tbl *gated, *gating;WARN_ON (codec->dp_mst); +if (!snd_hda_jack_tbl_new (codec, gated_nid,0 ) || + !snd_hda_jack_tbl_new (codec, gating_nid,0 )) +return -ENOMEM ; + gated =snd_hda_jack_tbl_get_mst (codec, gated_nid,0 ); + gating =snd_hda_jack_tbl_get_mst (codec, gating_nid,0 );if (!gated || !gating)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1538/1848 ALSA: usb-audio: Check mixer matrix size for UAC2/3 at parsing
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 22185ffd7b31885d03fdeb20055a8707779a70f9 ]
The matrix of input/output channels specified in a UAC2/3 mixer unit must fit to the upper limit 256. Add a sanity check and returns an error if an invalid size is detected.
Stable-dep-of: c01fb2ed90c0 ("ALSA: usb-audio: Fix invalid UAC2/3 mixer unit matrix evaluation")
--- sound/usb/mixer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/usb/mixer.c +10 -0
@@ -2195,6 +2195,16 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, num_outs = err; input_pins = desc->bNrInPins; +if (state->mixer->protocol ==UAC_VERSION_2 || + state->mixer->protocol ==UAC_VERSION_3 ) { +if (input_pins * num_outs >256 ) { +usb_audio_err (state->chip, +"invalid channels for MIXER UNIT %d: input=%d, output=%d\n" , + unitid, input_pins, num_outs); +return -EINVAL ; + } + } + num_ins =0 ; ich =0 ;for (pin =0 ; pin < input_pins; pin++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1539/1848 ALSA: usb-audio: Fix invalid UAC2/3 mixer unit matrix evaluation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit c01fb2ed90c0770560ea9cc1644f205956b26a70 ]
The bitmap matrix in the mixer unit descriptor for UAC2 and UAC3 has rather the size of input-pins x output-pins, while the current USB-audio driver code wrongly assumes the UAC1 bitmap matrix size, which is input-channels x output-pins. That is, when input pins have multiple channels, the column size differs and it leads to the accesses at a wrong position.
This patch corrects the access of the bitmap matrix for UAC2/UAC3. For making the code cleaner, split the parser to UAC1 and UAC2/3, too.
--- sound/usb/mixer.c | 112 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 34 deletions(-)
sound/usb/mixer.c +78 -34
@@ -2091,7 +2091,7 @@ static bool mixer_bitmap_overflow(struct uac_mixer_unit_descriptor *desc,*/ static void build_mixer_unit_ctl (struct mixer_build *state,struct uac_mixer_unit_descriptor *desc, -int in_pin,int in_ch,int num_outs, +int in_ch,int num_outs,int unitid,struct usb_audio_term *iterm) {struct usb_mixer_elem_info *cval;
@@ -2176,34 +2176,13 @@ static int parse_audio_input_terminal(struct mixer_build *state, int unitid,/* * parse a mixer unit */ -static int parse_audio_mixer_unit (struct mixer_build *state,int unitid, -void *raw_desc) +/* UAC1 mixer unit */ +static int parse_audio_mixer_unit_v1 (struct mixer_build *state,int unitid, +int input_pins,int num_outs, +struct uac_mixer_unit_descriptor *desc) { -struct uac_mixer_unit_descriptor *desc = raw_desc;struct usb_audio_term iterm; -int input_pins, num_ins, num_outs; -int pin, ich, err; - - err =uac_mixer_unit_get_channels (state, desc); -if (err <0 ) { -usb_audio_err (state->chip, -"invalid MIXER UNIT descriptor %d\n" , - unitid); -return err; - } - - num_outs = err; - input_pins = desc->bNrInPins; - -if (state->mixer->protocol ==UAC_VERSION_2 || - state->mixer->protocol ==UAC_VERSION_3 ) { -if (input_pins * num_outs >256 ) { -usb_audio_err (state->chip, -"invalid channels for MIXER UNIT %d: input=%d, output=%d\n" , - unitid, input_pins, num_outs); -return -EINVAL ; - } - } +int num_ins, pin, ich, och, err; num_ins =0 ; ich =0 ;
@@ -2222,25 +2201,90 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, num_ins, num_outs))break ;for (; ich < num_ins; ich++) { -int och, ich_has_controls =0 ; -for (och =0 ; och < num_outs; och++) {__u8 *c =uac_mixer_unit_bmControls (desc, state->mixer->protocol); -if (check_matrix_bitmap (c, ich, och, num_outs)) { - ich_has_controls =1 ; +if (check_matrix_bitmap (c, ich, och, num_outs))break ; - } } -if (ich_has_controls) -build_mixer_unit_ctl (state, desc, pin, ich, num_outs, +if (och < num_outs) +build_mixer_unit_ctl (state, desc, ich, num_outs, unitid, &iterm); } }return 0 ; } +/* UAC2/UAC3 mixer unit */ +static int parse_audio_mixer_unit_v2 (struct mixer_build *state,int unitid, +int input_pins,int num_outs, +struct uac_mixer_unit_descriptor *desc) +{ +struct usb_audio_term iterm; +int pin, och, err; + +if (input_pins * num_outs >256 || +mixer_bitmap_overflow (desc, state->mixer->protocol, + input_pins, num_outs)) { +usb_audio_err (state->chip, +"invalid channels for MIXER UNIT %d: input=%d, output=%d\n" , + unitid, input_pins, num_outs); +return -EINVAL ; + } + +for (pin =0 ; pin < input_pins; pin++) { + err =parse_audio_unit (state, desc->baSourceID[pin]); +if (err <0 ) +continue ; +if (!num_outs) +continue ; + err =check_input_term (state, desc->baSourceID[pin], &iterm); +if (err <0 ) +return err; + +for (och =0 ; och < num_outs; och++) { +__u8 *c =uac_mixer_unit_bmControls (desc, + state->mixer->protocol); + +if (check_matrix_bitmap (c, pin, och, num_outs)) +break ; + } +if (och < num_outs) +build_mixer_unit_ctl (state, desc, pin, num_outs, + unitid, &iterm); + } +return 0 ; +} + +static int parse_audio_mixer_unit (struct mixer_build *state,int unitid, +void *raw_desc) +{ +struct uac_mixer_unit_descriptor *desc = raw_desc; +int num_outs; + + num_outs =uac_mixer_unit_get_channels (state, desc); +if (num_outs <0 ) { +usb_audio_err (state->chip, +"invalid MIXER UNIT descriptor %d\n" , + unitid); +return num_outs; + } + +switch (state->mixer->protocol) { +case UAC_VERSION_1 : +default : +return parse_audio_mixer_unit_v1 (state, unitid, + desc->bNrInPins, num_outs, + desc); +case UAC_VERSION_2 : +case UAC_VERSION_3 : +return parse_audio_mixer_unit_v2 (state, unitid, + desc->bNrInPins, num_outs, + desc); + } +} +/* * Processing Unit / Extension Unit */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1540/1848 ALSA: hda: Avoid non-operational GPU warning at regular device removal
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 3af4ed9f927c469f23d03a76e3b438ed09715bd3 ]
When a hda-intel driver is removed manually and it has a GPU with switcheroo, it always gives a warning like "GPU sound probed, but not operational:..." no matter whether GPU has been actually operational or not. This warning was originally put for machines that really suffer from the non-operational GPU HDMI audio, but it's seen at the common path a normal device removal also goes over.
For avoiding a confusing warning, move the check and the warning at the error path of azx_probe_continue() that is the point where the non-functional GPU gets detected and given up.
--- sound/pci/hda/hda_intel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/pci/hda/hda_intel.c +2 -1
@@ -1409,7 +1409,6 @@ static void azx_free(struct azx *chip)* actually stop the chip) to allow GPU to suspend via * vga_switcheroo, and print a warning. */ -dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" );pm_runtime_disable (&pci->dev);pm_runtime_set_suspended (&pci->dev);pm_runtime_enable (&pci->dev);
@@ -2445,6 +2444,8 @@ static int azx_probe_continue(struct azx *chip) out_free:if (err <0 ) {pci_set_drvdata (pci,NULL ); +if (hda->vga_switcheroo_registered) +dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" );snd_card_free (chip->card);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1541/1848 crypto: talitos - allocate channels with main struct
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 24818f77603b3fcb7f3da5802b28bcc5ac7604aa ]
Use a flexible array member to combine allocations.
Add __counted_by for extra runtime analysis.
Error in case of no channels as they are required.
Stable-dep-of: 666d66df2525 ("crypto: talitos - init tasklets before requesting IRQs")
--- drivers/crypto/talitos.c | 19 +++++++------------ drivers/crypto/talitos.h | 5 +++-- 2 files changed, 10 insertions(+), 14 deletions(-)
drivers/crypto/talitos.c +7 -12
@@ -3341,14 +3341,20 @@ static int talitos_probe(struct platform_device *ofdev)struct device *dev = &ofdev->dev;struct device_node *np = ofdev->dev.of_node;struct talitos_private *priv; +unsigned int num_channels;int i, err;int stride;struct resource *res; - priv =devm_kzalloc (dev,sizeof (struct talitos_private ),GFP_KERNEL ); +if (of_property_read_u32 (np,"fsl,num-channels" , &num_channels)) +return -EINVAL ; + + priv =devm_kzalloc (dev,struct_size (priv, chan, num_channels),GFP_KERNEL );if (!priv)return -ENOMEM ; + priv->num_channels = num_channels; +INIT_LIST_HEAD (&priv->alg_list);dev_set_drvdata (dev, priv);
@@ -3368,7 +3374,6 @@ static int talitos_probe(struct platform_device *ofdev) }/* get SEC version capabilities from device tree */ -of_property_read_u32 (np,"fsl,num-channels" , &priv->num_channels);of_property_read_u32 (np,"fsl,channel-fifo-len" , &priv->chfifo_len);of_property_read_u32 (np,"fsl,exec-units-mask" , &priv->exec_units); of_property_read_u32(np, "fsl,descriptor-types-mask",
@@ -3443,16 +3448,6 @@ static int talitos_probe(struct platform_device *ofdev) } } - priv->chan =devm_kcalloc (dev, - priv->num_channels, -sizeof (struct talitos_channel ), -GFP_KERNEL ); -if (!priv->chan) { -dev_err (dev,"failed to allocate channel management space\n" ); - err = -ENOMEM ; - goto err_out; - } - priv->fifo_len =roundup_pow_of_two (priv->chfifo_len);for (i =0 ; i < priv->num_channels; i++) {
drivers/crypto/talitos.h +3 -2
@@ -139,8 +139,6 @@ struct talitos_private {*/ unsigned int fifo_len; -struct talitos_channel *chan; -/* next channel to be assigned next incoming descriptor */ atomic_t last_chan____cacheline_aligned ;
@@ -153,6 +151,9 @@ struct talitos_private {/* hwrng device */ struct hwrng rng;bool rng_registered; + + struct talitos_channel chan[] __counted_by(num_channels); + };/* .features flag */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1542/1848 crypto: talitos - use devm_platform_ioremap_resource()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 463be1c718fb9f07bdce3d51363a17eac4522538 ]
platform_get_resource and devm_ioremap effectively open codes this.
The return type of devm_platform_ioremap_resource() is also nice as it has multiple errors that it can return.
Because it internally calls devm_request_mem_region(), reg values and sizes cannot overlap. This was manually verified to be the case for all talitos users.
Stable-dep-of: 666d66df2525 ("crypto: talitos - init tasklets before requesting IRQs")
--- drivers/crypto/talitos.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/crypto/talitos.c +3 -7
@@ -3344,7 +3344,6 @@ static int talitos_probe(struct platform_device *ofdev)unsigned int num_channels;int i, err;int stride; -struct resource *res;if (of_property_read_u32 (np,"fsl,num-channels" , &num_channels))return -EINVAL ;
@@ -3363,13 +3362,10 @@ static int talitos_probe(struct platform_device *ofdev)spin_lock_init (&priv->reg_lock); - res =platform_get_resource (ofdev,IORESOURCE_MEM ,0 ); -if (!res) -return -ENXIO ; - priv->reg =devm_ioremap (dev, res->start,resource_size (res)); -if (!priv->reg) { + priv->reg =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (priv->reg)) {dev_err (dev,"failed to of_iomap\n" ); - err = -ENOMEM ; + err =PTR_ERR (priv->reg); goto err_out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1543/1848 crypto: talitos - Use platform_get_irq() to retrieve interrupt
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 4a1c7518cc31430b96458202b6a5b4064ff0cfa0 ]
Remove the need to call irq_dispose_mapping as needed by irq_of_parse_and_map().
Simplify the function as a result. No need for gotos anymore.
Add a missing free_irq.
Stable-dep-of: 666d66df2525 ("crypto: talitos - init tasklets before requesting IRQs")
--- drivers/crypto/talitos.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
drivers/crypto/talitos.c +13 -17
@@ -191,7 +191,7 @@ static int reset_device(struct device *dev) && --timeout)cpu_relax (); -if (priv->irq[1 ]) { +if (priv->irq[1 ] >0 ) { mcr =TALITOS_MCR_RCA1 |TALITOS_MCR_RCA3 ;setbits32 (priv->reg +TALITOS_MCR , mcr); }
@@ -3173,13 +3173,11 @@ static int talitos_remove(struct platform_device *ofdev)talitos_unregister_rng (dev);for (i =0 ; i <2 ; i++) -if (priv->irq[i]) { +if (priv->irq[i] >0 )free_irq (priv->irq[i], dev); -irq_dispose_mapping (priv->irq[i]); - }tasklet_kill (&priv->done_task[0 ]); -if (priv->irq[1 ]) +if (priv->irq[1 ] >0 )tasklet_kill (&priv->done_task[1 ]);return 0 ;
@@ -3285,26 +3283,26 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,static int talitos_probe_irq (struct platform_device *ofdev) {struct device *dev = &ofdev->dev; -struct device_node *np = ofdev->dev.of_node;struct talitos_private *priv =dev_get_drvdata (dev);int err;bool is_sec1 =has_ftr_sec1 (priv); - priv->irq[0 ] =irq_of_parse_and_map (np,0 ); -if (!priv->irq[0 ]) { -dev_err (dev,"failed to map irq\n" ); -return -EINVAL ; - } + priv->irq[0 ] =platform_get_irq (ofdev,0 ); +if (priv->irq[0 ] <0 ) +return priv->irq[0 ]; +if (is_sec1) { err =request_irq (priv->irq[0 ], talitos1_interrupt_4ch,0 ,dev_driver_string (dev), dev); goto primary_out; } - priv->irq[1 ] =irq_of_parse_and_map (np,1 ); + priv->irq[1 ] =platform_get_irq_optional (ofdev,1 ); +if (priv->irq[1 ] == -EPROBE_DEFER ) +return priv->irq[1 ];/* get the primary irq line */ -if (!priv->irq[1 ]) { +if (priv->irq[1 ] <0 ) { err =request_irq (priv->irq[0 ], talitos2_interrupt_4ch,0 ,dev_driver_string (dev), dev); goto primary_out;
@@ -3320,7 +3318,6 @@ static int talitos_probe_irq(struct platform_device *ofdev) dev_driver_string(dev), dev);if (err) {dev_err (dev,"failed to request secondary irq\n" ); -irq_dispose_mapping (priv->irq[1 ]); priv->irq[1 ] =0 ; }
@@ -3329,7 +3326,6 @@ static int talitos_probe_irq(struct platform_device *ofdev) primary_out:if (err) {dev_err (dev,"failed to request primary irq\n" ); -irq_dispose_mapping (priv->irq[0 ]); priv->irq[0 ] =0 ; }
@@ -3430,7 +3426,7 @@ static int talitos_probe(struct platform_device *ofdev)tasklet_init (&priv->done_task[0 ], talitos1_done_4ch, (unsigned long )dev); }else { -if (priv->irq[1 ]) { +if (priv->irq[1 ] >0 ) {tasklet_init (&priv->done_task[0 ], talitos2_done_ch0_2, (unsigned long )dev); tasklet_init(&priv->done_task[1], talitos2_done_ch1_3,
@@ -3448,7 +3444,7 @@ static int talitos_probe(struct platform_device *ofdev)for (i =0 ; i < priv->num_channels; i++) { priv->chan[i].reg = priv->reg + stride * (i +1 ); -if (!priv->irq[1 ] || !(i &1 )) +if (priv->irq[1 ] <0 || !(i &1 )) priv->chan[i].reg +=TALITOS_CH_BASE_OFFSET ;spin_lock_init (&priv->chan[i].head_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1544/1848 crypto: talitos - init tasklets before requesting IRQs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 666d66df25253070cb297cb920b0bcfcfe5eb871 ]
The talitos interrupt handlers schedule priv->done_task[] via tasklet_schedule(). Since the second IRQ support, probe has requested the IRQs before calling tasklet_init(), so an interrupt already pending when a line is requested, e.g. engine state left by the bootloader or a kexec'd kernel, would schedule a tasklet with a NULL callback.
Look up the IRQ numbers and map the registers up front, so that -EPROBE_DEFER returns before anything is allocated and the done_task[] selection and reset_device() can see the secondary IRQ. Only request the IRQs once the channel fifos are allocated and init_device() has reset the engine. This matches remove(), which frees the IRQs before killing the tasklets.
remove() frees every IRQ number that is > 0, so make sure that only requested lines are set when it runs from the probe error path: clear both numbers when probe fails before the request, and clear any line talitos_probe_irq() did not request. Previously a failed primary request in the two-IRQ case freed the never-requested secondary line.
--- drivers/crypto/talitos.c | 54 ++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 21 deletions(-)
drivers/crypto/talitos.c +33 -21
@@ -3287,21 +3287,13 @@ static int talitos_probe_irq(struct platform_device *ofdev)int err;bool is_sec1 =has_ftr_sec1 (priv); - priv->irq[0 ] =platform_get_irq (ofdev,0 ); -if (priv->irq[0 ] <0 ) -return priv->irq[0 ]; -if (is_sec1) { err =request_irq (priv->irq[0 ], talitos1_interrupt_4ch,0 ,dev_driver_string (dev), dev); goto primary_out; } - priv->irq[1 ] =platform_get_irq_optional (ofdev,1 ); -if (priv->irq[1 ] == -EPROBE_DEFER ) -return priv->irq[1 ]; - -/* get the primary irq line */ +/* single (or primary) irq line */ if (priv->irq[1 ] <0 ) { err =request_irq (priv->irq[0 ], talitos2_interrupt_4ch,0 ,dev_driver_string (dev), dev);
@@ -3313,7 +3305,7 @@ static int talitos_probe_irq(struct platform_device *ofdev)if (err) goto primary_out; -/* get the secondary irq line */ +/* secondary irq line */ err =request_irq (priv->irq[1 ], talitos2_interrupt_ch1_3,0 ,dev_driver_string (dev), dev);if (err) {
@@ -3326,7 +3318,9 @@ static int talitos_probe_irq(struct platform_device *ofdev) primary_out:if (err) {dev_err (dev,"failed to request primary irq\n" ); +/* neither line is requested, keep remove() from freeing them */ priv->irq[0 ] =0 ; + priv->irq[1 ] =0 ; }return err;
@@ -3338,12 +3332,27 @@ static int talitos_probe(struct platform_device *ofdev)struct device_node *np = ofdev->dev.of_node;struct talitos_private *priv;unsigned int num_channels; +void __iomem *reg;int i, err;int stride; +int irq0; +int irq1;if (of_property_read_u32 (np,"fsl,num-channels" , &num_channels))return -EINVAL ; + irq0 =platform_get_irq (ofdev,0 ); +if (irq0 <0 ) +return irq0; + + irq1 =platform_get_irq_optional (ofdev,1 ); +if (irq1 == -EPROBE_DEFER ) +return irq1; + + reg =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (reg)) +return PTR_ERR (reg); + priv =devm_kzalloc (dev,struct_size (priv, chan, num_channels),GFP_KERNEL );if (!priv)return -ENOMEM ;
@@ -3358,12 +3367,7 @@ static int talitos_probe(struct platform_device *ofdev)spin_lock_init (&priv->reg_lock); - priv->reg =devm_platform_ioremap_resource (ofdev,0 ); -if (IS_ERR (priv->reg)) { -dev_err (dev,"failed to of_iomap\n" ); - err =PTR_ERR (priv->reg); - goto err_out; - } + priv->reg = reg;/* get SEC version capabilities from device tree */ of_property_read_u32 (np,"fsl,channel-fifo-len" , &priv->chfifo_len);
@@ -3414,9 +3418,7 @@ static int talitos_probe(struct platform_device *ofdev) stride =TALITOS2_CH_STRIDE ; } - err =talitos_probe_irq (ofdev); -if (err) - goto err_out; + priv->irq[0 ] = irq0;if (has_ftr_sec1 (priv)) {if (priv->num_channels ==1 )
@@ -3426,6 +3428,7 @@ static int talitos_probe(struct platform_device *ofdev)tasklet_init (&priv->done_task[0 ], talitos1_done_4ch, (unsigned long )dev); }else { + priv->irq[1 ] = irq1;if (priv->irq[1 ] >0 ) {tasklet_init (&priv->done_task[0 ], talitos2_done_ch0_2, (unsigned long )dev);
@@ -3457,7 +3460,7 @@ static int talitos_probe(struct platform_device *ofdev)if (!priv->chan[i].fifo) {dev_err (dev,"failed to allocate request fifo %d\n" , i); err = -ENOMEM ; - goto err_out; + goto err_noirq; } atomic_set(&priv->chan[i].submit_count,
@@ -3470,9 +3473,14 @@ static int talitos_probe(struct platform_device *ofdev) err =init_device (dev);if (err) {dev_err (dev,"failed to initialize device\n" ); - goto err_out; + goto err_noirq; } +/* enable interrupts once the channel fifos and tasklets are set up */ + err =talitos_probe_irq (ofdev); +if (err) + goto err_out; +/* register the RNG, if available */ if (hw_supports (dev,DESC_HDR_SEL0_RNG )) { err =talitos_register_rng (dev);
@@ -3530,6 +3538,10 @@ static int talitos_probe(struct platform_device *ofdev)return 0 ; +err_noirq: +/* the irq numbers are known, but the lines are not requested yet */ + priv->irq[0 ] =0 ; + priv->irq[1 ] =0 ; err_out:talitos_remove (ofdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1545/1848 nilfs2: reject non-regular inodes in dsync recovery
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jake Labelle <[email protected]>
[ Upstream commit ef2ccb1554df254eb4066171ce93e6d5fb1af2e3 ]
During roll-forward recovery, nilfs_recover_dsync_blocks() obtains the inode designated by fi_ino of a dsync log without checking its type. If a corrupted image designates a special inode (e.g. a device node) there, the inode's embedded bmap was never initialized:__nilfs_read_inode() calls nilfs_bmap_read() only for regular files, directories and symlinks. The subsequent nilfs_get_block() then dereferences the uninitialized bmap->b_ops and jumps through it, crashing the kernel or worse.
Regular files, directories, and symlinks are the only inode types with data blocks to recover; reject anything else before touching its block mapping.
[ryusuke: conformed AI tag to guidelines]
--- fs/nilfs2/recovery.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
fs/nilfs2/recovery.c +17 -0
@@ -510,6 +510,23 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, goto failed_inode; } +/* +* Regular files, directories, and symlinks are the only +* inode types with data blocks and an initialized bmap; +* a crafted image can reference some other inode type +* here, whose i_bmap_data was never set up by +* __nilfs_read_inode(). +*/ +if (!likely (S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode) || +S_ISLNK (inode->i_mode))) { +nilfs_warn (sb, +"%s: invalid inode type (ino=%lu, mode=0%o)" , + __func__, (unsigned long )rb->ino, + inode->i_mode); + err = -EINVAL ; + goto failed_inode; + } + pos = rb->blkoff << inode->i_blkbits; err =block_write_begin (inode->i_mapping, pos, blocksize,0 , &page, nilfs_get_block);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1546/1848 xen/blkback: Prevent missed completion when draining I/O
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
[ Upstream commit 9b4df0baa2aa03d22310e59846ca628f7afd4115 ]
xen_blk_drain_io() sets drain before checking inflight. xen_blkbk_unmap_and_respond_callback() decrements inflight with atomic_dec_and_test() before checking drain.
The pre-wait condition check was added to avoid missing a completion, but atomic_set() is unordered. With one I/O in flight, the drain path can set drain to 1 and read inflight as 1 before the completion decrement. The completion path then decrements inflight to 0 but can still read drain as
0. It skips complete(), so the drain path waits until the timeout despite no I/O remaining.
Add a full barrier between setting drain and reading inflight. atomic_dec_and_test() already provides full ordering on the completion side.
Message-ID: <[email protected]>
--- drivers/block/xen-blkback/blkback.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/block/xen-blkback/blkback.c +7 -0
@@ -1021,6 +1021,13 @@ static void xen_blk_drain_io(struct xen_blkif_ring *ring)struct xen_blkif *blkif = ring->blkif;atomic_set (&blkif->drain,1 ); +/* +* Publish drain before checking inflight. Otherwise, +* xen_blkbk_unmap_and_respond_callback() can decrement inflight with +* atomic_dec_and_test() and still see drain == 0 after this path saw +* inflight > 0, missing the completion. +*/ +smp_mb (); do { if (atomic_read(&ring->inflight) == 0) break;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1547/1848 x86/PVH: dont truncate initrd address/size
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Beulich <[email protected]>
[ Upstream commit fcc43d1d6bf5fbd41e1e308b17187f9b759df56a ]
Consuming merely the lower halves of the provided values isn't very useful. (While generally loaders try to place it below 4G, especially when it's huge it may not fit there.)
Message-ID: <[email protected]>
--- arch/x86/platform/pvh/enlighten.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/platform/pvh/enlighten.c +2 -0
@@ -82,7 +82,9 @@ static void __init init_pvh_bootparams(bool xen_guest)struct hvm_modlist_entry *modaddr =__va (pvh_start_info.modlist_paddr); pvh_bootparams.hdr.ramdisk_image = modaddr->paddr; + pvh_bootparams.ext_ramdisk_image = modaddr->paddr >>32 ; pvh_bootparams.hdr.ramdisk_size = modaddr->size; + pvh_bootparams.ext_ramdisk_size = modaddr->size >>32 ; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1548/1848 sound: usb: remove third argument of usb_maxpacket()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Mailhol <[email protected]>
[ Upstream commit 80b2b03bacfc071ceaac034fa81d535d27d57b31 ]
The third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
Stable-dep-of: e2ef553dfe92 ("ALSA: line6: Reject too small max packet sizes")
--- sound/usb/line6/pcm.c | 4 ++-- sound/usb/midi.c | 4 ++-- sound/usb/usx2y/usb_stream.c | 6 +++--- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
sound/usb/line6/pcm.c +2 -2
@@ -560,10 +560,10 @@ int line6_init_pcm(struct usb_line6 *line6, line6pcm->max_packet_size_in =usb_maxpacket (line6->usbdev, -usb_rcvisocpipe (line6->usbdev, ep_read),0 ); +usb_rcvisocpipe (line6->usbdev, ep_read)); line6pcm->max_packet_size_out =usb_maxpacket (line6->usbdev, -usb_sndisocpipe (line6->usbdev, ep_write),1 ); +usb_sndisocpipe (line6->usbdev, ep_write));if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) {dev_err (line6pcm->line6->ifcdev,"cannot get proper max packet size\n" );
sound/usb/midi.c +2 -2
@@ -1377,7 +1377,7 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_rcvintpipe (umidi->dev, ep_info->in_ep); else pipe =usb_rcvbulkpipe (umidi->dev, ep_info->in_ep); - length =usb_maxpacket (umidi->dev, pipe,0 ); + length =usb_maxpacket (umidi->dev, pipe);for (i =0 ; i <INPUT_URBS ; ++i) { buffer =usb_alloc_coherent (umidi->dev, length,GFP_KERNEL , &ep->urbs[i]->transfer_dma);
@@ -1466,7 +1466,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_sndbulkpipe (umidi->dev, ep_info->out_ep);switch (umidi->usb_id) {default : - ep->max_transfer =usb_maxpacket (umidi->dev, pipe,1 ); + ep->max_transfer =usb_maxpacket (umidi->dev, pipe);break ;/* * Various chips declare a packet size larger than 4 bytes, but
sound/usb/usx2y/usb_stream.c +3 -3
@@ -51,7 +51,7 @@ static int init_pipe_urbs(struct usb_stream_kernel *sk, {int u, p;int maxpacket = use_packsize ? - use_packsize :usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + use_packsize :usb_maxpacket (dev, pipe);int transfer_length = maxpacket * sk->n_o_ps; for (u = 0; u < USB_STREAM_NURBS;
@@ -171,7 +171,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, out_pipe =usb_sndisocpipe (dev, out_endpoint); max_packsize = use_packsize ? - use_packsize :usb_maxpacket (dev, in_pipe,0 ); + use_packsize :usb_maxpacket (dev, in_pipe);/* t_period = period_frames / sample_rate
@@ -187,7 +187,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, read_size += packets *USB_STREAM_URBDEPTH * (max_packsize +sizeof (struct usb_stream_packet )); - max_packsize =usb_maxpacket (dev, out_pipe,1 ); + max_packsize =usb_maxpacket (dev, out_pipe); write_size = max_packsize * packets *USB_STREAM_URBDEPTH ;if (read_size >=256 *PAGE_SIZE || write_size >=256 *PAGE_SIZE ) {
sound/usb/usx2y/usbusx2yaudio.c +1 -1
@@ -422,7 +422,7 @@ static int usx2y_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
sound/usb/usx2y/usx2yhwdeppcm.c +1 -1
@@ -321,7 +321,7 @@ static int usx2y_usbpcm_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1549/1848 ALSA: line6: Reject too small max packet sizes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit e2ef553dfe923959632e580bcad8583d922868ac ]
Although the LINE6 driver has a sanity check for the given max packet sizes, it still has an implicit requirement of the minimal size being bytes-per-frame; e.g. the impulse test signal assuming the fixed size, and when a too small size is specified by a malformed USB descriptor, this may lead to an OOB access.
Change the sanity check conditions to reject too small max packet sizes for avoiding the scenario above.
--- sound/usb/line6/pcm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/usb/line6/pcm.c +5 -1
@@ -564,7 +564,11 @@ int line6_init_pcm(struct usb_line6 *line6, line6pcm->max_packet_size_out =usb_maxpacket (line6->usbdev,usb_sndisocpipe (line6->usbdev, ep_write)); -if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) { +/* reject max packet sizes smaller than bytes-per-frame; +* (the magic number 6 is taken from the playback case) +*/ +if (line6pcm->max_packet_size_in <6 || + line6pcm->max_packet_size_out <6 ) {dev_err (line6pcm->line6->ifcdev,"cannot get proper max packet size\n" );return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1550/1848 ALSA: line6: Fix potential OOB write in line6_capture_copy()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit d69798357b5d562bcda1af488cda3ead4d039f8f ]
line6_capture_copy() copies the data for the original byte size, but the buffer overwrap is checked against the frame size. Because of it, when the data size isn't aligned in frames, the remaining bytes might be still copied above the buffer size.
For avoiding the potential OOB write, correct the copied data size in line6_capture_copy() to be aligned with frames.
--- sound/usb/line6/capture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/usb/line6/capture.c +2 -1
@@ -129,7 +129,8 @@ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) }else {/* copy single chunk */ memcpy (runtime->dma_area + - line6pcm->in.pos_done * bytes_per_frame, fbuf, fsize); + line6pcm->in.pos_done * bytes_per_frame, fbuf, + frames * bytes_per_frame); } line6pcm->in.pos_done += frames;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1551/1848 ALSA: hda: intel: Cancel delayed work at shutdown, too
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit b83b78df0e53d9dd872d24e49a99658815b12770 ]
The shutdown procedure needs to cancel the delayed probe work in case where the probe work stalls or is slow but still possible to reactivated.
--- sound/pci/hda/hda_intel.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/pci/hda/hda_intel.c +6 -1
@@ -2490,12 +2490,17 @@ static void azx_remove(struct pci_dev *pci)static void azx_shutdown (struct pci_dev *pci) {struct snd_card *card =pci_get_drvdata (pci); +struct hda_intel *hda;struct azx *chip;if (!card)return ; chip = card->private_data; -if (chip && chip->running) +if (!chip) +return ; + hda = container_of(chip, struct hda_intel, chip); +cancel_delayed_work_sync (&hda->probe_work); +if (chip->running)__azx_shutdown_chip (chip, true); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1552/1848 wifi: ath6kl: dont take RTNL in del_virtual_intf
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 97aab70a03df478ffefcf890ed4be258c0240bcb ]
cfg80211 already holds the RTNL here, so this will just deadlock. Remove the extra RTNL acquisition.
Oddly enough this was all true even back when the
locking here was added, so this is just a revert
of a broken ~13 year old commit.
--- drivers/net/wireless/ath/ath6kl/cfg80211.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +0 -2
@@ -1551,9 +1551,7 @@ static int ath6kl_cfg80211_del_iface(struct wiphy *wiphy,ath6kl_cfg80211_vif_stop (vif,test_bit (WMI_READY , &ar->flag)); -rtnl_lock ();ath6kl_cfg80211_vif_cleanup (vif); -rtnl_unlock ();return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1553/1848 wifi: mac80211: clear fragment cache entry is_protected
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit f3d29dc9224b0881d10d34664456adf113bc4777 ]
In practice, we probably shouldn't end up with a fragmented frame that's protected, filled into the cache, finished or dropped and then the next frame is unprotected, since only unicast data frames can be fragmented.
However, tools complain and it's more correct to be able to do this (e.g. an unencrypted fragmented EAPOL _could_, at least in theory, happen), so clear the flag when the entry is reused.
--- net/mac80211/rx.c | 1 + 1 file changed, 1 insertion(+)
net/mac80211/rx.c +1 -0
@@ -2174,6 +2174,7 @@ ieee80211_reassemble_add(struct ieee80211_fragment_cache *cache, entry->rx_queue = rx_queue; entry->last_frag = frag; entry->check_sequential_pn = false; + entry->is_protected = false; entry->extra_len =0 ;return entry;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1554/1848 wifi: mac80211: mesh: use hlist_add_head_rcu()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 2ce8b78102e91c9d6536630cdef96491121c84d3 ]
The mesh paths walk list used under RCU, so we must use hlist_add_head_rcu() to publish an entry. Fix one place that didn't do that.
--- net/mac80211/mesh_pathtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mesh_pathtbl.c +1 -1
@@ -419,7 +419,7 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata, &new_mpath->rhash, mesh_rht_params);if (!mpath) -hlist_add_head (&new_mpath->walk_list, &tbl->walk_head); +hlist_add_head_rcu (&new_mpath->walk_list, &tbl->walk_head);spin_unlock_bh (&tbl->walk_lock);if (mpath) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1555/1848 wifi: mac80211: kill wake_txqs_tasklet on unregistration
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 8ea4f50c3426aaaf3f4c118ee2c2876326ca5db5 ]
We never kill the wake_txqs_tasklet so it could be running while the hardware is being freed. Kill it, late enough to never be able to restart afterwards.
--- net/mac80211/main.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac80211/main.c +2 -0
@@ -1393,6 +1393,8 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)flush_work (&local->sched_scan_stopped_work);flush_work (&local->radar_detected_work); +tasklet_kill (&local->wake_txqs_tasklet); +ieee80211_clear_tx_pending (local);rate_control_deinitialize (local);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1556/1848 wifi: mac80211: init radiotap iter after length checks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit e3cf8da7e0c560db67ac5ee8c9197514bb298ea7 ]
The radiotap iterator initialization will already parse the presence bitmaps, so it accesses a good part of the header. This might not be present in the linear part of the SKB, we haven't checked it at this point. Check the lengths first.
--- net/mac80211/tx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/mac80211/tx.c +4 -3
@@ -2077,8 +2077,6 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,struct ieee80211_radiotap_header *rthdr = (struct ieee80211_radiotap_header *) skb->data;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb); -int ret =ieee80211_radiotap_iterator_init (&iterator, rthdr, skb->len, -NULL );u16 txflags;u16 rate =0 ;bool rate_found = false;
@@ -2087,11 +2085,14 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,u8 mcs_known, mcs_flags, mcs_bw;u16 vht_known;u8 vht_mcs =0 , vht_nss =0 ; -int i; +int ret, i;if (!ieee80211_validate_radiotap_len (skb))return false; + ret =ieee80211_radiotap_iterator_init (&iterator, rthdr, skb->len, +NULL ); + info->flags |=IEEE80211_TX_INTFL_DONT_ENCRYPT |IEEE80211_TX_CTL_DONTFRAG ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1557/1848 rtc: abx80x: fix error check after i2c_smbus_read in read_alarm()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoni Pokusinski <[email protected]>
[ Upstream commit 07c57022afb3afc0d7c20efef45a4d3c7389b1c0 ]
i2c_smbus_read_i2c_block_data() returns the number of bytes read on success and a negative error code on failure. The existing code treated any non-zero return value as an error.
Fix the error handling by checking only for negative return values.
--- drivers/rtc/rtc-abx80x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/rtc/rtc-abx80x.c +4 -2
@@ -276,8 +276,10 @@ static int abx80x_read_alarm(struct device *dev, struct rtc_wkalrm *t) err =i2c_smbus_read_i2c_block_data (client,ABX8XX_REG_ASC ,sizeof (buf), buf); -if (err) +if (err <0 )return err; +if (err <ARRAY_SIZE (buf)) +return -EIO ; irq_mask =i2c_smbus_read_byte_data (client,ABX8XX_REG_IRQ );if (irq_mask <0 )
@@ -293,7 +295,7 @@ static int abx80x_read_alarm(struct device *dev, struct rtc_wkalrm *t) t->enabled = !!(irq_mask &ABX8XX_IRQ_AIE ); t->pending = (buf[6 ] &ABX8XX_STATUS_AF ) && t->enabled; -return err; +return 0 ; }static int abx80x_set_alarm (struct device *dev,struct rtc_wkalrm *t)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1558/1848 rtc: abx80x: Add utility function for writing configuration key
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kevin P. Fleming <[email protected]>
[ Upstream commit 49dfc1f16b03a6abc17721d4600f7a0bf3d3e4ed ]
Writing one of key two values into the configuration key register is a common operation, so a utility function has been added to provide consistent behavior and eliminate code duplication.
Stable-dep-of: 632916c7bde3 ("rtc: abx80x: properly handle shared IRQs")
--- drivers/rtc/rtc-abx80x.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-)
drivers/rtc/rtc-abx80x.c +16 -23
@@ -117,6 +117,16 @@ struct abx80x_priv {struct watchdog_device wdog; }; +static int abx80x_write_config_key (struct i2c_client *client,u8 key) +{ +if (i2c_smbus_write_byte_data (client,ABX8XX_REG_CFG_KEY , key) <0 ) { +dev_err (&client->dev,"Unable to write configuration key\n" ); +return -EIO ; + } + +return 0 ; +} +static int abx80x_is_rc_mode (struct i2c_client *client) {int flags =0 ;
@@ -140,12 +150,8 @@ static int abx80x_enable_trickle_charger(struct i2c_client *client,* Write the configuration key register to enable access to the Trickle * register */ - err =i2c_smbus_write_byte_data (client,ABX8XX_REG_CFG_KEY , -ABX8XX_CFG_KEY_MISC ); -if (err <0 ) { -dev_err (&client->dev,"Unable to write configuration key\n" ); +if (abx80x_write_config_key (client,ABX8XX_CFG_KEY_MISC ) <0 )return -EIO ; - } err = i2c_smbus_write_byte_data(client, ABX8XX_REG_TRICKLE, ABX8XX_TRICKLE_CHARGE_ENABLE |
@@ -360,12 +366,8 @@ static int abx80x_rtc_set_autocalibration(struct device *dev, }/* Unlock write access to Oscillator Control Register */ - retval =i2c_smbus_write_byte_data (client,ABX8XX_REG_CFG_KEY , -ABX8XX_CFG_KEY_OSC ); -if (retval <0 ) { -dev_err (dev,"Failed to write CONFIG_KEY register\n" ); -return retval; - } +if (abx80x_write_config_key (client,ABX8XX_CFG_KEY_OSC ) <0 ) +return -EIO ; retval =i2c_smbus_write_byte_data (client,ABX8XX_REG_OSC , flags);
@@ -452,12 +454,8 @@ static ssize_t oscillator_store(struct device *dev, flags |= (ABX8XX_OSC_OSEL );/* Unlock write access on Oscillator Control register */ - retval =i2c_smbus_write_byte_data (client,ABX8XX_REG_CFG_KEY , -ABX8XX_CFG_KEY_OSC ); -if (retval <0 ) { -dev_err (dev,"Failed to write CONFIG_KEY register\n" ); -return retval; - } +if (abx80x_write_config_key (client,ABX8XX_CFG_KEY_OSC ) <0 ) +return -EIO ; retval =i2c_smbus_write_byte_data (client,ABX8XX_REG_OSC , flags);if (retval <0 ) {
@@ -765,13 +763,8 @@ static int abx80x_probe(struct i2c_client *client,* Write the configuration key register to enable access to * the config2 register */ - err =i2c_smbus_write_byte_data (client,ABX8XX_REG_CFG_KEY , -ABX8XX_CFG_KEY_MISC ); -if (err <0 ) { -dev_err (&client->dev, -"Unable to write configuration key\n" ); +if (abx80x_write_config_key (client,ABX8XX_CFG_KEY_MISC ) <0 )return -EIO ; - } err =i2c_smbus_write_byte_data (client,ABX8XX_REG_OUT_CTRL , data |ABX8XX_OUT_CTRL_EXDS );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1559/1848 rtc: abx80x: properly handle shared IRQs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoni Pokusinski <[email protected]>
[ Upstream commit 632916c7bde35495f2f6776d8e335c3ec6e306ec ]
The abx80x RTC driver registers its interrupt handler with IRQF_SHARED, but the handler always returned IRQ_HANDLED and cleared the status register even when no interrupt source from the RTC was active.
This could cause the driver to claim interrupts belonging to other devices sharing the same IRQ line and could also clear unrelated status bits in the RTC status register.
Only handle the interrupt when the alarm or watchdog flags are set, and clear only those interrupt status bits that were handled. Return IRQ_NONE when the interrupt was not generated by the RTC.
--- drivers/rtc/rtc-abx80x.c | 52 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-)
drivers/rtc/rtc-abx80x.c +50 -2
@@ -48,12 +48,18 @@#define ABX8XX_CTRL2_RSVD BIT(5)#define ABX8XX_REG_IRQ 0x12 +#define ABX8XX_IRQ_EX1E BIT(0) +#define ABX8XX_IRQ_EX2E BIT(1)#define ABX8XX_IRQ_AIE BIT(2) +#define ABX8XX_IRQ_TIE BIT(3) +#define ABX8XX_IRQ_BLIE BIT(4)#define ABX8XX_IRQ_IM_1_4 (0x3 << 5)#define ABX8XX_REG_CD_TIMER_CTL 0x18#define ABX8XX_REG_OSC 0x1c +#define ABX8XX_OSC_ACIE BIT(0) +#define ABX8XX_OSC_OFIE BIT(1)#define ABX8XX_OSC_FOS BIT(3)#define ABX8XX_OSC_BOS BIT(4)#define ABX8XX_OSC_ACAL_512 BIT(5)
@@ -249,6 +255,7 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)struct i2c_client *client = dev_id;struct abx80x_priv *priv =i2c_get_clientdata (client);struct rtc_device *rtc = priv->rtc; +unsigned int status_flags_clear;int status; status =i2c_smbus_read_byte_data (client,ABX8XX_REG_STATUS );
@@ -265,9 +272,15 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)if (status &ABX8XX_STATUS_WDT )dev_alert (&client->dev,"watchdog timeout interrupt.\n" ); -i2c_smbus_write_byte_data (client,ABX8XX_REG_STATUS ,0 ); + status_flags_clear = status & (ABX8XX_STATUS_AF |ABX8XX_STATUS_WDT ); -return IRQ_HANDLED ; +if (status_flags_clear) { +i2c_smbus_write_byte_data (client,ABX8XX_REG_STATUS , + status & ~status_flags_clear); +return IRQ_HANDLED ; + } + +return IRQ_NONE ; }static int abx80x_read_alarm (struct device *dev,struct rtc_wkalrm *t)
@@ -821,6 +834,41 @@ static int abx80x_probe(struct i2c_client *client,i2c_set_clientdata (client, priv); +/* Disable unused interrupts */ + data =i2c_smbus_read_byte_data (client,ABX8XX_REG_IRQ ); +if (data <0 ) { +dev_err (&client->dev,"Unable to read irq register\n" ); +return -EIO ; + } + + err =i2c_smbus_write_byte_data (client,ABX8XX_REG_IRQ , + data & ~(ABX8XX_IRQ_EX1E | +ABX8XX_IRQ_EX2E | +ABX8XX_IRQ_TIE | +ABX8XX_IRQ_BLIE )); +if (err <0 ) { +dev_err (&client->dev,"Unable to write irq register\n" ); +return -EIO ; + } + + data =i2c_smbus_read_byte_data (client,ABX8XX_REG_OSC ); +if (data <0 ) { +dev_err (&client->dev,"Unable to read Oscillator Control register\n" ); +return -EIO ; + } + +/* Unlock write access to Oscillator Control Register */ +if (abx80x_write_config_key (client,ABX8XX_CFG_KEY_OSC ) <0 ) +return -EIO ; + + err =i2c_smbus_write_byte_data (client,ABX8XX_REG_OSC , + data & ~(ABX8XX_OSC_ACIE | +ABX8XX_OSC_OFIE )); +if (err <0 ) { +dev_err (&client->dev,"Unable to write Oscillator Control register\n" ); +return -EIO ; + } +if (abx80x_caps[part].has_wdog) { err =abx80x_setup_watchdog (priv);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1560/1848 mailbox: ti-msgmgr: Read exact number of trailing message bytes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beleswar Padhi <[email protected]>
[ Upstream commit 645ae2edd5597501b4af3837a644877fbe194227 ]
ti_msgmgr_send_data() copies the message to the data registers in u32 units. This has been harmless so far because the clients (TI-SCI) always passed its preallocated message buffer, which is sized to the maximum message size (60 or 64 bytes, a multiple of 4), so the extra bytes read were still within the buffer. But, with a later TI-SCI update, the message size can be varying now and not guaranteed to be a multiple of 4, which would trigger KASAN out-of-bounds reports.
Therefore, memcpy() only the trailing bytes into a zeroed u32 before writing it to the register. This is at most 3 bytes, so the overhead is negligible.
--- drivers/mailbox/ti-msgmgr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mailbox/ti-msgmgr.c +10 -4
@@ -19,6 +19,7 @@#include <linux/of_irq.h> #include <linux/platform_device.h> #include <linux/soc/ti/ti-msgmgr.h> +#include <linux/string.h> #define Q_DATA_OFFSET (proxy, queue, reg) \ ((0x10000 * (proxy)) + (0x80 * (queue)) + ((reg) * 4))
@@ -380,10 +381,15 @@ static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data) trail_bytes = message->len %sizeof (u32);if (trail_bytes) { -u32 data_trail = *word_data; - -/* Ensure all unused data is 0 */ - data_trail &=0xFFFFFFFF >> (8 * (sizeof (u32) - trail_bytes)); +/* +* Copy only the trailing bytes instead of reading a full u32, +* as the message buffer may end right after them and a u32 +* read would go past the end of it. This also leaves all +* unused data as 0. +*/ +u32 data_trail =0 ; + +memcpy (&data_trail, word_data, trail_bytes);writel (data_trail, data_reg); data_reg +=sizeof (u32); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1561/1848 RDMA/mlx5: Cancel deferred page-fault EQ work before teardown
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prathamesh Deshpande <[email protected]>
[ Upstream commit aea64024ac37d29e99b82b315a56a9145dc0bc23 ]
Page-fault EQ work can remain queued after the notifier is disabled. Destroying the EQ before cancelling that work can let the worker access freed EQ memory.
Cancel the deferred work before destroying the EQ.
--- drivers/infiniband/hw/mlx5/odp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/odp.c +1 -1
@@ -1644,8 +1644,8 @@ mlx5_ib_destroy_pf_eq(struct mlx5_ib_dev *dev, struct mlx5_ib_pf_eq *eq)int err;mlx5_eq_disable (dev->mdev, eq->core, &eq->irq_nb); - err =mlx5_eq_destroy_generic (dev->mdev, eq->core);cancel_work_sync (&eq->work); + err =mlx5_eq_destroy_generic (dev->mdev, eq->core);destroy_workqueue (eq->wq);mempool_destroy (eq->pool);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1562/1848 drm/panfrost: Explicitly enable MMU interrupts at device init
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrián Larumbe <[email protected]>
[ Upstream commit 8a597d099b8b2f25df655cbe8e30765013784fed ]
Because the device must be in a position to accept jobs between the time drm_dev_register() is called and autosuspend first kicks in, there's a very narrow window inbetween during which jobs targeting the tiler buffer object would time out, since the device's PM status is 'Active', but no MMU interrupts were enabled at device initialisation time.
--- drivers/gpu/drm/panfrost/panfrost_mmu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/panfrost/panfrost_mmu.c +9 -2
@@ -195,6 +195,12 @@ void panfrost_mmu_as_put(struct panfrost_device *pfdev, struct panfrost_mmu *mmuWARN_ON (atomic_read (&mmu->as_count) <0 ); } +static void panfrost_mmu_enable_interrupts (struct panfrost_device *pfdev) +{ +mmu_write (pfdev,MMU_INT_CLEAR , ~0 ); +mmu_write (pfdev,MMU_INT_MASK , ~0 ); +} +void panfrost_mmu_reset (struct panfrost_device *pfdev) {struct panfrost_mmu *mmu, *mmu_tmp;
@@ -211,8 +217,7 @@ void panfrost_mmu_reset(struct panfrost_device *pfdev)spin_unlock (&pfdev->as_lock); -mmu_write (pfdev,MMU_INT_CLEAR , ~0 ); -mmu_write (pfdev,MMU_INT_MASK , ~0 ); +panfrost_mmu_enable_interrupts (pfdev); }static size_t get_pgsize (u64 addr,size_t size)
@@ -706,6 +711,8 @@ int panfrost_mmu_init(struct panfrost_device *pfdev)return err; } +panfrost_mmu_enable_interrupts (pfdev); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1563/1848 ACPI: PCI: pci_link: clear driver_data before free
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 691c33289b4d7a50b6fe1e03918bfbc21d4641c5 ]
acpi_pci_link_remove() frees the link object without clearing the ACPI device's driver_data pointer. The ACPI device survives hot-removal and can later be retrieved by acpi_fetch_acpi_dev(), leaving callers with a dangling pointer.
Clear driver_data before freeing the link.
--- drivers/acpi/pci_link.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/pci_link.c +1 -0
@@ -802,6 +802,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)list_del (&link->list);mutex_unlock (&acpi_link_lock); + device->driver_data =NULL ;kfree (link); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1564/1848 btrfs: qgroup: do not treat "ret > 0" as error when deleting a qgroup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit dd906477cc2c33c82ec17e6301bd4be4ea588565 ]
[BUG]
There is a bug report that when removing a child qgroup, if removing the qgroup requires a rescan, it will delete the on-disk relation and qgroup items but not the in-memory qgroup rb entry.
This makes all later qgroup rescan to fail.
[CAUSE]
The call chain looks like the following:
btrfs_remove_qgroup()
|- __del_qgroup_relation() | |- quick_update_accounting() | Which returns 1, showing this operation will require | a qgroup rescan |- if (ret) goto out;
Which skips the del_qgroup_rb() call, leaving the in-memory qgroup rb entry still intact.
Then later qgroup rescan/update will always fail and mark qgroup inconsistent:
btrfs_run_qgroups()
|- update_qgroup_info_item() | |- btrfs_search_slot() | Which returns -ENOENT, as the qgroup info item is already | deleted. |- qgroup_mark_inconsistent() |- return -ENOENT;
[FIX]
Do not treat "ret > 0" as an error.
--- fs/btrfs/qgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/qgroup.c +1 -1
@@ -1661,7 +1661,7 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid) struct btrfs_qgroup_list, next_group); ret =__del_qgroup_relation (trans, qgroupid, list->group->qgroupid); -if (ret) +if (ret <0 ) goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1565/1848 btrfs: qgroup: fix swapped blocks existence check when tracing after COW
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 0388b5bd3a6eb8bcb20208c3b6dbee96fd30bbe0 ]
In btrfs_qgroup_trace_subtree_after_cow(), after we erase the swapped block, iterate over all possible tree levels to check if we sill have other swapped blocks. However the check is wrong, it considers that there are other swapped blocks if any rbtree for any level is empty, instead of not empty. As a consequence we set blocks->swapped to true basically every time since we always find an empty rbtree at least at level 7, since in practice it's nearly impossible to find such a huge btree. This makes every future call to btrfs_qgroup_trace_subtree_after_cow() do an unnecessary rbtree search instead of returning immediately.
Fix this by updating the condition to set swapped to true if we find an rbtree that is not empty.
--- fs/btrfs/ctree.h | 2 +- fs/btrfs/qgroup.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/ctree.h +1 -1
@@ -1039,7 +1039,7 @@ enum {*/ struct btrfs_qgroup_swapped_blocks {spinlock_t lock; -/* RM_EMPTY_ROOT() of above blocks[] */ +/* True if any of the rbtrees in the blocks array below is not empty. */ bool swapped;struct rb_root blocks[BTRFS_MAX_LEVEL ]; };
fs/btrfs/qgroup.c +1 -1
@@ -4356,7 +4356,7 @@ int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans,/* Found one, remove it from @blocks first and update blocks->swapped */ rb_erase (&block->node, &blocks->blocks[level]);for (i =0 ; i <BTRFS_MAX_LEVEL ; i++) { -if (RB_EMPTY_ROOT (&blocks->blocks[i])) { +if (!RB_EMPTY_ROOT (&blocks->blocks[i])) { swapped = true;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1566/1848 nfs: set gencount on protocol-specific remove
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roberto Bergantinos Corpas <[email protected]>
[ Upstream commit 8c955dacf45f8964b98f26910ffecb5e26c02e31 ]
commit bd4928ec799b ("NFS: Avoid changing nlink when file removes and attribute updates race") avoids races on attribute cache with any inflight RPC that may modify inode attributes (and gencount) during i.e. REMOVE.
However it does not take into account that REMOVE may trigger a delegation return which also advances gencount (via the attribute refresh during delegation return), and in that case the gencount mismatch is not due to an inflight RPC that already reflected the removal.
Push the setting of gencount under each version-specific layer, reordering correctly for nfsv4 case after the delegation returns.
This fixes LTP/inotify04 failure after bd4928ec799b.
--- fs/nfs/dir.c | 13 +++---------- fs/nfs/internal.h | 1 + fs/nfs/nfs3proc.c | 8 ++++++++ fs/nfs/nfs4proc.c | 5 +++++ fs/nfs/proc.c | 8 ++++++++ 5 files changed, 25 insertions(+), 10 deletions(-)
fs/nfs/dir.c +3 -10
@@ -1523,7 +1523,7 @@ static int nfs_dentry_delete(const struct dentry *dentry) }/* Ensure that we revalidate inode->i_nlink */ -static void nfs_drop_nlink (struct inode *inode,unsigned long gencount) +void nfs_drop_nlink (struct inode *inode,unsigned long gencount) {struct nfs_inode *nfsi =NFS_I (inode);
@@ -1537,6 +1537,7 @@ static void nfs_drop_nlink(struct inode *inode, unsigned long gencount) NFS_INO_INVALID_OTHER | NFS_INO_REVAL_FORCED);spin_unlock (&inode->i_lock); } +EXPORT_SYMBOL_GPL (nfs_drop_nlink);/* * Called when the dentry loses inode.
@@ -2079,7 +2080,6 @@ EXPORT_SYMBOL_GPL(nfs_rmdir);static int nfs_safe_remove (struct dentry *dentry) {struct inode *dir =d_inode (dentry->d_parent); -struct inode *inode =d_inode (dentry);int error = -EBUSY ;dfprintk (VFS ,"NFS: safe_remove(%pd2)\n" , dentry);
@@ -2091,14 +2091,7 @@ static int nfs_safe_remove(struct dentry *dentry) }trace_nfs_remove_enter (dir, dentry); -if (inode !=NULL ) { -unsigned long gencount =READ_ONCE (NFS_I (inode)->attr_gencount); - - error =NFS_PROTO (dir)->remove (dir, dentry); -if (error ==0 ) -nfs_drop_nlink (inode, gencount); - }else - error =NFS_PROTO (dir)->remove (dir, dentry); + error =NFS_PROTO (dir)->remove (dir, dentry);if (error == -ENOENT )nfs_dentry_handle_enoent (dentry);trace_nfs_remove_exit (dir, dentry, error);
fs/nfs/internal.h +1 -0
@@ -395,6 +395,7 @@ extern unsigned long nfs_access_cache_count(struct shrinker *shrink, struct shrink_control *sc);extern unsigned long nfs_access_cache_scan (struct shrinker *shrink,struct shrink_control *sc); +extern void nfs_drop_nlink (struct inode *inode,unsigned long gencount);struct dentry *nfs_lookup (struct inode *,struct dentry *,unsigned int );int nfs_create (struct inode *,struct dentry *,umode_t ,bool );int nfs_mkdir (struct inode *,struct dentry *,umode_t );
fs/nfs/nfs3proc.c +8 -0
@@ -419,13 +419,21 @@ nfs3_proc_remove(struct inode *dir, struct dentry *dentry) .rpc_resp = &res, };int status = -ENOMEM ; +struct inode *inode =d_inode (dentry); +unsigned long gencount;dprintk ("NFS call remove %pd2\n" , dentry); res.dir_attr =nfs_alloc_fattr ();if (res.dir_attr ==NULL ) goto out; +if (inode) + gencount =READ_ONCE (NFS_I (inode)->attr_gencount); + status =rpc_call_sync (NFS_CLIENT (dir), &msg,0 ); +if (status ==0 && inode) +nfs_drop_nlink (inode, gencount); +nfs_post_op_update_inode (dir, res.dir_attr);nfs_free_fattr (res.dir_attr); out:
fs/nfs/nfs4proc.c +5 -0
@@ -4645,12 +4645,14 @@ static int nfs4_proc_remove(struct inode *dir, struct dentry *dentry) };struct inode *inode =d_inode (dentry);int err; +unsigned long gencount;if (inode) {if (inode->i_nlink ==1 )nfs4_inode_return_delegation (inode);else nfs4_inode_make_writeable (inode); + gencount =READ_ONCE (NFS_I (inode)->attr_gencount); } do { err = _nfs4_proc_remove(dir, &dentry->d_name, NF4REG);
@@ -4658,6 +4660,9 @@ static int nfs4_proc_remove(struct inode *dir, struct dentry *dentry) err =nfs4_handle_exception (NFS_SERVER (dir), err, &exception); }while (exception.retry); + +if (err ==0 && inode) +nfs_drop_nlink (inode, gencount);return err; }
fs/nfs/proc.c +8 -0
@@ -322,9 +322,17 @@ nfs_proc_remove(struct inode *dir, struct dentry *dentry) .rpc_argp = &arg, };int status; +struct inode *inode =d_inode (dentry); +unsigned long gencount;dprintk ("NFS call remove %pd2\n" ,dentry); +if (inode) + gencount =READ_ONCE (NFS_I (inode)->attr_gencount); + status =rpc_call_sync (NFS_CLIENT (dir), &msg,0 ); +if (status ==0 && inode) +nfs_drop_nlink (inode, gencount); +nfs_mark_for_revalidate (dir);dprintk ("NFS reply remove: %d\n" , status);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1567/1848 ASoC: codecs: rt5659: propagate GPIO errors
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit c1e321bd5ce6ae3702db65837cfe0c792634d603 ]
devm_gpiod_get_optional() may return an error pointer, including -EPROBE_DEFER, but rt5659_i2c_probe() does not handle these errors for the ldo1-en GPIO and does not check for errors for the reset GPIO.
Check the return values and propagate GPIO lookup errors.
--- sound/soc/codecs/rt5659.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5659.c +5 -1
@@ -4115,10 +4115,14 @@ static int rt5659_i2c_probe(struct i2c_client *i2c, rt5659->gpiod_ldo1_en =devm_gpiod_get_optional (&i2c->dev,"ldo1-en" ,GPIOD_OUT_HIGH );if (IS_ERR (rt5659->gpiod_ldo1_en)) -dev_warn (&i2c->dev,"Request ldo1-en GPIO failed\n" ); +return dev_err_probe (&i2c->dev,PTR_ERR (rt5659->gpiod_ldo1_en), +"failed to get ldo1-en GPIO\n" ); rt5659->gpiod_reset =devm_gpiod_get_optional (&i2c->dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (rt5659->gpiod_reset)) +return dev_err_probe (&i2c->dev,PTR_ERR (rt5659->gpiod_reset), +"failed to get reset GPIO\n" );/* Sleep for 300 ms miniumum */ msleep (300 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1568/1848 rcutorture: Fix divide-by-zero with fwd_progress_div=1
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunwu Chan <[email protected]>
[ Upstream commit 5b748d8aa6833f2dec3f545311be69a2064bc6d1 ]
When fwd_progress_div=1, the forward-progress test computes:
sd4 = (sd + div - 1) / div = sd
dur = sd4 + torture_random(&trs) % (sd - sd4) = sd4 + % 0
The modulo operation with a zero divisor triggers an integer division by zero (undefined behavior at the C level, #DE trap on x86), causing a kernel Oops and panic. On x86_64, this manifests as:
rcu_torture_fwd_prog_nr: Starting forward-progress test 0
Oops: divide error: 0000 [#1] SMP PTI RIP: 0010:rcu_torture_fwd_prog+0x90b/0x1160 R12: 0000000000000000
The existing guard only handles non-positive values. However, fwd_progress_div=1 also makes the random range empty because sd4 == sd.
Change the guard to reject values below 2. The forward-progress test only reaches this calculation when stall_dur() is positive, so sd = stall_dur() + 1 >= 2. For fwd_progress_div >= 2, sd4 < sd, ensuring that sd - sd4 is at least 1.
Keep the existing fallback to the default value of 4 for invalid values.
Verified with QEMU/KVM: a 138-second run with fwd_progress_div=1 completed 81 forward-progress test cycles without a crash.
--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/rcutorture.c +1 -1
@@ -2176,7 +2176,7 @@ static int __init rcu_torture_fwd_prog_init(void) }if (fwd_progress_holdoff <=0 ) fwd_progress_holdoff =1 ; -if (fwd_progress_div <=0 ) +if (fwd_progress_div <2 ) fwd_progress_div =4 ; rfp =kzalloc (sizeof (*rfp),GFP_KERNEL );if (!rfp)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1569/1848 wifi: ath10k: avoid IDR mutation during TX cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 1c1a208e65a08191901cfded3bbccc4a54e4a75c ]
ath10k_htt_flush_tx_queue() walks pending_tx with idr_for_each(). Its callback calls ath10k_txrx_tx_unref(), which removes the current entry from pending_tx through ath10k_htt_tx_free_msdu_id().
idr_for_each() keeps radix-tree iterator state across the callback. Removing the current entry can therefore invalidate that state and make the remaining walk unsafe.
Use idr_for_each_entry(), which starts a fresh lookup after each callback. The current entry can then be removed safely, while the following idr_destroy() continues to release the IDR itself.
--- drivers/net/wireless/ath/ath10k/htt_tx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath10k/htt_tx.c +7 -5
@@ -504,9 +504,8 @@ int ath10k_htt_tx_start(struct ath10k_htt *htt)return ret; } -static int ath10k_htt_tx_clean_up_pending (int msdu_id,void *skb,void *ctx) +static void ath10k_htt_tx_clean_up_pending (int msdu_id,struct ath10k *ar) { -struct ath10k *ar = ctx;struct ath10k_htt *htt = &ar->htt;struct htt_tx_done tx_done = {0 };
@@ -516,8 +515,6 @@ static int ath10k_htt_tx_clean_up_pending(int msdu_id, void *skb, void *ctx) tx_done.status =HTT_TX_COMPL_STATE_DISCARD ;ath10k_txrx_tx_unref (htt, &tx_done); - -return 0 ; }void ath10k_htt_tx_destroy (struct ath10k_htt *htt)
@@ -534,8 +531,13 @@ void ath10k_htt_tx_destroy(struct ath10k_htt *htt)static void ath10k_htt_flush_tx_queue (struct ath10k_htt *htt) { +struct sk_buff *msdu; +int msdu_id; +ath10k_htc_stop_hl (htt->ar); -idr_for_each (&htt->pending_tx, ath10k_htt_tx_clean_up_pending, htt->ar); + +idr_for_each_entry (&htt->pending_tx, msdu, msdu_id) +ath10k_htt_tx_clean_up_pending (msdu_id, htt->ar); }void ath10k_htt_tx_stop (struct ath10k_htt *htt)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1570/1848 wifi: ath11k: avoid IDR mutation during pending mgmt TX cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 3e7f5d362b2b3a21b3adb4b860aad14b69a896ad ]
The pending management TX cleanup walks txmgmt_idr with idr_for_each(), and its callback removes the current entry. This can invalidate the radix-tree iterator retained by idr_for_each().
Use idr_for_each_entry() so every iteration starts with a fresh lookup. Continue to remove each entry under txmgmt_idr_lock before freeing its skb, preventing concurrent TX completion from finding a stale skb pointer.
--- drivers/net/wireless/ath/ath11k/core.c | 3 +-- drivers/net/wireless/ath/ath11k/mac.c | 12 ++++++------ drivers/net/wireless/ath/ath11k/mac.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath11k/core.c +1 -2
@@ -784,8 +784,7 @@ static void ath11k_core_restart(struct work_struct *work)complete (&ar->thermal.wmi_sync);wake_up (&ar->dp.tx_empty_waitq); -idr_for_each (&ar->txmgmt_idr, - ath11k_mac_tx_mgmt_pending_free, ar); +ath11k_mac_tx_mgmt_pending_free (ar);idr_destroy (&ar->txmgmt_idr); }
drivers/net/wireless/ath/ath11k/mac.c +6 -6
@@ -3919,13 +3919,13 @@ static void ath11k_mac_tx_mgmt_free(struct ath11k *ar, int buf_id)ieee80211_free_txskb (ar->hw, msdu); } -int ath11k_mac_tx_mgmt_pending_free (int buf_id,void *skb,void *ctx) +void ath11k_mac_tx_mgmt_pending_free (struct ath11k *ar) { -struct ath11k *ar = ctx; - -ath11k_mac_tx_mgmt_free (ar, buf_id); +struct sk_buff *msdu; +int buf_id; -return 0 ; +idr_for_each_entry (&ar->txmgmt_idr, msdu, buf_id) +ath11k_mac_tx_mgmt_free (ar, buf_id); }static int ath11k_mac_vif_txmgmt_idr_remove (int buf_id,void *skb,void *ctx)
@@ -6198,7 +6198,7 @@ static void __ath11k_mac_unregister(struct ath11k *ar)ieee80211_unregister_hw (ar->hw); -idr_for_each (&ar->txmgmt_idr, ath11k_mac_tx_mgmt_pending_free, ar); +ath11k_mac_tx_mgmt_pending_free (ar);idr_destroy (&ar->txmgmt_idr);kfree (ar->mac.sbands[NL80211_BAND_2GHZ ].channels);
drivers/net/wireless/ath/ath11k/mac.h +1 -1
@@ -142,7 +142,7 @@ struct ath11k *ath11k_mac_get_ar_vdev_stop_status(struct ath11k_base *ab,void ath11k_mac_drain_tx (struct ath11k *ar);void ath11k_mac_peer_cleanup_all (struct ath11k *ar); -int ath11k_mac_tx_mgmt_pending_free (int buf_id,void *skb,void *ctx); +void ath11k_mac_tx_mgmt_pending_free (struct ath11k *ar);u8 ath11k_mac_bw_to_mac80211_bw (u8 bw);enum ath11k_supported_bw ath11k_mac_mac80211_bw_to_ath11k_bw (enum rate_info_bw bw);enum hal_encrypt_type ath11k_dp_tx_get_encrypt_type (u32 cipher);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1571/1848 wifi: ath11k: avoid IDR mutation during vif mgmt TX cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit dc29226dada34a6d19af77b4b51e90f8a3a8de34 ]
ath11k_mac_op_remove_interface() walks txmgmt_idr with idr_for_each(), and its callback removes each entry belonging to the interface. Removing the current entry can invalidate the radix-tree iterator retained by idr_for_each().
Move the walk into a helper that uses idr_for_each_entry(). It performs a fresh lookup for every iteration, so each matching entry can be removed through the locked removal helper without retaining iterator state across the removal.
--- drivers/net/wireless/ath/ath11k/mac.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath11k/mac.c +11 -10
@@ -3928,16 +3928,18 @@ void ath11k_mac_tx_mgmt_pending_free(struct ath11k *ar)ath11k_mac_tx_mgmt_free (ar, buf_id); } -static int ath11k_mac_vif_txmgmt_idr_remove (int buf_id,void *skb,void *ctx) +static void ath11k_mac_vif_txmgmt_cleanup (struct ath11k *ar, +struct ieee80211_vif *vif) { -struct ieee80211_vif *vif = ctx; -struct ath11k_skb_cb *skb_cb =ATH11K_SKB_CB ((struct sk_buff *)skb); -struct ath11k *ar = skb_cb->ar; - -if (skb_cb->vif == vif) -ath11k_mac_tx_mgmt_free (ar, buf_id); +struct ath11k_skb_cb *skb_cb; +struct sk_buff *skb; +int buf_id; -return 0 ; +idr_for_each_entry (&ar->txmgmt_idr, skb, buf_id) { + skb_cb =ATH11K_SKB_CB (skb); +if (skb_cb->vif == vif) +ath11k_mac_tx_mgmt_free (ar, buf_id); + } } static int ath11k_mac_mgmt_tx_wmi(struct ath11k *ar, struct ath11k_vif *arvif,
@@ -4716,8 +4718,7 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw,ath11k_peer_cleanup (ar, arvif->vdev_id); -idr_for_each (&ar->txmgmt_idr, - ath11k_mac_vif_txmgmt_idr_remove, vif); +ath11k_mac_vif_txmgmt_cleanup (ar, vif);for (i =0 ; i <DP_TCL_NUM_RING_MAX ; i++) {spin_lock_bh (&ab->dp.tx_ring[i].tx_idr_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1572/1848 mm/hmm/test: reject overflowing page counts
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit b59925301211ccc351d98d70b11f6d1b2c63150f ]
The number of pages comes directly from userspace. Shifting a value larger than ULONG_MAX >> PAGE_SHIFT discards its high bits before the existing end-address check. A request for a huge number of pages can therefore be accepted and processed as a much smaller request.
Reject page counts that cannot be represented as a byte size before performing the shift.
So far as ChatGPT and I can tell this doesn't cause an issue in practice but preventing this integer overflow is the correct thing to do.
--- lib/test_hmm.c | 2 ++ 1 file changed, 2 insertions(+)
lib/test_hmm.c +2 -0
@@ -930,6 +930,8 @@ static long dmirror_fops_unlocked_ioctl(struct file *filp,if (cmd.addr & ~PAGE_MASK )return -EINVAL ; +if (cmd.npages >ULONG_MAX >>PAGE_SHIFT ) +return -EINVAL ;if (cmd.addr >= (cmd.addr + (cmd.npages <<PAGE_SHIFT )))return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1573/1848 platform/x86: intel_telemetry: initialize default trace verbosity
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandrova Alyona <[email protected]>
[ Upstream commit 1b55ec81926eb7f6e4fad692fa4040a569e9daf7 ]
telemetry_def_get_trace_verbosity() returns success without initializing the output verbosity value.
The default telemetry operations are installed when the core driver is initialized and again by telemetry_clear_pltdata() when the platform driver is removed. The telemetry debugfs files can remain available after the platform driver removal.
A subsequent read of pss_trace_verbosity or ioss_trace_verbosity calls telemetry_get_trace_verbosity(), which may use the default callback and return success without setting verbosity. The uninitialized value is then passed to seq_printf().
Validate the output pointer and initialize the default verbosity to zero so callers never use an uninitialized value after a successful call.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/platform/x86/intel_telemetry_core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/platform/x86/intel_telemetry_core.c +4 -0
@@ -51,6 +51,10 @@ static int telemetry_def_get_eventconfig(static int telemetry_def_get_trace_verbosity (enum telemetry_unit telem_unit,u32 *verbosity) { +if (!verbosity) +return -EINVAL ; + + *verbosity =0 ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1574/1848 platform/olpc: Reserve space for a string terminator
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 1fe88b1741ff655bb59e4fd78178fe2c557b9185 ]
ec_dbgfs_cmd_write() copies user input into a zero-initialized stack buffer and passes it to sscanf(). A write that overwrites the entire buffer leaves no terminator, so the subsequent parsing can read beyond the buffer.
Limit the copy to leave room for the trailing NUL.
--- drivers/platform/olpc/olpc-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/olpc/olpc-ec.c +1 -1
@@ -270,7 +270,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,mutex_lock (&ec_dbgfs_lock); - size =simple_write_to_buffer (cmdbuf,sizeof (cmdbuf), ppos, buf, size); + size =simple_write_to_buffer (cmdbuf,sizeof (cmdbuf) -1 , ppos, buf, size); m = sscanf(cmdbuf, "%x:%u %x %x %x %x %x", &ec_cmd_int[0], &ec_dbgfs_resp_bytes, &ec_cmd_int[1], &ec_cmd_int[2],
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1575/1848 fbdev: gxt4500: Release WC setup on probe failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit b71e0bb7ad40c005b167e9b48be3af5a3fa51974 ]
gxt4500_probe() adds a write-combining range before allocating the cmap and registering the framebuffer. If a later step fails, the range is not released. Add the missing cleanup before unmapping the framebuffer, matching the successful remove path.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/video/fbdev/gxt4500.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/gxt4500.c +1 -0
@@ -717,6 +717,7 @@ static int gxt4500_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_free_cmap:fb_dealloc_cmap (&info->cmap); err_unmap_all: +arch_phys_wc_del (par->wc_cookie);iounmap (info->screen_base); err_unmap_regs:iounmap (par->regs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1576/1848 ALSA: rawmidi: Drain input work before freeing the runtime
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 8c3529f0a8faaac7d73333486f69da1617ecc579 ]
The input runtime embeds event_work, so the work must be drained before close_substream() frees the runtime. The cancellation in snd_rawmidi_input_trigger() runs before close clears substream->opened, leaving a window for snd_rawmidi_receive() to enqueue more work.
With a sequencer subscription to a USB MIDI input port, an in-flight completion can overlap the last subscription's midisynth_unsubscribe():
1. snd_usbmidi_input_data() observes input_triggered and is delayed before calling snd_rawmidi_receive().
2. Unsubscribe enters close_substream(), clears input_triggered through the provider trigger callback and returns from cancel_work_sync(). The substream is still opened.
3. The completion resumes. snd_rawmidi_receive() takes substream->lock, sees opened set and queues runtime->event_work before dropping the lock.
4. Close clears opened under that lock, closes the provider and frees the runtime. Stopping USB URBs does not drain the raw-MIDI work.
5. The queued work runs and snd_rawmidi_input_event_work() reads event or substream from the freed runtime, causing a use-after-free.
Cancel input event_work again after clearing opened, before closing the provider or releasing the runtime's private data. Receive holds substream->lock through its opened check and work enqueue, so once close has cleared opened under that lock, no further receive can queue work. The final cancellation therefore drains any late work before the runtime is freed. Keep it outside the spinlock so a running callback can finish.
--- sound/core/rawmidi.c | 3 +++ 1 file changed, 3 insertions(+)
sound/core/rawmidi.c +3 -0
@@ -521,6 +521,9 @@ static void close_substream(struct snd_rawmidi *rmidi,snd_rawmidi_output_trigger (substream,0 ); } } +/* Drain input work queued after the earlier cancellation. */ +if (substream->stream ==SNDRV_RAWMIDI_STREAM_INPUT ) +cancel_work_sync (&substream->runtime->event_work); substream->ops->close (substream);if (substream->runtime->private_free) substream->runtime->private_free (substream);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1577/1848 calipso: hash the cache key, not the option start, in calipso_cache_add()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <[email protected]>
[ Upstream commit d538cc3ec0bc4cb7b40981b3213a6c6671959ed5 ]
calipso_cache_add() stores calipso_ptr + 2 as the cache key, but computes entry->hash over calipso_ptr, i.e. starting two bytes earlier at the option type and length. calipso_opt_getattr() looks entries up with calipso_cache_check(calipso + 2, calipso[1], ...), which hashes the key itself.
The two hashes only match on a jhash collision, so the CALIPSO label cache never hits and every labelled packet takes the full DOI lookup and category conversion path. The memcmp() on the key keeps lookups correct, so this is a performance bug only.
Hash the stored key, as cipso_v4_cache_add() does for CIPSO.
--- net/ipv6/calipso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/calipso.c +1 -1
@@ -284,7 +284,7 @@ static int calipso_cache_add(const unsigned char *calipso_ptr, goto cache_add_failure; } entry->key_len = calipso_ptr_len; - entry->hash =calipso_map_cache_hash (calipso_ptr, calipso_ptr_len); + entry->hash =calipso_map_cache_hash (entry->key, calipso_ptr_len);refcount_inc (&secattr->cache->refcount); entry->lsm_data = secattr->cache;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1578/1848 clocksource/drivers/timer-mediatek: Fix random crash at boot
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Leonardo Scorcia <[email protected]>
[ Upstream commit 8496a1d234e8cf9cb15c4282cb3a11c6550bd242 ]
MediaTek bootloaders generally enable APXGPT timers at boot. This means that a timer IRQ can sometimes happen between the IRQ line request and the configuration of the clock event handler. This leads to a hard crash with an instruction abort, branch to pc 0x0 in mtk_gpt_interrupt handler as clkevt is null.
To avoid this issue request the IRQ with IRQF_NO_AUTOEN and enable it explicitly after the clock event is configured.
Issue was reported and fix tested on the Lenovo Tab E7 (TB-7104F, mt8167).
--- drivers/clocksource/timer-mediatek.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/timer-mediatek.c +3 -1
@@ -251,7 +251,7 @@ static struct timer_of to = { }, .of_irq = { - .flags = IRQF_TIMER | IRQF_IRQPOLL, + .flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NO_AUTOEN, }, };
@@ -272,6 +272,7 @@ static int __init mtk_syst_init(struct device_node *node)clockevents_config_and_register (&to.clkevt,timer_of_rate (&to),TIMER_SYNC_TICKS ,0xffffffff ); +enable_irq (timer_of_irq (&to));return 0 ; }
@@ -306,6 +307,7 @@ static int __init mtk_gpt_init(struct device_node *node) TIMER_SYNC_TICKS, 0xffffffff);mtk_gpt_enable_irq (&to,TIMER_CLK_EVT ); +enable_irq (timer_of_irq (&to));return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1579/1848 RDMA/siw: Enforce IB_ACCESS_REMOTE_READ for read responses
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haitam Lazaar <[email protected]>
[ Upstream commit f74eac4fc6c56274fb96c2c44ffad8f01c325f17 ]
When generating an RDMA READ response (SIW_OP_READ_RESPONSE), siw_check_sgl_tx() unconditionally passes 0 as the required permission mask:
/* Reference memory to be tx'd w/o checking access for LOCAL_READ */
rv = siw_check_sgl_tx(qp->pd, wqe, 0);Because perms is 0, siw_check_mem()'s authorization test:
if ((mem->perms & perms) < perms)
evaluates to (mem->perms & 0) < 0, which is always false. Consequently, an untrusted remote peer can issue an RDMA Read targeting any valid STag in the Protection Domain, even if the memory was registered strictly as write-only (IB_ACCESS_REMOTE_WRITE) without IB_ACCESS_REMOTE_READ.
Enforce that the target memory region was granted IB_ACCESS_REMOTE_READ when answering SIW_OP_READ_RESPONSE work queue entries, while preserving perms = 0 for standard local sends.
--- drivers/infiniband/sw/siw/siw_qp_tx.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +11 -7
@@ -803,17 +803,21 @@ static int siw_qp_sq_proc_tx(struct siw_qp *qp, struct siw_wqe *wqe)if (wqe->wr_status ==SIW_WR_QUEUED ) {if (!(wqe->sqe.flags &SIW_WQE_INLINE )) { -if (tx_type (wqe) ==SIW_OP_READ_RESPONSE ) - wqe->sqe.num_sge =1 ; -if (tx_type (wqe) !=SIW_OP_READ &&tx_type (wqe) !=SIW_OP_READ_LOCAL_INV ) { +enum ib_access_flags perms =0 ; +/* -* Reference memory to be tx'd w/o checking -* access for LOCAL_READ permission, since -* not defined in RDMA core. +* Local READ permission doesn't exist in RDMA core. +* A READ RESPONSE source is read by the remote peer, +* so it must be checked for REMOTE_READ permission. */ - rv =siw_check_sgl_tx (qp->pd, wqe,0 ); +if (tx_type (wqe) ==SIW_OP_READ_RESPONSE ) { + perms =IB_ACCESS_REMOTE_READ ; + wqe->sqe.num_sge =1 ; + } + + rv =siw_check_sgl_tx (qp->pd, wqe, perms);if (rv <0 ) {if (tx_type (wqe) ==SIW_OP_READ_RESPONSE )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1580/1848 wifi: mac80211: fix encryption tailroom
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chien Wong <[email protected]>
[ Upstream commit c49f54fd2abff08964677db8fdc1674c713ab42c ]
BIP-CMAC-256 and BIP-GMAC append a 26-byte MME but mac80211 currently reserves only 18 bytes of encryption tailroom.
Generating 26-byte MME may happen to work because the actual skb tailroom can exceed the requested amount. For example, dev_alloc_skb() rounds the allocation to kmalloc size buckets or alignment boundaries, and the extra space may cover the 8-byte shortfall.
Reserve enough tailroom for the 26-byte MME.
--- net/mac80211/ieee80211_i.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/ieee80211_i.h +1 -1
@@ -48,7 +48,7 @@ struct ieee80211_local;/* Required encryption head and tailroom */ #define IEEE80211_ENCRYPT_HEADROOM 8 -#define IEEE80211_ENCRYPT_TAILROOM 18 +#define IEEE80211_ENCRYPT_TAILROOM 26/* current max: GMAC/CMAC-256 MME */ /* power level hasn't been configured (or set to automatic) */ #define IEEE80211_UNSET_POWER_LEVEL INT_MIN
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1581/1848 tcp_bic: fix divide by zero on max_increment == 0
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 8edbf6c23363563e508a61f3f26f4e4b6eec9dd5 ]
max_increment is how many packets cwnd can grow per RTT, so 0 makes no sense, and bictcp_update() divides by it.
Reject values below 1 when the parameter is written.
--- net/ipv4/tcp_bic.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/ipv4/tcp_bic.c +12 -2
@@ -27,15 +27,25 @@*/ static int fast_convergence =1 ; -static int max_increment =16 ; +static unsigned int max_increment =16 ;static int low_window =14 ;static int beta =819 ;/* = 819/1024 (BICTCP_BETA_SCALE) */ static int initial_ssthresh;static int smooth_part =20 ; +static int max_increment_set (const char *val,const struct kernel_param *kp) +{ +return param_set_uint_minmax (val, kp,1 ,INT_MAX ); +} + +static const struct kernel_param_ops max_increment_ops = { + .set = max_increment_set, + .get = param_get_uint, +}; +module_param (fast_convergence, int,0644 );MODULE_PARM_DESC (fast_convergence,"turn on/off fast convergence" ); -module_param (max_increment, int,0644 ); +module_param_cb (max_increment, &max_increment_ops, &max_increment,0644 );MODULE_PARM_DESC (max_increment,"Limit on increment allowed during binary search" );module_param (low_window, int,0644 );MODULE_PARM_DESC (low_window,"lower bound on congestion window (for TCP friendliness)" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1582/1848 tcp_hybla: fix divide by zero on rtt0 == 0
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit f09eb97322b16a6f709a47599c95b62f786905f9 ]
rtt0 is the reference RTT in ms, so 0 makes no sense, and hybla_recalc_param() divides by it right from hybla_init().
Reject values below 1 when the parameter is written. Also cap it at U32_MAX / USEC_PER_MSEC, since rtt0 * USEC_PER_MSEC can wrap to 0 on 32-bit. An rtt0 above that (about 71 minutes) makes no sense anyway.
--- net/ipv4/tcp_hybla.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
net/ipv4/tcp_hybla.c +14 -2
@@ -26,8 +26,20 @@ struct hybla { };/* Hybla reference round trip time (default= 1/40 sec = 25 ms), in ms */ -static int rtt0 =25 ; -module_param (rtt0, int,0644 ); +static unsigned int rtt0 =25 ; + +static int rtt0_set (const char *val,const struct kernel_param *kp) +{ +/* avoid rtt0 * USEC_PER_MSEC overflow */ +return param_set_uint_minmax (val, kp,1 ,U32_MAX /USEC_PER_MSEC ); +} + +static const struct kernel_param_ops rtt0_ops = { + .set = rtt0_set, + .get = param_get_uint, +}; + +module_param_cb (rtt0, &rtt0_ops, &rtt0,0644 );MODULE_PARM_DESC (rtt0,"reference rout trip time (ms)" );/* This is called to refresh values for hybla parameters */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1583/1848 serial: max310x: dont clobber the TX break bit in set_termios
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tapio Reijonen <[email protected]>
[ Upstream commit 3b2de448ec0332c1cb8c38b4c5ff0c8e860befbc ]
A TX break asserted with TIOCSBRK ends early, with no error reported, as soon as any termios change lands on the port: a break is a state that must hold until TIOCCBRK, but max310x_set_termios() overwrites the whole LCR register, and LCR also carries the TX break bit that break_ctl() drives. No concurrency is required - a baud or parity change from the same process ends the break just as well, and break-led protocols lose their break with nothing in the logs.
Update only the LCR bits that are derived from termios and leave the TX break and RTS pin control bits untouched. Since nothing clears a break when a port is closed with the break still asserted - the tty core sends no break-off on release, and the unconditional write here was the accidental recovery - clear TXBREAK in startup(), the same way 8250 does.
--- drivers/tty/serial/max310x.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/tty/serial/max310x.c +15 -2
@@ -154,6 +154,8 @@#define MAX310X_LCR_FORCEPARITY_BIT (1 << 5)/* 9-bit multidrop parity */ #define MAX310X_LCR_TXBREAK_BIT (1 << 6)/* TX break enable */ #define MAX310X_LCR_RTS_BIT (1 << 7)/* RTS pin control */ +/* LCR bits owned by termios; TX break and RTS are driven elsewhere */ +#define MAX310X_LCR_TERMIOS_MASK GENMASK(5, 0)/* IRDA register bits */ #define MAX310X_IRDA_IRDAEN_BIT (1 << 0)/* IRDA mode enable */
@@ -962,8 +964,12 @@ static void max310x_set_termios(struct uart_port *port,if (termios->c_cflag &CSTOPB ) lcr |=MAX310X_LCR_STOPLEN_BIT ;/* 2 stops */ -/* Update LCR register */ -max310x_port_write (port,MAX310X_LCR_REG , lcr); +/* +* Update LCR register. Leave the TX break bit alone: it is driven by +* break_ctl(), and a whole-register write here would end a break in +* progress. +*/ +max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TERMIOS_MASK , lcr);/* Set read status mask */ port->read_status_mask =MAX310X_LSR_RXOVR_BIT ;
@@ -1083,6 +1089,13 @@ static int max310x_startup(struct uart_port *port) s->devtype->power (port,1 ); +/* +* Clear a latched break: nothing clears TXBREAK when a port is +* closed with a break still asserted, and set_termios() no longer +* rewrites it. +*/ +max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TXBREAK_BIT ,0 ); +/* Configure MODE1 register */ max310x_port_update (port,MAX310X_MODE1_REG ,MAX310X_MODE1_TRNSCVCTRL_BIT ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1584/1848 serial: max310x: remove trailing whitespaces
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit cee8e0cc9308ab55d4c3bd8eae5f6b4b65898e59 ]
Fix coding style. No functional changes.
Stable-dep-of: 4efacb600bf9 ("serial: max310x: fix breaks not reaching the wire in RS485 mode")
--- drivers/tty/serial/max310x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/max310x.c +1 -1
@@ -412,7 +412,7 @@ static int max14830_detect(struct device *dev) ret = s->if_cfg->extended_reg_enable (dev, true);if (ret)return ret; - +regmap_read (s->regmap, s->if_cfg->rev_id_reg, &val); s->if_cfg->extended_reg_enable (dev, false);if (((val & MAX310x_REV_MASK) !=MAX14830_REV_ID )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1585/1848 serial: max310x: remove holes in struct max310x_devtype
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit eaf29135abb1c152a05572a5454c61dcd65bdeea ]
Running pahole shows that there are some holes within the max310x_devtype structure.
Remove holes and optimize alignment by reorganizing structure members.
This can also lead to data structure size reduction for some CPUs.
On 64-bit CPU (arm64):
Before:
/* size: 40, cachelines: 1, members: 6 */
/* sum members: 34, holes: 2, sum holes: 6 */
/* last cacheline: 40 bytes */
After:
/* size: 40, cachelines: 1, members: 6 */
/* padding: 6 */
/* last cacheline: 40 bytes */On 32-bit CPU (i386):
Before:
/* size: 32, cachelines: 1, members: 6 */
/* sum members: 26, holes: 2, sum holes: 6 */
/* last cacheline: 32 bytes */
After:
/* size: 24, cachelines: 1, members: 8 */
/* padding: 2 */
/* last cacheline: 24 bytes */Stable-dep-of: 4efacb600bf9 ("serial: max310x: fix breaks not reaching the wire in RS485 mode")
--- drivers/tty/serial/max310x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/max310x.c +2 -2
@@ -268,11 +268,11 @@ struct max310x_devtype {unsigned short min;unsigned short max; } slave_addr; -char name[9 ];int nr; -u8 mode1;int (*detect)(struct device *);void (*power)(struct uart_port *,int ); +char name[9 ]; +u8 mode1; };struct max310x_one {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1586/1848 serial: max310x: simplify probe() and remove() error handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 5d888f1c32e2281843d58eef963e3ebd625b77a9 ]
Simplify error handling and only call uart_remove_one_port() if line bit is set, instead of having to manually set s->p[i].port.dev to NULL.
Stable-dep-of: 4efacb600bf9 ("serial: max310x: fix breaks not reaching the wire in RS485 mode")
--- drivers/tty/serial/max310x.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/tty/serial/max310x.c +7 -8
@@ -1450,10 +1450,9 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty/* Register port */ ret =uart_add_one_port (&max310x_uart, &s->p[i].port); -if (ret) { - s->p[i].port.dev =NULL ; +if (ret) goto out_uart; - } +set_bit (line, max310x_lines);/* Go to suspend mode */
@@ -1489,10 +1488,8 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty out_uart:for (i =0 ; i < devtype->nr; i++) { -if (s->p[i].port.dev) { +if (test_and_clear_bit (s->p[i].port.line, max310x_lines))uart_remove_one_port (&max310x_uart, &s->p[i].port); -clear_bit (s->p[i].port.line, max310x_lines); - } } out_clk:
@@ -1510,8 +1507,10 @@ static int max310x_remove(struct device *dev)cancel_work_sync (&s->p[i].tx_work);cancel_work_sync (&s->p[i].md_work);cancel_work_sync (&s->p[i].rs_work); -uart_remove_one_port (&max310x_uart, &s->p[i].port); -clear_bit (s->p[i].port.line, max310x_lines); + +if (test_and_clear_bit (s->p[i].port.line, max310x_lines)) +uart_remove_one_port (&max310x_uart, &s->p[i].port); + s->devtype->power (&s->p[i].port,0 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1587/1848 serial: max310x: use common detect function for all variants
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 74fe93eae5389c96d4cfd4bc0cc5a547373ab96a ]
Simplify driver by defining a common function to handle the detection of all variants.
Stable-dep-of: 4efacb600bf9 ("serial: max310x: fix breaks not reaching the wire in RS485 mode")
--- drivers/tty/serial/max310x.c | 134 ++++++++++++++--------------------- 1 file changed, 54 insertions(+), 80 deletions(-)
drivers/tty/serial/max310x.c +54 -80
@@ -66,6 +66,7 @@#define MAX310X_BRGDIVMSB_REG (0x1d)/* Baud rate divisor MSB */ #define MAX310X_CLKSRC_REG (0x1e)/* Clock source */ #define MAX310X_REG_1F (0x1f) +#define MAX310X_EXTREG_START (0x20)/* Only relevant in SPI mode. */ #define MAX310X_REVID_REG MAX310X_REG_1F/* Revision ID */
@@ -73,9 +74,9 @@#define MAX310X_GLOBALCMD_REG MAX310X_REG_1F/* Global Command (WO) */ /* Extended registers */ -#define MAX310X_SPI_REVID_EXTREG MAX310X_REG_05/* Revision ID */ -#define MAX310X_I2C_REVID_EXTREG (0x25)/* Revision ID */ - +#define MAX310X_REVID_EXTREG (0x25)/* Revision ID +* (extended addressing space) +*/ /* IRQ register bits */ #define MAX310X_IRQ_LSR_BIT (1 << 0)/* LSR interrupt */ #define MAX310X_IRQ_SPCHR_BIT (1 << 1)/* Special char interrupt */
@@ -259,8 +260,7 @@struct max310x_if_cfg {int (*extended_reg_enable)(struct device *dev,bool enable); - -unsigned int rev_id_reg; +u8 rev_id_offset; };struct max310x_devtype {
@@ -269,10 +269,11 @@ struct max310x_devtype {unsigned short max; } slave_addr;int nr; -int (*detect)(struct device *);void (*power)(struct uart_port *,int );char name[9 ];u8 mode1; +u8 rev_id_val; +u8 rev_id_reg;/* Relevant only if rev_id_val is defined. */ };struct max310x_one {
@@ -333,62 +334,52 @@ static void max310x_port_update(struct uart_port *port, u8 reg, u8 mask, u8 val)regmap_update_bits (one->regmap, reg, mask, val); } -static int max3107_detect (struct device *dev) +static int max310x_detect (struct device *dev) {struct max310x_port *s =dev_get_drvdata (dev);unsigned int val =0 ;int ret; - ret =regmap_read (s->regmap,MAX310X_REVID_REG , &val); -if (ret) -return ret; - -if (((val & MAX310x_REV_MASK) !=MAX3107_REV_ID )) { -dev_err (dev, -"%s ID 0x%02x does not match\n" , s->devtype->name, val); -return -ENODEV ; - } +/* Check if variant supports REV ID register: */ +if (s->devtype->rev_id_val) { +u8 rev_id_reg = s->devtype->rev_id_reg; -return 0 ; -} +/* Check if REV ID is in extended addressing space: */ +if (s->devtype->rev_id_reg >=MAX310X_EXTREG_START ) { + ret = s->if_cfg->extended_reg_enable (dev, true); +if (ret) +return ret; -static int max3108_detect (struct device *dev) -{ -struct max310x_port *s =dev_get_drvdata (dev); -unsigned int val =0 ; -int ret; - -/* MAX3108 have not REV ID register, we just check default value -* from clocksource register to make sure everything works. -*/ - ret =regmap_read (s->regmap,MAX310X_CLKSRC_REG , &val); -if (ret) -return ret; - -if (val != (MAX310X_CLKSRC_EXTCLK_BIT |MAX310X_CLKSRC_PLLBYP_BIT )) { -dev_err (dev,"%s not present\n" , s->devtype->name); -return -ENODEV ; - } +/* Adjust REV ID extended addressing space address: */ +if (s->if_cfg->rev_id_offset) + rev_id_reg -= s->if_cfg->rev_id_offset; + } -return 0 ; -} +regmap_read (s->regmap, rev_id_reg, &val); -static int max3109_detect (struct device *dev) -{ -struct max310x_port *s =dev_get_drvdata (dev); -unsigned int val =0 ; -int ret; +if (s->devtype->rev_id_reg >=MAX310X_EXTREG_START ) { + ret = s->if_cfg->extended_reg_enable (dev, false); +if (ret) +return ret; + } - ret = s->if_cfg->extended_reg_enable (dev, true); -if (ret) -return ret; +if (((val & MAX310x_REV_MASK) != s->devtype->rev_id_val)) +return dev_err_probe (dev, -ENODEV , +"%s ID 0x%02x does not match\n" , + s->devtype->name, val); + }else { +/* +* For variant without REV ID register, just check default value +* from clocksource register to make sure everything works. +*/ + ret =regmap_read (s->regmap,MAX310X_CLKSRC_REG , &val); +if (ret) +return ret; -regmap_read (s->regmap, s->if_cfg->rev_id_reg, &val); - s->if_cfg->extended_reg_enable (dev, false); -if (((val & MAX310x_REV_MASK) !=MAX3109_REV_ID )) { -dev_err (dev, -"%s ID 0x%02x does not match\n" , s->devtype->name, val); -return -ENODEV ; +if (val != (MAX310X_CLKSRC_EXTCLK_BIT |MAX310X_CLKSRC_PLLBYP_BIT )) +return dev_err_probe (dev, -ENODEV , +"%s not present\n" , + s->devtype->name); }return 0 ;
@@ -403,27 +394,6 @@ static void max310x_power(struct uart_port *port, int on)msleep (50 ); } -static int max14830_detect (struct device *dev) -{ -struct max310x_port *s =dev_get_drvdata (dev); -unsigned int val =0 ; -int ret; - - ret = s->if_cfg->extended_reg_enable (dev, true); -if (ret) -return ret; - -regmap_read (s->regmap, s->if_cfg->rev_id_reg, &val); - s->if_cfg->extended_reg_enable (dev, false); -if (((val & MAX310x_REV_MASK) !=MAX14830_REV_ID )) { -dev_err (dev, -"%s ID 0x%02x does not match\n" , s->devtype->name, val); -return -ENODEV ; - } - -return 0 ; -} -static void max14830_power (struct uart_port *port,int on) { max310x_port_update(port, MAX310X_BRGCFG_REG,
@@ -437,7 +407,8 @@ static const struct max310x_devtype max3107_devtype = { .name = "MAX3107", .nr = 1, .mode1 = MAX310X_MODE1_AUTOSLEEP_BIT | MAX310X_MODE1_IRQSEL_BIT, - .detect = max3107_detect, + .rev_id_val = MAX3107_REV_ID, + .rev_id_reg = MAX310X_REVID_REG, .power = max310x_power, .slave_addr = { .min = 0x2c,
@@ -449,7 +420,8 @@ static const struct max310x_devtype max3108_devtype = { .name = "MAX3108", .nr = 1, .mode1 = MAX310X_MODE1_AUTOSLEEP_BIT, - .detect = max3108_detect, + .rev_id_val = 0, /* Unsupported. */ + .rev_id_reg = 0, /* Irrelevant when rev_id_val is not defined. */ .power = max310x_power, .slave_addr = { .min = 0x60,
@@ -461,7 +433,8 @@ static const struct max310x_devtype max3109_devtype = { .name = "MAX3109", .nr = 2, .mode1 = MAX310X_MODE1_AUTOSLEEP_BIT, - .detect = max3109_detect, + .rev_id_val = MAX3109_REV_ID, + .rev_id_reg = MAX310X_REVID_EXTREG, .power = max310x_power, .slave_addr = { .min = 0x60,
@@ -473,7 +446,8 @@ static const struct max310x_devtype max14830_devtype = { .name = "MAX14830", .nr = 4, .mode1 = MAX310X_MODE1_IRQSEL_BIT, - .detect = max14830_detect, + .rev_id_val = MAX14830_REV_ID, + .rev_id_reg = MAX310X_REVID_EXTREG, .power = max14830_power, .slave_addr = { .min = 0x60,
@@ -1374,7 +1348,7 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devtydev_set_drvdata (dev, s);/* Check device to ensure we are talking to what we expect */ - ret = devtype->detect (dev); + ret =max310x_detect (dev);if (ret) goto out_clk;
@@ -1554,7 +1528,7 @@ static int max310x_spi_extended_reg_enable(struct device *dev, bool enable)static const struct max310x_if_cfg __maybe_unused max310x_spi_if_cfg = { .extended_reg_enable = max310x_spi_extended_reg_enable, - .rev_id_reg =MAX310X_SPI_REVID_EXTREG , + .rev_id_offset =MAX310X_EXTREG_START , };static int max310x_spi_probe (struct spi_device *spi)
@@ -1625,7 +1599,7 @@ static struct regmap_config regcfg_i2c = { .writeable_reg = max310x_reg_writeable, .volatile_reg = max310x_reg_volatile, .precious_reg = max310x_reg_precious, - .max_register = MAX310X_I2C_REVID_EXTREG, + .max_register = MAX310X_REVID_EXTREG, .writeable_noinc_reg = max310x_reg_noinc, .readable_noinc_reg = max310x_reg_noinc, .max_raw_read = MAX310X_FIFO_SIZE,
@@ -1634,7 +1608,7 @@ static struct regmap_config regcfg_i2c = {static const struct max310x_if_cfg max310x_i2c_if_cfg = { .extended_reg_enable = max310x_i2c_extended_reg_enable, - .rev_id_reg =MAX310X_I2C_REVID_EXTREG , + .rev_id_offset =0 ,/* No offset in I2C mode. */ }; static unsigned short max310x_i2c_slave_addr(unsigned short addr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1588/1848 serial: max310x: use common power function for all variants
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 9464833a765f66a9fbc0b972e89c1e1a13f4d3a0 ]
Simplify driver by defining a common function to handle the power control of all variants.
Stable-dep-of: 4efacb600bf9 ("serial: max310x: fix breaks not reaching the wire in RS485 mode")
--- drivers/tty/serial/max310x.c | 44 ++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 25 deletions(-)
drivers/tty/serial/max310x.c +19 -25
@@ -269,11 +269,12 @@ struct max310x_devtype {unsigned short max; } slave_addr;int nr; -void (*power)(struct uart_port *,int );char name[9 ];u8 mode1;u8 rev_id_val;u8 rev_id_reg;/* Relevant only if rev_id_val is defined. */ +u8 power_reg;/* Register address for power/sleep control. */ +u8 power_bit;/* Bit for sleep or power-off mode (active high). */ };struct max310x_one {
@@ -387,18 +388,10 @@ static int max310x_detect(struct device *dev)static void max310x_power (struct uart_port *port,int on) { -max310x_port_update (port,MAX310X_MODE1_REG , -MAX310X_MODE1_FORCESLEEP_BIT , - on ?0 :MAX310X_MODE1_FORCESLEEP_BIT ); -if (on) -msleep (50 ); -} +struct max310x_port *s =dev_get_drvdata (port->dev); -static void max14830_power (struct uart_port *port,int on) -{ -max310x_port_update (port,MAX310X_BRGCFG_REG , -MAX14830_BRGCFG_CLKDIS_BIT , - on ?0 :MAX14830_BRGCFG_CLKDIS_BIT ); +max310x_port_update (port, s->devtype->power_reg, s->devtype->power_bit, + on ?0 : s->devtype->power_bit);if (on)msleep (50 ); }
@@ -409,7 +402,8 @@ static const struct max310x_devtype max3107_devtype = { .mode1 = MAX310X_MODE1_AUTOSLEEP_BIT | MAX310X_MODE1_IRQSEL_BIT, .rev_id_val = MAX3107_REV_ID, .rev_id_reg = MAX310X_REVID_REG, - .power = max310x_power, + .power_reg = MAX310X_MODE1_REG, + .power_bit = MAX310X_MODE1_FORCESLEEP_BIT, .slave_addr = { .min = 0x2c, .max = 0x2f,
@@ -422,7 +416,8 @@ static const struct max310x_devtype max3108_devtype = { .mode1 = MAX310X_MODE1_AUTOSLEEP_BIT, .rev_id_val = 0, /* Unsupported. */ .rev_id_reg = 0, /* Irrelevant when rev_id_val is not defined. */ - .power = max310x_power, + .power_reg = MAX310X_MODE1_REG, + .power_bit = MAX310X_MODE1_FORCESLEEP_BIT, .slave_addr = { .min = 0x60, .max = 0x6f,
@@ -435,7 +430,8 @@ static const struct max310x_devtype max3109_devtype = { .mode1 = MAX310X_MODE1_AUTOSLEEP_BIT, .rev_id_val = MAX3109_REV_ID, .rev_id_reg = MAX310X_REVID_EXTREG, - .power = max310x_power, + .power_reg = MAX310X_MODE1_REG, + .power_bit = MAX310X_MODE1_FORCESLEEP_BIT, .slave_addr = { .min = 0x60, .max = 0x6f,
@@ -448,7 +444,8 @@ static const struct max310x_devtype max14830_devtype = { .mode1 = MAX310X_MODE1_IRQSEL_BIT, .rev_id_val = MAX14830_REV_ID, .rev_id_reg = MAX310X_REVID_EXTREG, - .power = max14830_power, + .power_reg = MAX310X_BRGCFG_REG, + .power_bit = MAX14830_BRGCFG_CLKDIS_BIT, .slave_addr = { .min = 0x60, .max = 0x6f,
@@ -1058,10 +1055,9 @@ static int max310x_rs485_config(struct uart_port *port,static int max310x_startup (struct uart_port *port) { -struct max310x_port *s =dev_get_drvdata (port->dev);unsigned int val; - s->devtype->power (port,1 ); +max310x_power (port,1 );/* * Clear a latched break: nothing clears TXBREAK when a port is
@@ -1113,12 +1109,10 @@ static int max310x_startup(struct uart_port *port)static void max310x_shutdown (struct uart_port *port) { -struct max310x_port *s =dev_get_drvdata (port->dev); -/* Disable all interrupts */ max310x_port_write (port,MAX310X_IRQEN_REG ,0 ); - s->devtype->power (port,0 ); +max310x_power (port,0 ); }static const char *max310x_type (struct uart_port *port)
@@ -1180,7 +1174,7 @@ static int __maybe_unused max310x_suspend(struct device *dev)for (i =0 ; i < s->devtype->nr; i++) {uart_suspend_port (&max310x_uart, &s->p[i].port); - s->devtype->power (&s->p[i].port,0 ); +max310x_power (&s->p[i].port,0 ); }return 0 ;
@@ -1192,7 +1186,7 @@ static int __maybe_unused max310x_resume(struct device *dev)int i;for (i =0 ; i < s->devtype->nr; i++) { - s->devtype->power (&s->p[i].port,1 ); +max310x_power (&s->p[i].port,1 );uart_resume_port (&max310x_uart, &s->p[i].port); }
@@ -1430,7 +1424,7 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devtyset_bit (line, max310x_lines);/* Go to suspend mode */ - devtype->power (&s->p[i].port,0 ); +max310x_power (&s->p[i].port,0 ); }#ifdef CONFIG_GPIOLIB
@@ -1485,7 +1479,7 @@ static int max310x_remove(struct device *dev)if (test_and_clear_bit (s->p[i].port.line, max310x_lines))uart_remove_one_port (&max310x_uart, &s->p[i].port); - s->devtype->power (&s->p[i].port,0 ); +max310x_power (&s->p[i].port,0 ); }clk_disable_unprepare (s->clk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1589/1848 serial: max310x: fix breaks not reaching the wire in RS485 mode
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tapio Reijonen <[email protected]>
[ Upstream commit 4efacb600bf98b13e0659f05afa4549795277e35 ]
The chip's auto-RTS (MODE1.TRNSCVCTRL) asserts the RS485 transceiver only while FIFO data is shifting out, and a break is not FIFO data: on an RS485 port a requested break sets the TX break bit but the transceiver is never enabled, so the break never reaches the wire. Break-led protocols cannot work at all.
Disable auto-RTS for the break duration and drive RTS manually via the LCR RTS bit, then restore auto-RTS when the break ends. Track the break in tx_break and leave MODE1 alone in the rs485-config worker while it is set - a TIOCSRS485 arriving mid-break would otherwise re-enable auto-RTS on top of the manual RTS and release the transceiver before the break ends; break_ctl() restores auto-RTS from the then-current configuration when the break completes. The worker runs under port->mutex - break_ctl() and set_termios() already do - so the tx_break test and the MODE1 write cannot straddle a break starting or ending, and startup() clears tx_break alongside the latched TXBREAK bit, since a port can be closed with a break still asserted.
Only the break assertion is gated on RS485 being enabled; the restore at break end runs unconditionally and derives MODE1 from the current configuration. Returning early for a port whose RS485 was disabled mid-break - that reconfigure is deferred like any other - would leak the manually driven RTS and leave the transceiver holding the bus indefinitely after the break ends. On a non-RS485 port the restore is a no-op: nothing else writes the LCR RTS bit.
--- drivers/tty/serial/max310x.c | 49 ++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)
drivers/tty/serial/max310x.c +47 -2
@@ -283,6 +283,7 @@ struct max310x_one {struct work_struct md_work;struct work_struct rs_work;struct regmap *regmap; +bool tx_break;/* break_ctl() owns the transceiver */ u8 rx_buf[MAX310X_FIFO_SIZE ]; };
@@ -655,6 +656,12 @@ static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned int lregmap_noinc_read (one->regmap,MAX310X_RHR_REG , rxbuf, len); } +static void max310x_rts_ctl (struct uart_port *port,bool rts_state) +{ +max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_RTS_BIT , + rts_state ?MAX310X_LCR_RTS_BIT :0 ); +} +static void max310x_handle_rx (struct uart_port *port,unsigned int rxlen) {struct max310x_one *one =to_max310x_port (port);
@@ -893,9 +900,32 @@ static void max310x_set_mctrl(struct uart_port *port, unsigned int mctrl)static void max310x_break_ctl (struct uart_port *port,int break_state) { +struct max310x_one *one =to_max310x_port (port); + + one->tx_break = break_state; +max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TXBREAK_BIT , break_state ?MAX310X_LCR_TXBREAK_BIT :0 ); + +/* +* The chip's auto-RTS asserts the transceiver only while FIFO data is +* shifting out, and a break is not FIFO data. Disable auto-RTS for the +* break duration and drive RTS manually so the break reaches the wire; +* restore auto-RTS when the break ends. +*/ +if (break_state) { +if (!(port->rs485.flags &SER_RS485_ENABLED )) +return ; +max310x_port_update (port,MAX310X_MODE1_REG , +MAX310X_MODE1_TRNSCVCTRL_BIT ,0 ); + }else { +max310x_port_update (port,MAX310X_MODE1_REG , +MAX310X_MODE1_TRNSCVCTRL_BIT , + (port->rs485.flags &SER_RS485_ENABLED ) ? +MAX310X_MODE1_TRNSCVCTRL_BIT :0 ); + } +max310x_rts_ctl (port, break_state); } static void max310x_set_termios(struct uart_port *port,
@@ -1017,6 +1047,13 @@ static void max310x_rs_proc(struct work_struct *ws) struct max310x_one *one = container_of(ws, struct max310x_one, rs_work);unsigned int delay, mode1 =0 , mode2 =0 ; +/* +* Serialize against break_ctl() and set_termios(), which run under +* port->mutex: the tx_break test below and the MODE1 write must not +* straddle a break starting or ending. +*/ +guard (mutex)(&one->port.state->port.mutex); + delay = (one->port.rs485.delay_rts_before_send <<4 ) | one->port.rs485.delay_rts_after_send;max310x_port_write (&one->port,MAX310X_HDPIXDELAY_REG , delay);
@@ -1028,8 +1065,14 @@ static void max310x_rs_proc(struct work_struct *ws) mode2 =MAX310X_MODE2_ECHOSUPR_BIT ; } -max310x_port_update (&one->port,MAX310X_MODE1_REG , -MAX310X_MODE1_TRNSCVCTRL_BIT , mode1); +/* +* A break owns the transceiver: break_ctl() disabled auto-RTS and +* drives RTS manually, and restores it when the break ends. Leave +* MODE1 alone meanwhile or the break goes undriven mid-way. +*/ +if (!one->tx_break) +max310x_port_update (&one->port,MAX310X_MODE1_REG , +MAX310X_MODE1_TRNSCVCTRL_BIT , mode1);max310x_port_update (&one->port,MAX310X_MODE2_REG ,MAX310X_MODE2_ECHOSUPR_BIT , mode2); }
@@ -1055,6 +1098,7 @@ static int max310x_rs485_config(struct uart_port *port,static int max310x_startup (struct uart_port *port) { +struct max310x_one *one =to_max310x_port (port);unsigned int val;max310x_power (port,1 );
@@ -1064,6 +1108,7 @@ static int max310x_startup(struct uart_port *port)* closed with a break still asserted, and set_termios() no longer * rewrites it. */ + one->tx_break = false;max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TXBREAK_BIT ,0 );/* Configure MODE1 register */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1590/1848 serial: max310x: centralize the RS485 transceiver programming
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tapio Reijonen <[email protected]>
[ Upstream commit 56051740bf9720335a1a56e87a99e3491c33ce54 ]
The HDPIXDELAY RTS delays and the MODE1 auto-transceiver enable are programmed in three places - the rs485-config worker, startup() and break_ctl()'s break-off restore - each with its own copy of the register sequence. Move the sequence into a helper, max310x_set_rts_ctl_params(), together with the tx_break guard that keeps the MODE1 write away from a break in progress; the break-off restore reapplies the current configuration through the same helper.
No functional change intended. The copies differed only in that startup() clamped the delays to the 4-bit field while the worker wrote them unclamped; the helper clamps, and the difference is unreachable while rs485_config() still rejects delays above 15 ms with -ERANGE. Break-off additionally rewrites HDPIXDELAY with the values it already holds, a no-op on the wire.
Stable-dep-of: 7784d6aee59a ("serial: max310x: fix RS485 delays being programmed as bit-times")
--- drivers/tty/serial/max310x.c | 85 ++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 38 deletions(-)
drivers/tty/serial/max310x.c +47 -38
@@ -898,6 +898,38 @@ static void max310x_set_mctrl(struct uart_port *port, unsigned int mctrl)schedule_work (&one->md_work); } +/* +* Program the chip's RS485 RTS timing (HDPIXDELAY) and the auto +* transceiver control (MODE1) from the current configuration. The +* rs485-config worker, startup() and break_ctl()'s break-off restore +* each carried their own copy of this sequence. +*/ +static void max310x_set_rts_ctl_params (struct max310x_one *one) +{ +struct uart_port *port = &one->port; +unsigned int delay; +u8 mode1 =0 ; + + delay = (clamp (port->rs485.delay_rts_before_send,0U ,15U ) <<4 ) | +clamp (port->rs485.delay_rts_after_send,0U ,15U ); +max310x_port_write (port,MAX310X_HDPIXDELAY_REG , delay); + +if (port->rs485.flags &SER_RS485_ENABLED ) + mode1 =MAX310X_MODE1_TRNSCVCTRL_BIT ; + +/* +* A break owns the transceiver: break_ctl() disabled auto-RTS and +* drives RTS manually, and restores it from the current +* configuration when the break ends. Touching MODE1 here would +* release the transceiver mid-break. +*/ +if (one->tx_break) +return ; + +max310x_port_update (port,MAX310X_MODE1_REG , +MAX310X_MODE1_TRNSCVCTRL_BIT , mode1); +} +static void max310x_break_ctl (struct uart_port *port,int break_state) {struct max310x_one *one =to_max310x_port (port);
@@ -920,10 +952,7 @@ static void max310x_break_ctl(struct uart_port *port, int break_state)max310x_port_update (port,MAX310X_MODE1_REG ,MAX310X_MODE1_TRNSCVCTRL_BIT ,0 ); }else { -max310x_port_update (port,MAX310X_MODE1_REG , -MAX310X_MODE1_TRNSCVCTRL_BIT , - (port->rs485.flags &SER_RS485_ENABLED ) ? -MAX310X_MODE1_TRNSCVCTRL_BIT :0 ); +max310x_set_rts_ctl_params (one); }max310x_rts_ctl (port, break_state); }
@@ -1045,36 +1074,23 @@ static void max310x_set_termios(struct uart_port *port,static void max310x_rs_proc (struct work_struct *ws) { struct max310x_one *one = container_of(ws, struct max310x_one, rs_work); -unsigned int delay, mode1 =0 , mode2 =0 ; +unsigned int mode2 =0 ;/* * Serialize against break_ctl() and set_termios(), which run under -* port->mutex: the tx_break test below and the MODE1 write must not +* port->mutex: the tx_break-guarded register writes must not * straddle a break starting or ending. */ guard (mutex)(&one->port.state->port.mutex); - delay = (one->port.rs485.delay_rts_before_send <<4 ) | - one->port.rs485.delay_rts_after_send; -max310x_port_write (&one->port,MAX310X_HDPIXDELAY_REG , delay); +max310x_set_rts_ctl_params (one); -if (one->port.rs485.flags &SER_RS485_ENABLED ) { - mode1 =MAX310X_MODE1_TRNSCVCTRL_BIT ; +if (one->port.rs485.flags &SER_RS485_ENABLED && + !(one->port.rs485.flags &SER_RS485_RX_DURING_TX )) + mode2 =MAX310X_MODE2_ECHOSUPR_BIT ; -if (!(one->port.rs485.flags &SER_RS485_RX_DURING_TX )) - mode2 =MAX310X_MODE2_ECHOSUPR_BIT ; - } - -/* -* A break owns the transceiver: break_ctl() disabled auto-RTS and -* drives RTS manually, and restores it when the break ends. Leave -* MODE1 alone meanwhile or the break goes undriven mid-way. -*/ -if (!one->tx_break) -max310x_port_update (&one->port,MAX310X_MODE1_REG , -MAX310X_MODE1_TRNSCVCTRL_BIT , mode1);max310x_port_update (&one->port,MAX310X_MODE2_REG , -MAX310X_MODE2_ECHOSUPR_BIT , mode2); +MAX310X_MODE2_ECHOSUPR_BIT , mode2); } static int max310x_rs485_config(struct uart_port *port,
@@ -1121,21 +1137,14 @@ static int max310x_startup(struct uart_port *port)max310x_port_update (port,MAX310X_MODE2_REG ,MAX310X_MODE2_FIFORST_BIT ,0 ); -/* Configure mode1/mode2 to have rs485/rs232 enabled at startup */ - val = (clamp (port->rs485.delay_rts_before_send,0U ,15U ) <<4 ) | -clamp (port->rs485.delay_rts_after_send,0U ,15U ); -max310x_port_write (port,MAX310X_HDPIXDELAY_REG , val); - -if (port->rs485.flags &SER_RS485_ENABLED ) { -max310x_port_update (port,MAX310X_MODE1_REG , -MAX310X_MODE1_TRNSCVCTRL_BIT , -MAX310X_MODE1_TRNSCVCTRL_BIT ); +/* Configure the RS485 RTS timing and the RS485/RS232 mode bits. */ +max310x_set_rts_ctl_params (one); -if (!(port->rs485.flags &SER_RS485_RX_DURING_TX )) -max310x_port_update (port,MAX310X_MODE2_REG , -MAX310X_MODE2_ECHOSUPR_BIT , -MAX310X_MODE2_ECHOSUPR_BIT ); - } +if (port->rs485.flags &SER_RS485_ENABLED && + !(port->rs485.flags &SER_RS485_RX_DURING_TX )) +max310x_port_update (port,MAX310X_MODE2_REG , +MAX310X_MODE2_ECHOSUPR_BIT , +MAX310X_MODE2_ECHOSUPR_BIT );/* Configure flow control levels */ /* Flow control halt level 96, resume level 48 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1591/1848 serial: max310x: fix RS485 delays being programmed as bit-times
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tapio Reijonen <[email protected]>
[ Upstream commit 7784d6aee59a142505072b3fbea97932b2fd1fa0 ]
The HDPIXDELAY register counts the RTS setup and hold delays in bit-times, four bits per direction, but the driver has been writing the struct serial_rs485 delay_rts_before_send/delay_rts_after_send values into it unconverted - and the uapi expresses those in milliseconds. A requested 9 ms setup delay is programmed as 9 bit-times, which at 9600 baud is 0.94 ms, roughly a tenth of what userspace asked for; the error grows with the baud rate.
Cache the baud rate in set_termios() and convert the delays to bit-times at the current rate, rounding up so the delay on the wire is never shorter than requested, and capping at the 15 bit-times the 4-bit field can hold. The conversion lives in max310x_set_rts_ctl_params(); set_termios() now calls it as well, since the conversion depends on the baud rate.
The delays a 4-bit bit-time field can represent still fall well short of the milliseconds the uapi can express; requests beyond 15 bit-times are capped, and the -ERANGE rejection of values above 15 ms remains in place for now.
--- drivers/tty/serial/max310x.c | 40 ++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-)
drivers/tty/serial/max310x.c +31 -9
@@ -162,6 +162,10 @@#define MAX310X_IRDA_IRDAEN_BIT (1 << 0)/* IRDA mode enable */ #define MAX310X_IRDA_SIR_BIT (1 << 1)/* SIR mode enable */ +/* HDPIXDELAY accessor macros */ +#define MAX310X_HDPIXDELAY_SETUP (val) (((val) & 0x0f) << 4) +#define MAX310X_HDPIXDELAY_HOLD (val) ((val) & 0x0f) +/* Flow control trigger level register masks */ #define MAX310X_FLOWLVL_HALT_MASK (0x000f)/* Flow control halt level */ #define MAX310X_FLOWLVL_RES_MASK (0x00f0)/* Flow control resume level */
@@ -283,6 +287,7 @@ struct max310x_one {struct work_struct md_work;struct work_struct rs_work;struct regmap *regmap; +unsigned int baud;bool tx_break;/* break_ctl() owns the transceiver */ u8 rx_buf[MAX310X_FIFO_SIZE ];
@@ -899,23 +904,33 @@ static void max310x_set_mctrl(struct uart_port *port, unsigned int mctrl) }/* -* Program the chip's RS485 RTS timing (HDPIXDELAY) and the auto -* transceiver control (MODE1) from the current configuration. The -* rs485-config worker, startup() and break_ctl()'s break-off restore -* each carried their own copy of this sequence. +* Program the chip's RS485 RTS timing. The HDPIXDELAY setup and hold fields +* count bit-times, four bits per direction, while the uapi expresses the +* delays in milliseconds: convert at the current baud rate, rounding up, and +* cap at the field maximum. */ static void max310x_set_rts_ctl_params (struct max310x_one *one) { +const unsigned int max_bit_dly =15 ;struct uart_port *port = &one->port; -unsigned int delay; +unsigned int setup =0 , hold =0 ;u8 mode1 =0 ; - delay = (clamp (port->rs485.delay_rts_before_send,0U ,15U ) <<4 ) | -clamp (port->rs485.delay_rts_after_send,0U ,15U ); -max310x_port_write (port,MAX310X_HDPIXDELAY_REG , delay); +if (port->rs485.flags &SER_RS485_ENABLED ) { +/* Convert milliseconds to bit-times, rounding up. */ + setup =DIV_ROUND_UP (one->baud * port->rs485.delay_rts_before_send, +MSEC_PER_SEC ); + hold =DIV_ROUND_UP (one->baud * port->rs485.delay_rts_after_send, +MSEC_PER_SEC ); + setup =min (setup, max_bit_dly); + hold =min (hold, max_bit_dly); -if (port->rs485.flags &SER_RS485_ENABLED ) mode1 =MAX310X_MODE1_TRNSCVCTRL_BIT ; + } + +max310x_port_write (port,MAX310X_HDPIXDELAY_REG , +MAX310X_HDPIXDELAY_SETUP (setup) | +MAX310X_HDPIXDELAY_HOLD (hold));/* * A break owns the transceiver: break_ctl() disabled auto-RTS and
@@ -1069,6 +1084,13 @@ static void max310x_set_termios(struct uart_port *port,/* Update timeout according to new baud rate */ uart_update_timeout (port, termios->c_cflag, baud); + +/* +* Cache the new baud rate and reprogram the RS485 RTS delays, whose +* millisecond-to-bit-time conversion depends on it. +*/ +to_max310x_port (port)->baud = baud; +max310x_set_rts_ctl_params (to_max310x_port (port)); }static void max310x_rs_proc (struct work_struct *ws)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1592/1848 net: alacritech: fix dma_free_coherent() in error path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 05b5019b01fb9443b09ae4ed34af1135a80a84c8 ]
In slic_init_stat_queue(), a series of coherent buffers is allocated with the length size. The size is then stored in stq->mem_size for normal deallocation. However, in the error path, stq->mem_size is also used but is not initialized. This error may leave the freed buffers mapped, leaking a resource and allowing the device to access freed memory.
Change the length in error path to size.
--- drivers/net/ethernet/alacritech/slicoss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/alacritech/slicoss.c +1 -1
@@ -813,7 +813,7 @@ static int slic_init_stat_queue(struct slic_device *sdev) free_descs:while (i--) { -dma_free_coherent (&sdev->pdev->dev, stq->mem_size, +dma_free_coherent (&sdev->pdev->dev, size, stq->descs[i] - stq->addr_offset[i], stq->paddr[i] - stq->addr_offset[i]); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1593/1848 comedi: comedi_parport: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 790ea6844593bcd03b0379986fc821d8c511746e ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. comedi_parport passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
A parallel port asserts a legacy ISA interrupt, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
syzbot hit this one:
remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'comedi_parport' WARNING: fs/proc/generic.c:747 at remove_proc_entry+0x4e7/0x610 fs/proc/generic.c:747 Call Trace: <TASK> unregister_irq_proc+0x206/0x2a0 kernel/irq/proc.c:406 free_desc+0x89/0x330 kernel/irq/irqdesc.c:482 irq_free_descs+0x84/0xc0 kernel/irq/irqdesc.c:865 irq_domain_free_irqs+0x46a/0x5c0 kernel/irq/irqdomain.c:1917 mp_unmap_irq+0xf8/0x130 arch/x86/kernel/apic/io_apic.c:1061 acpi_unregister_gsi_ioapic+0x40/0x60 arch/x86/kernel/acpi/boot.c:722 acpi_pci_irq_disable+0x275/0x360 drivers/acpi/pci_irq.c:517 pci_disable_device+0x130/0x270 drivers/pci/pci.c:2206 pci_device_remove+0xb2/0x1d0 drivers/pci/pci-driver.c:512 device_release_driver_internal+0x44e/0x620 drivers/base/dd.c:1372 unbind_store+0xf8/0x110 drivers/base/bus.c:244 </TASK>
The leaked /proc entry the warning names is the mild part. mp_chip_data->count tracks GSI mappings rather than request_irq() users, and __setup_irq() takes no reference on the descriptor, so the irq_desc is freed with the comedi irqaction still attached to it.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/staging/comedi/drivers/comedi_parport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/comedi/drivers/comedi_parport.c +2 -1
@@ -241,7 +241,8 @@ static int parport_attach(struct comedi_device *dev,outb (0 , dev->iobase +PARPORT_DATA_REG );outb (0 , dev->iobase +PARPORT_CTRL_REG ); -if (it->options[1 ]) { +/* only ISA interrupts are valid on a parallel port */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], parport_interrupt,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1594/1848 comedi: ni_atmio16d: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 71424db0ebb5f484fa3f386910f8ce9da95b8b2e ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. ni_atmio16d passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
The driver already documents which interrupts the board can assert -- "0 == no irq; or 3,4,5,6,7,9,10,11,12,14,15" -- so use exactly that set rather than the whole ISA range.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/staging/comedi/drivers/ni_atmio16d.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/comedi/drivers/ni_atmio16d.c +3 -1
@@ -593,7 +593,9 @@ static int atmio16d_attach(struct comedi_device *dev,/* reset the atmio16d hardware */ reset_atmio16d (dev); -if (it->options[1 ]) { +/* only irqs 3, 4, 5, 6, 7, 9, 10, 11, 12, 14, and 15 are valid */ +if (it->options[1 ] >=3 && it->options[1 ] <=15 && + (1 << it->options[1 ]) &0xdef8 ) { ret =request_irq (it->options[1 ], atmio16d_interrupt,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1595/1848 comedi: dt2814: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 81026c2b3f9096cdfdfa02918f94865629fb7f90 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. dt2814 passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
Every interrupt this board can assert is a legacy ISA one, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/staging/comedi/drivers/dt2814.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/comedi/drivers/dt2814.c +2 -1
@@ -244,7 +244,8 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) i =inb (dev->iobase +DT2814_DATA ); i =inb (dev->iobase +DT2814_DATA ); -if (it->options[1 ]) { +/* only ISA interrupts are valid on this board */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], dt2814_interrupt,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1596/1848 comedi: dmm32at: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 797d56d7f90864e67424f8e82639a9b3aedf37e0 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. dmm32at passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
Every interrupt this board can assert is a legacy ISA one, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/staging/comedi/drivers/dmm32at.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/comedi/drivers/dmm32at.c +2 -1
@@ -585,7 +585,8 @@ static int dmm32at_attach(struct comedi_device *dev,return ret; } -if (it->options[1 ]) { +/* only ISA interrupts are valid on this board */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], dmm32at_isr,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1597/1848 comedi: pcmmio: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 23c6fc62e754f8bc412ceb5c0d9aaa14f2c9ff31 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. pcmmio passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
The board's interrupt is routed in software rather than jumpered, and the driver notes that "any IRQ from 1-15 is OK", so the ISA range is exactly the right bound.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/staging/comedi/drivers/pcmmio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/comedi/drivers/pcmmio.c +2 -1
@@ -684,7 +684,8 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)pcmmio_reset (dev); -if (it->options[1 ]) { +/* the irq is configured in software, so any ISA irq is OK */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], interrupt_pcmmio,0 , dev->board_name, dev);if (ret ==0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1598/1848 comedi: pcmuio: validate the IRQs supplied by userspace
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 9c325b21bba99e597771137fc11b9427c86618d8 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. pcmuio passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
Every interrupt this board can assert is a legacy ISA one, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
This board takes two interrupts, one per ASIC, so options[1] and options[2] both need the check. The existing options[2] == dev->irq case is left alone: it covers both ASICs sharing one interrupt and neither having one, and by then options[1] has already been validated.
--- drivers/staging/comedi/drivers/pcmuio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/comedi/drivers/pcmuio.c +3 -2
@@ -546,7 +546,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)pcmuio_reset (dev); -if (it->options[1 ]) { +/* only ISA interrupts are valid on this board */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) {/* request the irq for the 1st asic */ ret =request_irq (it->options[1 ], pcmuio_interrupt,0 , dev->board_name, dev);
@@ -558,7 +559,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)if (it->options[2 ] == dev->irq) {/* the same irq (or none) is used by both asics */ devpriv->irq2 = it->options[2 ]; - }else if (it->options[2 ]) { + }else if (it->options[2 ] >=1 && it->options[2 ] <=15 ) {/* request the irq for the 2nd asic */ ret =request_irq (it->options[2 ], pcmuio_interrupt,0 , dev->board_name, dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1599/1848 thermal/drivers/ti-soc-thermal: Cancel pending alert work on remove
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit aaa6c8dec49339710f9fd2a2af5646cf4111dbd4 ]
On a threshold crossing, the talert IRQ handler calls ti_thermal_report_sensor_temperature(), which queues the work embedded in the sensor's ti_thermal_data on the system workqueue. Nothing ever cancels or flushes that work.
ti_bandgap_remove() frees the talert IRQ last. free_irq() waits for a running handler, but not for the work the handler has queued. When remove returns, devres unregisters and frees the thermal zones and then frees the devm-allocated ti_thermal_data, so a work item that is still pending runs ti_thermal_work() on freed memory:
ti_thermal_work() data = container_of(work, struct ti_thermal_data, thermal_wq); thermal_zone_device_update(data->ti_thermal, ...);
Free the talert IRQ before removing the sensors, so that no new work can be queued, and cancel the work in ti_thermal_remove_sensor().
This needs an OMAP4460/4470 or OMAP5 SoC (DRA7 has TALERT but no ->report_temperature, so it never queues the work), a threshold crossing just before the driver is unbound or unloaded, and the work still pending when devres frees the data.
Found by static analysis tool CodeQL.
--- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 7 ++++--- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/thermal/ti-soc-thermal/ti-bandgap.c +4 -3
@@ -1072,6 +1072,10 @@ int ti_bandgap_remove(struct platform_device *pdev)if (!soc_device_match (soc_no_cpu_notifier))cpu_pm_unregister_notifier (&bgp->nb); +/* Stop the alerts first: they queue work on the sensors' data */ +if (TI_BANDGAP_HAS (bgp,TALERT )) +free_irq (bgp->irq, bgp); +/* Remove sensor interfaces */ for (i =0 ; i < bgp->conf->sensor_count; i++) {if (bgp->conf->sensors[i].unregister_cooling)
@@ -1088,9 +1092,6 @@ int ti_bandgap_remove(struct platform_device *pdev)clk_put (bgp->fclock);clk_put (bgp->div_clk); -if (TI_BANDGAP_HAS (bgp,TALERT )) -free_irq (bgp->irq, bgp); -if (TI_BANDGAP_HAS (bgp,TSHUT ))free_irq (gpiod_to_irq (bgp->tshut_gpiod),NULL );
drivers/thermal/ti-soc-thermal/ti-thermal-common.c +4 -0
@@ -196,6 +196,10 @@ int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id) data =ti_bandgap_get_sensor_data (bgp, id); +/* Work queued by the talert IRQ must not outlive the data */ +if (!IS_ERR_OR_NULL (data)) +cancel_work_sync (&data->thermal_wq); +if (!IS_ERR_OR_NULL (data) && data->ti_thermal) {if (data->our_zone)thermal_zone_device_unregister (data->ti_thermal);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1600/1848 char: scx200_gpio: check cdev_add() return value
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit fe26c195c265c033e474d015061a0183c7a02193 ]
cdev_add() can fail. The driver currently ignores the return value and reports probe success even when the cdev was not registered, leaving a chrdev region allocated with no working file operations.
Check the return value, emit an error, and unwind the chrdev region and platform device on failure.
--- drivers/char/scx200_gpio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/char/scx200_gpio.c +7 -1
@@ -108,10 +108,16 @@ static int __init scx200_gpio_init(void) }cdev_init (&scx200_gpio_cdev, &scx200_gpio_fileops); -cdev_add (&scx200_gpio_cdev, devid,MAX_PINS ); + rc =cdev_add (&scx200_gpio_cdev, devid,MAX_PINS ); +if (rc) { +dev_err (&pdev->dev,"cdev_add err: %d\n" , rc); + goto undo_chrdev_region; + }return 0 ;/* succeed */ +undo_chrdev_region: +unregister_chrdev_region (devid,MAX_PINS ); undo_platform_device_add:platform_device_del (pdev); undo_malloc:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1601/1848 bus: arm-cci: Drop CPU node reference in cci_ace_init_ports()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 41d6c0fcd4d75bf78c304c6660d60fcf757885ce ]
cci_ace_init_ports() looks up each possible CPU's node with of_get_cpu_node(), which returns the node with its reference count raised, but never releases it: neither when the CPU has no ACE port nor after the port has been recorded. Before the commit below the loop used for_each_child_of_node(), which manages the references itself.
The node is only needed for the port lookup, so drop the reference right after __cci_ace_get_port().
--- drivers/bus/arm-cci.c | 1 + 1 file changed, 1 insertion(+)
drivers/bus/arm-cci.c +1 -0
@@ -199,6 +199,7 @@ static void cci_ace_init_ports(void)continue ; port =__cci_ace_get_port (cpun,ACE_PORT ); +of_node_put (cpun);if (port <0 )continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1602/1848 bus: arm-cci: Drop cci-control-port node reference in __cci_ace_get_port()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 810ccc792193909ba9bbb4246e0eb0de14dad724 ]
__cci_ace_get_port() looks up the device's "cci-control-port" node with of_parse_phandle(), which returns the node with its reference count raised, and only compares the pointer against the probed ports. Neither the match nor the no-match return releases it.
Drop the reference on both paths once the comparison is done.
--- drivers/bus/arm-cci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bus/arm-cci.c +4 -1
@@ -167,9 +167,12 @@ static int __cci_ace_get_port(struct device_node *dn, int type) cci_portn =of_parse_phandle (dn,"cci-control-port" ,0 );for (i =0 ; i < nb_cci_ports; i++) { ace_match = ports[i].type == type; -if (ace_match && cci_portn == ports[i].dn) +if (ace_match && cci_portn == ports[i].dn) { +of_node_put (cci_portn);return i; + } } +of_node_put (cci_portn);return -ENODEV ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1603/1848 clk: qcom: mmcc-msm8996: Fix FD AHB clock register offset
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit 7cb2d65286b817d8d7e26f454a9c374d65e87072 ]
The FD AHB clock branch register is at offset 0x3b74, not 0x3ba74. The incorrect offset exceeds the regmap maximum of 0xb008, so regmap rejects accesses to it and the clock cannot be enabled.
Correct both the enable and halt register offsets so the driver can enable the branch and check its status.
--- drivers/clk/qcom/mmcc-msm8996.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/mmcc-msm8996.c +2 -2
@@ -2876,9 +2876,9 @@ static struct clk_branch fd_core_uar_clk = { };static struct clk_branch fd_ahb_clk = { - .halt_reg =0x3ba74 , + .halt_reg =0x3b74 , .clkr = { - .enable_reg =0x3ba74 , + .enable_reg =0x3b74 , .enable_mask =BIT (0 ), .hw.init = &(struct clk_init_data ){ .name ="fd_ahb_clk" ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1604/1848 clk: qcom: rcg2: Propagate force-enable status errors
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 8c0f93e10fa9e34009817bd37bb75c1b5a691fa2 ]
clk_rcg2_is_enabled() returns either a hardware status or a negative regmap error. The force-enable polling loop treats every nonzero return as an enabled clock, so a failed status read is incorrectly reported as success and clock reconfiguration can continue with unknown hardware state.
Check for negative returns before testing the enabled status and propagate the read error to the caller.
--- drivers/clk/qcom/clk-rcg2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg2.c +4 -1
@@ -828,7 +828,10 @@ static int clk_rcg2_set_force_enable(struct clk_hw *hw)/* wait for RCG to turn ON */ for (count =500 ; count >0 ; count--) { -if (clk_rcg2_is_enabled (hw)) + ret =clk_rcg2_is_enabled (hw); +if (ret <0 ) +return ret; +if (ret)return 0 ;udelay (1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1605/1848 clk: qcom: rcg2: Clear force enable after rate failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit d4e8c6b9aef42d06cf5755543ad10097b2217990 ]
Shared RCG rate changes assert force-enable before programming the new configuration. If programming fails, the function returns without clearing force-enable, leaving the root running while CCF can release temporary parent and resource references.
Attempt to clear force-enable on the configuration error path before returning the original programming error. This restores the same cleanup performed after a successful configuration while preserving the primary failure for callers.
--- drivers/clk/qcom/clk-rcg2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg2.c +3 -1
@@ -860,8 +860,10 @@ clk_rcg2_shared_force_enable_clear(struct clk_hw *hw, const struct freq_tbl *f)return ret; ret =clk_rcg2_configure (rcg, f); -if (ret) +if (ret) { +clk_rcg2_clear_force_enable (hw);return ret; + }return clk_rcg2_clear_force_enable (hw); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1606/1848 s390/uprobes: Fix off-by-one bug in emulated PER handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 2ba01cf7b2598571486425a0605f1434909b532d ]
The uprobes code emulates some instructions, and with that also PER storage-alteration handling, in case a debugger is attached.
The PER storage-alteration handling contains an off-by-one bug, which may lead to PER traps which should not happen. Adjust the comparison in sim_stor_event() to fix that.
--- arch/s390/kernel/uprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/uprobes.c +1 -1
@@ -253,7 +253,7 @@ static void sim_stor_event(struct pt_regs *regs, void *addr, int len)return ;if (!(current->thread.per_user.control &PER_EVENT_STORE ))return ; -if ((void *)current->thread.per_user.start > (addr + len)) +if ((void *)current->thread.per_user.start > (addr + len -1 ))return ;if ((void *)current->thread.per_user.end < addr)return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1607/1848 nvme: tcp: split controller bringup handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit 10fd7fb676d71482b64bc61f5058b1011133f984 ]
Drivers must call nvme_uninit_ctrl after a successful nvme_init_ctrl. Split the allocation side out to make the error handling boundary easier to navigate. The nvme tcp driver's error handling had different returns in the error goto label's, which harm readability.
Stable-dep-of: 87a1ac965502 ("nvme-tcp: store and use the caller's network namespace")
--- drivers/nvme/host/tcp.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/nvme/host/tcp.c +19 -6
@@ -2613,7 +2613,7 @@ nvme_tcp_existing_controller(struct nvmf_ctrl_options *opts)return found; } -static struct nvme_ctrl *nvme_tcp_create_ctrl (struct device *dev, +static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl (struct device *dev,struct nvmf_ctrl_options *opts) {struct nvme_tcp_ctrl *ctrl;
@@ -2679,6 +2679,24 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev,if (ret) goto out_kfree_queues; +return ctrl; +out_kfree_queues: +kfree (ctrl->queues); +out_free_ctrl: +kfree (ctrl); +return ERR_PTR (ret); +} + +static struct nvme_ctrl *nvme_tcp_create_ctrl (struct device *dev, +struct nvmf_ctrl_options *opts) +{ +struct nvme_tcp_ctrl *ctrl; +int ret; + + ctrl =nvme_tcp_alloc_ctrl (dev, opts); +if (IS_ERR (ctrl)) +return ERR_CAST (ctrl); +if (!nvme_change_ctrl_state (&ctrl->ctrl,NVME_CTRL_CONNECTING )) {WARN_ON_ONCE (1 ); ret = -EINTR ;
@@ -2704,11 +2722,6 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev,if (ret >0 ) ret = -EIO ;return ERR_PTR (ret); -out_kfree_queues: -kfree (ctrl->queues); -out_free_ctrl: -kfree (ctrl); -return ERR_PTR (ret); }static struct nvmf_transport_ops nvme_tcp_transport = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1608/1848 nvme-tcp: fix selinux denied when calling sock_sendmsg
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peijie Shao <[email protected]>
[ Upstream commit 1be52169c3488ef98582ed553ab35cefa3978817 ]
In a SELinux enabled kernel, socket_create() initializes the security label of the socket using the security label of the calling process, this typically works well.
However, in a containerized environment like Kubernetes, problem arises when a privileged container(domain spc_t) connects to an NVMe target and mounts the NVMe as persistent storage for unprivileged containers(domain container_t).
This is because the container_t domain cannot access resources labeled with spc_t, resulting in socket_sendmsg returning -EACCES.
The solution is to use socket_create_kern() instead of socket_create(), which labels the socket context to kernel_t. Access control will then be handled by the VFS layer rather than the socket itself.
Stable-dep-of: 87a1ac965502 ("nvme-tcp: store and use the caller's network namespace")
--- drivers/nvme/host/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/tcp.c +2 -1
@@ -1503,7 +1503,8 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, queue->cmnd_capsule_len =sizeof (struct nvme_command ) +NVME_TCP_ADMIN_CCSZ ; - ret =sock_create (ctrl->addr.ss_family,SOCK_STREAM , + ret =sock_create_kern (current->nsproxy->net_ns, + ctrl->addr.ss_family,SOCK_STREAM ,IPPROTO_TCP , &queue->sock);if (ret) { dev_err(nctrl->device,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1609/1848 nvme-tcp: store and use the callers network namespace
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Surabhi Gogte <[email protected]>
[ Upstream commit 87a1ac965502858f9207153a92c3aef8ecf6d4ae ]
nvme_tcp_alloc_queue() creates each socket using current->nsproxy->net_ns, which is correct for the initial connect that runs in userspace context. However, the reconnect and error recovery paths run from a workqueue where current netns is a kernel thread in init_net, so sockets created during reconnect end up in a different namespace than the one the controller was originally connected from.
Fix this by capturing the caller's network namespace at controller allocation time. Use ctrl->net for all socket creation so that every queue, on initial connect, reset, or reconnect, is created in the same namespace.
--- drivers/nvme/host/tcp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/nvme/host/tcp.c +6 -1
@@ -168,6 +168,7 @@ struct nvme_tcp_ctrl {struct delayed_work connect_work;struct nvme_tcp_request async_req;u32 io_queues[HCTX_MAX_TYPES ]; +struct net *net; };static LIST_HEAD (nvme_tcp_ctrl_list);
@@ -1503,7 +1504,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, queue->cmnd_capsule_len =sizeof (struct nvme_command ) +NVME_TCP_ADMIN_CCSZ ; - ret =sock_create_kern (current->nsproxy->net_ns, + ret =sock_create_kern (ctrl->net, ctrl->addr.ss_family,SOCK_STREAM ,IPPROTO_TCP , &queue->sock);if (ret) {
@@ -2281,6 +2282,7 @@ static void nvme_tcp_free_ctrl(struct nvme_ctrl *nctrl)nvmf_free_options (nctrl->opts); free_ctrl: +put_net (ctrl->net);kfree (ctrl->queues);kfree (ctrl); }
@@ -2676,12 +2678,15 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev, goto out_free_ctrl; } + ctrl->net =get_net (current->nsproxy->net_ns); + ret =nvme_init_ctrl (&ctrl->ctrl, dev, &nvme_tcp_ctrl_ops,0 );if (ret) goto out_kfree_queues;return ctrl; out_kfree_queues: +put_net (ctrl->net);kfree (ctrl->queues); out_free_ctrl:kfree (ctrl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1610/1848 ASoC: amd: raven: Fix acp3x_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 37ceef26df57c4a86a5e984b1951995aa96d4342 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp3x_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/raven/acp3x-pcm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/raven/acp3x-pcm-dma.c +1 -1
@@ -239,7 +239,7 @@ static int acp3x_dma_open(struct snd_soc_component *component, i2s_data->acp3x_base = adata->acp3x_base; runtime->private_data = i2s_data; -return ret; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1611/1848 ASoC: amd: renoir: Fix acp_pdm_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit a92571113ef297840270e4d8d4263a842302c9c4 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp_pdm_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/renoir/acp3x-pdm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/renoir/acp3x-pdm-dma.c +1 -1
@@ -233,7 +233,7 @@ static int acp_pdm_dma_open(struct snd_soc_component *component, pdm_data->acp_base = adata->acp_base; runtime->private_data = pdm_data; -return ret; +return 0 ; } static int acp_pdm_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1612/1848 ASoC: atmel: atmel-pcm-pdc: Fix atmel_pcm_close() being skipped on rollback
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 50aaca643038774b6779c911c4f96bc7e0d607e9 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from atmel_pcm_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/atmel/atmel-pcm-pdc.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/atmel/atmel-pcm-pdc.c +2 -0
@@ -363,6 +363,8 @@ static int atmel_pcm_open(struct snd_soc_component *component, } runtime->private_data = prtd; +return 0 ; + out:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1613/1848 ASoC: atmel-i2s: fix MCK generator error handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 2e2da92de9bffd2cdbb9a2558fe60de7f1bb09e3 ]
Disable the gclk and reset the MCK configuration when an error occurs while enabling the MCK generator.
This prevents the gclk from remaining enabled after a failed clock configuration.
--- sound/soc/atmel/atmel-i2s.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
sound/soc/atmel/atmel-i2s.c +13 -3
@@ -466,11 +466,21 @@ static int atmel_i2s_switch_mck_generator(struct atmel_i2s_dev *dev, mr |=ATMEL_I2SC_MR_IMCKMODE_I2SMCK ; ret =regmap_update_bits (dev->regmap,ATMEL_I2SC_MR , mr_mask, mr);if (ret) -return ret; + goto err_disable_gclk;/* Finally enable the I2S Master Clock generator. */ -return regmap_write (dev->regmap,ATMEL_I2SC_CR , -ATMEL_I2SC_CR_CKEN ); + ret =regmap_write (dev->regmap,ATMEL_I2SC_CR ,ATMEL_I2SC_CR_CKEN ); +if (ret) + goto err_reset_mr; + +return 0 ; + +err_reset_mr: +regmap_update_bits (dev->regmap,ATMEL_I2SC_MR , mr_mask,0 ); +err_disable_gclk: +clk_disable_unprepare (dev->gclk); + +return ret; } static int atmel_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1614/1848 ASoC: atmel-i2s: do not warn if muxclk is missing
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Codrin Ciubotariu <[email protected]>
[ Upstream commit f4bf1f4d1385b7cb61a3fc811bb4912d49aa394a ]
Besides the fact that muxclk is optional, muxclk can be set using assigned-clocks, removing the need to set it in driver. The warning is thus unneeded, so we can transform it in a debug print, eventually to just reflect that muxclk was not set by the driver.
Stable-dep-of: be952abd69c1 ("ASoC: atmel-i2s: use optional API for muxclk")
--- sound/soc/atmel/atmel-i2s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/atmel/atmel-i2s.c +2 -2
@@ -594,8 +594,8 @@ static int atmel_i2s_sama5d2_mck_init(struct atmel_i2s_dev *dev, err =PTR_ERR (muxclk);if (err == -EPROBE_DEFER )return -EPROBE_DEFER ; -dev_warn (dev->dev, -"failed to get the I2S clock control: %d\n" , err); +dev_dbg (dev->dev, +"failed to get the I2S clock control: %d\n" , err);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1615/1848 ASoC: atmel-i2s: use optional API for muxclk
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit be952abd69c1f2c845e42e72147751e4c910cd81 ]
The muxclk is an optional clock according to the device tree binding.
Use devm_clk_get_optional() to handle the optional muxclk instead of handling the missing clock explicitly.
When muxclk is not available, devm_clk_get_optional() returns NULL. clk_set_parent() returns 0 when passed NULL, preserving the existing behavior.
Unlike the existing code, errors other than -EPROBE_DEFER are now returned instead of being silently ignored.
--- sound/soc/atmel/atmel-i2s.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
sound/soc/atmel/atmel-i2s.c +5 -11
@@ -583,21 +583,15 @@ static int atmel_i2s_sama5d2_mck_init(struct atmel_i2s_dev *dev, struct device_node *np) {struct clk *muxclk; -int err;if (!dev->gclk)return 0 ; -/* muxclk is optional, so we return error for probe defer only */ - muxclk =devm_clk_get (dev->dev,"muxclk" ); -if (IS_ERR (muxclk)) { - err =PTR_ERR (muxclk); -if (err == -EPROBE_DEFER ) -return -EPROBE_DEFER ; -dev_dbg (dev->dev, -"failed to get the I2S clock control: %d\n" , err); -return 0 ; - } +/* muxclk is optional */ + muxclk =devm_clk_get_optional (dev->dev,"muxclk" ); +if (IS_ERR (muxclk)) +return dev_err_probe (dev->dev,PTR_ERR (muxclk), +"failed to get the I2S clock control\n" );return clk_set_parent (muxclk, dev->gclk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1616/1848 ASoC: atmel-i2s: use optional API for gclk
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit b431a055fb7688c0d3725fa3c55aeef852991178 ]
The gclk is an optional clock according to the device tree binding.
Use devm_clk_get_optional() to handle the optional gclk directly.
Unlike the existing code, errors other than -EPROBE_DEFER are now returned instead of being silently ignored.
--- sound/soc/atmel/atmel-i2s.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
sound/soc/atmel/atmel-i2s.c +4 -7
@@ -665,13 +665,10 @@ static int atmel_i2s_probe(struct platform_device *pdev) }/* Get audio clock to generate the I2S Master Clock (I2S_MCK) */ - dev->gclk =devm_clk_get (&pdev->dev,"gclk" ); -if (IS_ERR (dev->gclk)) { -if (PTR_ERR (dev->gclk) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; -/* Master Mode not supported */ - dev->gclk =NULL ; - } + dev->gclk =devm_clk_get_optional (&pdev->dev,"gclk" ); +if (IS_ERR (dev->gclk)) +return PTR_ERR (dev->gclk); + dev->dev = &pdev->dev; dev->regmap = regmap;platform_set_drvdata (pdev, dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1617/1848 sh: sh7785lcr: Register the PCA9564 controller as I2C bus 0
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 3b8386ffc0c33b6b5a6a8e64e1487c1adec57dc9 ]
Before commit 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly specified"), a negative ID was replaced by zero, and I2C bus zero was instantiated. Since that commit, a negative ID is passed verbatim, instantiating an I2C bus with a dynamic number. As SH boards still use i2c_register_board_info(0, ...) to register I2C devices, they rely on the I2C bus being bus zero.
The SH7785LCR is the only SH board whose I2C adapter has a negative ID and its PCA9564 controller becomes i2c-1, causing registration of the R2025S/D RTC to fail and hwclock not detecting /dev/rtc0.
Set the platform device ID to 0 so that the adapter is registered as bus zero again.
--- arch/sh/boards/board-sh7785lcr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/boards/board-sh7785lcr.c +1 -1
@@ -256,7 +256,7 @@ static struct i2c_pca9564_pf_platform_data i2c_platform_data = {static struct platform_device i2c_device = { .name ="i2c-pca-platform" , - .id =-1 , + .id =0 , .dev = { .platform_data = &i2c_platform_data, },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1618/1848 lib: validate in-memory LZ4 chunk length
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 138a84817df01eda67bb23032ab49c23fe2ffc16 ]
We found and validated an issue in lib/decompress_unlz4.c. The bug is reachable by a root user through kexec_file_load() with a crafted external initrd.
unlz4() reads the compressed chunk length from an in-memory initrd and passes it to LZ4_decompress_safe(). It only checks the chunk length against the allocation size when the input is filled by a callback.
Reject an in-memory chunk that extends past the remaining input before calling the LZ4 decoder. This prevents malformed initrds from making the decoder read past the mapped archive.
--- lib/decompress_unlz4.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/decompress_unlz4.c +4 -0
@@ -139,6 +139,10 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,if (!fill) { inp +=4 ; size -=4 ; +if (chunksize > size) { +error ("data corrupted" ); + goto exit_2; + } }else {if (chunksize >LZ4_compressBound (uncomp_chunksize)) {error ("chunk length is longer than allocated" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1619/1848 ocfs2: retain all security xattrs during inode creation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit d637475617d8468c2740a3436428681bcc8d3572 ]
When creating a new inode, ocfs2_init_security_get() stores the security xattr returned by the LSM framework in ocfs2_security_xattr_info so that it can be written later within the same transaction. But ocfs2_initxattrs() only ever looks at the first element of the xattr array, and it keeps the name as a bare pointer into memory owned by the security layer instead of copying it. The value, by contrast, is already duplicated with kmemdup().
With stacked LSMs, security_inode_init_security() provides one xattr per LSM, so all labels but the first are silently dropped and never written to disk, leaving newly created files without the security xattrs the other LSMs rely on.
The borrowed name is not an outright bug with the LSMs in tree today:security_inode_init_security() frees only ->value once the callback returns, and documents ->name as the attribute name suffix, so the pointer stays valid for as long as ocfs2 uses it. It is fragile though, as an LSM that allocates the name together with the value would turn it into a use-after-free, so the rework below copies the names as well.
Fix this by storing copies of all the security xattrs: allocate an array in ocfs2_initxattrs(), copy the names and values, account for all of them in the credit calculations, and write each one in ocfs2_init_security_set().
While at it, switch the allocations from GFP_KERNEL to GFP_NOFS. The callback runs in the inode creation path with the parent directory locked, and the security layer allocates the very same xattr array with GFP_NOFS, so direct reclaim must not be allowed to recurse into the filesystem from here.
--- fs/ocfs2/namei.c | 6 +-- fs/ocfs2/xattr.c | 133 +++++++++++++++++++++++++++++++++++++---------- fs/ocfs2/xattr.h | 12 +++-- 3 files changed, 116 insertions(+), 35 deletions(-)
fs/ocfs2/namei.c +2 -4
@@ -244,7 +244,6 @@ static int ocfs2_mknod(struct inode *dir,int want_meta =0 ;int xattr_credits =0 ;struct ocfs2_security_xattr_info si = { - .name =NULL , .enable =1 , };int did_quota_inode =0 ;
@@ -471,7 +470,7 @@ static int ocfs2_mknod(struct inode *dir,brelse (new_fe_bh);brelse (parent_fe_bh); -kfree (si.value); +ocfs2_free_security_xattrs (&si);ocfs2_acl_init_release (&acl_state);
@@ -1810,7 +1809,6 @@ static int ocfs2_symlink(struct inode *dir,int want_clusters =0 ;int xattr_credits =0 ;struct ocfs2_security_xattr_info si = { - .name =NULL , .enable =1 , };int did_quota =0 , did_quota_inode =0 ;
@@ -2042,7 +2040,7 @@ static int ocfs2_symlink(struct inode *dir,brelse (new_fe_bh);brelse (parent_fe_bh); -kfree (si.value); +ocfs2_free_security_xattrs (&si);ocfs2_free_dir_lookup_result (&lookup);if (inode_ac)ocfs2_free_alloc_context (inode_ac);
fs/ocfs2/xattr.c +105 -28
193 lines not on this page · raw message
fs/ocfs2/xattr.h +9 -3
@@ -22,13 +22,18 @@ enum ocfs2_xattr_type { OCFS2_XATTR_MAX }; -struct ocfs2_security_xattr_info { -int enable; -const char *name; +struct ocfs2_security_xattr { +char *name;void *value;size_t value_len; }; +struct ocfs2_security_xattr_info { +int enable; +struct ocfs2_security_xattr *xattrs; +int count; +}; +extern const struct xattr_handler ocfs2_xattr_user_handler;extern const struct xattr_handler ocfs2_xattr_trusted_handler;extern const struct xattr_handler ocfs2_xattr_security_handler;
@@ -49,6 +54,7 @@ int ocfs2_xattr_remove(struct inode *, struct buffer_head *);int ocfs2_init_security_get (struct inode *,struct inode *,const struct qstr *,struct ocfs2_security_xattr_info *); +void ocfs2_free_security_xattrs (struct ocfs2_security_xattr_info *); int ocfs2_init_security_set(handle_t *, struct inode *, struct buffer_head *, struct ocfs2_security_xattr_info *,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1620/1848 ocfs2: fix possible deadlock between nfs_sync_rwlock and fs_reclaim
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 169bc4d16a8efa7852b101fdaa4c028505cd6750 ]
syzbot detected a circular locking dependency on &osb->nfs_sync_rwlock:
CPU0 CPU1
---- ----
lock(fs_reclaim);
lock(&ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]);
lock(fs_reclaim); rlock(&osb->nfs_sync_rwlock);
*** DEADLOCK ***
Chain exists of: &osb->nfs_sync_rwlock --> &ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE] --> fs_reclaim
CPU0 is kswapd. The dentry shrinker runs under fs_reclaim and reaches ocfs2_delete_inode() through ->evict_inode():
kswapd
balance_pgdat
shrink_node
shrink_slab
super_cache_scan
prune_dcache_sb
shrink_dentry_list
dentry_kill
ocfs2_dentry_iput
evict
ocfs2_evict_inode
ocfs2_delete_inode
ocfs2_nfs_sync_lock
down_read(&osb->nfs_sync_rwlock) //C0: grabbingCPU1 is a task deleting an inode. It takes nfs_sync_rwlock first, then the orphan dir and inode alloc system inode i_rwsems, and allocates the metadata reservation with GFP_KERNEL while holding them:
evict
ocfs2_evict_inode
ocfs2_delete_inode
+ ocfs2_nfs_sync_lock
| down_read(&osb->nfs_sync_rwlock) //C1: hold
+ ocfs2_wipe_inode
+ inode_lock(orphan_dir_inode) //C1: hold
+ ocfs2_truncate_for_delete
| ocfs2_commit_truncate
| ocfs2_remove_btree_range
| ocfs2_reserve_blocks_for_rec_trunc
| ocfs2_reserve_new_metadata_blocks
| kzalloc_obj() //C1: grabbing
| // GFP_KERNEL -> might_alloc -> fs_reclaim_acquire
+ ocfs2_remove_inode
inode_lock(inode_alloc_inode)
jbd2 pins allocations to GFP_NOFS for the lifetime of a transaction handle, but these reservations are made before ocfs2_start_trans(), so fs_reclaim is acquired with ocfs2 locks still held and the cycle closes.
The same cycle is reachable from ocfs2_get_dentry() and ocfs2_get_parent(), which hold nfs_sync_rwlock for write across ocfs2_test_inode_bit() and ocfs2_iget().
This is more than a lockdep artifact. A GFP_KERNEL allocation under the orphan dir i_rwsem enters direct reclaim, which runs the shrinkers, which can evict another ocfs2 inode and re-enter ocfs2_wipe_inode() on the same task; the second inode_lock() on the singleton orphan dir inode then self-deadlocks, since i_rwsem is not recursive.
Establish a GFP_NOFS allocation context for the whole nfs_sync_rwlock critical section so that nothing holding it can recurse into filesystem reclaim. Do it in ocfs2_nfs_sync_lock()/ocfs2_nfs_sync_unlock() rather than at the call sites, so that future callers cannot forget it.
--- fs/ocfs2/dlmglue.c | 29 +++++++++++++++++++++++++---- fs/ocfs2/dlmglue.h | 5 +++-- fs/ocfs2/export.c | 10 ++++++---- fs/ocfs2/inode.c | 5 +++-- 4 files changed, 37 insertions(+), 12 deletions(-)
fs/ocfs2/dlmglue.c +25 -4
@@ -20,6 +20,7 @@#include <linux/seq_file.h> #include <linux/time.h> #include <linux/quotaops.h> +#include <linux/sched/mm.h> #include <linux/sched/signal.h> #define MLOG_MASK_PREFIX ML_DLM_GLUE
@@ -2846,21 +2847,34 @@ void ocfs2_rename_unlock(struct ocfs2_super *osb)ocfs2_cluster_unlock (osb, lockres,DLM_LOCK_EX ); } -int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex) +int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex,unsigned int *nofs_flag) {int status; +unsigned int flags;struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;if (ocfs2_is_hard_readonly (osb))return -EROFS ; +/* +* ocfs2_delete_inode() takes this lock from ->evict_inode(), which the +* dentry shrinker reaches while holding fs_reclaim. Anything allocated +* under the lock must therefore stay out of filesystem reclaim, or +* reclaim recurses back into the shrinker and tries to take this lock +* again. Cover the whole critical section, including the cluster lock +* and the sysfile inode locks the callers take below it. +*/ + flags =memalloc_nofs_save (); +if (ex)down_write (&osb->nfs_sync_rwlock);else down_read (&osb->nfs_sync_rwlock); -if (ocfs2_mount_local (osb)) +if (ocfs2_mount_local (osb)) { + *nofs_flag = flags;return 0 ; + } status =ocfs2_cluster_lock (osb, lockres, ex ?LKM_EXMODE :LKM_PRMODE ,0 ,0 );
@@ -2871,12 +2885,17 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)up_write (&osb->nfs_sync_rwlock); else up_read(&osb->nfs_sync_rwlock); +memalloc_nofs_restore (flags); +return status; } -return status; + *nofs_flag = flags; + +return 0 ; } -void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex) +void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex, +unsigned int nofs_flag) {struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;
@@ -2887,6 +2906,8 @@ void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex)up_write (&osb->nfs_sync_rwlock); else up_read(&osb->nfs_sync_rwlock); + +memalloc_nofs_restore (nofs_flag); } int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
fs/ocfs2/dlmglue.h +3 -2
@@ -165,8 +165,9 @@ void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno);int ocfs2_rename_lock (struct ocfs2_super *osb);void ocfs2_rename_unlock (struct ocfs2_super *osb); -int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex); -void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex); +int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex,unsigned int *nofs_flag); +void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex, +unsigned int nofs_flag);void ocfs2_trim_fs_lock_res_init (struct ocfs2_super *osb);void ocfs2_trim_fs_lock_res_uninit (struct ocfs2_super *osb); int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
fs/ocfs2/export.c +6 -4
@@ -39,6 +39,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,struct inode *inode;struct ocfs2_super *osb =OCFS2_SB (sb);u64 blkno = handle->ih_blkno; +unsigned int nofs_flag =0 ;int status, set;struct dentry *result;
@@ -61,7 +62,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,* This will synchronize us against ocfs2_delete_inode() on * all nodes */ - status =ocfs2_nfs_sync_lock (osb,1 ); + status =ocfs2_nfs_sync_lock (osb,1 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(EX) failed %d\n" , status); goto check_err;
@@ -91,7 +92,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, inode =ocfs2_iget (osb, blkno,0 ,0 ); unlock_nfs_sync: -ocfs2_nfs_sync_unlock (osb,1 ); +ocfs2_nfs_sync_unlock (osb,1 , nofs_flag); check_err:if (status <0 ) {
@@ -134,12 +135,13 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)u64 blkno;struct dentry *parent;struct inode *dir =d_inode (child); +unsigned int nofs_flag =0 ;int set;trace_ocfs2_get_parent (child, child->d_name.len, child->d_name.name, (unsigned long long )OCFS2_I (dir)->ip_blkno); - status =ocfs2_nfs_sync_lock (OCFS2_SB (dir->i_sb),1 ); + status =ocfs2_nfs_sync_lock (OCFS2_SB (dir->i_sb),1 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(EX) failed %d\n" , status); parent =ERR_PTR (status);
@@ -183,7 +185,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)ocfs2_inode_unlock (dir,0 ); unlock_nfs_sync: -ocfs2_nfs_sync_unlock (OCFS2_SB (dir->i_sb),1 ); +ocfs2_nfs_sync_unlock (OCFS2_SB (dir->i_sb),1 , nofs_flag); bail:trace_ocfs2_get_parent_end (parent);
fs/ocfs2/inode.c +3 -2
@@ -1028,6 +1028,7 @@ static void ocfs2_delete_inode(struct inode *inode) {int wipe, status;sigset_t oldset; +unsigned int nofs_flag =0 ;struct buffer_head *di_bh =NULL ;struct ocfs2_dinode *di =NULL ;
@@ -1062,7 +1063,7 @@ static void ocfs2_delete_inode(struct inode *inode)* shared mode so that all nodes can still concurrently * process deletes. */ - status =ocfs2_nfs_sync_lock (OCFS2_SB (inode->i_sb),0 ); + status =ocfs2_nfs_sync_lock (OCFS2_SB (inode->i_sb),0 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(PR) failed %d\n" , status);ocfs2_cleanup_delete_inode (inode,0 );
@@ -1134,7 +1135,7 @@ static void ocfs2_delete_inode(struct inode *inode)brelse (di_bh); bail_unlock_nfs_sync: -ocfs2_nfs_sync_unlock (OCFS2_SB (inode->i_sb),0 ); +ocfs2_nfs_sync_unlock (OCFS2_SB (inode->i_sb),0 , nofs_flag); bail_unblock:ocfs2_unblock_signals (&oldset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1621/1848 ocfs2: validate chunk and block counts of the local quota file
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
[ Upstream commit b10ef5d2c2083ea4c40e963c10a73a154793c5d4 ]
ocfs2_local_read_info() trusts dqi_chunks and dqi_blocks from the local quota file header. If dqi_blocks is too small, ocfs2_extend_local_quota_file() computes a bogus chunk length, extends the file, and maps logical block dqi_blocks, which is already in the inode's metadata cache (the header or a chunk header read at mount). sb_getblk() returns that cached buffer and ocfs2_set_new_buffer_uptodate() hits BUG_ON(ocfs2_buffer_cached()):
kernel BUG at fs/ocfs2/uptodate.c:509!
ocfs2_extend_local_quota_file+0x45c/0x1100 ocfs2_create_local_dquot+0x8ac/0xb50 ocfs2_acquire_dquot+0x614/0xae0 ocfs2_get_init_inode+0xe9/0x1b0 ocfs2_mkdir+0x174/0x430
ocfs2_local_quota_add_chunk() has the same exposure.
Reject a header whose counts don't fit the chunk layout or exceed i_size.
Reproduced with a crafted image (dqi_blocks = 1, chunk 0 dqc_free = 0); syzbot has no reproducer for this report.
--- fs/ocfs2/quota_local.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/ocfs2/quota_local.c +24 -0
@@ -245,6 +245,25 @@ static void ocfs2_release_local_quota_bitmaps(struct list_head *head) } } +/* Check that the on-disk chunk and block counts match the file layout */ +static int ocfs2_check_local_quota_info (struct inode *inode, +unsigned int chunks, +unsigned int blocks) +{ +u64 chunk_len =ol_chunk_blocks (inode->i_sb) +1 ; +u64 min_blocks = chunks ?1 + chunk_len * (chunks -1 ) +1 :1 ; +u64 max_blocks =1 + chunk_len * chunks; + +if (blocks >= min_blocks && blocks <= max_blocks && + blocks <=i_size_read (inode) >> inode->i_sb->s_blocksize_bits) +return 0 ; + +return ocfs2_error (inode->i_sb, +"Quota file %llu has bad info: %u chunks, %u blocks\n" , + (unsigned long long )OCFS2_I (inode)->ip_blkno, + chunks, blocks); +} +/* Load quota bitmaps into memory */ static int ocfs2_load_local_quota_bitmaps(struct inode *inode, struct ocfs2_local_disk_dqinfo *ldinfo,
@@ -730,6 +749,11 @@ static int ocfs2_local_read_info(struct super_block *sb, int type) oinfo->dqi_blocks =le32_to_cpu (ldinfo->dqi_blocks); oinfo->dqi_libh = bh; + status =ocfs2_check_local_quota_info (lqinode, oinfo->dqi_chunks, + oinfo->dqi_blocks); +if (status <0 ) + goto out_err; +/* We crashed when using local quota file? */ if (!(oinfo->dqi_flags &OLQF_CLEAN )) { rec =OCFS2_SB (sb)->quota_rec;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1622/1848 ALSA: pcm: Fix driver_tstamp value reporting
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amadeusz Sławiński <[email protected]>
[ Upstream commit 8ff1161ac5aa02f3261e00f07d6212be2b12384b ]
In some cases (system32 and compat64) due to incorrect assignment wrong value is being reported. Fix it.
--- sound/core/pcm_compat.c | 4 ++-- sound/core/pcm_native.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
sound/core/pcm_compat.c +2 -2
@@ -219,8 +219,8 @@ static int snd_pcm_status_user_compat64(struct snd_pcm_substream *substream, .audio_tstamp_data = status.audio_tstamp_data, .audio_tstamp_sec = status.audio_tstamp_sec, .audio_tstamp_nsec = status.audio_tstamp_nsec, - .driver_tstamp_sec = status.audio_tstamp_sec, - .driver_tstamp_nsec = status.audio_tstamp_nsec, + .driver_tstamp_sec = status.driver_tstamp_sec, + .driver_tstamp_nsec = status.driver_tstamp_nsec, .audio_tstamp_accuracy = status.audio_tstamp_accuracy, };
sound/core/pcm_native.c +2 -2
@@ -1120,8 +1120,8 @@ static int snd_pcm_status_user32(struct snd_pcm_substream *substream, .audio_tstamp_data = status64.audio_tstamp_data, .audio_tstamp_sec = status64.audio_tstamp_sec, .audio_tstamp_nsec = status64.audio_tstamp_nsec, - .driver_tstamp_sec = status64.audio_tstamp_sec, - .driver_tstamp_nsec = status64.audio_tstamp_nsec, + .driver_tstamp_sec = status64.driver_tstamp_sec, + .driver_tstamp_nsec = status64.driver_tstamp_nsec, .audio_tstamp_accuracy = status64.audio_tstamp_accuracy, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1623/1848 ALSA: jack: Fix kctl free at error in snd_jack_kctl_new()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit f421be924fec67f74bb0b6988ea8f0a3480df2a7 ]
When an error happens in snd_jack_kctl_new(), it tries to free the new kcontrol element via snd_ctl_free_one(). But snd_ctl_free_one() releases only the memories, and the internal linked list and hash entries still remain, which may lead to bogus accesses to user.
Replace with the correct destructor, snd_ctl_remove(), for clearing the whole resources of the given kcontrol, instead.
--- sound/core/jack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/jack.c +1 -1
@@ -163,7 +163,7 @@ static struct snd_jack_kctl * snd_jack_kctl_new(struct snd_card *card, const chareturn jack_kctl; error: -snd_ctl_free_one (kctl); +snd_ctl_remove (card, kctl);return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1624/1848 ALSA: line6: Use kzalloc() for PCM buffer allocation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 9ec633573c1d162bfc82cae52d14c220c875612f ]
LINE6 driver allocates the PCM buffer via kmalloc(), and this might leave some bytes uninitialized that are out of the actual ring buffer size, while it's still exposed via mmap.
For avoiding the leak of the uninitialized kernel memory, simply replace it with kzalloc().
--- sound/usb/line6/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/line6/pcm.c +1 -1
@@ -155,7 +155,7 @@ static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,/* Invoked multiple times in a row so allocate once only */ if (!test_and_set_bit (type, &pstr->opened) && !pstr->buffer) { pstr->buffer = -kmalloc (array3_size (line6pcm->line6->iso_buffers, +kzalloc (array3_size (line6pcm->line6->iso_buffers,LINE6_ISO_PACKETS , pkt_size),GFP_KERNEL );if (!pstr->buffer)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1625/1848 ALSA: usb-audio: Use fixed control index for us16x08 mixer elements
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit a68a688ce220f1b359bec53fa38d1504314dc70f ]
The callbacks for us16x08 mixer elements assume that id.index points to the channel to be operated, and the assumption is correct for now. However, since the kctls are added via snd_usb_mixer_add_control() and it looks for the empty slot if the same control name is already present, in theory, the index can become more than the channel numbers (if a conflicting name really happens).
Since the mixer code in us16x08 doesn't need the search for an empty slot but requires the fixed index, this patch changes slightly how to assign the kcontrols. Now, a new argument is added to snd_usb_mixer_add_list() in order to disable the empty slot search, and use it in us16x08's add_new_ctl() helper function, instead.
--- sound/usb/mixer.c | 13 +++++++++---- sound/usb/mixer.h | 5 +++-- sound/usb/mixer_quirks.c | 2 +- sound/usb/mixer_us16x08.c | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-)
sound/usb/mixer.c +9 -4
@@ -576,20 +576,25 @@ static int check_matrix_bitmap(unsigned char *bmap,/* * add an alsa control element -* search and increment the index until an empty slot is found. +* when @look_for_empty is set, search and increment the index until an empty +* slot is found. * * if failed, give up and free the control instance. */ int snd_usb_mixer_add_list (struct usb_mixer_elem_list *list,struct snd_kcontrol *kctl, -bool is_std_info) +bool is_std_info, +bool look_for_empty) {struct usb_mixer_interface *mixer = list->mixer;int err; -while (snd_ctl_find_id (mixer->chip->card, &kctl->id)) - kctl->id.index++; +if (look_for_empty) { +while (snd_ctl_find_id (mixer->chip->card, &kctl->id)) + kctl->id.index++; + } + err =snd_ctl_add (mixer->chip->card, kctl);if (err <0 ) { usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n",
sound/usb/mixer.h +3 -2
@@ -107,10 +107,11 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,int snd_usb_mixer_add_list (struct usb_mixer_elem_list *list,struct snd_kcontrol *kctl, -bool is_std_info); +bool is_std_info, +bool look_for_empty);#define snd_usb_mixer_add_control (list, kctl) \ - snd_usb_mixer_add_list(list, kctl, true) + snd_usb_mixer_add_list(list, kctl, true, true) void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list, struct usb_mixer_interface *mixer,
sound/usb/mixer_quirks.c +1 -1
@@ -162,7 +162,7 @@ static int add_single_ctl_with_resume(struct usb_mixer_interface *mixer, } kctl->private_free = snd_usb_mixer_elem_free;/* don't use snd_usb_mixer_add_control() here, this is a special list element */ -return snd_usb_mixer_add_list (list, kctl, false); +return snd_usb_mixer_add_list (list, kctl, false, true); }/*
sound/usb/mixer_us16x08.c +2 -1
@@ -1112,7 +1112,8 @@ static int add_new_ctl(struct usb_mixer_interface *mixer,strlcpy (kctl->id.name, name,sizeof (kctl->id.name)); - err =snd_usb_mixer_add_control (&elem->head, kctl); +/* look_for_empty=false, as we want the fixed id.index as channel */ + err =snd_usb_mixer_add_list (&elem->head, kctl, true, false);if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1626/1848 thermal/drivers/sprd: validate the sensor id from the device tree
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit b17d799ce49bfaad68be5ff3df995b3bd021a9d7 ]
sprd_thm_probe() reads each sensor child node's "reg" property into sen->id and uses it without validation: to compute the sensor's register offsets in sprd_thm_sensor_init(), as the thermal zone id, and finally as an index into thm->sensor[], which has SPRD_THM_MAX_SENSOR
(8) entries:
ret = of_property_read_u32(sen_child, "reg", &sen->id); ... thm->sensor[sen->id] = sen;
Only the number of sensor nodes is checked against SPRD_THM_MAX_SENSOR. A "reg" value of 8 or more, or one that is negative once stored in the int sen->id, makes the register offsets point outside the sensor range and the final store land outside thm->sensor[], overwriting the fields that follow it in struct sprd_thermal_data or other memory.
Reject an out-of-range id right after reading it, before it is used.
This does not address sparse ids, such as a single sensor with id 7:
they leave holes in thm->sensor[] that the later loops over 0..nr_sensors-1 dereference. That needs a separate fix.
Found by static analysis tool CodeQL.
--- drivers/thermal/sprd_thermal.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/thermal/sprd_thermal.c +6 -0
@@ -400,6 +400,12 @@ static int sprd_thm_probe(struct platform_device *pdev) goto of_put; } +if (sen->id <0 || sen->id >=SPRD_THM_MAX_SENSOR ) { +dev_err (&pdev->dev,"invalid sensor id %d\n" , sen->id); + ret = -EINVAL ; + goto of_put; + } + ret =sprd_thm_sensor_calibration (sen_child, thm, sen);if (ret) {dev_err (&pdev->dev,"efuse cal analysis failed" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1627/1848 tools/thermal/tmon: Fix string truncation warning in optarg copy
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 602da762f7a7c494a95cb204ac005965b214e556 ]
GCC warns about possible string truncation with -Wstringop-truncation:
tmon.c: In function ‘main’:
tmon.c:233:25: warning: ‘__builtin_strncpy’ specified bound 20 equals
destination size [-Wstringop-truncation]
233 | strncpy(ctrl_cdev, optarg,
CDEV_NAME_SIZE);
|^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Replace strncpy() with snprintf() to guarantee NUL-termination and silence the compiler warning.
--- tools/thermal/tmon/tmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/thermal/tmon/tmon.c +1 -1
@@ -230,7 +230,7 @@ int main(int argc, char **argv)switch (c) {case 'c' : no_control =0 ; -strncpy (ctrl_cdev, optarg,CDEV_NAME_SIZE ); +snprintf (ctrl_cdev,sizeof (ctrl_cdev),"%s" , optarg);break ;case 'd' :start_daemon_mode ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1628/1848 thermal: ti-soc-thermal: Fix the return value in ti_bandgap_get_sensor_data() kernel-doc
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 82bb005cd9cf5a9df4cfe4a52db90346ac5fd17a ]
ti_bandgap_get_sensor_data() returns an ERR_PTR() if the bandgap instance or sensor ID is invalid. Otherwise it returns the stored sensor data, which can be NULL if no data has been set or the stored value has been cleared.
This mismatch was already present in omap_bandgap_get_sensor_data() when the driver was introduced in staging.
Document the validation errors while retaining NULL as a possible stored value.
--- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/ti-soc-thermal/ti-bandgap.c +2 -1
@@ -576,7 +576,8 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data)* @bgp: pointer to bandgap instance * @id: sensor id * -* Return: data stored by set function with sensor id on success or NULL +* Return: the stored sensor data, which may be %NULL, or an ERR_PTR() +* if @bgp or @id is invalid. */ void *ti_bandgap_get_sensor_data (struct ti_bandgap *bgp,int id) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1629/1848 ipvs: fix buffer overflow when sending sync messages
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit 3e3fe49e8678c1a3d535ed02f32a9a6e80674263 ]
Sashiko reports for possible heap buffer overflow when generating sync message for the v0 and v1 message formats. We should read the cp->flags only once because another CPU can concurrently set the SEQ_MASK between the two reads.
Note that IPVS does not set the SEQ_MASK anymore for the ip_vs_ftp.c helper starting from commit 7f1c40757951 ("IPVS: make FTP work with full NAT support") (2.6.36+), so the problem should not be reproducible.
--- net/netfilter/ipvs/ip_vs_sync.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +14 -9
@@ -544,13 +544,15 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,struct ip_vs_sync_conn_v0 *s;struct ip_vs_sync_buff *buff;struct ipvs_master_sync_state *ms; -int id; +u32 flags, seq_mask;unsigned int len; +int id;if (unlikely (cp->af !=AF_INET ))return ; + flags =READ_ONCE (cp->flags);/* Do not sync ONE PACKET */ -if (cp->flags &IP_VS_CONN_F_ONE_PACKET ) +if (flags &IP_VS_CONN_F_ONE_PACKET )return ;if (!ip_vs_sync_conn_needed (ipvs, cp, pkts))
@@ -565,8 +567,8 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, id =select_master_thread_id (ipvs, cp); ms = &ipvs->ms[id]; buff = ms->sync_buff; - len = (cp->flags &IP_VS_CONN_F_SEQ_MASK ) ?FULL_CONN_SIZE : -SIMPLE_CONN_SIZE ; + seq_mask = flags &IP_VS_CONN_F_SEQ_MASK ; + len = seq_mask ?FULL_CONN_SIZE :SIMPLE_CONN_SIZE ;if (buff) { m = (struct ip_vs_sync_mesg_v0 *) buff->mesg;/* Send buffer if it is for v1 */
@@ -598,9 +600,9 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, s->caddr = cp->caddr.ip; s->vaddr = cp->vaddr.ip; s->daddr = cp->daddr.ip; - s->flags =htons (cp->flags & ~IP_VS_CONN_F_HASHED ); + s->flags =htons (flags & ~IP_VS_CONN_F_HASHED ); s->state =htons (cp->state); -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { +if (seq_mask) {struct ip_vs_sync_conn_options *opt = (struct ip_vs_sync_conn_options *)&s[1 ];memcpy (opt, &cp->sync_conn_opt,sizeof (*opt));
@@ -636,6 +638,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)int id;__u8 *p;unsigned int len, pe_name_len, pad; +u32 flags, seq_mask;/* Handle old version of the protocol */ if (sysctl_sync_ver (ipvs) ==0 ) {
@@ -648,6 +651,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts) sloop:if (!ip_vs_sync_conn_needed (ipvs, cp, pkts)) goto control; + flags =READ_ONCE (cp->flags);/* Sanity checks */ pe_name_len =0 ;
@@ -675,7 +679,8 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)#endif len =sizeof (struct ip_vs_sync_v4 ); -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) + seq_mask = flags &IP_VS_CONN_F_SEQ_MASK ; +if (seq_mask) len +=sizeof (struct ip_vs_sync_conn_options ) +2 ;if (cp->pe_data_len)
@@ -721,7 +726,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)/* Set message type & copy members */ s->v4.type = (cp->af ==AF_INET6 ?STYPE_F_INET6 :0 ); s->v4.ver_size =htons (len &SVER_MASK );/* Version 0 */ - s->v4.flags =htonl (cp->flags & ~IP_VS_CONN_F_HASHED ); + s->v4.flags =htonl (flags & ~IP_VS_CONN_F_HASHED ); s->v4.state =htons (cp->state); s->v4.protocol = cp->protocol; s->v4.cport = cp->cport;
@@ -745,7 +750,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts) s->v4.vaddr = cp->vaddr.ip; s->v4.daddr = cp->daddr.ip; } -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { +if (seq_mask) { *(p++) =IPVS_OPT_SEQ_DATA ; *(p++) =sizeof (struct ip_vs_sync_conn_options );hton_seq (&cp->in_seq, (struct ip_vs_seq *)p);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1630/1848 ALSA: pcm: Unlink substreams before releasing them
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit d1e57f8fb7a6b6d32a4aaa31fd6fc4c77339608f ]
A closing PCM substream can remain in its linked group after the driver close callback has freed its private data. With two configured dummy capture substreams on the same PCM device, linked with LINK, PREPARE on the surviving substream can still visit the closing member:
Final close of A PREPARE on linked B
---------------- -------------------
snd_pcm_drop(): group -> SETUP
do_hw_free(A)
dummy_pcm_close(A): free dpcm
Take snd_pcm_link_rwsem for reading Walk the group, including A dummy_pcm_prepare(A)
Read freed timer_ops
pcm_release_private(A)
snd_pcm_unlink(A)
Unlink at the start of final substream release, before dropping the stream or releasing driver resources. The link write lock waits for an existing group PREPARE, and unlink removes the closing member from later group actions. Keep the existing stop synchronization in do_hw_free() before the driver resources are freed.
Make unlink independent of the pcm_release callback so OSS substreams are covered too. Remove the native-only unlink callback and its registration, while retaining the callback hook for OSS cleanup.
The existing KASAN report below records the freed timer_ops read in dummy_pcm_prepare().
KASAN report as below:
BUG: KASAN: slab-use-after-free in dummy_pcm_prepare+0xb7/0xc0
Read of size 8 at addr ffff888106b35f00 by task alsa_pcm_fixtur/491
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? dummy_pcm_prepare+0xb7/0xc0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? dummy_pcm_prepare+0xb7/0xc0
kasan_report+0xe0/0x110
? dummy_pcm_prepare+0xb7/0xc0
dummy_pcm_prepare+0xb7/0xc0
snd_pcm_do_prepare+0x71/0xb0
snd_pcm_action_group+0x505/0xb30
snd_pcm_action_nonatomic+0xab/0x150
snd_pcm_common_ioctl+0x1bf5/0x3a50
? srso_alias_return_thunk+0x5/0xfbef5
? do_vfs_ioctl+0x1f5/0x1280
? __pfx_do_vfs_ioctl+0x10/0x10
? ioctl_has_perm.constprop.0.isra.0+0x34f/0x500
? __pfx_snd_pcm_common_ioctl+0x10/0x10
? __fput+0x5ba/0xa60
? srso_alias_return_thunk+0x5/0xfbef5
snd_pcm_ioctl+0x76/0xb0
? __pfx_snd_pcm_ioctl+0x10/0x10
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x41ee8d
Code: 04 25 28 00 00 00 48 89 45 c8 31 c0 48 8d 45 10 c7 45 b0 10 00 00 00 48 89 45 b8 48 8d 45 d0 48 89 45 c0 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1a 48 8b 45 c8 64 48 2b 04 25 28 00 00 00
RSP: 002b:00007ffcfa72fb60 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 000000000041ee8d
RDX: 0000000000000000 RSI: 0000000000004140 RDI: 0000000000000004
RBP: 00007ffcfa72fbb0 R08: 00007ffcfa72fb98 R09: 0000000000000110
R10: 0000000000000001 R11: 0000000000000246 R12: 00007ffcfa72fcd8
R13: 00007ffcfa72fcf0 R14: 00000000004a8f28 R15: 0000000000000001
</TASK>
Allocated by task 488:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x251/0x610
dummy_hrtimer_create+0x4a/0x170
dummy_pcm_open+0xe7/0x730
snd_pcm_open_substream+0x926/0x1580
snd_pcm_open+0x28d/0x6d0
snd_pcm_capture_open+0x82/0xe0
snd_open+0x1ec/0x3e0
chrdev_open+0x21f/0x660
do_dentry_open+0x5c8/0x1300
vfs_open+0x87/0x390
path_openat+0x2460/0x3cd0
do_file_open+0x21e/0x470
do_sys_openat2+0xf4/0x1b0
__x64_sys_openat+0x136/0x1e0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 490:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
dummy_hrtimer_free+0x72/0xe0
dummy_pcm_close+0x9f/0xd0
snd_pcm_release_substream.part.0+0x104/0x310
snd_pcm_release+0x106/0x240
__fput+0x39f/0xa60
fput_close_sync+0xff/0x200
__x64_sys_close+0x8c/0xf0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
==================================================================--- sound/core/pcm_native.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
sound/core/pcm_native.c +2 -8
@@ -2706,18 +2706,14 @@ static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream)return 0 ; } -static void pcm_release_private (struct snd_pcm_substream *substream) -{ -if (snd_pcm_stream_linked (substream)) -snd_pcm_unlink (substream); -} -void snd_pcm_release_substream (struct snd_pcm_substream *substream) { substream->ref_count--;if (substream->ref_count >0 )return ; +snd_pcm_unlink (substream); +snd_pcm_drop (substream);if (substream->hw_opened) {if (substream->runtime->status->state !=SNDRV_PCM_STATE_OPEN )
@@ -2794,8 +2790,6 @@ static int snd_pcm_open_file(struct file *file,return -ENOMEM ; } pcm_file->substream = substream; -if (substream->ref_count ==1 ) - substream->pcm_release = pcm_release_private; file->private_data = pcm_file;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1631/1848 serial: pmac_zilog: report received breaks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tim Douglas <[email protected]>
[ Upstream commit 8db79ea07a67b126c773da6efdc00066000daeb8 ]
pmz_status_handle() sets PMACZILOG_FLAG_BREAK from RR0, and pmz_receive_chars() clears it on the null character that ends the break without marking that character, then tests BRK_ABRT in RR1, where the SCC does not set it in asynchronous mode. Breaks therefore arrive as plain NULs: brk is never counted and BRKINT, PARMRK and SysRq never see them.
Set BRK_ABRT in r1 for that character, as sunzilog does.
--- drivers/tty/serial/pmac_zilog.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/pmac_zilog.c +1 -0
@@ -240,6 +240,7 @@ static bool pmz_receive_chars(struct uart_pmac_port *uap) ch &= uap->parity_mask;if (ch ==0 && uap->flags &PMACZILOG_FLAG_BREAK ) { uap->flags &= ~PMACZILOG_FLAG_BREAK ; + r1 |=BRK_ABRT ; }#if defined(CONFIG_MAGIC_SYSRQ ) && defined(CONFIG_SERIAL_CORE_CONSOLE )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1632/1848 ASoC: codecs: wm8990: Fix definition of right input PGA controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 5bd6d05197affaf5a2d7fae0e06e7373fd839b7c ]
The right input PGA boost (R12MNBST, R34MNBST) and routing (R12MNB, R34MNB) bits are in Input Mixer4 (R42), not in Input Mixer3 (R41), where these controls write the left channel bits.
--- sound/soc/codecs/wm8990.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8990.c +4 -4
@@ -97,8 +97,8 @@ static const struct snd_kcontrol_new wm8990_snd_controls[] = {SOC_SINGLE ("LIN12 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_L12MNBST_BIT ,1 ,0 ),SOC_SINGLE ("LIN34 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_L34MNBST_BIT ,1 ,0 ),/* INMIXR */ -SOC_SINGLE ("RIN12 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_R12MNBST_BIT ,1 ,0 ), -SOC_SINGLE ("RIN34 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_R34MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN12 PGA Boost" ,WM8990_INPUT_MIXER4 ,WM8990_R12MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN34 PGA Boost" ,WM8990_INPUT_MIXER4 ,WM8990_R34MNBST_BIT ,1 ,0 ),/* LOMIX */ SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8990_OUTPUT_MIXER3,
@@ -377,9 +377,9 @@ SOC_DAPM_SINGLE_TLV("Record Right Volume", WM8990_INPUT_MIXER4, WM8990_RDBVOL_SHIFT, WM8990_RDBVOL_MASK, 0, in_mix_tlv),SOC_DAPM_SINGLE_TLV ("RIN2 Volume" ,WM8990_INPUT_MIXER6 ,WM8990_RI2BVOL_SHIFT ,7 ,0 , in_mix_tlv), -SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8990_INPUT_MIXER3 ,WM8990_L12MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8990_INPUT_MIXER4 ,WM8990_R12MNB_BIT ,1 ,0 ), -SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8990_INPUT_MIXER3 ,WM8990_L34MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8990_INPUT_MIXER4 ,WM8990_R34MNB_BIT , 1, 0), };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1633/1848 ASoC: codecs: wm8990: Fix definition of LOMIX AINLMUX Bypass Volume control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 75e0b607e3456c9eb15dfb783984f814a89cbcaf ]
The LOMIX AINLMUX bypass volume (LLBLOVOL) is at bits 2:0 of Output Mixer5, not at bits 5:3, which hold the AINRMUX bypass volume (LRBLOVOL).
--- sound/soc/codecs/wm8990.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8990.c +1 -1
@@ -112,7 +112,7 @@ SOC_SINGLE_TLV("LOMIX RIN3 Bypass Volume", WM8990_OUTPUT_MIXER5,SOC_SINGLE_TLV ("LOMIX AINRMUX Bypass Volume" ,WM8990_OUTPUT_MIXER5 ,WM8990_LRBLOVOL_SHIFT ,WM8990_LRBLOVOL_MASK ,1 , out_mix_tlv),SOC_SINGLE_TLV ("LOMIX AINLMUX Bypass Volume" ,WM8990_OUTPUT_MIXER5 , -WM8990_LRBLOVOL_SHIFT ,WM8990_LRBLOVOL_MASK ,1 , out_mix_tlv), +WM8990_LLBLOVOL_SHIFT ,WM8990_LLBLOVOL_MASK ,1 , out_mix_tlv),/* ROMIX */ SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8990_OUTPUT_MIXER4,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1634/1848 ASoC: codecs: wm8991: Fix definition of right input PGA controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 2dfecdc25d4937a36675c0c36ee0addc99e1e7f9 ]
The right input PGA boost (R12MNBST, R34MNBST) and routing (R12MNB, R34MNB) bits are in Input Mixer4 (R42), not in Input Mixer3 (R41), where these controls write the left channel bits.
--- sound/soc/codecs/wm8991.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8991.c +4 -4
@@ -169,8 +169,8 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = {SOC_SINGLE ("LIN12 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_L12MNBST_BIT ,1 ,0 ),SOC_SINGLE ("LIN34 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_L34MNBST_BIT ,1 ,0 ),/* INMIXR */ -SOC_SINGLE ("RIN12 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_R12MNBST_BIT ,1 ,0 ), -SOC_SINGLE ("RIN34 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_R34MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN12 PGA Boost" ,WM8991_INPUT_MIXER4 ,WM8991_R12MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN34 PGA Boost" ,WM8991_INPUT_MIXER4 ,WM8991_R34MNBST_BIT ,1 ,0 ),/* LOMIX */ SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8991_OUTPUT_MIXER3,
@@ -446,9 +446,9 @@ static const struct snd_kcontrol_new wm8991_dapm_inmixr_controls[] = { WM8991_RDBVOL_SHIFT, WM8991_RDBVOL_MASK, 0, in_mix_tlv),SOC_DAPM_SINGLE_TLV ("RIN2 Volume" ,WM8991_INPUT_MIXER6 ,WM8991_RI2BVOL_SHIFT ,7 ,0 , in_mix_tlv), -SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8991_INPUT_MIXER3 ,WM8991_L12MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8991_INPUT_MIXER4 ,WM8991_R12MNB_BIT ,1 ,0 ), -SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8991_INPUT_MIXER3 ,WM8991_L34MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8991_INPUT_MIXER4 ,WM8991_R34MNB_BIT , 1, 0), };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1635/1848 ASoC: codecs: wm8991: Fix definition of LOMIX AINLMUX Bypass Volume control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit fee722db39c2a1f18c944f747271fd1e131910a6 ]
The LOMIX AINLMUX bypass volume (LLBLOVOL) is at bits 2:0 of Output Mixer5, not at bits 5:3, which hold the AINRMUX bypass volume (LRBLOVOL).
--- sound/soc/codecs/wm8991.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8991.c +1 -1
@@ -184,7 +184,7 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = {SOC_SINGLE_TLV ("LOMIX AINRMUX Bypass Volume" ,WM8991_OUTPUT_MIXER5 ,WM8991_LRBLOVOL_SHIFT ,WM8991_LRBLOVOL_MASK ,1 , out_mix_tlv),SOC_SINGLE_TLV ("LOMIX AINLMUX Bypass Volume" ,WM8991_OUTPUT_MIXER5 , -WM8991_LRBLOVOL_SHIFT ,WM8991_LRBLOVOL_MASK ,1 , out_mix_tlv), +WM8991_LLBLOVOL_SHIFT ,WM8991_LLBLOVOL_MASK ,1 , out_mix_tlv),/* ROMIX */ SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8991_OUTPUT_MIXER4,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1636/1848 ASoC: codecs: wm8983: Fix definition of ADC 128x Oversampling control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit c1af9e2272f025ff75be76e03413074d5e7801c9 ]
ADC 128x oversampling (ADCOSR128) is at bit 3 of ADC Control, not at bit 8, which is the high pass filter enable (HPFEN).
--- sound/soc/codecs/wm8983.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8983.c +1 -1
@@ -234,7 +234,7 @@ static const struct snd_kcontrol_new wm8983_snd_controls[] = { 8, 1, 0, pga_boost_tlv),SOC_DOUBLE ("ADC Inversion Switch" ,WM8983_ADC_CONTROL ,0 ,1 ,1 ,0 ), -SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8983_ADC_CONTROL ,8 ,1 ,0 ), +SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8983_ADC_CONTROL ,3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Playback Volume" ,WM8983_LEFT_DAC_DIGITAL_VOL , WM8983_RIGHT_DAC_DIGITAL_VOL, 0, 255, 0, dac_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1637/1848 ASoC: codecs: wm8985: Fix definition of ADC 128x Oversampling control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit a747ec6e12cf7a71e42567a479af18b930890d9d ]
ADC 128x oversampling (ADCOSR128) is at bit 3 of ADC Control, not at bit 8, which is the high pass filter enable (HPFEN).
--- sound/soc/codecs/wm8985.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8985.c +1 -1
@@ -327,7 +327,7 @@ static const struct snd_kcontrol_new wm8985_common_snd_controls[] = { 8, 1, 0, pga_boost_tlv),SOC_DOUBLE ("ADC Inversion Switch" ,WM8985_ADC_CONTROL ,0 ,1 ,1 ,0 ), -SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8985_ADC_CONTROL ,8 ,1 ,0 ), +SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8985_ADC_CONTROL ,3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Playback Volume" ,WM8985_LEFT_DAC_DIGITAL_VOL , WM8985_RIGHT_DAC_DIGITAL_VOL, 0, 255, 0, dac_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1638/1848 ASoC: codecs: wm8994: Fix definition of WM8958 noise gate hold time controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 291d81d628f3453026b029507a26b856056e4fdc ]
The noise gate hold time (NG_HLD) is at bits 6:5 of each WM8958 DAC noise gate register, not at bits 3:1, which hold the threshold (NG_THR).
--- sound/soc/codecs/wm8994.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/wm8994.c +3 -3
@@ -700,17 +700,17 @@ static const char *wm8958_ng_text[] = { static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac1_ng_hold, WM8958_AIF1_DAC1_NOISE_GATE, - WM8958_AIF1DAC1_NG_THR_SHIFT, + WM8958_AIF1DAC1_NG_HLD_SHIFT, wm8958_ng_text); static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac2_ng_hold, WM8958_AIF1_DAC2_NOISE_GATE, - WM8958_AIF1DAC2_NG_THR_SHIFT, + WM8958_AIF1DAC2_NG_HLD_SHIFT, wm8958_ng_text); static SOC_ENUM_SINGLE_DECL(wm8958_aif2dac_ng_hold, WM8958_AIF2_DAC_NOISE_GATE, - WM8958_AIF2DAC_NG_THR_SHIFT, + WM8958_AIF2DAC_NG_HLD_SHIFT, wm8958_ng_text);static const struct snd_kcontrol_new wm8958_snd_controls[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1639/1848 ASoC: codecs: wm8955: Fix definition of Treble Cutoff control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 71911bf5bb3fe97da2124d17fc1dd3dbb9379e03 ]
Treble cutoff (TC) is at bit 6 of Treble Control, not at bit 2, which is part of the treble volume (TRBL[3:0]).
--- sound/soc/codecs/wm8955.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8955.c +1 -1
@@ -426,7 +426,7 @@ static const char *treble_cutoff_text[] = {"High" ,"Low" }; -static SOC_ENUM_SINGLE_DECL(treble_cutoff, WM8955_TREBLE_CONTROL, 2, +static SOC_ENUM_SINGLE_DECL(treble_cutoff, WM8955_TREBLE_CONTROL, 6, treble_cutoff_text); static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1640/1848 ASoC: codecs: wm_hubs: Fix definition of MIXINR to MIXOUTR volume control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 22bfcedd3febd6acc63ecf8bfd9638210e4b9a5e ]
The Right Output Mixer Right Input Volume (MIXINR_MIXOUTR_VOL) is at bits 2:0 of Output Mixer6, not at bits 8:6, which hold the IN2LN volume (IN2LN_MIXOUTR_VOL).
--- sound/soc/codecs/wm_hubs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm_hubs.c +1 -1
@@ -426,7 +426,7 @@ SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume",SOC_SINGLE_TLV ("Right Output Mixer Left Input Volume" ,WM8993_OUTPUT_MIXER6 ,3 ,7 ,1 , outmix_tlv),SOC_SINGLE_TLV ("Right Output Mixer Right Input Volume" , -WM8993_OUTPUT_MIXER6 ,6 ,7 ,1 , outmix_tlv), +WM8993_OUTPUT_MIXER6 ,0 ,7 ,1 , outmix_tlv),SOC_SINGLE_TLV ("Right Output Mixer DAC Volume" , WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1641/1848 ASoC: codecs: wm8737: Fix definition of zero cross switches
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 121963197200ca89050f05a704f53c281702ec16 ]
The mic (xMZC) and PGA (xPZC) zero cross bits are bits 3 and 2 of each channel's Audio Path register. SOC_DOUBLE takes one register and two shifts, so both controls only write the left register. Use SOC_DOUBLE_R, as the Mic Boost Switch next to them does.
--- sound/soc/codecs/wm8737.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8737.c +4 -4
@@ -149,13 +149,13 @@ SOC_DOUBLE_R_TLV("Mic Boost Volume", WM8737_AUDIO_PATH_L, WM8737_AUDIO_PATH_R, 6, 3, 0, micboost_tlv),SOC_DOUBLE_R ("Mic Boost Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R ,4 ,1 ,0 ), -SOC_DOUBLE ("Mic ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , -3 ,1 ,0 ), +SOC_DOUBLE_R ("Mic ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , +3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Capture Volume" ,WM8737_LEFT_PGA_VOLUME ,WM8737_RIGHT_PGA_VOLUME ,0 ,255 ,0 , pga_tlv), -SOC_DOUBLE ("Capture ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , -2 ,1 ,0 ), +SOC_DOUBLE_R ("Capture ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , +2 ,1 ,0 ), SOC_DOUBLE("INPUT1 DC Bias Switch", WM8737_MISC_BIAS_CONTROL, 0, 1, 1, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1642/1848 ASoC: codecs: wm5100: Fix definition of EQ3 Band 1 Volume control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 96d30816a9a4fa6b3cc470f82d0f53e8a6425ab9 ]
The EQ3 band 1 gain is in WM5100_EQ3_1, not in WM5100_EQ1_1, which holds the EQ1 band 1 gain.
--- sound/soc/codecs/wm5100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm5100.c +1 -1
@@ -655,7 +655,7 @@ SOC_SINGLE_TLV("EQ2 Band 4 Volume", WM5100_EQ2_2, WM5100_EQ2_B4_GAIN_SHIFT,SOC_SINGLE_TLV ("EQ2 Band 5 Volume" ,WM5100_EQ2_2 ,WM5100_EQ2_B5_GAIN_SHIFT ,24 ,0 , eq_tlv), -SOC_SINGLE_TLV ("EQ3 Band 1 Volume" ,WM5100_EQ1_1 ,WM5100_EQ3_B1_GAIN_SHIFT , +SOC_SINGLE_TLV ("EQ3 Band 1 Volume" ,WM5100_EQ3_1 ,WM5100_EQ3_B1_GAIN_SHIFT ,24 ,0 , eq_tlv),SOC_SINGLE_TLV ("EQ3 Band 2 Volume" ,WM5100_EQ3_1 ,WM5100_EQ3_B2_GAIN_SHIFT , 24, 0, eq_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1643/1848 ASoC: codecs: wm8750: Fix definition of ALC Capture NG Type control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 8c299077c787c151c5c88928467d8e8d85cebdb7 ]
The noise gate type is wm8750_enum[7], bit 1 of WM8750_NGATE, not wm8750_enum[4], which is the 3D upper cut-off.
--- sound/soc/codecs/wm8750.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8750.c +1 -1
@@ -171,7 +171,7 @@ SOC_SINGLE("ALC Capture Hold Time", WM8750_ALC2, 0, 15, 0),SOC_SINGLE ("ALC Capture Decay Time" ,WM8750_ALC3 ,4 ,15 ,0 ),SOC_SINGLE ("ALC Capture Attack Time" ,WM8750_ALC3 ,0 ,15 ,0 ),SOC_SINGLE ("ALC Capture NG Threshold" ,WM8750_NGATE ,3 ,31 ,0 ), -SOC_ENUM ("ALC Capture NG Type" , wm8750_enum[4 ]), +SOC_ENUM ("ALC Capture NG Type" , wm8750_enum[7 ]),SOC_SINGLE ("ALC Capture NG Switch" ,WM8750_NGATE ,0 ,1 ,0 ), SOC_SINGLE("Left ADC Capture Volume", WM8750_LADC, 0, 255, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1644/1848 ASoC: codecs: wm8510: Fix definition of ADC Inversion Switch control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 22d50113078dfbeff0d005d64fd9cc680249831c ]
ADC polarity is bit 0 of WM8510_ADC, not bit 0 of WM8510_COMP, which is the loopback enable. wm8974, which has the same register layout, already uses WM8974_ADC for this control.
--- sound/soc/codecs/wm8510.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8510.c +1 -1
@@ -135,7 +135,7 @@ SOC_SINGLE("Master Playback Volume", WM8510_DACVOL, 0, 127, 0),SOC_SINGLE ("High Pass Filter Switch" ,WM8510_ADC ,8 ,1 ,0 ),SOC_SINGLE ("High Pass Cut Off" ,WM8510_ADC ,4 ,7 ,0 ), -SOC_SINGLE ("ADC Inversion Switch" ,WM8510_COMP ,0 ,1 ,0 ), +SOC_SINGLE ("ADC Inversion Switch" ,WM8510_ADC ,0 ,1 ,0 ), SOC_SINGLE("Capture Volume", WM8510_ADCVOL, 0, 127, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1645/1848 rpmsg: mtk: release channel OF node on device teardown
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit 00e100cfbf7bc159e462df16832cddeaf2cab770 ]
mtk_rpmsg_match_device_subnode() returns a referenced OF child node, which is stored in rpdev->dev.of_node.
mtk_rpmsg_release_device() later frees the containing allocation without dropping that ref.
Release the OF node when the RPMsg device is destroyed.
--- drivers/rpmsg/mtk_rpmsg.c | 1 + 1 file changed, 1 insertion(+)
drivers/rpmsg/mtk_rpmsg.c +1 -0
@@ -168,6 +168,7 @@ static void mtk_rpmsg_release_device(struct device *dev)struct rpmsg_device *rpdev =to_rpmsg_device (dev);struct mtk_rpmsg_device *mdev =to_mtk_rpmsg_device (rpdev); +of_node_put (dev->of_node);kfree (mdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1646/1848 ARM: 9492/1: alignment: fix LSR #32 and ASR #32 offset decoding
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 9f878a6c2207f0c12f34a715a6a05cfc95f47460 ]
The register-offset form of LDR/STR may apply a shift to Rm. Per DecodeImmShift() (ARM ARM DDI0406C section A8.4.3, "Pseudocode details of instruction-specified shifts and rotates"), an imm5 of 0 encodes a shift of 32 for LSR and ASR; only LSL treats 0 as "no shift", and ROR with 0 encodes RRX.
do_alignment() special-cases RRX but not LSR or ASR, and IS_SHIFT() does not filter these encodings out, so the block is entered with shiftval == 0 and the offset becomes Rm instead of 0 (LSR #32) or the replicated sign of Rm (ASR #32).
do_alignment_finish_ldst() applies the offset to the base-register writeback of the post-indexed form, so the emulated access itself uses the correct faulting address but Rn is left holding the wrong value.
Reproduced on ARM926EJ-S (versatile_defconfig, CONFIG_ALIGNMENT_TRAP=y, gcc 13.3.0) with a misaligned base and Rm = 0x1000:
ldr r0, [r1], r2, lsr #32 Rn advanced by 0x1000, must be unchanged ldr r0, [r1], r2, asr #32 Rn advanced by 0x1000, must be unchanged ldr r0, [r1], r2, asr #32 with Rm negative, Rn must decrease by 1
All three are correct with the patch applied, while a lsr #1 control case is emulated correctly both before and after.
--- arch/arm/mm/alignment.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/arm/mm/alignment.c +8 -2
@@ -915,11 +915,17 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)break ;case SHIFT_LSR : - offset.un >>= shiftval; +if (shiftval ==0 ) + offset.un =0 ; +else + offset.un >>= shiftval;break ;case SHIFT_ASR : - offset.sn >>= shiftval; +if (shiftval ==0 ) + offset.sn >>=31 ; +else + offset.sn >>= shiftval;break ;case SHIFT_RORRRX :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1647/1848 ARM: 9519/1: dma-mapping: Fix wrong free function in __iommu_alloc_simple() error path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 74f79365839720bdb0c6bb4fe85c5b2a929ff5d1 ]
In __iommu_alloc_simple(), when IOMMU mapping creation fails, the error path unconditionally called __free_from_pool() regardless of the allocation path taken.
For the COHERENT case, memory is allocated via __alloc_simple_buffer(), which does not use the atomic pool. Calling __free_from_pool() on such memory silently returns without freeing, causing a page memory leak.
Fix this by matching the free function to the allocation path:
- COHERENT: use __dma_free_buffer(virt_to_page(addr), size)
- non-COHERENT: use __free_from_pool(addr, size)
--- arch/arm/mm/dma-mapping.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/mm/dma-mapping.c +4 -1
@@ -1405,7 +1405,10 @@ static void *__iommu_alloc_simple(struct device *dev, size_t size, gfp_t gfp,return addr; err_mapping: -__free_from_pool (addr, size); +if (coherent_flag ==COHERENT ) +__dma_free_buffer (virt_to_page (addr), size); +else +__free_from_pool (addr, size);return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1648/1848 PCI: Fix out-of-bounds MMIO read in nvme_disable_and_flr()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Raizudeen <[email protected]>
[ Upstream commit 6aaa3f42e3410ea8e26c857477260159f724cb1d ]
In nvme_disable_and_flr(), the PCI bar is mapped using NVME_REG_CC + sizeof(cfg) which is (0x14 + 4 = 0x18 bytes)
However, the function later reads the controller status from NVME_REG_CSTS - offset 0x1C, which is outside the mapped 0x18 byte boundary. This violates the API contract.
Fix this by increasing the mapping size to include NVME_REG_CSTS. Also change sizeof(cfg) to sizeof(u32) to make the intent clearer.
--- drivers/pci/quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/quirks.c +1 -1
@@ -3929,7 +3929,7 @@ static int nvme_disable_and_flr(struct pci_dev *dev, int probe)if (probe)return 0 ; - bar =pci_iomap (dev,0 ,NVME_REG_CC +sizeof (cfg)); + bar =pci_iomap (dev,0 ,NVME_REG_CSTS +sizeof (u32));if (!bar)return -ENOTTY ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1649/1848 Bluetooth: L2CAP: hold chan in l2cap_ecred_conn_rsp()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit b508a2a2d846ccc4c8f691e4e3dfca6f97dfe85a ]
l2cap_chan_del() calls l2cap_chan_put() to drop the conn->chan_l reference. If this was the last reference, UAF follows.
l2cap_ecred_conn_rsp() iterates chan_l list and calls l2cap_chan_del() on some members, without holding chan reference.
Fix by holding refcount while using chan after l2cap_chan_del().
Since orig is looked up by dcid provided by remote, it's also possible orig == chan, so reference needs to be held also after orig use.
--- net/bluetooth/l2cap_core.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/l2cap_core.c +5 -0
@@ -6419,12 +6419,14 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, chan->state == BT_CONNECTED)continue ; +l2cap_chan_hold (chan);l2cap_chan_lock (chan);/* Check that there is a dcid for each pending channel */ if (cmd_len <sizeof (dcid)) {l2cap_chan_del (chan,ECONNREFUSED );l2cap_chan_unlock (chan); +l2cap_chan_put (chan);continue ; }
@@ -6463,6 +6465,8 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn,__set_chan_timer (orig,0 );l2cap_chan_unlock (orig); } + +l2cap_chan_put (chan);continue ; }
@@ -6508,6 +6512,7 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, }l2cap_chan_unlock (chan); +l2cap_chan_put (chan); }mutex_unlock (&conn->chan_lock);
Signature · 1 line
2.53.0