pinctrl: mediatek: fix global-out-of-bounds issue
Subsystems (13)
Sasha Levin
maintainerPATCH 1/26 pinctrl: mediatek: fix global-out-of-bounds issue
From: Guodong Liu <[email protected]>
[ Upstream commit 2d5446da5acecf9c67db1c9d55ae2c3e5de01f8d ]
When eint virtual eint number is greater than gpio number, it maybe produce 'desc[eint_n]' size globle-out-of-bounds issue.
--- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +6 -2
@@ -285,8 +285,12 @@ static int mtk_xt_get_gpio_n(void *data, unsigned long eint_n, desc = (const struct mtk_pin_desc *)hw->soc->pins; *gpio_chip = &hw->chip; -/* Be greedy to guess first gpio_n is equal to eint_n */ -if (desc[eint_n].eint.eint_n == eint_n) +/* +* Be greedy to guess first gpio_n is equal to eint_n. +* Only eint virtual eint number is greater than gpio number. +*/ +if (hw->soc->npins > eint_n && + desc[eint_n].eint.eint_n == eint_n) *gpio_n = eint_n;else *gpio_n =mtk_xt_find_eint_num (hw, eint_n);
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 2/26 Input: i8042 - add deferred probe support
From: Takashi Iwai <[email protected]>
[ Upstream commit 9222ba68c3f4065f6364b99cc641b6b019ef2d42 ]
We've got a bug report about the non-working keyboard on ASUS ZenBook UX425UA. It seems that the PS/2 device isn't ready immediately at boot but takes some seconds to get ready. Until now, the only workaround is to defer the probe, but it's available only when the driver is a module. However, many distros, including openSUSE as in the original report, build the PS/2 input drivers into kernel, hence it won't work easily.
This patch adds the support for the deferred probe for i8042 stuff as a workaround of the problem above. When the deferred probe mode is enabled and the device couldn't be probed, it'll be repeated with the standard deferred probe mechanism.
The deferred probe mode is enabled either via the new option i8042.probe_defer or via the quirk table entry. As of this patch, the quirk table contains only ASUS ZenBook UX425UA.
The deferred probe part is based on Fabio's initial work.
--- .../admin-guide/kernel-parameters.txt | 2 + drivers/input/serio/i8042-x86ia64io.h | 14 +++++ drivers/input/serio/i8042.c | 54 ++++++++++++------- 3 files changed, 51 insertions(+), 19 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +2 -0
@@ -1690,6 +1690,8 @@ architectures force reset to be always executed i8042.unlock [HW] Unlock (ignore) the keylock i8042.kbdreset [HW] Reset device connected to KBD port + i8042.probe_defer + [HW] Allow deferred probing upon i8042 probe errors i810= [HW,DRM]
drivers/input/serio/i8042-x86ia64io.h +14 -0
@@ -995,6 +995,17 @@ static const struct dmi_system_id __initconst i8042_dmi_kbdreset_table[] = { { } }; +static const struct dmi_system_id i8042_dmi_probe_defer_table[]__initconst = { + { +/* ASUS ZenBook UX425UA */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), +DMI_MATCH (DMI_PRODUCT_NAME ,"ZenBook UX425UA" ), + }, + }, + { } +}; +#endif /* CONFIG_X86 */ #ifdef CONFIG_PNP
@@ -1315,6 +1326,9 @@ static int __init i8042_platform_init(void)if (dmi_check_system (i8042_dmi_kbdreset_table)) i8042_kbdreset = true; +if (dmi_check_system (i8042_dmi_probe_defer_table)) + i8042_probe_defer = true; +/* * A20 was already enabled during early kernel init. But some buggy * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
drivers/input/serio/i8042.c +35 -19
164 lines not on this page · raw message
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 3/26 Input: iqs626a - prohibit inlining of channel parsing functions
In reply to Sasha LevinFrom: Jeff LaBundy <[email protected]>
[ Upstream commit e1f5e848209a1b51ccae50721b27684c6f9d978f ]
Some automated builds report a stack frame size in excess of 2 kB for iqs626_probe(); the culprit appears to be the call to iqs626_parse_prop().
To solve this problem, specify noinline_for_stack for all of the iqs626_parse_*() helper functions which are called inside a for loop within iqs626_parse_prop().
As a result, a build with '-Wframe-larger-than' as low as 512 is free of any such warnings.
--- drivers/input/misc/iqs626a.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/input/misc/iqs626a.c +12 -9
@@ -456,9 +456,10 @@ struct iqs626_private {unsigned int suspend_mode; }; -static int iqs626_parse_events (struct iqs626_private *iqs626, -const struct fwnode_handle *ch_node, -enum iqs626_ch_id ch_id) +static noinline_for_stack int +iqs626_parse_events (struct iqs626_private *iqs626, +const struct fwnode_handle *ch_node, +enum iqs626_ch_id ch_id) {struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg;struct i2c_client *client = iqs626->client;
@@ -604,9 +605,10 @@ static int iqs626_parse_events(struct iqs626_private *iqs626,return 0 ; } -static int iqs626_parse_ati_target (struct iqs626_private *iqs626, -const struct fwnode_handle *ch_node, -enum iqs626_ch_id ch_id) +static noinline_for_stack int +iqs626_parse_ati_target (struct iqs626_private *iqs626, +const struct fwnode_handle *ch_node, +enum iqs626_ch_id ch_id) {struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg;struct i2c_client *client = iqs626->client;
@@ -885,9 +887,10 @@ static int iqs626_parse_trackpad(struct iqs626_private *iqs626,return 0 ; } -static int iqs626_parse_channel (struct iqs626_private *iqs626, -const struct fwnode_handle *ch_node, -enum iqs626_ch_id ch_id) +static noinline_for_stack int +iqs626_parse_channel (struct iqs626_private *iqs626, +const struct fwnode_handle *ch_node, +enum iqs626_ch_id ch_id) {struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg;struct i2c_client *client = iqs626->client;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 4/26 ASoC: SOF: Intel: pci-tgl: add ADL-N support
In reply to Sasha LevinFrom: Kai Vehmanen <[email protected]>
[ Upstream commit cd57eb3c403cb864e5558874ecd57dd954a5a7f7 ]
Add PCI DID for Intel AlderLake-N.
--- sound/soc/sof/intel/pci-tgl.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/sof/intel/pci-tgl.c +2 -0
@@ -119,6 +119,8 @@ static const struct pci_device_id sof_pci_ids[] = { .driver_data = (unsigned long)&adl_desc}, { PCI_DEVICE(0x8086, 0x51cc), /* ADL-M */ .driver_data = (unsigned long)&adl_desc}, + { PCI_DEVICE(0x8086, 0x54c8), /* ADL-N */ + .driver_data = (unsigned long)&adl_desc}, { 0, } };MODULE_DEVICE_TABLE (pci, sof_pci_ids);
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 5/26 ASoC: SOF: Intel: pci-tgl: add new ADL-P variant
In reply to Sasha LevinFrom: Kai Vehmanen <[email protected]>
[ Upstream commit de7dd9092cd38384f774d345cccafe81b4b866b0 ]
Add a PCI DID for a variant of Intel AlderLake-P.
--- sound/soc/sof/intel/pci-tgl.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/sof/intel/pci-tgl.c +2 -0
@@ -117,6 +117,8 @@ static const struct pci_device_id sof_pci_ids[] = { .driver_data = (unsigned long)&adls_desc}, { PCI_DEVICE(0x8086, 0x51c8), /* ADL-P */ .driver_data = (unsigned long)&adl_desc}, + { PCI_DEVICE(0x8086, 0x51cd), /* ADL-P */ + .driver_data = (unsigned long)&adl_desc}, { PCI_DEVICE(0x8086, 0x51cc), /* ADL-M */ .driver_data = (unsigned long)&adl_desc}, { PCI_DEVICE(0x8086, 0x54c8), /* ADL-N */
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 6/26 Input: i8042 - enable deferred probe quirk for ASUS UM325UA
In reply to Sasha LevinFrom: Samuel Čavoj <[email protected]>
[ Upstream commit 44ee250aeeabb28b52a10397ac17ffb8bfe94839 ]
The ASUS UM325UA suffers from the same issue as the ASUS UX425UA, which is a very similar laptop. The i8042 device is not usable immediately after boot and fails to initialize, requiring a deferred retry.
Enable the deferred probe quirk for the UM325UA.
--- drivers/input/serio/i8042-x86ia64io.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +7 -0
@@ -1003,6 +1003,13 @@ static const struct dmi_system_id i8042_dmi_probe_defer_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "ZenBook UX425UA"), }, }, + { + /* ASUS ZenBook UM325UA */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "ZenBook UX325UA_UM325UA"), + }, + }, { } };
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 7/26 Input: goodix - add id->model mapping for the "9111" model
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 81e818869be522bc8fa6f7df1b92d7e76537926c ]
Add d->model mapping for the "9111" model, this fixes uses using a wrong config_len of 240 bytes while the "9111" model uses only 186 bytes of config.
--- drivers/input/touchscreen/goodix.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/touchscreen/goodix.c +1 -0
@@ -162,6 +162,7 @@ static const struct goodix_chip_id goodix_chip_ids[] = { { .id = "911", .data = >911_chip_data }, { .id = "9271", .data = >911_chip_data }, { .id = "9110", .data = >911_chip_data }, + { .id = "9111", .data = >911_chip_data }, { .id = "927", .data = >911_chip_data }, { .id = "928", .data = >911_chip_data },
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 8/26 hwmon: (lm90) Do not report 'busy' status bit as alarm
In reply to Sasha LevinFrom: Guenter Roeck <[email protected]>
[ Upstream commit cdc5287acad9ede121924a9c9313544b80d15842 ]
Bit 7 of the status register indicates that the chip is busy doing a conversion. It does not indicate an alarm status. Stop reporting it as alarm status bit.
--- drivers/hwmon/lm90.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/lm90.c +2 -1
@@ -192,6 +192,7 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,#define LM90_STATUS_RHIGH (1 << 4)/* remote high temp limit tripped */ #define LM90_STATUS_LLOW (1 << 5)/* local low temp limit tripped */ #define LM90_STATUS_LHIGH (1 << 6)/* local high temp limit tripped */ +#define LM90_STATUS_BUSY (1 << 7)/* conversion is ongoing */ #define MAX6696_STATUS2_R2THRM (1 << 1)/* remote2 THERM limit tripped */ #define MAX6696_STATUS2_R2OPEN (1 << 2)/* remote2 is an open circuit */
@@ -792,7 +793,7 @@ static int lm90_update_device(struct device *dev) val =lm90_read_reg (client,LM90_REG_R_STATUS );if (val <0 )return val; - data->alarms = val;/* lower 8 bit of alarms */ + data->alarms = val & ~LM90_STATUS_BUSY ;if (data->kind == max6696) { val =lm90_select_remote_channel (data,1 );
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 9/26 ASoC: rt5682: fix the wrong jack type detected
In reply to Sasha LevinFrom: Derek Fang <[email protected]>
[ Upstream commit 8deb34a90f06374fd26f722c2a79e15160f66be7 ]
Some powers were changed during the jack insert detection and clk's enable/disable in CCF.
If in parallel, the influence has a chance to detect the wrong jack type, so add a lock.
--- sound/soc/codecs/rt5682.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/codecs/rt5682.c +4 -0
@@ -927,6 +927,8 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)unsigned int val, count;if (jack_insert) { +snd_soc_dapm_mutex_lock (dapm); +snd_soc_component_update_bits (component,RT5682_PWR_ANLG_1 ,RT5682_PWR_VREF2 |RT5682_PWR_MB ,RT5682_PWR_VREF2 |RT5682_PWR_MB );
@@ -973,6 +975,8 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)snd_soc_component_update_bits (component,RT5682_MICBIAS_2 ,RT5682_PWR_CLK25M_MASK |RT5682_PWR_CLK1M_MASK ,RT5682_PWR_CLK25M_PU |RT5682_PWR_CLK1M_PU ); + +snd_soc_dapm_mutex_unlock (dapm); }else {rt5682_enable_push_button_irq (component, false); snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 10/26 ASoC: tas2770: Fix setting of high sample rates
In reply to Sasha LevinFrom: Martin Povišer <[email protected]>
[ Upstream commit 80d5be1a057e05f01d66e986cfd34d71845e5190 ]
Although the codec advertises support for 176.4 and 192 ksps, without this fix setting those sample rates fails with EINVAL at hw_params time.
--- sound/soc/codecs/tas2770.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/tas2770.c +2 -2
@@ -291,11 +291,11 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate) ramp_rate_val =TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |TAS2770_TDM_CFG_REG0_31_88_2_96KHZ ;break ; -case 19200 : +case 192000 : ramp_rate_val =TAS2770_TDM_CFG_REG0_SMP_48KHZ |TAS2770_TDM_CFG_REG0_31_176_4_192KHZ ;break ; -case 17640 : +case 176400 : ramp_rate_val =TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |TAS2770_TDM_CFG_REG0_31_176_4_192KHZ ;break ;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 11/26 Revert "x86/boot: Pull up cmdline preparation and early param parsing"
In reply to Sasha LevinFrom: Borislav Petkov <[email protected]>
[ Upstream commit fbe6183998546f8896ee0b620ece86deff5a2fd1 ]
This reverts commit 8d48bf8206f77aa8687f0e241e901e5197e52423.
It turned out to be a bad idea as it broke supplying mem= cmdline parameters due to parse_memopt() requiring preparatory work like setting up the e820 table in e820__memory_setup() in order to be able to exclude the range specified by mem=.
Pulling that up would've broken Xen PV again, see threads at
https://lkml.kernel.org/r/[email protected]
due to xen_memory_setup() needing the first reservations in early_reserve_memory() - kernel and initrd - to have happened already.
This could be fixed again by having Xen do those reservations itself...
Long story short, revert this and do a simpler fix in a later patch.
--- arch/x86/kernel/setup.c | 66 +++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 39 deletions(-)
arch/x86/kernel/setup.c +27 -39
@@ -742,28 +742,6 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } -static char *prepare_command_line (void ) -{ -#ifdef CONFIG_CMDLINE_BOOL -#ifdef CONFIG_CMDLINE_OVERRIDE -strlcpy (boot_command_line, builtin_cmdline,COMMAND_LINE_SIZE ); -#else -if (builtin_cmdline[0 ]) { -/* append boot loader cmdline to builtin */ -strlcat (builtin_cmdline," " ,COMMAND_LINE_SIZE ); -strlcat (builtin_cmdline, boot_command_line,COMMAND_LINE_SIZE ); -strlcpy (boot_command_line, builtin_cmdline,COMMAND_LINE_SIZE ); - } -#endif -#endif - -strlcpy (command_line, boot_command_line,COMMAND_LINE_SIZE ); - -parse_early_param (); - -return command_line; -} -/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures
@@ -852,23 +830,6 @@ void __init setup_arch(char **cmdline_p) x86_init.oem.arch_setup (); -/* -* x86_configure_nx() is called before parse_early_param() (called by -* prepare_command_line()) to detect whether hardware doesn't support -* NX (so that the early EHCI debug console setup can safely call -* set_fixmap()). It may then be called again from within noexec_setup() -* during parsing early parameters to honor the respective command line -* option. -*/ -x86_configure_nx (); - -/* -* This parses early params and it needs to run before -* early_reserve_memory() because latter relies on such settings -* supplied as early params. -*/ - *cmdline_p =prepare_command_line (); -/* * Do some memory reservations *before* memory is added to memblock, so * memblock allocations won't overwrite it.
@@ -902,6 +863,33 @@ void __init setup_arch(char **cmdline_p) bss_resource.start =__pa_symbol (__bss_start); bss_resource.end =__pa_symbol (__bss_stop)-1 ; +#ifdef CONFIG_CMDLINE_BOOL +#ifdef CONFIG_CMDLINE_OVERRIDE +strlcpy (boot_command_line, builtin_cmdline,COMMAND_LINE_SIZE ); +#else +if (builtin_cmdline[0 ]) { +/* append boot loader cmdline to builtin */ +strlcat (builtin_cmdline," " ,COMMAND_LINE_SIZE ); +strlcat (builtin_cmdline, boot_command_line,COMMAND_LINE_SIZE ); +strlcpy (boot_command_line, builtin_cmdline,COMMAND_LINE_SIZE ); + } +#endif +#endif + +strlcpy (command_line, boot_command_line,COMMAND_LINE_SIZE ); + *cmdline_p = command_line; + +/* +* x86_configure_nx() is called before parse_early_param() to detect +* whether hardware doesn't support NX (so that the early EHCI debug +* console setup can safely call set_fixmap()). It may then be called +* again from within noexec_setup() during parsing early parameters +* to honor the respective command line option. +*/ +x86_configure_nx (); + +parse_early_param (); +#ifdef CONFIG_MEMORY_HOTPLUG /* * Memory used by the kernel cannot be hot-removed because Linux
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 12/26 tomoyo: Check exceeded quota early in tomoyo_domain_quota_is_ok().
In reply to Sasha LevinFrom: Dmitry Vyukov <[email protected]>
[ Upstream commit 04e57a2d952bbd34bc45744e72be3eecdc344294 ]
If tomoyo is used in a testing/fuzzing environment in learning mode, for lots of domains the quota will be exceeded and stay exceeded for prolonged periods of time. In such cases it's pointless (and slow) to walk the whole acl list again and again just to rediscover that the quota is exceeded. We already have the TOMOYO_DIF_QUOTA_WARNED flag that notes the overflow condition. Check it early to avoid the slowdown.
[penguin-kernel]
This patch causes a user visible change that the learning mode will not be automatically resumed after the quota is increased. To resume the learning mode, administrator will need to explicitly clear TOMOYO_DIF_QUOTA_WARNED flag after increasing the quota. But I think that this change is generally preferable, for administrator likely wants to optimize the acl list for that domain before increasing the quota, or that domain likely hits the quota again. Therefore, don't try to care to clear TOMOYO_DIF_QUOTA_WARNED flag automatically when the quota for that domain changed.
--- security/tomoyo/util.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
security/tomoyo/util.c +7 -7
@@ -1051,6 +1051,8 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)return false;if (!domain)return true; +if (READ_ONCE (domain->flags[TOMOYO_DIF_QUOTA_WARNED ])) +return false;list_for_each_entry_rcu (ptr, &domain->acl_info_list, list,srcu_read_lock_held (&tomoyo_ss)) {u16 perm;
@@ -1096,14 +1098,12 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)if (count <tomoyo_profile (domain->ns, domain->profile)-> pref[TOMOYO_PREF_MAX_LEARNING_ENTRY ])return true; -if (!domain->flags[TOMOYO_DIF_QUOTA_WARNED ]) { - domain->flags[TOMOYO_DIF_QUOTA_WARNED ] = true; -/* r->granted = false; */ -tomoyo_write_log (r,"%s" , tomoyo_dif[TOMOYO_DIF_QUOTA_WARNED ]); +WRITE_ONCE (domain->flags[TOMOYO_DIF_QUOTA_WARNED ], true); +/* r->granted = false; */ +tomoyo_write_log (r,"%s" , tomoyo_dif[TOMOYO_DIF_QUOTA_WARNED ]);#ifndef CONFIG_SECURITY_TOMOYO_INSECURE_BUILTIN_SETTING -pr_warn ("WARNING: Domain '%s' has too many ACLs to hold. Stopped learning mode.\n" , - domain->domainname->name); +pr_warn ("WARNING: Domain '%s' has too many ACLs to hold. Stopped learning mode.\n" , + domain->domainname->name);#endif - }return false; }
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 13/26 tomoyo: use hwight16() in tomoyo_domain_quota_is_ok()
In reply to Sasha LevinFrom: Tetsuo Handa <[email protected]>
[ Upstream commit f702e1107601230eec707739038a89018ea3468d ]
hwight16() is much faster. While we are at it, no need to include "perm =" part into data_race() macro, for perm is a local variable that cannot be accessed by other threads.
--- security/tomoyo/util.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
security/tomoyo/util.c +7 -10
@@ -1056,7 +1056,6 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)list_for_each_entry_rcu (ptr, &domain->acl_info_list, list,srcu_read_lock_held (&tomoyo_ss)) {u16 perm; -u8 i;if (ptr->is_deleted)continue ;
@@ -1067,23 +1066,23 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)*/ switch (ptr->type) {case TOMOYO_TYPE_PATH_ACL : - data_race(perm = container_of(ptr, struct tomoyo_path_acl, head)->perm); + perm = data_race(container_of(ptr, struct tomoyo_path_acl, head)->perm);break ;case TOMOYO_TYPE_PATH2_ACL : - data_race(perm = container_of(ptr, struct tomoyo_path2_acl, head)->perm); + perm = data_race(container_of(ptr, struct tomoyo_path2_acl, head)->perm);break ;case TOMOYO_TYPE_PATH_NUMBER_ACL : - data_race(perm = container_of(ptr, struct tomoyo_path_number_acl, head) + perm = data_race(container_of(ptr, struct tomoyo_path_number_acl, head) ->perm);break ;case TOMOYO_TYPE_MKDEV_ACL : - data_race(perm = container_of(ptr, struct tomoyo_mkdev_acl, head)->perm); + perm = data_race(container_of(ptr, struct tomoyo_mkdev_acl, head)->perm);break ;case TOMOYO_TYPE_INET_ACL : - data_race(perm = container_of(ptr, struct tomoyo_inet_acl, head)->perm); + perm = data_race(container_of(ptr, struct tomoyo_inet_acl, head)->perm);break ;case TOMOYO_TYPE_UNIX_ACL : - data_race(perm = container_of(ptr, struct tomoyo_unix_acl, head)->perm); + perm = data_race(container_of(ptr, struct tomoyo_unix_acl, head)->perm);break ;case TOMOYO_TYPE_MANUAL_TASK_ACL : perm =0 ;
@@ -1091,9 +1090,7 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)default : perm =1 ; } -for (i =0 ; i <16 ; i++) -if (perm & (1 << i)) - count++; + count +=hweight16 (perm); }if (count <tomoyo_profile (domain->ns, domain->profile)-> pref[TOMOYO_PREF_MAX_LEARNING_ENTRY ])
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 14/26 x86/boot: Move EFI range reservation after cmdline parsing
In reply to Sasha LevinFrom: Mike Rapoport <[email protected]>
[ Upstream commit 2f5b3514c33fecad4003ce0f22ca9691492d310b ]
The memory reservation in arch/x86/platform/efi/efi.c depends on at least two command line parameters. Put it back later in the boot process and move efi_memblock_x86_reserve_range() out of early_memory_reserve().
An attempt to fix this was done in
8d48bf8206f7 ("x86/boot: Pull up cmdline preparation and early param parsing")
but that caused other troubles so it got reverted.
The bug this is addressing is:
Dan reports that Anjaneya Chagam can no longer use the efi=nosoftreserve kernel command line parameter to suppress "soft reservation" behavior.
This is due to the fact that the following call-chain happens at boot:
early_reserve_memory
|-> efi_memblock_x86_reserve_range
|-> efi_fake_memmap_early
which does
if (!efi_soft_reserve_enabled())
return;and that would have set EFI_MEM_NO_SOFT_RESERVE after having parsed "nosoftreserve".
However, parse_early_param() gets called *after* it, leading to the boot cmdline not being taken into account.
See also https://lore.kernel.org/r/[email protected]
[ bp: Turn into a proper patch. ]
--- arch/x86/kernel/setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/setup.c +3 -3
@@ -713,9 +713,6 @@ static void __init early_reserve_memory(void)early_reserve_initrd (); -if (efi_enabled (EFI_BOOT )) -efi_memblock_x86_reserve_range (); -memblock_x86_reserve_range_setup_data ();reserve_ibft_region ();
@@ -890,6 +887,9 @@ void __init setup_arch(char **cmdline_p)parse_early_param (); +if (efi_enabled (EFI_BOOT )) +efi_memblock_x86_reserve_range (); +#ifdef CONFIG_MEMORY_HOTPLUG /* * Memory used by the kernel cannot be hot-removed because Linux
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 15/26 net/sched: Extend qdisc control block with tc control block
In reply to Sasha LevinFrom: Paul Blakey <[email protected]>
[ Upstream commit ec624fe740b416fb68d536b37fb8eef46f90b5c2 ]
BPF layer extends the qdisc control block via struct bpf_skb_data_end and because of that there is no more room to add variables to the qdisc layer control block without going over the skb->cb size.
Extend the qdisc control block with a tc control block, and move all tc related variables to there as a pre-step for extending the tc control block with additional members.
--- include/net/pkt_sched.h | 15 +++++++++++++++ include/net/sch_generic.h | 2 -- net/core/dev.c | 8 ++++---- net/sched/act_ct.c | 14 +++++++------- net/sched/cls_api.c | 6 ++++-- net/sched/cls_flower.c | 3 ++- net/sched/sch_frag.c | 3 ++- 7 files changed, 34 insertions(+), 17 deletions(-)
include/net/pkt_sched.h +15 -0
@@ -193,4 +193,19 @@ static inline void skb_txtime_consumed(struct sk_buff *skb) skb->tstamp =ktime_set (0 ,0 ); } +struct tc_skb_cb { +struct qdisc_skb_cb qdisc_cb; + +u16 mru; +bool post_ct; +}; + +static inline struct tc_skb_cb *tc_skb_cb (const struct sk_buff *skb) +{ +struct tc_skb_cb *cb = (struct tc_skb_cb *)skb->cb; + + BUILD_BUG_ON(sizeof(*cb) > sizeof_field(struct sk_buff, cb)); +return cb; +} +#endif
include/net/sch_generic.h +0 -2
@@ -440,8 +440,6 @@ struct qdisc_skb_cb { };#define QDISC_CB_PRIV_LEN 20unsigned char data[QDISC_CB_PRIV_LEN ]; -u16 mru; -bool post_ct; };typedef void tcf_chain_head_change_t (struct tcf_proto *tp_head,void *priv);
net/core/dev.c +4 -4
@@ -3934,8 +3934,8 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)return skb;/* qdisc_skb_cb(skb)->pkt_len was already set by the caller. */ -qdisc_skb_cb (skb)->mru =0 ; -qdisc_skb_cb (skb)->post_ct = false; +tc_skb_cb (skb)->mru =0 ; +tc_skb_cb (skb)->post_ct = false;mini_qdisc_bstats_cpu_update (miniq, skb);switch (tcf_classify (skb, miniq->block, miniq->filter_list, &cl_res, false)) {
@@ -5088,8 +5088,8 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret, }qdisc_skb_cb (skb)->pkt_len = skb->len; -qdisc_skb_cb (skb)->mru =0 ; -qdisc_skb_cb (skb)->post_ct = false; +tc_skb_cb (skb)->mru =0 ; +tc_skb_cb (skb)->post_ct = false; skb->tc_at_ingress =1 ;mini_qdisc_bstats_cpu_update (miniq, skb);
net/sched/act_ct.c +7 -7
@@ -690,10 +690,10 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb, u8 family, u16 zone, bool *defrag) { enum ip_conntrack_info ctinfo; -struct qdisc_skb_cb cb;struct nf_conn *ct;int err =0 ;bool frag; +u16 mru;/* Previously seen (loopback)? Ignore. */ ct =nf_ct_get (skb, &ctinfo);
@@ -708,7 +708,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,return err;skb_get (skb); - cb = *qdisc_skb_cb (skb); + mru =tc_skb_cb (skb)->mru;if (family ==NFPROTO_IPV4 ) {enum ip_defrag_users user =IP_DEFRAG_CONNTRACK_IN + zone;
@@ -722,7 +722,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,if (!err) { *defrag = true; - cb.mru =IPCB (skb)->frag_max_size; + mru =IPCB (skb)->frag_max_size; } }else {/* NFPROTO_IPV6 */ #if IS_ENABLED (CONFIG_NF_DEFRAG_IPV6 )
@@ -735,7 +735,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,if (!err) { *defrag = true; - cb.mru =IP6CB (skb)->frag_max_size; + mru =IP6CB (skb)->frag_max_size; }#else err = -EOPNOTSUPP ;
@@ -744,7 +744,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb, }if (err != -EINPROGRESS ) - *qdisc_skb_cb (skb) = cb; +tc_skb_cb (skb)->mru = mru;skb_clear_hash (skb); skb->ignore_df =1 ;return err;
@@ -963,7 +963,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,tcf_action_update_bstats (&c->common, skb);if (clear) { -qdisc_skb_cb (skb)->post_ct = false; +tc_skb_cb (skb)->post_ct = false; ct =nf_ct_get (skb, &ctinfo);if (ct) {nf_conntrack_put (&ct->ct_general);
@@ -1048,7 +1048,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, out_push:skb_push_rcsum (skb, nh_ofs); -qdisc_skb_cb (skb)->post_ct = true; +tc_skb_cb (skb)->post_ct = true; out_clear:if (defrag)qdisc_skb_cb (skb)->pkt_len = skb->len;
net/sched/cls_api.c +4 -2
@@ -1617,12 +1617,14 @@ int tcf_classify(struct sk_buff *skb,/* If we missed on some chain */ if (ret ==TC_ACT_UNSPEC && last_executed_chain) { +struct tc_skb_cb *cb =tc_skb_cb (skb); + ext =tc_skb_ext_alloc (skb);if (WARN_ON_ONCE (!ext))return TC_ACT_SHOT ; ext->chain = last_executed_chain; - ext->mru =qdisc_skb_cb (skb)->mru; - ext->post_ct =qdisc_skb_cb (skb)->post_ct; + ext->mru = cb->mru; + ext->post_ct = cb->post_ct; }return ret;
net/sched/cls_flower.c +2 -1
@@ -19,6 +19,7 @@#include <net/sch_generic.h> #include <net/pkt_cls.h> +#include <net/pkt_sched.h> #include <net/ip.h> #include <net/flow_dissector.h> #include <net/geneve.h>
@@ -309,7 +310,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, struct tcf_result *res) {struct cls_fl_head *head =rcu_dereference_bh (tp->root); -bool post_ct =qdisc_skb_cb (skb)->post_ct; +bool post_ct =tc_skb_cb (skb)->post_ct;struct fl_flow_key skb_key;struct fl_flow_mask *mask;struct cls_fl_filter *f;
net/sched/sch_frag.c +2 -1
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB #include <net/netlink.h> #include <net/sch_generic.h> +#include <net/pkt_sched.h> #include <net/dst.h> #include <net/ip.h> #include <net/ip6_fib.h>
@@ -137,7 +138,7 @@ static int sch_fragment(struct net *net, struct sk_buff *skb,int sch_frag_xmit_hook (struct sk_buff *skb,int (*xmit)(struct sk_buff *skb)) { -u16 mru =qdisc_skb_cb (skb)->mru; +u16 mru =tc_skb_cb (skb)->mru;int err;if (mru && skb->len > mru + skb->dev->hard_header_len)
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 16/26 tun: avoid double free in tun_free_netdev
In reply to Sasha LevinFrom: George Kennedy <[email protected]>
[ Upstream commit 158b515f703e75e7d68289bf4d98c664e1d632df ]
Avoid double free in tun_free_netdev() by moving the dev->tstats and tun->security allocs to a new ndo_init routine (tun_net_init()) that will be called by register_netdevice(). ndo_init is paired with the desctructor (tun_free_netdev()), so if there's an error in register_netdevice() the destructor will handle the frees.
BUG: KASAN: double-free or invalid-free in selinux_tun_dev_free_security+0x1a/0x20 security/selinux/hooks.c:5605 CPU: 0 PID: 25750 Comm: syz-executor416 Not tainted 5.16.0-rc2-syzk #1 Hardware name: Red Hat KVM, BIOS Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x89/0xb5 lib/dump_stack.c:106 print_address_description.constprop.9+0x28/0x160 mm/kasan/report.c:247 kasan_report_invalid_free+0x55/0x80 mm/kasan/report.c:372 ____kasan_slab_free mm/kasan/common.c:346 [inline] __kasan_slab_free+0x107/0x120 mm/kasan/common.c:374 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1723 [inline] slab_free_freelist_hook mm/slub.c:1749 [inline] slab_free mm/slub.c:3513 [inline] kfree+0xac/0x2d0 mm/slub.c:4561 selinux_tun_dev_free_security+0x1a/0x20 security/selinux/hooks.c:5605 security_tun_dev_free_security+0x4f/0x90 security/security.c:2342 tun_free_netdev+0xe6/0x150 drivers/net/tun.c:2215 netdev_run_todo+0x4df/0x840 net/core/dev.c:10627 rtnl_unlock+0x13/0x20 net/core/rtnetlink.c:112 __tun_chr_ioctl+0x80c/0x2870 drivers/net/tun.c:3302 tun_chr_ioctl+0x2f/0x40 drivers/net/tun.c:3311 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl fs/ioctl.c:860 [inline] __x64_sys_ioctl+0x19d/0x220 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3a/0x80 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae
--- drivers/net/tun.c | 115 ++++++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 56 deletions(-)
drivers/net/tun.c +59 -56
@@ -209,6 +209,9 @@ struct tun_struct {struct tun_prog __rcu *steering_prog;struct tun_prog __rcu *filter_prog;struct ethtool_link_ksettings link_ksettings; +/* init args */ +struct file *file; +struct ifreq *ifr; };struct veth {
@@ -216,6 +219,9 @@ struct veth {__be16 h_vlan_TCI; }; +static void tun_flow_init (struct tun_struct *tun); +static void tun_flow_uninit (struct tun_struct *tun); +static int tun_napi_receive (struct napi_struct *napi,int budget) { struct tun_file *tfile = container_of(napi, struct tun_file, napi);
@@ -953,6 +959,49 @@ static int check_filter(struct tap_filter *filter, const struct sk_buff *skb)static const struct ethtool_ops tun_ethtool_ops; +static int tun_net_init (struct net_device *dev) +{ +struct tun_struct *tun =netdev_priv (dev); +struct ifreq *ifr = tun->ifr; +int err; + + dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); +if (!dev->tstats) +return -ENOMEM ; + +spin_lock_init (&tun->lock); + + err =security_tun_dev_alloc_security (&tun->security); +if (err <0 ) { +free_percpu (dev->tstats); +return err; + } + +tun_flow_init (tun); + + dev->hw_features =NETIF_F_SG |NETIF_F_FRAGLIST | +TUN_USER_FEATURES |NETIF_F_HW_VLAN_CTAG_TX | +NETIF_F_HW_VLAN_STAG_TX ; + dev->features = dev->hw_features |NETIF_F_LLTX ; + dev->vlan_features = dev->features & + ~(NETIF_F_HW_VLAN_CTAG_TX | +NETIF_F_HW_VLAN_STAG_TX ); + + tun->flags = (tun->flags & ~TUN_FEATURES ) | + (ifr->ifr_flags &TUN_FEATURES ); + +INIT_LIST_HEAD (&tun->disabled); + err =tun_attach (tun, tun->file, false, ifr->ifr_flags &IFF_NAPI , + ifr->ifr_flags &IFF_NAPI_FRAGS , false); +if (err <0 ) { +tun_flow_uninit (tun); +security_tun_dev_free_security (tun->security); +free_percpu (dev->tstats); +return err; + } +return 0 ; +} +/* Net device detach from fd. */ static void tun_net_uninit (struct net_device *dev) {
@@ -1169,6 +1218,7 @@ static int tun_net_change_carrier(struct net_device *dev, bool new_carrier) }static const struct net_device_ops tun_netdev_ops = { + .ndo_init = tun_net_init, .ndo_uninit = tun_net_uninit, .ndo_open = tun_net_open, .ndo_stop = tun_net_close,
@@ -1252,6 +1302,7 @@ static int tun_xdp_tx(struct net_device *dev, struct xdp_buff *xdp) }static const struct net_device_ops tap_netdev_ops = { + .ndo_init = tun_net_init, .ndo_uninit = tun_net_uninit, .ndo_open = tun_net_open, .ndo_stop = tun_net_close,
@@ -1292,7 +1343,7 @@ static void tun_flow_uninit(struct tun_struct *tun)#define MAX_MTU 65535/* Initialize net device. */ -static void tun_net_init (struct net_device *dev) +static void tun_net_initialize (struct net_device *dev) {struct tun_struct *tun =netdev_priv (dev);
@@ -2206,11 +2257,6 @@ static void tun_free_netdev(struct net_device *dev)BUG_ON (!(list_empty (&tun->disabled)));free_percpu (dev->tstats); -/* We clear tstats so that tun_set_iff() can tell if -* tun_free_netdev() has been called from register_netdevice(). -*/ - dev->tstats =NULL ; -tun_flow_uninit (tun);security_tun_dev_free_security (tun->security);__tun_set_ebpf (tun, &tun->steering_prog,NULL );
@@ -2716,41 +2762,16 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) tun->rx_batched =0 ;RCU_INIT_POINTER (tun->steering_prog,NULL ); - dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); -if (!dev->tstats) { - err = -ENOMEM ; - goto err_free_dev; - } - -spin_lock_init (&tun->lock); - - err =security_tun_dev_alloc_security (&tun->security); -if (err <0 ) - goto err_free_stat; - -tun_net_init (dev); -tun_flow_init (tun); + tun->ifr = ifr; + tun->file = file; - dev->hw_features =NETIF_F_SG |NETIF_F_FRAGLIST | -TUN_USER_FEATURES |NETIF_F_HW_VLAN_CTAG_TX | -NETIF_F_HW_VLAN_STAG_TX ; - dev->features = dev->hw_features |NETIF_F_LLTX ; - dev->vlan_features = dev->features & - ~(NETIF_F_HW_VLAN_CTAG_TX | -NETIF_F_HW_VLAN_STAG_TX ); - - tun->flags = (tun->flags & ~TUN_FEATURES ) | - (ifr->ifr_flags &TUN_FEATURES ); - -INIT_LIST_HEAD (&tun->disabled); - err =tun_attach (tun, file, false, ifr->ifr_flags &IFF_NAPI , - ifr->ifr_flags &IFF_NAPI_FRAGS , false); -if (err <0 ) - goto err_free_flow; +tun_net_initialize (dev); err =register_netdevice (tun->dev); -if (err <0 ) - goto err_detach; +if (err <0 ) { +free_netdev (dev); +return err; + }/* free_netdev() won't check refcnt, to avoid race * with dev_put() we need publish tun after registration. */
@@ -2767,24 +2788,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)strcpy (ifr->ifr_name, tun->dev->name);return 0 ; - -err_detach: -tun_detach_all (dev); -/* We are here because register_netdevice() has failed. -* If register_netdevice() already called tun_free_netdev() -* while dealing with the error, dev->stats has been cleared. -*/ -if (!dev->tstats) - goto err_free_dev; - -err_free_flow: -tun_flow_uninit (tun); -security_tun_dev_free_security (tun->security); -err_free_stat: -free_percpu (dev->tstats); -err_free_dev: -free_netdev (dev); -return err; }static void tun_get_iff (struct tun_struct *tun,struct ifreq *ifr)
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 17/26 ax25: NPD bug when detaching AX25 device
In reply to Sasha LevinFrom: Lin Ma <[email protected]>
[ Upstream commit 1ade48d0c27d5da1ccf4b583d8c5fc8b534a3ac8 ]
The existing cleanup routine implementation is not well synchronized with the syscall routine. When a device is detaching, below race could occur.
static int ax25_sendmsg(...) {
...
lock_sock()
ax25 = sk_to_ax25(sk);
if (ax25->ax25_dev == NULL) // CHECK
...
ax25_queue_xmit(skb, ax25->ax25_dev->dev); // USE
...
}
static void ax25_kill_by_device(...) {
...
if (s->ax25_dev == ax25_dev) {
s->ax25_dev = NULL;
...
}Other syscall functions like ax25_getsockopt, ax25_getname, ax25_info_show also suffer from similar races. To fix them, this patch introduce lock_sock() into ax25_kill_by_device in order to guarantee that the nullify action in cleanup routine cannot proceed when another socket request is pending.
--- net/ax25/af_ax25.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ax25/af_ax25.c +3 -1
@@ -85,8 +85,10 @@ static void ax25_kill_by_device(struct net_device *dev) again:ax25_for_each (s, &ax25_list) {if (s->ax25_dev == ax25_dev) { - s->ax25_dev =NULL ;spin_unlock_bh (&ax25_list_lock); +lock_sock (s->sk); + s->ax25_dev =NULL ; +release_sock (s->sk);ax25_disconnect (s,ENETUNREACH );spin_lock_bh (&ax25_list_lock);
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 18/26 Input: elants_i2c - do not check Remark ID on eKTH3900/eKTH5312
In reply to Sasha LevinFrom: Johnny Chuang <[email protected]>
[ Upstream commit 4ebfee2bbc1a9c343dd50565ba5ae249fac32267 ]
The eKTH3900/eKTH5312 series do not support the firmware update rules of Remark ID. Exclude these two series from checking it when updating the firmware in touch controllers.
--- drivers/input/touchscreen/elants_i2c.c | 46 +++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-)
drivers/input/touchscreen/elants_i2c.c +45 -1
@@ -117,6 +117,19 @@#define ELAN_POWERON_DELAY_USEC 500#define ELAN_RESET_DELAY_MSEC 20 +/* FW boot code version */ +#define BC_VER_H_BYTE_FOR_EKTH3900x1_I2C 0x72 +#define BC_VER_H_BYTE_FOR_EKTH3900x2_I2C 0x82 +#define BC_VER_H_BYTE_FOR_EKTH3900x3_I2C 0x92 +#define BC_VER_H_BYTE_FOR_EKTH5312x1_I2C 0x6D +#define BC_VER_H_BYTE_FOR_EKTH5312x2_I2C 0x6E +#define BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C 0x77 +#define BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C 0x78 +#define BC_VER_H_BYTE_FOR_EKTH5312x1_I2C_USB 0x67 +#define BC_VER_H_BYTE_FOR_EKTH5312x2_I2C_USB 0x68 +#define BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C_USB 0x74 +#define BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C_USB 0x75 +enum elants_chip_id {EKTH3500 ,EKTF3624 ,
@@ -736,6 +749,37 @@ static int elants_i2c_validate_remark_id(struct elants_data *ts,return 0 ; } +static bool elants_i2c_should_check_remark_id (struct elants_data *ts) +{ +struct i2c_client *client = ts->client; +const u8 bootcode_version = ts->iap_version; +bool check; + +/* I2C eKTH3900 and eKTH5312 are NOT support Remark ID */ +if ((bootcode_version == BC_VER_H_BYTE_FOR_EKTH3900x1_I2C) || + (bootcode_version == BC_VER_H_BYTE_FOR_EKTH3900x2_I2C) || + (bootcode_version == BC_VER_H_BYTE_FOR_EKTH3900x3_I2C) || + (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x1_I2C) || + (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x2_I2C) || + (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C) || + (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C) || + (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x1_I2C_USB) || + (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x2_I2C_USB) || + (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C_USB) || + (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C_USB)) { +dev_dbg (&client->dev, +"eKTH3900/eKTH5312(0x%02x) are not support remark id\n" , + bootcode_version); + check = false; + }else if (bootcode_version >=0x60 ) { + check = true; + }else { + check = false; + } + +return check; +} +static int elants_i2c_do_update_firmware (struct i2c_client *client,const struct firmware *fw,bool force)
@@ -749,7 +793,7 @@ static int elants_i2c_do_update_firmware(struct i2c_client *client,u16 send_id;int page, n_fw_pages;int error; -bool check_remark_id = ts->iap_version >=0x60 ; +bool check_remark_id =elants_i2c_should_check_remark_id (ts);/* Recovery mode detection! */ if (force) {
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 19/26 phonet/pep: refuse to enable an unbound pipe
In reply to Sasha LevinFrom: Rémi Denis-Courmont <[email protected]>
[ Upstream commit 75a2f31520095600f650597c0ac41f48b5ba0068 ]
This ioctl() implicitly assumed that the socket was already bound to a valid local socket name, i.e. Phonet object. If the socket was not bound, two separate problems would occur:
1) We'd send an pipe enablement request with an invalid source object.
2) Later socket calls could BUG on the socket unexpectedly being connected yet not bound to a valid object.
--- net/phonet/pep.c | 2 ++ 1 file changed, 2 insertions(+)
net/phonet/pep.c +2 -0
@@ -946,6 +946,8 @@ static int pep_ioctl(struct sock *sk, int cmd, unsigned long arg) ret = -EBUSY ; else if (sk->sk_state == TCP_ESTABLISHED) ret = -EISCONN ; + else if (!pn->pn_sk.sobject) + ret = -EADDRNOTAVAIL ; else ret =pep_sock_enable (sk,NULL ,0 );release_sock (sk);
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 20/26 parisc: Clear stale IIR value on instruction access rights trap
In reply to Sasha LevinFrom: Helge Deller <[email protected]>
[ Upstream commit 484730e5862f6b872dca13840bed40fd7c60fa26 ]
When a trap 7 (Instruction access rights) occurs, this means the CPU couldn't execute an instruction due to missing execute permissions on the memory region. In this case it seems the CPU didn't even fetched the instruction from memory and thus did not store it in the cr19 (IIR) register before calling the trap handler. So, the trap handler will find some random old stale value in cr19.
This patch simply overwrites the stale IIR value with a constant magic "bad food" value (0xbaadf00d), in the hope people don't start to try to understand the various random IIR values in trap 7 dumps.
--- arch/parisc/kernel/traps.c | 2 ++ 1 file changed, 2 insertions(+)
arch/parisc/kernel/traps.c +2 -0
@@ -729,6 +729,8 @@ void notrace handle_interruption(int code, struct pt_regs *regs) }mmap_read_unlock (current->mm); } +/* CPU could not fetch instruction, so clear stale IIR value. */ + regs->iir =0xbaadf00d ; fallthrough;case 27 :/* Data memory protection ID trap */
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 21/26 platform/mellanox: mlxbf-pmc: Fix an IS_ERR() vs NULL bug in mlxbf_pmc_map_counters
In reply to Sasha LevinFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 804034c4ffc502795cea9b3867acb2ec7fad99ba ]
The devm_ioremap() function returns NULL on error, it doesn't return error pointers. Also according to doc of device_property_read_u64_array, values in info array are properties of device or NULL.
--- drivers/platform/mellanox/mlxbf-pmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/mellanox/mlxbf-pmc.c +2 -2
@@ -1374,8 +1374,8 @@ static int mlxbf_pmc_map_counters(struct device *dev) pmc->block[i].counters = info[2 ]; pmc->block[i].type = info[3 ]; -if (IS_ERR (pmc->block[i].mmio_base)) -return PTR_ERR (pmc->block[i].mmio_base); +if (!pmc->block[i].mmio_base) +return -ENOMEM ; ret =mlxbf_pmc_create_groups (dev, i);if (ret)
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 22/26 platform/x86: apple-gmux: use resource_size() with res
In reply to Sasha LevinFrom: Wang Qing <[email protected]>
[ Upstream commit eb66fb03a727cde0ab9b1a3858de55c26f3007da ]
This should be (res->end - res->start + 1) here actually, use resource_size() derectly.
--- drivers/platform/x86/apple-gmux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/apple-gmux.c +1 -1
@@ -625,7 +625,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) } gmux_data->iostart = res->start; - gmux_data->iolen = res->end - res->start; + gmux_data->iolen =resource_size (res);if (gmux_data->iolen <GMUX_MIN_IO_LEN ) { pr_err("gmux I/O region too small (%lu < %u)\n",
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 23/26 memblock: fix memblock_phys_alloc() section mismatch error
In reply to Sasha LevinFrom: Jackie Liu <[email protected]>
[ Upstream commit d7f55471db2719629f773c2d6b5742a69595bfd3 ]
Fix modpost Section mismatch error in memblock_phys_alloc()
[...]
WARNING: modpost: vmlinux.o(.text.unlikely+0x1dcc): Section mismatch in reference from the function memblock_phys_alloc() to the function .init.text:memblock_phys_alloc_range() The function memblock_phys_alloc() references
the function __init memblock_phys_alloc_range().
This is often because memblock_phys_alloc lacks a __init
annotation or the annotation of memblock_phys_alloc_range is wrong.
ERROR: modpost: Section mismatches detected. Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them. [...]
memblock_phys_alloc() is a one-line wrapper, make it __always_inline to avoid these section mismatches.
--- include/linux/memblock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/memblock.h +2 -2
@@ -388,8 +388,8 @@ phys_addr_t memblock_alloc_range_nid(phys_addr_t size, phys_addr_t end, int nid, bool exact_nid);phys_addr_t memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid); -static inline phys_addr_t memblock_phys_alloc (phys_addr_t size, -phys_addr_t align) +static __always_inline phys_addr_t memblock_phys_alloc(phys_addr_t size, +phys_addr_t align) {return memblock_phys_alloc_range (size, align,0 ,MEMBLOCK_ALLOC_ACCESSIBLE );
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 24/26 ALSA: hda: intel-sdw-acpi: harden detection of controller
In reply to Sasha LevinFrom: Libin Yang <[email protected]>
[ Upstream commit 385f287f9853da402d94278e59f594501c1d1dad ]
The existing code currently sets a pointer to an ACPI handle before checking that it's actually a SoundWire controller. This can lead to issues where the graph walk continues and eventually fails, but the pointer was set already.
This patch changes the logic so that the information provided to the caller is set when a controller is found.
--- sound/hda/intel-sdw-acpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/hda/intel-sdw-acpi.c +3 -2
@@ -132,8 +132,6 @@ static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level,return AE_NOT_FOUND ; } - info->handle = handle; -/* * On some Intel platforms, multiple children of the HDAS * device can be found, but only one of them is the SoundWire
@@ -144,6 +142,9 @@ static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level,if (FIELD_GET (GENMASK (31 ,28 ), adr) !=SDW_LINK_TYPE )return AE_OK ;/* keep going */ +/* found the correct SoundWire controller */ + info->handle = handle; +/* device found, stop namespace walk */ return AE_CTRL_TERMINATE ; }
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 25/26 ALSA: hda: intel-sdw-acpi: go through HDAS ACPI at max depth of 2
In reply to Sasha LevinFrom: Libin Yang <[email protected]>
[ Upstream commit 78ea40efb48e978756db2ce45fcfa55bac056b91 ]
In the HDAS ACPI scope, the SoundWire may not be the direct child of HDAS. It needs to go through the ACPI table at max depth of 2 to find the SoundWire device from HDAS.
--- sound/hda/intel-sdw-acpi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/hda/intel-sdw-acpi.c +7 -1
@@ -165,8 +165,14 @@ int sdw_intel_acpi_scan(acpi_handle *parent_handle,acpi_status status; info->handle =NULL ; +/* +* In the HDAS ACPI scope, 'SNDW' may be either the child of +* 'HDAS' or the grandchild of 'HDAS'. So let's go through +* the ACPI from 'HDAS' at max depth of 2 to find the 'SNDW' +* device. +*/ status =acpi_walk_namespace (ACPI_TYPE_DEVICE , - parent_handle,1 , + parent_handle,2 , sdw_intel_acpi_cb,NULL , info,NULL );if (ACPI_FAILURE (status) || info->handle ==NULL )
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 26/26 r8152: sync ocp base
In reply to Sasha LevinFrom: Hayes Wang <[email protected]>
[ Upstream commit b24edca309535c2d9af86aab95d64065f6ef1d26 ]
There are some chances that the actual base of hardware is different from the value recorded by driver, so we have to reset the variable of ocp_base to sync it.
Set ocp_base to -1. Then, it would be updated and the new base would be set to the hardware next time.
--- drivers/net/usb/r8152.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/net/usb/r8152.c +22 -4
@@ -32,7 +32,7 @@#define NETNEXT_VERSION "12"/* Information for net */ -#define NET_VERSION "11" +#define NET_VERSION "12"#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION#define DRIVER_AUTHOR "Realtek linux nic maintainers <[email protected]>"
@@ -4016,6 +4016,11 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)ocp_write_word (tp, type,PLA_BP_BA ,0 ); } +static inline void rtl_reset_ocp_base (struct r8152 *tp) +{ + tp->ocp_base =-1 ; +} +static int rtl_phy_patch_request (struct r8152 *tp,bool request,bool wait) {u16 data, check;
@@ -4087,8 +4092,6 @@ static int rtl_post_ram_code(struct r8152 *tp, u16 key_addr, bool wait)rtl_phy_patch_request (tp, false, wait); -ocp_write_word (tp,MCU_TYPE_PLA ,PLA_OCP_GPHY_BASE , tp->ocp_base); -return 0 ; }
@@ -4800,6 +4803,8 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, struct fw_phy_speed_up *phy,u32 len;u8 *data; +rtl_reset_ocp_base (tp); +if (sram_read (tp,SRAM_GPHY_FW_VER ) >=__le16_to_cpu (phy->version)) {dev_dbg (&tp->intf->dev,"PHY firmware has been the newest\n" );return ;
@@ -4845,7 +4850,8 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, struct fw_phy_speed_up *phy, } } -ocp_write_word (tp,MCU_TYPE_PLA ,PLA_OCP_GPHY_BASE , tp->ocp_base); +rtl_reset_ocp_base (tp); +rtl_phy_patch_request (tp, false, wait);if (sram_read (tp,SRAM_GPHY_FW_VER ) ==__le16_to_cpu (phy->version))
@@ -4861,6 +4867,8 @@ static int rtl8152_fw_phy_ver(struct r8152 *tp, struct fw_phy_ver *phy_ver) ver_addr =__le16_to_cpu (phy_ver->ver.addr); ver =__le16_to_cpu (phy_ver->ver.data); +rtl_reset_ocp_base (tp); +if (sram_read (tp, ver_addr) >= ver) {dev_dbg (&tp->intf->dev,"PHY firmware has been the newest\n" );return 0 ;
@@ -4877,6 +4885,8 @@ static void rtl8152_fw_phy_fixup(struct r8152 *tp, struct fw_phy_fixup *fix) {u16 addr, data; +rtl_reset_ocp_base (tp); + addr =__le16_to_cpu (fix->setting.addr); data =ocp_reg_read (tp, addr);
@@ -4908,6 +4918,8 @@ static void rtl8152_fw_phy_union_apply(struct r8152 *tp, struct fw_phy_union *phu32 length;int i, num; +rtl_reset_ocp_base (tp); + num = phy->pre_num;for (i =0 ; i < num; i++) sram_write(tp, __le16_to_cpu(phy->pre_set[i].addr),
@@ -4938,6 +4950,8 @@ static void rtl8152_fw_phy_nc_apply(struct r8152 *tp, struct fw_phy_nc *phy)u32 length, i, num;__le16 *data; +rtl_reset_ocp_base (tp); + mode_reg =__le16_to_cpu (phy->mode_reg);sram_write (tp, mode_reg,__le16_to_cpu (phy->mode_pre)); sram_write(tp, __le16_to_cpu(phy->ba_reg),
@@ -5107,6 +5121,7 @@ static void rtl8152_apply_firmware(struct r8152 *tp, bool power_cut)if (rtl_fw->post_fw) rtl_fw->post_fw (tp); +rtl_reset_ocp_base (tp);strscpy (rtl_fw->version, fw_hdr->version,RTL_VER_SIZE );dev_info (&tp->intf->dev,"load %s successfully\n" , rtl_fw->version); }
@@ -8467,6 +8482,8 @@ static int rtl8152_resume(struct usb_interface *intf)mutex_lock (&tp->control); +rtl_reset_ocp_base (tp); +if (test_bit (SELECTIVE_SUSPEND , &tp->flags)) ret =rtl8152_runtime_resume (tp);else
@@ -8482,6 +8499,7 @@ static int rtl8152_reset_resume(struct usb_interface *intf)struct r8152 *tp =usb_get_intfdata (intf);clear_bit (SELECTIVE_SUSPEND , &tp->flags); +rtl_reset_ocp_base (tp); tp->rtl_ops.init (tp);queue_delayed_work (system_long_wq, &tp->hw_phy_work,0 );set_ethernet_addr (tp, true);
Signature · 1 line
2.34.1