6.6.88-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 301/393 Revert "PCI: Avoid reset when disabled via sysfs"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
commit bc0b828ef6e561081ebc4c758d0c4d166bb9829c upstream.
This reverts commit 479380efe1625e251008d24b2810283db60d6fcd.
The reset_method attribute on a PCI device is only intended to manage the availability of function scoped resets for a device. It was never intended to restrict resets targeting the bus or slot.
In introducing a restriction that each device must support function level reset by testing pci_reset_supported(), we essentially create a catch-22, that a device must have a function scope reset in order to support bus/slot reset, when we use bus/slot reset to effect a reset of a device that does not support a function scoped reset, especially multi-function devices.
This breaks the majority of uses cases where vfio-pci uses bus/slot resets to manage multifunction devices that do not support function scoped resets.
--- drivers/pci/pci.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/pci/pci.c +0 -4
@@ -5714,8 +5714,6 @@ static bool pci_bus_resettable(struct pcreturn false;list_for_each_entry (dev, &bus->devices, bus_list) { -if (!pci_reset_supported (dev)) -return false;if (dev->dev_flags &PCI_DEV_FLAGS_NO_BUS_RESET || (dev->subordinate && !pci_bus_resettable (dev->subordinate)))return false;
@@ -5792,8 +5790,6 @@ static bool pci_slot_resettable(struct plist_for_each_entry (dev, &slot->bus->devices, bus_list) {if (!dev->slot || dev->slot != slot)continue ; -if (!pci_reset_supported (dev)) -return false;if (dev->dev_flags &PCI_DEV_FLAGS_NO_BUS_RESET || (dev->subordinate && !pci_bus_resettable (dev->subordinate)))return false;
Greg Kroah-Hartman
maintainerPATCH 302/393 ASoC: codecs:lpass-wsa-macro: Fix vi feedback rate
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit d7bff1415e85b889dc8908be6aedba8807ae5e37 upstream.
Currently the VI feedback rate is set to fixed 8K, fix this by getting the correct rate from params_rate.
Without this patch incorrect rate will be set on the VI feedback recording resulting in rate miss match and audio artifacts.
--- sound/soc/codecs/lpass-wsa-macro.c | 39 ++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-)
sound/soc/codecs/lpass-wsa-macro.c +36 -3
@@ -66,6 +66,10 @@#define CDC_WSA_TX_SPKR_PROT_CLK_DISABLE 0#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK GENMASK(3, 0)#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_8K 0 +#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_16K 1 +#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_24K 2 +#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_32K 3 +#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_48K 4#define CDC_WSA_TX0_SPKR_PROT_PATH_CFG0 (0x0248)#define CDC_WSA_TX1_SPKR_PROT_PATH_CTL (0x0264)#define CDC_WSA_TX1_SPKR_PROT_PATH_CFG0 (0x0268)
@@ -347,6 +351,7 @@ struct wsa_macro {int ear_spkr_gain;int spkr_gain_offset;int spkr_mode; +u32 pcm_rate_vi;int is_softclip_on[WSA_MACRO_SOFTCLIP_MAX ];int softclip_clk_users[WSA_MACRO_SOFTCLIP_MAX ];struct regmap *regmap;
@@ -974,6 +979,7 @@ static int wsa_macro_hw_params(struct sn struct snd_soc_dai *dai) {struct snd_soc_component *component = dai->component; +struct wsa_macro *wsa =snd_soc_component_get_drvdata (component);int ret;switch (substream->stream) {
@@ -986,6 +992,11 @@ static int wsa_macro_hw_params(struct snreturn ret; }break ; +case SNDRV_PCM_STREAM_CAPTURE : +if (dai->id ==WSA_MACRO_AIF_VI ) + wsa->pcm_rate_vi =params_rate (params); + +break ;default :break ; }
@@ -1159,6 +1170,28 @@ static int wsa_macro_enable_vi_feedback(struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm);struct wsa_macro *wsa =snd_soc_component_get_drvdata (component);u32 tx_reg0, tx_reg1; +u32 rate_val; + +switch (wsa->pcm_rate_vi) { +case 8000 : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_8K ; +break ; +case 16000 : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_16K ; +break ; +case 24000 : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_24K ; +break ; +case 32000 : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_32K ; +break ; +case 48000 : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_48K ; +break ; +default : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_8K ; +break ; + }if (test_bit (WSA_MACRO_TX0 , &wsa->active_ch_mask[WSA_MACRO_AIF_VI ])) { tx_reg0 =CDC_WSA_TX0_SPKR_PROT_PATH_CTL ;
@@ -1170,7 +1203,7 @@ static int wsa_macro_enable_vi_feedback(switch (event) {case SND_SOC_DAPM_POST_PMU : -/* Enable V&I sensing */ +/* Enable V&I sensing */ snd_soc_component_update_bits (component, tx_reg0,CDC_WSA_TX_SPKR_PROT_RESET_MASK ,CDC_WSA_TX_SPKR_PROT_RESET );
@@ -1179,10 +1212,10 @@ static int wsa_macro_enable_vi_feedback( CDC_WSA_TX_SPKR_PROT_RESET);snd_soc_component_update_bits (component, tx_reg0,CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , -CDC_WSA_TX_SPKR_PROT_PCM_RATE_8K ); + rate_val);snd_soc_component_update_bits (component, tx_reg1,CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , -CDC_WSA_TX_SPKR_PROT_PCM_RATE_8K ); + rate_val);snd_soc_component_update_bits (component, tx_reg0,CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK ,CDC_WSA_TX_SPKR_PROT_CLK_ENABLE );
Greg Kroah-Hartman
maintainerPATCH 303/393 ASoC: codecs:lpass-wsa-macro: Fix logic of enabling vi channels
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 7648beb65600220996ebb2da207610b1ff9b735e upstream.
Existing code only configures one of WSA_MACRO_TX0 or WSA_MACRO_TX1 paths eventhough we enable both of them. Fix this bug by adding proper checks and rearranging some of the common code to able to allow setting both TX0 and TX1 paths
Without this patch only one channel gets enabled in VI path instead of 2 channels. End result would be 1 channel recording instead of 2.
--- sound/soc/codecs/lpass-wsa-macro.c | 108 +++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 45 deletions(-)
sound/soc/codecs/lpass-wsa-macro.c +63 -45
@@ -1153,6 +1153,67 @@ static void wsa_macro_mclk_enable(struct } } +static void wsa_macro_enable_disable_vi_sense (struct snd_soc_component *component,bool enable, +u32 tx_reg0,u32 tx_reg1,u32 val) +{ +if (enable) { +/* Enable V&I sensing */ +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_RESET ); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_RESET ); +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , + val); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , + val); +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , +CDC_WSA_TX_SPKR_PROT_CLK_ENABLE ); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , +CDC_WSA_TX_SPKR_PROT_CLK_ENABLE ); +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_NO_RESET ); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_NO_RESET ); + }else { +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_RESET ); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_RESET ); +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , +CDC_WSA_TX_SPKR_PROT_CLK_DISABLE ); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , +CDC_WSA_TX_SPKR_PROT_CLK_DISABLE ); + } +} + +static void wsa_macro_enable_disable_vi_feedback (struct snd_soc_component *component, +bool enable,u32 rate) +{ +struct wsa_macro *wsa =snd_soc_component_get_drvdata (component); + +if (test_bit (WSA_MACRO_TX0 , &wsa->active_ch_mask[WSA_MACRO_AIF_VI ])) +wsa_macro_enable_disable_vi_sense (component, enable, +CDC_WSA_TX0_SPKR_PROT_PATH_CTL , +CDC_WSA_TX1_SPKR_PROT_PATH_CTL , rate); + +if (test_bit (WSA_MACRO_TX1 , &wsa->active_ch_mask[WSA_MACRO_AIF_VI ])) +wsa_macro_enable_disable_vi_sense (component, enable, +CDC_WSA_TX2_SPKR_PROT_PATH_CTL , +CDC_WSA_TX3_SPKR_PROT_PATH_CTL , rate); +} +static int wsa_macro_mclk_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event) {
@@ -1169,7 +1230,6 @@ static int wsa_macro_enable_vi_feedback( {struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm);struct wsa_macro *wsa =snd_soc_component_get_drvdata (component); -u32 tx_reg0, tx_reg1;u32 rate_val;switch (wsa->pcm_rate_vi) {
@@ -1193,56 +1253,14 @@ static int wsa_macro_enable_vi_feedback(break ; } -if (test_bit (WSA_MACRO_TX0 , &wsa->active_ch_mask[WSA_MACRO_AIF_VI ])) { - tx_reg0 =CDC_WSA_TX0_SPKR_PROT_PATH_CTL ; - tx_reg1 =CDC_WSA_TX1_SPKR_PROT_PATH_CTL ; - }else if (test_bit (WSA_MACRO_TX1 , &wsa->active_ch_mask[WSA_MACRO_AIF_VI ])) { - tx_reg0 =CDC_WSA_TX2_SPKR_PROT_PATH_CTL ; - tx_reg1 =CDC_WSA_TX3_SPKR_PROT_PATH_CTL ; - } -switch (event) {case SND_SOC_DAPM_POST_PMU :/* Enable V&I sensing */ -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_RESET ); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_RESET ); -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , - rate_val); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , - rate_val); -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , -CDC_WSA_TX_SPKR_PROT_CLK_ENABLE ); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , -CDC_WSA_TX_SPKR_PROT_CLK_ENABLE ); -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_NO_RESET ); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_NO_RESET ); +wsa_macro_enable_disable_vi_feedback (component, true, rate_val);break ;case SND_SOC_DAPM_POST_PMD :/* Disable V&I sensing */ -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_RESET ); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_RESET ); -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , -CDC_WSA_TX_SPKR_PROT_CLK_DISABLE ); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , -CDC_WSA_TX_SPKR_PROT_CLK_DISABLE ); +wsa_macro_enable_disable_vi_feedback (component, false, rate_val);break ; }
Greg Kroah-Hartman
maintainerPATCH 304/393 ASoC: qcom: Fix sc7280 lpass potential buffer overflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Evgeny Pimenov <[email protected]>
commit a31a4934b31faea76e735bab17e63d02fcd8e029 upstream.
Case values introduced in commit5f78e1fb7a3e ("ASoC: qcom: Add driver support for audioreach solution") cause out of bounds access in arrays of sc7280 driver data (e.g. in case of RX_CODEC_DMA_RX_0 in sc7280_snd_hw_params()).
Redefine LPASS_MAX_PORTS to consider the maximum possible port id for q6dsp as sc7280 driver utilizes some of those values.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- sound/soc/qcom/lpass.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/qcom/lpass.h +2 -1
@@ -13,10 +13,11 @@#include <linux/platform_device.h> #include <linux/regmap.h> #include <dt-bindings/sound/qcom,lpass.h> +#include <dt-bindings/sound/qcom,q6afe.h> #include "lpass-hdmi.h" #define LPASS_AHBIX_CLOCK_FREQUENCY 131072000 -#define LPASS_MAX_PORTS (LPASS_CDC_DMA_VA_TX8 + 1) +#define LPASS_MAX_PORTS (DISPLAY_PORT_RX_7 + 1)#define LPASS_MAX_MI2S_PORTS (8)#define LPASS_MAX_DMA_CHANNELS (8)#define LPASS_MAX_HDMI_DMA_CHANNELS (4)
Greg Kroah-Hartman
maintainerPATCH 305/393 asus-laptop: Fix an uninitialized variable
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 6c683c6887e4addcd6bd1ddce08cafccb0a21e32 upstream.
The value returned by acpi_evaluate_integer() is not checked, but the result is not always successful, so it is necessary to add a check of the returned value.
If the result remains negative during three iterations of the loop, then the uninitialized variable 'val' will be used in the clamp_val() macro, so it must be initialized with the current value of the 'curr' variable.
In this case, the algorithm should be less noisy.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/platform/x86/asus-laptop.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/platform/x86/asus-laptop.c +6 -3
@@ -427,11 +427,14 @@ static int asus_pega_lucid_set(struct asstatic int pega_acc_axis (struct asus_laptop *asus,int curr,char *method) { +unsigned long long val = (unsigned long long )curr; +acpi_status status;int i, delta; -unsigned long long val; -for (i =0 ; i <PEGA_ACC_RETRIES ; i++) { -acpi_evaluate_integer (asus->handle, method,NULL , &val); +for (i =0 ; i <PEGA_ACC_RETRIES ; i++) { + status =acpi_evaluate_integer (asus->handle, method,NULL , &val); +if (ACPI_FAILURE (status)) +continue ;/* The output is noisy. From reading the ASL * dissassembly, timeout errors are returned with 1's * in the high word, and the lack of locking around
Greg Kroah-Hartman
maintainerPATCH 306/393 nfs: add missing selections of CONFIG_CRC32
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
[ Upstream commit cd35b6cb46649750b7dbd0df0e2d767415d8917b ]
nfs.ko, nfsd.ko, and lockd.ko all use crc32_le(), which is available only when CONFIG_CRC32 is enabled. But the only NFS kconfig option that selected CONFIG_CRC32 was CONFIG_NFS_DEBUG, which is client-specific and did not actually guard the use of crc32_le() even on the client.
The code worked around this bug by only actually calling crc32_le() when CONFIG_CRC32 is built-in, instead hard-coding '0' in other cases. This avoided randconfig build errors, and in real kernels the fallback code was unlikely to be reached since CONFIG_CRC32 is 'default y'. But, this really needs to just be done properly, especially now that I'm planning to update CONFIG_CRC32 to not be 'default y'.
Therefore, make CONFIG_NFS_FS, CONFIG_NFSD, and CONFIG_LOCKD select CONFIG_CRC32. Then remove the fallback code that becomes unnecessary, as well as the selection of CONFIG_CRC32 from CONFIG_NFS_DEBUG.
--- fs/Kconfig | 1 + fs/nfs/Kconfig | 2 +- fs/nfs/internal.h | 7 ------- fs/nfs/nfs4session.h | 4 ---- fs/nfsd/Kconfig | 1 + fs/nfsd/nfsfh.h | 7 ------- include/linux/nfs.h | 7 ------- 7 files changed, 3 insertions(+), 26 deletions(-)
fs/Kconfig +1 -0
@@ -365,6 +365,7 @@ config GRACE_PERIOD config LOCKD tristate depends on FILE_LOCKING + select CRC32 select GRACE_PERIOD config LOCKD_V4
fs/nfs/Kconfig +1 -1
@@ -2,6 +2,7 @@ config NFS_FS tristate "NFS client support" depends on INET && FILE_LOCKING && MULTIUSER + select CRC32 select LOCKD select SUNRPC select NFS_ACL_SUPPORT if NFS_V3_ACL
@@ -194,7 +195,6 @@ config NFS_USE_KERNEL_DNS config NFS_DEBUG bool depends on NFS_FS && SUNRPC_DEBUG - select CRC32 default y config NFS_DISABLE_UDP_SUPPORT
fs/nfs/internal.h +0 -7
@@ -859,18 +859,11 @@ u64 nfs_timespec_to_change_attr(const struct timespec64 *ts)return ((u64 )ts->tv_sec <<30 ) + ts->tv_nsec; } -#ifdef CONFIG_CRC32 static inline u32 nfs_stateid_hash (const nfs4_stateid *stateid) {return ~crc32_le (0xFFFFFFFF , &stateid->other[0 ],NFS4_STATEID_OTHER_SIZE ); } -#else -static inline u32 nfs_stateid_hash (nfs4_stateid *stateid) -{ -return 0 ; -} -#endif static inline bool nfs_error_is_fatal (int err) {
fs/nfs/nfs4session.h +0 -4
@@ -148,16 +148,12 @@ static inline void nfs4_copy_sessionid(struct nfs4_sessionid *dst, memcpy(dst->data, src->data, NFS4_MAX_SESSIONID_LEN); } -#ifdef CONFIG_CRC32 /* * nfs_session_id_hash - calculate the crc32 hash for the session id * @session - pointer to session */ #define nfs_session_id_hash (sess_id) \ (~crc32_le(0xFFFFFFFF, &(sess_id)->data[0], sizeof((sess_id)->data))) -#else -#define nfs_session_id_hash (session) (0) -#endif #else /* defined(CONFIG_NFS_V4_1) */ static inline int nfs4_init_session (struct nfs_client *clp)
fs/nfsd/Kconfig +1 -0
@@ -4,6 +4,7 @@ config NFSD depends on INET depends on FILE_LOCKING depends on FSNOTIFY + select CRC32 select LOCKD select SUNRPC select EXPORTFS
fs/nfsd/nfsfh.h +0 -7
@@ -263,7 +263,6 @@ static inline bool fh_fsid_match(const struct knfsd_fh *fh1,return true; } -#ifdef CONFIG_CRC32 /** * knfsd_fh_hash - calculate the crc32 hash for the filehandle * @fh - pointer to filehandle
@@ -275,12 +274,6 @@ static inline u32 knfsd_fh_hash(const struct knfsd_fh *fh) {return ~crc32_le (0xFFFFFFFF , fh->fh_raw, fh->fh_size); } -#else -static inline u32 knfsd_fh_hash (const struct knfsd_fh *fh) -{ -return 0 ; -} -#endif /** * fh_clear_pre_post_attrs - Reset pre/post attributes
include/linux/nfs.h +0 -7
@@ -46,7 +46,6 @@ enum nfs3_stable_how { NFS_INVALID_STABLE_HOW = -1 }; -#ifdef CONFIG_CRC32 /** * nfs_fhandle_hash - calculate the crc32 hash for the filehandle * @fh - pointer to filehandle
@@ -58,10 +57,4 @@ static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh) {return ~crc32_le (0xFFFFFFFF , &fh->data[0 ], fh->size); } -#else /* CONFIG_CRC32 */ -static inline u32 nfs_fhandle_hash (const struct nfs_fh *fh) -{ -return 0 ; -} -#endif /* CONFIG_CRC32 */ #endif /* _LINUX_NFS_H */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 307/393 nfsd: decrease sc_count directly if fail to queue dl_recall
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Lingfeng <[email protected]>
[ Upstream commit a1d14d931bf700c1025db8c46d6731aa5cf440f9 ]
A deadlock warning occurred when invoking nfs4_put_stid following a failed dl_recall queue operation:
T1 T2
nfs4_laundromat
nfs4_get_client_reaplist
nfs4_anylock_blockers__break_lease
spin_lock // ctx->flc_lock
spin_lock // clp->cl_lock
nfs4_lockowner_has_blockers
locks_owner_has_blockers
spin_lock // flctx->flc_lock
nfsd_break_deleg_cb
nfsd_break_one_deleg
nfs4_put_stid
refcount_dec_and_lock
spin_lock // clp->cl_lockWhen a file is opened, an nfs4_delegation is allocated with sc_count initialized to 1, and the file_lease holds a reference to the delegation. The file_lease is then associated with the file through kernel_setlease.
The disassociation is performed in nfsd4_delegreturn via the following call chain:nfsd4_delegreturn --> destroy_delegation --> destroy_unhashed_deleg --> nfs4_unlock_deleg_lease --> kernel_setlease --> generic_delete_lease The corresponding sc_count reference will be released after this disassociation.
Since nfsd_break_one_deleg executes while holding the flc_lock, the disassociation process becomes blocked when attempting to acquire flc_lock in generic_delete_lease. This means:
1) sc_count in nfsd_break_one_deleg will not be decremented to 0;
2) The nfs4_put_stid called by nfsd_break_one_deleg will not attempt to acquire cl_lock;
3) Consequently, no deadlock condition is created.
Given that sc_count in nfsd_break_one_deleg remains non-zero, we can safely perform refcount_dec on sc_count directly. This approach effectively avoids triggering deadlock warnings.
--- fs/nfsd/nfs4state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4state.c +1 -1
@@ -4938,7 +4938,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp) queued =nfsd4_run_cb (&dp->dl_recall);WARN_ON_ONCE (!queued);if (!queued) -nfs4_put_stid (&dp->dl_stid); +refcount_dec (&dp->dl_stid.sc_count); }/* Called from break_lease() with flc_lock held. */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 308/393 i2c: atr: Fix wrong include
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 75caec0c2aa3a7ec84348d438c74cb8a2eb4de97 ]
The fwnode.h is not supposed to be used by the drivers as it has the definitions for the core parts for different device property provider implementations. Drop it.
Note, that fwnode API for drivers is provided in property.h which is included here.
--- drivers/i2c/i2c-atr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-atr.c +1 -1
@@ -8,12 +8,12 @@* Originally based on i2c-mux.c */ -#include <linux/fwnode.h> #include <linux/i2c-atr.h> #include <linux/i2c.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/spinlock.h>
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 309/393 ftrace: fix incorrect hash size in register_ftrace_direct()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Menglong Dong <[email protected]>
[ Upstream commit 92f1d3b40179b15630d72e2c6e4e25a899b67ba9 ]
The maximum of the ftrace hash bits is made fls(32) in register_ftrace_direct(), which seems illogical. So, we fix it by making the max hash bits FTRACE_HASH_MAX_BITS instead.
--- kernel/trace/ftrace.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +4 -3
@@ -5420,9 +5420,10 @@ int register_ftrace_direct(struct ftrace_ops *ops, unsigned long addr)/* Make a copy hash to place the new and the old entries in */ size = hash->count + direct_functions->count; -if (size >32 ) - size =32 ; - new_hash =alloc_ftrace_hash (fls (size)); + size =fls (size); +if (size >FTRACE_HASH_MAX_BITS ) + size =FTRACE_HASH_MAX_BITS ; + new_hash =alloc_ftrace_hash (size);if (!new_hash) goto out_unlock;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 310/393 Bluetooth: l2cap: Process valid commands in too long frame
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frédéric Danis <[email protected]>
commit e2e49e214145a8f6ece6ecd52fec63ebc2b27ce9 upstream.
This is required for passing PTS test cases:
- L2CAP/COS/CED/BI-14-C
Multiple Signaling Command in one PDU, Data Truncated, BR/EDR, Connection Request
- L2CAP/COS/CED/BI-15-C
Multiple Signaling Command in one PDU, Data Truncated, BR/EDR, Disconnection Request
The test procedure defined in L2CAP.TS.p39 for both tests is:
1. The Lower Tester sends a C-frame to the IUT with PDU Length set to 8 and Channel ID set to the correct signaling channel for the logical link. The Information payload contains one L2CAP_ECHO_REQ packet with Data Length set to 0 with 0 octets of echo data and one command packet and Data Length set as specified in Table 4.6 and the correct command data.
2. The IUT sends an L2CAP_ECHO_RSP PDU to the Lower Tester.
3. Perform alternative 3A, 3B, 3C, or 3D depending on the IUT’s response.
Alternative 3A (IUT terminates the link):
3A.1 The IUT terminates the link.
3A.2 The test ends with a Pass verdict.
Alternative 3B (IUT discards the frame):
3B.1 The IUT does not send a reply to the Lower Tester.
Alternative 3C (IUT rejects PDU):
3C.1 The IUT sends an L2CAP_COMMAND_REJECT_RSP PDU to the
Lower Tester.
Alternative 3D (Any other IUT response):
3D.1 The Upper Tester issues a warning and the test ends.
4. The Lower Tester sends a C-frame to the IUT with PDU Length set to 4 and Channel ID set to the correct signaling channel for the logical link. The Information payload contains Data Length set to 0 with an L2CAP_ECHO_REQ packet with 0 octets of echo data.
5. The IUT sends an L2CAP_ECHO_RSP PDU to the Lower Tester.
With expected outcome:
In Steps 2 and 5, the IUT responds with an L2CAP_ECHO_RSP. In Step 3A.1, the IUT terminates the link.
In Step 3B.1, the IUT does not send a reply to the Lower Tester. In Step 3C.1, the IUT rejects the PDU.
In Step 3D.1, the IUT sends any valid response.
Currently PTS fails with the following logs:
Failed to receive ECHO RESPONSE.
And HCI logs:
Quoted 1 line
ACL Data RX: Handle 11 flags
0x02dlen 20
L2CAP: Information Response (0x0b) ident 2 len 12
Type: Fixed channels supported (0x0003)
Result: Success (0x0000)
Channels: 0x000000000000002e
L2CAP Signaling (BR/EDR)
Connectionless reception
AMP Manager Protocol
L2CAP Signaling (LE)Quoted 1 line
ACL Data RX: Handle 11 flags
0x02dlen 13
frame too long
08 01 00 00 08 02 01 00 aa .........
--- net/bluetooth/l2cap_core.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +17 -1
@@ -7510,8 +7510,24 @@ void l2cap_recv_acldata(struct hci_connif (skb->len > len) {BT_ERR ("Frame is too long (len %u, expected len %d)" , skb->len, len); +/* PTS test cases L2CAP/COS/CED/BI-14-C and BI-15-C +* (Multiple Signaling Command in one PDU, Data +* Truncated, BR/EDR) send a C-frame to the IUT with +* PDU Length set to 8 and Channel ID set to the +* correct signaling channel for the logical link. +* The Information payload contains one L2CAP_ECHO_REQ +* packet with Data Length set to 0 with 0 octets of +* echo data and one invalid command packet due to +* data truncated in PDU but present in HCI packet. +* +* Shorter the socket buffer to the PDU length to +* allow to process valid commands from the PDU before +* setting the socket unreliable. +*/ + skb->len = len; +l2cap_recv_frame (conn, skb);l2cap_conn_unreliable (conn,ECOMM ); - goto drop; + goto unlock; }/* Append fragment into frame (with header) */
Greg Kroah-Hartman
maintainerPATCH 311/393 Bluetooth: vhci: Avoid needless snprintf() calls
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 875db86e1ec75fe633f1e85ed2f92c731cdbf760 upstream.
Avoid double-copying of string literals. Use a "const char *" for each string instead of copying from .rodata into stack and then into the skb. We can go directly from .rodata to the skb.
This also works around a Clang bug (that has since been fixed[1]).
--- drivers/bluetooth/hci_vhci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/bluetooth/hci_vhci.c +5 -5
@@ -289,18 +289,18 @@ static void vhci_coredump(struct hci_devstatic void vhci_coredump_hdr (struct hci_dev *hdev,struct sk_buff *skb) { -char buf[80 ]; +const char *buf; -snprintf (buf,sizeof (buf),"Controller Name: vhci_ctrl\n" ); + buf ="Controller Name: vhci_ctrl\n" ;skb_put_data (skb, buf,strlen (buf)); -snprintf (buf,sizeof (buf),"Firmware Version: vhci_fw\n" ); + buf ="Firmware Version: vhci_fw\n" ;skb_put_data (skb, buf,strlen (buf)); -snprintf (buf,sizeof (buf),"Driver: vhci_drv\n" ); + buf ="Driver: vhci_drv\n" ;skb_put_data (skb, buf,strlen (buf)); -snprintf (buf,sizeof (buf),"Vendor: vhci\n" ); + buf ="Vendor: vhci\n" ;skb_put_data (skb, buf,strlen (buf)); }
Greg Kroah-Hartman
maintainerPATCH 312/393 btrfs: correctly escape subvol in btrfs_show_options()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Kimmel <[email protected]>
commit dc08c58696f8555e4a802f1f23c894a330d80ab7 upstream.
Currently, displaying the btrfs subvol mount option doesn't escape ','. This makes parsing /proc/self/mounts and /proc/self/mountinfo ambiguous for subvolume names that contain commas. The text after the comma could be mistaken for another option (think "subvol=foo,ro", where ro is actually part of the subvolumes name).
Replace the manual escape characters list with a call to seq_show_option(). Thanks to Calvin Walton for suggesting this approach.
--- fs/btrfs/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/super.c +1 -2
@@ -1336,8 +1336,7 @@ static int btrfs_show_options(struct seq subvol_name =btrfs_get_subvol_name_from_objectid (info,BTRFS_I (d_inode (dentry))->root->root_key.objectid);if (!IS_ERR (subvol_name)) { -seq_puts (seq,",subvol=" ); -seq_escape (seq, subvol_name," \t\n\\" ); +seq_show_option (seq,"subvol" , subvol_name);kfree (subvol_name); }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 313/393 cpufreq: Avoid using inconsistent policy->min and policy->max
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit 7491cdf46b5cbdf123fc84fbe0a07e9e3d7b7620 upstream.
Since cpufreq_driver_resolve_freq() can run in parallel with cpufreq_set_policy() and there is no synchronization between them, the former may access policy->min and policy->max while the latter is updating them and it may see intermediate values of them due to the way the update is carried out. Also the compiler is free to apply any optimizations it wants both to the stores in cpufreq_set_policy() and to the loads in cpufreq_driver_resolve_freq() which may result in additional inconsistencies.
To address this, use WRITE_ONCE() when updating policy->min and policy->max in cpufreq_set_policy() and use READ_ONCE() for reading them in cpufreq_driver_resolve_freq(). Moreover, rearrange the update in cpufreq_set_policy() to avoid storing intermediate values in policy->min and policy->max with the help of the observation that their new values are expected to be properly ordered upfront.
Also modify cpufreq_driver_resolve_freq() to take the possible reverse ordering of policy->min and policy->max, which may happen depending on the ordering of operations when this function and cpufreq_set_policy() run concurrently, into account by always honoring the max when it turns out to be less than the min (in case it comes from thermal throttling or similar).
--- drivers/cpufreq/cpufreq.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)
drivers/cpufreq/cpufreq.c +25 -7
@@ -538,8 +538,6 @@ static unsigned int __resolve_freq(struc {unsigned int idx; - target_freq =clamp_val (target_freq, policy->min, policy->max); -if (!policy->freq_table)return target_freq;
@@ -563,7 +561,22 @@ static unsigned int __resolve_freq(strucunsigned int cpufreq_driver_resolve_freq (struct cpufreq_policy *policy,unsigned int target_freq) { -return __resolve_freq (policy, target_freq,CPUFREQ_RELATION_LE ); +unsigned int min =READ_ONCE (policy->min); +unsigned int max =READ_ONCE (policy->max); + +/* +* If this function runs in parallel with cpufreq_set_policy(), it may +* read policy->min before the update and policy->max after the update +* or the other way around, so there is no ordering guarantee. +* +* Resolve this by always honoring the max (in case it comes from +* thermal throttling or similar). +*/ +if (unlikely (min > max)) + min = max; + +return __resolve_freq (policy,clamp_val (target_freq, min, max), +CPUFREQ_RELATION_LE ); }EXPORT_SYMBOL_GPL (cpufreq_driver_resolve_freq);
@@ -2335,6 +2348,7 @@ int __cpufreq_driver_target(struct cpufrif (cpufreq_disabled ())return -ENODEV ; + target_freq =clamp_val (target_freq, policy->min, policy->max); target_freq =__resolve_freq (policy, target_freq, relation); pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
@@ -2625,11 +2639,15 @@ static int cpufreq_set_policy(struct cpu* Resolve policy min/max to available frequencies. It ensures * no frequency resolution will neither overshoot the requested maximum * nor undershoot the requested minimum. +* +* Avoid storing intermediate values in policy->max or policy->min and +* compiler optimizations around them because they may be accessed +* concurrently by cpufreq_driver_resolve_freq() during the update. */ - policy->min = new_data.min; - policy->max = new_data.max; - policy->min =__resolve_freq (policy, policy->min,CPUFREQ_RELATION_L ); - policy->max =__resolve_freq (policy, policy->max,CPUFREQ_RELATION_H ); +WRITE_ONCE (policy->max,__resolve_freq (policy, new_data.max,CPUFREQ_RELATION_H )); + new_data.min =__resolve_freq (policy, new_data.min,CPUFREQ_RELATION_L ); +WRITE_ONCE (policy->min, new_data.min > policy->max ? policy->max : new_data.min); +trace_cpu_frequency_limits (policy); policy->cached_target_freq =UINT_MAX ;
Greg Kroah-Hartman
maintainerPATCH 314/393 crypto: caam/qi - Fix drv_ctx refcount bug
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit b7b39df7e710b0068356e4c696af07aa10e2cd3d upstream.
Ensure refcount is raised before request is enqueued since it could be dequeued before the call returns.
--- drivers/crypto/caam/qi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/caam/qi.c +3 -3
@@ -122,12 +122,12 @@ int caam_qi_enqueue(struct device *qidevqm_fd_addr_set64 (&fd, addr); do { + refcount_inc(&req->drv_ctx->refcnt); ret = qman_enqueue(req->drv_ctx->req_fq, &fd); - if (likely(!ret)) { - refcount_inc(&req->drv_ctx->refcnt); + if (likely(!ret)) return 0; - } + refcount_dec(&req->drv_ctx->refcnt); if (ret != -EBUSY) break; num_retries++;
Greg Kroah-Hartman
maintainerPATCH 315/393 hfs/hfsplus: fix slab-out-of-bounds in hfs_bnode_read_key
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasiliy Kovalev <[email protected]>
commit bb5e07cb927724e0b47be371fa081141cfb14414 upstream.
Syzbot reported an issue in hfs subsystem:
BUG: KASAN: slab-out-of-bounds in memcpy_from_page include/linux/highmem.h:423 [inline] BUG: KASAN: slab-out-of-bounds in hfs_bnode_read fs/hfs/bnode.c:35 [inline] BUG: KASAN: slab-out-of-bounds in hfs_bnode_read_key+0x314/0x450 fs/hfs/bnode.c:70 Write of size 94 at addr ffff8880123cd100 by task syz-executor237/5102 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189 __asan_memcpy+0x40/0x70 mm/kasan/shadow.c:106 memcpy_from_page include/linux/highmem.h:423 [inline] hfs_bnode_read fs/hfs/bnode.c:35 [inline] hfs_bnode_read_key+0x314/0x450 fs/hfs/bnode.c:70 hfs_brec_insert+0x7f3/0xbd0 fs/hfs/brec.c:159 hfs_cat_create+0x41d/0xa50 fs/hfs/catalog.c:118 hfs_mkdir+0x6c/0xe0 fs/hfs/dir.c:232 vfs_mkdir+0x2f9/0x4f0 fs/namei.c:4257 do_mkdirat+0x264/0x3a0 fs/namei.c:4280 __do_sys_mkdir fs/namei.c:4300 [inline] __se_sys_mkdir fs/namei.c:4298 [inline] __x64_sys_mkdir+0x6c/0x80 fs/namei.c:4298 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fbdd6057a99
Add a check for key length in hfs_bnode_read_key to prevent out-of-bounds memory access. If the key length is invalid, the key buffer is cleared, improving stability and reliability.
--- fs/hfs/bnode.c | 6 ++++++ fs/hfsplus/bnode.c | 6 ++++++ 2 files changed, 12 insertions(+)
fs/hfs/bnode.c +6 -0
@@ -67,6 +67,12 @@ void hfs_bnode_read_key(struct hfs_bnodeelse key_len = tree->max_key_len +1 ; +if (key_len >sizeof (hfs_btree_key) || key_len <1 ) { +memset (key,0 ,sizeof (hfs_btree_key)); +pr_err ("hfs: Invalid key length: %d\n" , key_len); +return ; + } +hfs_bnode_read (node, key, off, key_len); }
fs/hfsplus/bnode.c +6 -0
@@ -67,6 +67,12 @@ void hfs_bnode_read_key(struct hfs_bnodeelse key_len = tree->max_key_len +2 ; +if (key_len >sizeof (hfsplus_btree_key) || key_len <1 ) { +memset (key,0 ,sizeof (hfsplus_btree_key)); +pr_err ("hfsplus: Invalid key length: %d\n" , key_len); +return ; + } +hfs_bnode_read (node, key, off, key_len); }
Greg Kroah-Hartman
maintainerPATCH 316/393 i2c: cros-ec-tunnel: defer probe if parent EC is not present
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
commit 424eafe65647a8d6c690284536e711977153195a upstream.
When i2c-cros-ec-tunnel and the EC driver are built-in, the EC parent device will not be found, leading to NULL pointer dereference.
That can also be reproduced by unbinding the controller driver and then loading i2c-cros-ec-tunnel module (or binding the device).
[ 271.991245] BUG: kernel NULL pointer dereference, address: 0000000000000058 [ 271.998215] #PF: supervisor read access in kernel mode [ 272.003351] #PF: error_code(0x0000) - not-present page [ 272.008485] PGD 0 P4D 0 [ 272.011022] Oops: Oops: 0000 [#1] SMP NOPTI [ 272.015207] CPU: 0 UID: 0 PID: 3859 Comm: insmod Tainted: G S 6.15.0-rc1-00004-g44722359ed83 #30 PREEMPT(full) 3c7fb39a552e7d949de2ad921a7d6588d3a4fdc5 [ 272.030312] Tainted: [S]=CPU_OUT_OF_SPEC [ 272.034233] Hardware name: HP Berknip/Berknip, BIOS Google_Berknip.13434.356.0 05/17/2021 [ 272.042400] RIP: 0010:ec_i2c_probe+0x2b/0x1c0 [i2c_cros_ec_tunnel] [ 272.048577] Code: 1f 44 00 00 41 57 41 56 41 55 41 54 53 48 83 ec 10 65 48 8b 05 06 a0 6c e7 48 89 44 24 08 4c 8d 7f 10 48 8b 47 50 4c 8b 60 78 <49> 83 7c 24 58 00 0f 84 2f 01 00 00 48 89 fb be 30 06 00 00 4c 9 [ 272.067317] RSP: 0018:ffffa32082a03940 EFLAGS: 00010282 [ 272.072541] RAX: ffff969580b6a810 RBX: ffff969580b68c10 RCX: 0000000000000000 [ 272.079672] RDX: 0000000000000000 RSI: 0000000000000282 RDI: ffff969580b68c00 [ 272.086804] RBP: 00000000fffffdfb R08: 0000000000000000 R09: 0000000000000000 [ 272.093936] R10: 0000000000000000 R11: ffffffffc0600000 R12: 0000000000000000 [ 272.101067] R13: ffffffffa666fbb8 R14: ffffffffc05b5528 R15: ffff969580b68c10 [ 272.108198] FS: 00007b930906fc40(0000) GS:ffff969603149000(0000) knlGS:0000000000000000 [ 272.116282] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 272.122024] CR2: 0000000000000058 CR3: 000000012631c000 CR4: 00000000003506f0 [ 272.129155] Call Trace: [ 272.131606] <TASK> [ 272.133709] ? acpi_dev_pm_attach+0xdd/0x110 [ 272.137985] platform_probe+0x69/0xa0 [ 272.141652] really_probe+0x152/0x310 [ 272.145318] __driver_probe_device+0x77/0x110 [ 272.149678] driver_probe_device+0x1e/0x190 [ 272.153864] __driver_attach+0x10b/0x1e0 [ 272.157790] ? driver_attach+0x20/0x20 [ 272.161542] bus_for_each_dev+0x107/0x150 [ 272.165553] bus_add_driver+0x15d/0x270 [ 272.169392] driver_register+0x65/0x110 [ 272.173232] ? cleanup_module+0xa80/0xa80 [i2c_cros_ec_tunnel 3a00532f3f4af4a9eade753f86b0f8dd4e4e5698] [ 272.182617] do_one_initcall+0x110/0x350 [ 272.186543] ? security_kernfs_init_security+0x49/0xd0 [ 272.191682] ? __kernfs_new_node+0x1b9/0x240 [ 272.195954] ? security_kernfs_init_security+0x49/0xd0 [ 272.201093] ? __kernfs_new_node+0x1b9/0x240 [ 272.205365] ? kernfs_link_sibling+0x105/0x130 [ 272.209810] ? kernfs_next_descendant_post+0x1c/0xa0 [ 272.214773] ? kernfs_activate+0x57/0x70 [ 272.218699] ? kernfs_add_one+0x118/0x160 [ 272.222710] ? __kernfs_create_file+0x71/0xa0 [ 272.227069] ? sysfs_add_bin_file_mode_ns+0xd6/0x110 [ 272.232033] ? internal_create_group+0x453/0x4a0 [ 272.236651] ? __vunmap_range_noflush+0x214/0x2d0 [ 272.241355] ? __free_frozen_pages+0x1dc/0x420 [ 272.245799] ? free_vmap_area_noflush+0x10a/0x1c0 [ 272.250505] ? load_module+0x1509/0x16f0 [ 272.254431] do_init_module+0x60/0x230 [ 272.258181] __se_sys_finit_module+0x27a/0x370 [ 272.262627] do_syscall_64+0x6a/0xf0 [ 272.266206] ? do_syscall_64+0x76/0xf0 [ 272.269956] ? irqentry_exit_to_user_mode+0x79/0x90 [ 272.274836] entry_SYSCALL_64_after_hwframe+0x55/0x5d [ 272.279887] RIP: 0033:0x7b9309168d39 [ 272.283466] Code: 5b 41 5c 5d c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d af 40 0c 00 f7 d8 64 89 01 8 [ 272.302210] RSP: 002b:00007fff50f1a288 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 272.309774] RAX: ffffffffffffffda RBX: 000058bf9b50f6d0 RCX: 00007b9309168d39 [ 272.316905] RDX: 0000000000000000 RSI: 000058bf6c103a77 RDI: 0000000000000003 [ 272.324036] RBP: 00007fff50f1a2e0 R08: 00007fff50f19218 R09: 0000000021ec4150 [ 272.331166] R10: 000058bf9b50f7f0 R11: 0000000000000246 R12: 0000000000000000 [ 272.338296] R13: 00000000fffffffe R14: 0000000000000000 R15: 000058bf6c103a77 [ 272.345428] </TASK> [ 272.347617] Modules linked in: i2c_cros_ec_tunnel(+) [ 272.364585] gsmi: Log Shutdown Reason 0x03
Returning -EPROBE_DEFER will allow the device to be bound once the controller is bound, in the case of built-in drivers.
--- drivers/i2c/busses/i2c-cros-ec-tunnel.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/i2c/busses/i2c-cros-ec-tunnel.c +3 -0
@@ -247,6 +247,9 @@ static int ec_i2c_probe(struct platform_u32 remote_bus;int err; +if (!ec) +return dev_err_probe (dev, -EPROBE_DEFER ,"couldn't find parent EC device\n" ); +if (!ec->cmd_xfer) {dev_err (dev,"Missing sendrecv\n" );return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 317/393 isofs: Prevent the use of too small fid
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
commit 0405d4b63d082861f4eaff9d39c78ee9dc34f845 upstream.
syzbot reported a slab-out-of-bounds Read in isofs_fh_to_parent. [1]
The handle_bytes value passed in by the reproducing program is equal to 12. In handle_to_path(), only 12 bytes of memory are allocated for the structure file_handle->f_handle member, which causes an out-of-bounds access when accessing the member parent_block of the structure isofs_fid in isofs, because accessing parent_block requires at least 16 bytes of f_handle. Here, fh_len is used to indirectly confirm that the value of handle_bytes is greater than 3 before accessing parent_block.
[1]
BUG: KASAN: slab-out-of-bounds in isofs_fh_to_parent+0x1b8/0x210 fs/isofs/export.c:183 Read of size 4 at addr ffff0000cc030d94 by task syz-executor215/6466 CPU: 1 UID: 0 PID: 6466 Comm: syz-executor215 Not tainted 6.14.0-rc7-syzkaller-ga2392f333575 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 Call trace: show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:466 (C) __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0x198/0x550 mm/kasan/report.c:521 kasan_report+0xd8/0x138 mm/kasan/report.c:634 __asan_report_load4_noabort+0x20/0x2c mm/kasan/report_generic.c:380 isofs_fh_to_parent+0x1b8/0x210 fs/isofs/export.c:183 exportfs_decode_fh_raw+0x2dc/0x608 fs/exportfs/expfs.c:523 do_handle_to_path+0xa0/0x198 fs/fhandle.c:257 handle_to_path fs/fhandle.c:385 [inline] do_handle_open+0x8cc/0xb8c fs/fhandle.c:403 __do_sys_open_by_handle_at fs/fhandle.c:443 [inline] __se_sys_open_by_handle_at fs/fhandle.c:434 [inline] __arm64_sys_open_by_handle_at+0x80/0x94 fs/fhandle.c:434 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:49 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:744 el0t_64_sync_handler+0x84/0x108 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:600 Allocated by task 6466: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x40/0x78 mm/kasan/common.c:68 kasan_save_alloc_info+0x40/0x50 mm/kasan/generic.c:562 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:394 kasan_kmalloc include/linux/kasan.h:260 [inline] __do_kmalloc_node mm/slub.c:4294 [inline] __kmalloc_noprof+0x32c/0x54c mm/slub.c:4306 kmalloc_noprof include/linux/slab.h:905 [inline] handle_to_path fs/fhandle.c:357 [inline] do_handle_open+0x5a4/0xb8c fs/fhandle.c:403 __do_sys_open_by_handle_at fs/fhandle.c:443 [inline] __se_sys_open_by_handle_at fs/fhandle.c:434 [inline] __arm64_sys_open_by_handle_at+0x80/0x94 fs/fhandle.c:434 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:49 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:744 el0t_64_sync_handler+0x84/0x108 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:600
--- fs/isofs/export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/isofs/export.c +1 -1
@@ -180,7 +180,7 @@ static struct dentry *isofs_fh_to_parentreturn NULL ;return isofs_export_iget (sb, - fh_len >2 ? ifid->parent_block :0 , + fh_len >3 ? ifid->parent_block :0 , ifid->parent_offset, fh_len >4 ? ifid->parent_generation :0 ); }
Greg Kroah-Hartman
maintainerPATCH 318/393 loop: properly send KOBJ_CHANGED uevent for disk device
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit e7bc0010ceb403d025100698586c8e760921d471 upstream.
The original commit message and the wording "uncork" in the code comment indicate that it is expected that the suppressed event instances are automatically sent after unsuppressing.
This is not the case, instead they are discarded.
In effect this means that no "changed" events are emitted on the device itself by default.
While each discovered partition does trigger a changed event on the device, devices without partitions don't have any event emitted.
This makes udev miss the device creation and prompted workarounds in userspace. See the linked util-linux/losetup bug.
Explicitly emit the events and drop the confusingly worded comments.
--- drivers/block/loop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/loop.c +2 -2
@@ -629,8 +629,8 @@ static int loop_change_fd(struct loop_de error =0 ; done: -/* enable and uncork uevent now that we are done */ dev_set_uevent_suppress (disk_to_dev (lo->lo_disk),0 ); +kobject_uevent (&disk_to_dev (lo->lo_disk)->kobj,KOBJ_CHANGE );return error; out_err:
@@ -1104,8 +1104,8 @@ static int loop_configure(struct loop_deif (partscan)clear_bit (GD_SUPPRESS_PART_SCAN , &lo->lo_disk->state); -/* enable and uncork uevent now that we are done */ dev_set_uevent_suppress (disk_to_dev (lo->lo_disk),0 ); +kobject_uevent (&disk_to_dev (lo->lo_disk)->kobj,KOBJ_CHANGE );loop_global_unlock (lo, is_loop);if (partscan)
Greg Kroah-Hartman
maintainerPATCH 319/393 loop: LOOP_SET_FD: send uevents for partitions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit 0dba7a05b9e47d8b546399117b0ddf2426dc6042 upstream.
Remove the suppression of the uevents before scanning for partitions. The partitions inherit their suppression settings from their parent device, which lead to the uevents being dropped.
This is similar to the same changes for LOOP_CONFIGURE done in commit bb430b694226 ("loop: LOOP_CONFIGURE: send uevents for partitions").
--- drivers/block/loop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/loop.c +2 -1
@@ -624,12 +624,12 @@ static int loop_change_fd(struct loop_de* dependency. */ fput (old_file); +dev_set_uevent_suppress (disk_to_dev (lo->lo_disk),0 );if (partscan)loop_reread_partitions (lo); error =0 ; done: -dev_set_uevent_suppress (disk_to_dev (lo->lo_disk),0 );kobject_uevent (&disk_to_dev (lo->lo_disk)->kobj,KOBJ_CHANGE );return error;
@@ -637,6 +637,7 @@ out_err:loop_global_unlock (lo, is_loop); out_putf:fput (file); +dev_set_uevent_suppress (disk_to_dev (lo->lo_disk),0 ); goto done; }
Greg Kroah-Hartman
maintainerPATCH 320/393 mm/gup: fix wrongly calculated returned value in fault_in_safe_writeable()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baoquan He <[email protected]>
commit 8c03ebd7cdc06bd0d2fecb4d1a609ef1dbb7d0aa upstream.
Not like fault_in_readable() or fault_in_writeable(), in fault_in_safe_writeable() local variable 'start' is increased page by page to loop till the whole address range is handled. However, it mistakenly calculates the size of the handled range with 'uaddr - start'.
Fix it here.
Andreas said:
: In gfs2, fault_in_iov_iter_writeable() is used in
: gfs2_file_direct_read() and gfs2_file_read_iter(), so this potentially : affects buffered as well as direct reads. This bug could cause those : gfs2 functions to spin in a loop.
--- mm/gup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/gup.c +2 -2
@@ -1871,8 +1871,8 @@ size_t fault_in_safe_writeable(const cha }while (start != end);mmap_read_unlock (mm); -if (size > (unsigned long )uaddr - start) -return size - ((unsigned long )uaddr - start); +if (size > start - (unsigned long )uaddr) +return size - (start - (unsigned long )uaddr);return 0 ; }EXPORT_SYMBOL (fault_in_safe_writeable);
Greg Kroah-Hartman
maintainerPATCH 321/393 mm: fix filemap_get_folios_contig returning batches of identical folios
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishal Moola (Oracle) <[email protected]>
commit 8ab1b16023961dc640023b10436d282f905835ad upstream.
filemap_get_folios_contig() is supposed to return distinct folios found within [start, end]. Large folios in the Xarray become multi-index entries. xas_next() can iterate through the sub-indexes before finding a sibling entry and breaking out of the loop.
This can result in a returned folio_batch containing an indeterminate number of duplicate folios, which forces the callers to skeptically handle the returned batch. This is inefficient and incurs a large maintenance overhead.
We can fix this by calling xas_advance() after we have successfully adding a folio to the batch to ensure our Xarray is positioned such that it will correctly find the next folio - similar to filemap_get_read_batch().
--- mm/filemap.c | 1 + 1 file changed, 1 insertion(+)
mm/filemap.c +1 -0
@@ -2256,6 +2256,7 @@ unsigned filemap_get_folios_contig(struc *start = folio->index + nr; goto out; } +xas_advance (&xas,folio_next_index (folio) -1 );continue ; put_folio:folio_put (folio);
Greg Kroah-Hartman
maintainerPATCH 322/393 mm: fix apply_to_existing_page_range()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kirill A. Shutemov <[email protected]>
commit a995199384347261bb3f21b2e171fa7f988bd2f8 upstream.
In the case of apply_to_existing_page_range(), apply_to_pte_range() is reached with 'create' set to false. When !create, the loop over the PTE page table is broken.
apply_to_pte_range() will only move to the next PTE entry if 'create' is true or if the current entry is not pte_none().
This means that the user of apply_to_existing_page_range() will not have 'fn' called for any entries after the first pte_none() in the PTE page table.
Fix the loop logic in apply_to_pte_range().
There are no known runtime issues from this, but the fix is trivial enough for stable@ even without a known buggy user.
--- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memory.c +2 -2
@@ -2600,11 +2600,11 @@ static int apply_to_pte_range(struct mm_if (fn) {do {if (create || !pte_none (ptep_get (pte))) { - err =fn (pte++, addr, data); + err =fn (pte, addr, data);if (err)break ; } - }while (addr +=PAGE_SIZE , addr != end); + }while (pte++, addr +=PAGE_SIZE , addr != end); } *mask |=PGTBL_PTE_MODIFIED ;
Greg Kroah-Hartman
maintainerPATCH 323/393 ovl: dont allow datadir only
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit eb3a04a8516ee9b5174379306f94279fc90424c4 upstream.
In theory overlayfs could support upper layer directly referring to a data layer, but there's no current use case for this.
Originally, when data-only layers were introduced, this wasn't allowed, only introduced by the "datadir+" feature, but without actually handling this case, resulting in an Oops.
Fix by disallowing datadir without lowerdir.
--- fs/overlayfs/super.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/overlayfs/super.c +5 -0
@@ -1180,6 +1180,11 @@ static struct ovl_entry *ovl_get_lowerstreturn ERR_PTR (-EINVAL ); } +if (ctx->nr == ctx->nr_data) { +pr_err ("at least one non-data lowerdir is required\n" ); +return ERR_PTR (-EINVAL ); + } + err = -EINVAL ;for (i =0 ; i < ctx->nr; i++) { l = &ctx->lower[i];
Greg Kroah-Hartman
maintainerPATCH 324/393 ksmbd: Fix dangling pointer in krb_authenticate
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Heelan <[email protected]>
commit 1e440d5b25b7efccb3defe542a73c51005799a5f upstream.
krb_authenticate frees sess->user and does not set the pointer to NULL. It calls ksmbd_krb5_authenticate to reinitialise sess->user but that function may return without doing so. If that happens then smb2_sess_setup, which calls krb_authenticate, will be accessing free'd memory when it later uses sess->user.
--- fs/smb/server/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +3 -1
@@ -1599,8 +1599,10 @@ static int krb5_authenticate(struct ksmbif (prev_sess_id && prev_sess_id != sess->id)destroy_previous_session (conn, sess->user, prev_sess_id); -if (sess->state ==SMB2_SESSION_VALID ) +if (sess->state ==SMB2_SESSION_VALID ) {ksmbd_free_user (sess->user); + sess->user =NULL ; + } retval =ksmbd_krb5_authenticate (sess, in_blob, in_len, out_blob, &out_len);
Greg Kroah-Hartman
maintainerPATCH 325/393 ksmbd: fix use-after-free in smb_break_all_levII_oplock()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit 18b4fac5ef17f77fed9417d22210ceafd6525fc7 upstream.
There is a room in smb_break_all_levII_oplock that can cause racy issues when unlocking in the middle of the loop. This patch use read lock to protect whole loop.
--- fs/smb/server/oplock.c | 29 +++++++++-------------------- fs/smb/server/oplock.h | 1 - 2 files changed, 9 insertions(+), 21 deletions(-)
fs/smb/server/oplock.c +9 -20
@@ -129,14 +129,6 @@ static void free_opinfo(struct oplock_inkfree (opinfo); } -static inline void opinfo_free_rcu (struct rcu_head *rcu_head) -{ -struct oplock_info *opinfo; - - opinfo = container_of(rcu_head, struct oplock_info, rcu_head); -free_opinfo (opinfo); -} -struct oplock_info *opinfo_get (struct ksmbd_file *fp) {struct oplock_info *opinfo;
@@ -157,8 +149,8 @@ static struct oplock_info *opinfo_get_liif (list_empty (&ci->m_op_list))return NULL ; -rcu_read_lock (); - opinfo = list_first_or_null_rcu(&ci->m_op_list, struct oplock_info, +down_read (&ci->m_lock); + opinfo = list_first_entry(&ci->m_op_list, struct oplock_info, op_entry);if (opinfo) { if (opinfo->conn == NULL ||
@@ -171,8 +163,7 @@ static struct oplock_info *opinfo_get_li } } } - -rcu_read_unlock (); +up_read (&ci->m_lock);return opinfo; }
@@ -185,7 +176,7 @@ void opinfo_put(struct oplock_info *opinif (!atomic_dec_and_test (&opinfo->refcount))return ; -call_rcu (&opinfo->rcu_head, opinfo_free_rcu); +free_opinfo (opinfo); }static void opinfo_add (struct oplock_info *opinfo)
@@ -193,7 +184,7 @@ static void opinfo_add(struct oplock_infstruct ksmbd_inode *ci = opinfo->o_fp->f_ci;down_write (&ci->m_lock); -list_add_rcu (&opinfo->op_entry, &ci->m_op_list); +list_add (&opinfo->op_entry, &ci->m_op_list);up_write (&ci->m_lock); }
@@ -207,7 +198,7 @@ static void opinfo_del(struct oplock_infwrite_unlock (&lease_list_lock); }down_write (&ci->m_lock); -list_del_rcu (&opinfo->op_entry); +list_del (&opinfo->op_entry);up_write (&ci->m_lock); }
@@ -1347,8 +1338,8 @@ void smb_break_all_levII_oplock(struct k ci = fp->f_ci; op =opinfo_get (fp); -rcu_read_lock (); -list_for_each_entry_rcu (brk_op, &ci->m_op_list, op_entry) { +down_read (&ci->m_lock); +list_for_each_entry (brk_op, &ci->m_op_list, op_entry) {if (brk_op->conn ==NULL )continue ;
@@ -1358,7 +1349,6 @@ void smb_break_all_levII_oplock(struct kif (ksmbd_conn_releasing (brk_op->conn))continue ; -rcu_read_unlock ();if (brk_op->is_lease && (brk_op->o_lease->state & (~(SMB2_LEASE_READ_CACHING_LE |SMB2_LEASE_HANDLE_CACHING_LE )))) {
@@ -1388,9 +1378,8 @@ void smb_break_all_levII_oplock(struct koplock_break (brk_op,SMB2_OPLOCK_LEVEL_NONE ,NULL ); next:opinfo_put (brk_op); -rcu_read_lock (); } -rcu_read_unlock (); +up_read (&ci->m_lock);if (op)opinfo_put (op);
fs/smb/server/oplock.h +0 -1
@@ -78,7 +78,6 @@ struct oplock_info {struct list_head lease_entry;wait_queue_head_t oplock_q;/* Other server threads */ wait_queue_head_t oplock_brk;/* oplock breaking wait */ -struct rcu_head rcu_head; };struct lease_break_info {
Greg Kroah-Hartman
maintainerPATCH 326/393 ksmbd: Prevent integer overflow in calculation of deadtime
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit a93ff742820f75bf8bb3fcf21d9f25ca6eb3d4c6 upstream.
The user can set any value for 'deadtime'. This affects the arithmetic expression 'req->deadtime * SMB_ECHO_INTERVAL', which is subject to overflow. The added check makes the server behavior more predictable.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/smb/server/transport_ipc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/smb/server/transport_ipc.c +6 -1
@@ -296,7 +296,11 @@ static int ipc_server_config_on_startup( server_conf.signing = req->signing; server_conf.tcp_port = req->tcp_port; server_conf.ipc_timeout = req->ipc_timeout *HZ ; - server_conf.deadtime = req->deadtime *SMB_ECHO_INTERVAL ; +if (check_mul_overflow (req->deadtime,SMB_ECHO_INTERVAL , + &server_conf.deadtime)) { + ret = -EINVAL ; + goto out; + } server_conf.share_fake_fscaps = req->share_fake_fscaps;ksmbd_init_domain (req->sub_auth);
@@ -322,6 +326,7 @@ static int ipc_server_config_on_startup( ret |=ksmbd_set_work_group (req->work_group); ret |=ksmbd_tcp_set_interfaces (KSMBD_STARTUP_CONFIG_INTERFACES (req), req->ifc_list_sz); +out:if (ret) { pr_err("Server configuration error: %s %s %s\n", req->netbios_name, req->server_string,
Greg Kroah-Hartman
maintainerPATCH 327/393 ksmbd: fix the warning from __kernel_write_iter
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit b37f2f332b40ad1c27f18682a495850f2f04db0a upstream.
[ 2110.972290] ------------[ cut here ]------------ [ 2110.972301] WARNING: CPU: 3 PID: 735 at fs/read_write.c:599 __kernel_write_iter+0x21b/0x280
This patch doesn't allow writing to directory.
--- fs/smb/server/vfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/server/vfs.c +2 -1
@@ -496,7 +496,8 @@ int ksmbd_vfs_write(struct ksmbd_work *wint err =0 ;if (work->conn->connection_type) { -if (!(fp->daccess & (FILE_WRITE_DATA_LE |FILE_APPEND_DATA_LE ))) { +if (!(fp->daccess & (FILE_WRITE_DATA_LE |FILE_APPEND_DATA_LE )) || +S_ISDIR (file_inode (fp->filp)->i_mode)) {pr_err ("no right to write(%pD)\n" , fp->filp); err = -EACCES ; goto out;
Greg Kroah-Hartman
maintainerPATCH 328/393 Revert "smb: client: Fix netns refcount imbalance causing leaks and use-after-free"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
commit c707193a17128fae2802d10cbad7239cc57f0c95 upstream.
This reverts commit 4e7f1644f2ac6d01dc584f6301c3b1d5aac4eaef.
The commit e9f2517a3e18 ("smb: client: fix TCP timers deadlock after rmmod") is not only a bogus fix for LOCKDEP null-ptr-deref but also introduces a real issue, TCP sockets leak, which will be explained in detail in the next revert.
Also, CNA assigned CVE-2024-54680 to it but is rejecting it. [0]
Thus, we are reverting the commit and its follow-up commit 4e7f1644f2ac ("smb: client: Fix netns refcount imbalance causing leaks and use-after-free").
--- fs/smb/client/connect.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
fs/smb/client/connect.c +8 -8
@@ -316,7 +316,6 @@ cifs_abort_connection(struct TCP_Server_ server->ssocket->flags);sock_release (server->ssocket); server->ssocket =NULL ; -put_net (cifs_net_ns (server)); } server->sequence_number =0 ; server->session_estab = false;
@@ -3150,12 +3149,8 @@ generic_ip_connect(struct TCP_Server_Inf/* * Grab netns reference for the socket. * -* This reference will be released in several situations: -* - In the failure path before the cifsd thread is started. -* - In the all place where server->socket is released, it is -* also set to NULL. -* - Ultimately in clean_demultiplex_info(), during the final -* teardown. +* It'll be released here, on error, or in clean_demultiplex_info() upon server +* teardown. */ get_net (net);
@@ -3171,8 +3166,10 @@ generic_ip_connect(struct TCP_Server_Inf } rc =bind_socket (server); -if (rc <0 ) +if (rc <0 ) { +put_net (cifs_net_ns (server));return rc; + }/* * Eventually check for other socket options to change from
@@ -3218,6 +3215,9 @@ generic_ip_connect(struct TCP_Server_Infif (sport ==htons (RFC1001_PORT )) rc =ip_rfc1001_connect (server); +if (rc <0 ) +put_net (cifs_net_ns (server)); +return rc; }
Greg Kroah-Hartman
maintainerPATCH 329/393 Revert "smb: client: fix TCP timers deadlock after rmmod"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
commit 95d2b9f693ff2a1180a23d7d59acc0c4e72f4c41 upstream.
This reverts commit e9f2517a3e18a54a3943c098d2226b245d488801.
Commit e9f2517a3e18 ("smb: client: fix TCP timers deadlock after rmmod") is intended to fix a null-ptr-deref in LOCKDEP, which is mentioned as CVE-2024-54680, but is actually did not fix anything; The issue can be reproduced on top of it. [0]
Also, it reverted the change by commit ef7134c7fc48 ("smb: client:
Fix use-after-free of network namespace.") and introduced a real issue by reviving the kernel TCP socket.
When a reconnect happens for a CIFS connection, the socket state transitions to FIN_WAIT_1. Then, inet_csk_clear_xmit_timers_sync() in tcp_close() stops all timers for the socket.
If an incoming FIN packet is lost, the socket will stay at FIN_WAIT_1 forever, and such sockets could be leaked up to net.ipv4.tcp_max_orphans.
Usually, FIN can be retransmitted by the peer, but if the peer aborts the connection, the issue comes into reality.
I warned about this privately by pointing out the exact report [1], but the bogus fix was finally merged.
So, we should not stop the timers to finally kill the connection on our side in that case, meaning we must not use a kernel socket for TCP whose sk->sk_net_refcnt is 0.
The kernel socket does not have a reference to its netns to make it possible to tear down netns without cleaning up every resource in it.
For example, tunnel devices use a UDP socket internally, but we can destroy netns without removing such devices and let it complete during exit. Otherwise, netns would be leaked when the last application died.
However, this is problematic for TCP sockets because TCP has timers to close the connection gracefully even after the socket is close()d. The lifetime of the socket and its netns is different from the lifetime of the underlying connection.
If the socket user does not maintain the netns lifetime, the timer could be fired after the socket is close()d and its netns is freed up, resulting in use-after-free.
Actually, we have seen so many similar issues and converted such sockets to have a reference to netns.
That's why I converted the CIFS client socket to have a reference to netns (sk->sk_net_refcnt == 1), which is somehow mentioned as out-of-scope of CIFS and technically wrong in e9f2517a3e18, but **is in-scope and right fix**.
Regarding the LOCKDEP issue, we can prevent the module unload by bumping the module refcount when switching the LOCKDDEP key in sock_lock_init_class_and_name(). [2]
For a while, let's revert the bogus fix.
Note that now we can use sk_net_refcnt_upgrade() for the socket conversion, but I'll do so later separately to make backport easy.
--- fs/smb/client/connect.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-)
fs/smb/client/connect.c +10 -26
@@ -1003,13 +1003,9 @@ clean_demultiplex_info(struct TCP_Servermsleep (125 );if (cifs_rdma_enabled (server))smbd_destroy (server); -if (server->ssocket) {sock_release (server->ssocket); server->ssocket =NULL ; - -/* Release netns reference for the socket. */ -put_net (cifs_net_ns (server)); }if (!list_empty (&server->pending_mid_q)) {
@@ -1058,7 +1054,6 @@ clean_demultiplex_info(struct TCP_Server*/ } -/* Release netns reference for this server. */ put_net (cifs_net_ns (server));kfree (server->leaf_fullpath);kfree (server->hostname);
@@ -1730,8 +1725,6 @@ cifs_get_tcp_session(struct smb3_fs_cont tcp_ses->ops = ctx->ops; tcp_ses->vals = ctx->vals; - -/* Grab netns reference for this server. */ cifs_set_net_ns (tcp_ses,get_net (current->nsproxy->net_ns)); tcp_ses->conn_id =atomic_inc_return (&tcpSesNextId);
@@ -1863,7 +1856,6 @@ smbd_connected: out_err_crypto_release:cifs_crypto_secmech_release (tcp_ses); -/* Release netns reference for this server. */ put_net (cifs_net_ns (tcp_ses)); out_err:
@@ -1872,10 +1864,8 @@ out_err:cifs_put_tcp_session (tcp_ses->primary_server, false);kfree (tcp_ses->hostname);kfree (tcp_ses->leaf_fullpath); -if (tcp_ses->ssocket) { +if (tcp_ses->ssocket)sock_release (tcp_ses->ssocket); -put_net (cifs_net_ns (tcp_ses)); - }kfree (tcp_ses); }return ERR_PTR (rc);
@@ -3139,20 +3129,20 @@ generic_ip_connect(struct TCP_Server_Inf socket = server->ssocket; }else {struct net *net =cifs_net_ns (server); +struct sock *sk; - rc =sock_create_kern (net, sfamily,SOCK_STREAM ,IPPROTO_TCP , &server->ssocket); + rc =__sock_create (net, sfamily,SOCK_STREAM , +IPPROTO_TCP , &server->ssocket,1 );if (rc <0 ) {cifs_server_dbg (VFS ,"Error %d creating socket\n" , rc);return rc; } -/* -* Grab netns reference for the socket. -* -* It'll be released here, on error, or in clean_demultiplex_info() upon server -* teardown. -*/ -get_net (net); + sk = server->ssocket->sk; +__netns_tracker_free (net, &sk->ns_tracker, false); + sk->sk_net_refcnt =1 ; +get_net_track (net, &sk->ns_tracker,GFP_KERNEL ); +sock_inuse_add (net,1 );/* BB other socket options to set KEEPALIVE, NODELAY? */ cifs_dbg (FYI ,"Socket created\n" );
@@ -3166,10 +3156,8 @@ generic_ip_connect(struct TCP_Server_Inf } rc =bind_socket (server); -if (rc <0 ) { -put_net (cifs_net_ns (server)); +if (rc <0 )return rc; - }/* * Eventually check for other socket options to change from
@@ -3206,7 +3194,6 @@ generic_ip_connect(struct TCP_Server_Infif (rc <0 ) {cifs_dbg (FYI ,"Error %d connecting to server\n" , rc);trace_smb3_connect_err (server->hostname, server->conn_id, &server->dstaddr, rc); -put_net (cifs_net_ns (server));sock_release (socket); server->ssocket =NULL ;return rc;
@@ -3215,9 +3202,6 @@ generic_ip_connect(struct TCP_Server_Infif (sport ==htons (RFC1001_PORT )) rc =ip_rfc1001_connect (server); -if (rc <0 ) -put_net (cifs_net_ns (server)); -return rc; }
Greg Kroah-Hartman
maintainerPATCH 330/393 riscv: Avoid fortify warning in syscall_get_arguments()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit adf53771a3123df99ca26e38818760fbcf5c05d0 upstream.
When building with CONFIG_FORTIFY_SOURCE=y and W=1, there is a warning because of the memcpy() in syscall_get_arguments():
In file included from include/linux/string.h:392,
from include/linux/bitmap.h:13,
from include/linux/cpumask.h:12,
from arch/riscv/include/asm/processor.h:55,
from include/linux/sched.h:13,
from kernel/ptrace.c:13:
In function 'fortify_memcpy_chk',
inlined from 'syscall_get_arguments.isra' at arch/riscv/include/asm/syscall.h:66:2:
include/linux/fortify-string.h:580:25: error: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
580 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
The fortified memcpy() routine enforces that the source is not overread and the destination is not overwritten if the size of either field and the size of the copy are known at compile time. The memcpy() in syscall_get_arguments() intentionally overreads from a1 to a5 in 'struct pt_regs' but this is bigger than the size of a1.
Normally, this could be solved by wrapping a1 through a5 with struct_group() but there was already a struct_group() applied to these members in commit bba547810c66 ("riscv: tracing: Fix __write_overflow_field in ftrace_partial_regs()").
Just avoid memcpy() altogether and write the copying of args from regs manually, which clears up the warning at the expense of three extra lines of code.
--- arch/riscv/include/asm/syscall.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/riscv/include/asm/syscall.h +5 -2
@@ -62,8 +62,11 @@ static inline void syscall_get_arguments unsigned long *args) { args[0 ] = regs->orig_a0; - args++; -memcpy (args, ®s->a1,5 *sizeof (args[0 ])); + args[1 ] = regs->a1; + args[2 ] = regs->a2; + args[3 ] = regs->a3; + args[4 ] = regs->a4; + args[5 ] = regs->a5; }static inline int syscall_get_arch (struct task_struct *task)
Greg Kroah-Hartman
maintainerPATCH 331/393 selftests/mm: generate a temporary mountpoint for cgroup filesystem
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit 9c02223e2d9df5cb37c51aedb78f3960294e09b5 upstream.
Currently if the filesystem for the cgroups version it wants to use is not mounted charge_reserved_hugetlb.sh and hugetlb_reparenting_test.sh tests will attempt to mount it on the hard coded path /dev/cgroup/memory, deleting that directory when the test finishes. This will fail if there is not a preexisting directory at that path, and since the directory is deleted subsequent runs of the test will fail. Instead of relying on this hard coded directory name use mktemp to generate a temporary directory to use as a mountpoint, fixing both the assumption and the disruption caused by deleting a preexisting directory.
This means that if the relevant cgroup filesystem is not already mounted then we rely on having coreutils (which provides mktemp) installed. I suspect that many current users are relying on having things automounted by default, and given that the script relies on bash it's probably not an unreasonable requirement.
--- tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 4 ++-- tools/testing/selftests/mm/hugetlb_reparenting_test.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/charge_reserved_hugetlb.sh +2 -2
@@ -27,7 +27,7 @@ fi if [[ $cgroup2 ]]; then cgroup_path=$(mount -t cgroup2 | head -1 | awk '{print $3}') if [[ -z "$cgroup_path" ]]; then - cgroup_path=/dev/cgroup/memory + cgroup_path=$(mktemp -d) mount -t cgroup2 none $cgroup_path do_umount=1 fi
@@ -35,7 +35,7 @@ if [[ $cgroup2 ]]; then else cgroup_path=$(mount -t cgroup | grep ",hugetlb" | awk '{print $3}') if [[ -z "$cgroup_path" ]]; then - cgroup_path=/dev/cgroup/memory + cgroup_path=$(mktemp -d) mount -t cgroup memory,hugetlb $cgroup_path do_umount=1 fi
tools/testing/selftests/mm/hugetlb_reparenting_test.sh +1 -1
@@ -22,7 +22,7 @@ fi if [[ $cgroup2 ]]; then CGROUP_ROOT=$(mount -t cgroup2 | head -1 | awk '{print $3}') if [[ -z "$CGROUP_ROOT" ]]; then - CGROUP_ROOT=/dev/cgroup/memory + CGROUP_ROOT=$(mktemp -d) mount -t cgroup2 none $CGROUP_ROOT do_umount=1 fi
Greg Kroah-Hartman
maintainerPATCH 332/393 smb3 client: fix open hardlink on deferred close file error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chunjie Zhu <[email protected]>
commit 262b73ef442e68e53220b9d6fc5a0d08b557fa42 upstream.
The following Python script results in unexpected behaviour when run on a CIFS filesystem against a Windows Server:
# Create file
fd = os.open('test', os.O_WRONLY|os.O_CREAT)
os.write(fd, b'foo')
os.close(fd)
# Open and close the file to leave a pending deferred close
fd = os.open('test', os.O_RDONLY|os.O_DIRECT)
os.close(fd)
# Try to open the file via a hard link
os.link('test', 'new')
newfd = os.open('new', os.O_RDONLY|os.O_DIRECT)The final open returns EINVAL due to the server returning STATUS_INVALID_PARAMETER. The root cause of this is that the client caches lease keys per inode, but the spec requires them to be related to the filename which causes problems when hard links are involved:
Quoted 1 line
From MS-SMB2 section 3.3.5.9.11:
"The server MUST attempt to locate a Lease by performing a lookup in the LeaseTable.LeaseList using the LeaseKey in the SMB2_CREATE_REQUEST_LEASE_V2 as the lookup key. If a lease is found, Lease.FileDeleteOnClose is FALSE, and Lease.Filename does not match the file name for the incoming request, the request MUST be failed with STATUS_INVALID_PARAMETER"
On client side, we first check the context of file open, if it hits above conditions, we first close all opening files which are belong to the same inode, then we do open the hard link file.
--- fs/smb/client/cifsproto.h | 2 ++ fs/smb/client/file.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
fs/smb/client/cifsproto.h +2 -0
@@ -158,6 +158,8 @@ extern int cifs_get_writable_path(structextern struct cifsFileInfo *find_readable_file (struct cifsInodeInfo *,bool );extern int cifs_get_readable_path (struct cifs_tcon *tcon,const char *name,struct cifsFileInfo **ret_file); +extern int cifs_get_hardlink_path (struct cifs_tcon *tcon,struct inode *inode, +struct file *file);extern unsigned int smbCalcSize (void *buf);extern int decode_negTokenInit (unsigned char *security_blob,int length,struct TCP_Server_Info *server);
fs/smb/client/file.c +28 -0
@@ -816,6 +816,11 @@ int cifs_open(struct inode *inode, struc }else {_cifsFileInfo_put (cfile, true, false); } + }else { +/* hard link on the defeered close file */ + rc =cifs_get_hardlink_path (tcon, inode, file); +if (rc) +cifs_close_deferred_file (CIFS_I (inode)); }if (server->oplocks)
@@ -1878,6 +1883,29 @@ cifs_move_llist(struct list_head *sourcelist_move (li, dest); } +int +cifs_get_hardlink_path (struct cifs_tcon *tcon,struct inode *inode, +struct file *file) +{ +struct cifsFileInfo *open_file =NULL ; +struct cifsInodeInfo *cinode =CIFS_I (inode); +int rc =0 ; + +spin_lock (&tcon->open_file_lock); +spin_lock (&cinode->open_file_lock); + +list_for_each_entry (open_file, &cinode->openFileList, flist) { +if (file->f_flags == open_file->f_flags) { + rc = -EINVAL ; +break ; + } + } + +spin_unlock (&cinode->open_file_lock); +spin_unlock (&tcon->open_file_lock); +return rc; +} +void cifs_free_llist (struct list_head *llist) {
Greg Kroah-Hartman
maintainerPATCH 333/393 string: Add load_unaligned_zeropad() code path to sized_strscpy()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Collingbourne <[email protected]>
commit d94c12bd97d567de342fd32599e7cd9e50bfa140 upstream.
The call to read_word_at_a_time() in sized_strscpy() is problematic with MTE because it may trigger a tag check fault when reading across a tag granule (16 bytes) boundary. To make this code MTE compatible, let's start using load_unaligned_zeropad() on architectures where it is available (i.e. architectures that define CONFIG_DCACHE_WORD_ACCESS). Because load_unaligned_zeropad() takes care of page boundaries as well as tag granule boundaries, also disable the code preventing crossing page boundaries when using load_unaligned_zeropad().
--- lib/string.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
lib/string.c +10 -3
@@ -128,6 +128,7 @@ ssize_t strscpy(char *dest, const char *if (count ==0 ||WARN_ON_ONCE (count >INT_MAX ))return -E2BIG ; +#ifndef CONFIG_DCACHE_WORD_ACCESS #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS /* * If src is unaligned, don't cross a page boundary,
@@ -143,11 +144,13 @@ ssize_t strscpy(char *dest, const char *if (((long ) dest | (long ) src) & (sizeof (long ) -1 )) max =0 ;#endif +#endif /* -* read_word_at_a_time() below may read uninitialized bytes after the -* trailing zero and use them in comparisons. Disable this optimization -* under KMSAN to prevent false positive reports. +* load_unaligned_zeropad() or read_word_at_a_time() below may read +* uninitialized bytes after the trailing zero and use them in +* comparisons. Disable this optimization under KMSAN to prevent +* false positive reports. */ if (IS_ENABLED (CONFIG_KMSAN )) max =0 ;
@@ -155,7 +158,11 @@ ssize_t strscpy(char *dest, const char *while (max >=sizeof (unsigned long )) {unsigned long c, data; +#ifdef CONFIG_DCACHE_WORD_ACCESS + c =load_unaligned_zeropad (src+res); +#else c =read_word_at_a_time (src+res); +#endif if (has_zero (c, &data, &constants)) { data =prep_zero_mask (c, data, &constants); data =create_zero_mask (data);
Greg Kroah-Hartman
maintainerPATCH 334/393 tracing: Fix filter string testing
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit a8c5b0ed89a3f2c81c6ae0b041394e6eea0e7024 upstream.
The filter string testing uses strncpy_from_kernel/user_nofault() to retrieve the string to test the filter against. The if() statement was incorrect as it considered 0 as a fault, when it is only negative that it faulted.
Running the following commands:
# cd /sys/kernel/tracing # echo "filename.ustring ~ \"/proc*\"" > events/syscalls/sys_enter_openat/filter # echo 1 > events/syscalls/sys_enter_openat/enable # ls /proc/$$/maps # cat trace
Would produce nothing, but with the fix it will produce something like:
ls-1192 [007] ..... 8169.828333: sys_openat(dfd: ffffffffffffff9c, filename: 7efc18359904, flags: 80000, mode: 0)
--- kernel/trace/trace_events_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_events_filter.c +2 -2
@@ -808,7 +808,7 @@ static __always_inline char *test_string kstr = ubuf->buffer;/* For safety, do not trust the string pointer */ -if (!strncpy_from_kernel_nofault (kstr, str,USTRING_BUF_SIZE )) +if (strncpy_from_kernel_nofault (kstr, str,USTRING_BUF_SIZE ) <0 )return NULL ;return kstr; }
@@ -827,7 +827,7 @@ static __always_inline char *test_ustrin/* user space address? */ ustr = (char __user *)str; -if (!strncpy_from_user_nofault (kstr, ustr,USTRING_BUF_SIZE )) +if (strncpy_from_user_nofault (kstr, ustr,USTRING_BUF_SIZE ) <0 )return NULL ;return kstr;
Greg Kroah-Hartman
maintainerPATCH 335/393 virtiofs: add filesystem context source name check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiangsheng Hou <[email protected]>
commit a94fd938df2b1628da66b498aa0eeb89593bc7a2 upstream.
In certain scenarios, for example, during fuzz testing, the source name may be NULL, which could lead to a kernel panic. Therefore, an extra check for the source name should be added.
--- fs/fuse/virtio_fs.c | 3 +++ 1 file changed, 3 insertions(+)
fs/fuse/virtio_fs.c +3 -0
@@ -1430,6 +1430,9 @@ static int virtio_fs_get_tree(struct fs_unsigned int virtqueue_size;int err = -EIO ; +if (!fsc->source) +return invalf (fsc,"No source specified" ); +/* This gets a reference on virtio_fs object. This ptr gets installed * in fc->iq->priv. Once fuse_conn is going away, it calls ->put() * to drop the reference to this object.
Greg Kroah-Hartman
maintainerPATCH 336/393 x86/microcode/AMD: Extend the SHA check to Zen5, block loading of any unreleased standalone Zen5 microcode patches
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov (AMD) <[email protected]>
commit 805b743fc163f1abef7ce1bea8eca8dfab5b685b upstream.
All Zen5 machines out there should get BIOS updates which update to the correct microcode patches addressing the microcode signature issue. However, silly people carve out random microcode blobs from BIOS packages and think are doing other people a service this way...
Block loading of any unreleased standalone Zen5 microcode patches.
--- arch/x86/kernel/cpu/microcode/amd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/microcode/amd.c +7 -2
@@ -201,6 +201,12 @@ static bool need_sha_check(u32 cur_rev)case 0xa70c0 :return cur_rev <=0xa70C009 ;break ;case 0xaa001 :return cur_rev <=0xaa00116 ;break ;case 0xaa002 :return cur_rev <=0xaa00218 ;break ; +case 0xb0021 :return cur_rev <=0xb002146 ;break ; +case 0xb1010 :return cur_rev <=0xb101046 ;break ; +case 0xb2040 :return cur_rev <=0xb204031 ;break ; +case 0xb4040 :return cur_rev <=0xb404031 ;break ; +case 0xb6000 :return cur_rev <=0xb600031 ;break ; +case 0xb7000 :return cur_rev <=0xb700031 ;break ;default :break ; }
@@ -216,8 +222,7 @@ static bool verify_sha256_digest(u32 patstruct sha256_state s;int i; -if (x86_family (bsp_cpuid_1_eax) <0x17 || -x86_family (bsp_cpuid_1_eax) >0x19 ) +if (x86_family (bsp_cpuid_1_eax) <0x17 )return true;if (!need_sha_check (cur_rev))
Greg Kroah-Hartman
maintainerPATCH 337/393 x86/cpu/amd: Fix workaround for erratum 1054
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandipan Das <[email protected]>
commit 263e55949d8902a6a09bdb92a1ab6a3f67231abe upstream.
Erratum 1054 affects AMD Zen processors that are a part of Family 17h Models 00-2Fh and the workaround is to not set HWCR[IRPerfEn]. However, when X86_FEATURE_ZEN1 was introduced, the condition to detect unaffected processors was incorrectly changed in a way that the IRPerfEn bit gets set only for unaffected Zen 1 processors.
Ensure that HWCR[IRPerfEn] is set for all unaffected processors. This includes a subset of Zen 1 (Family 17h Models 30h and above) and all later processors. Also clear X86_FEATURE_IRPERF on affected processors so that the IRPerfCount register is not used by other entities like the MSR PMU driver.
--- arch/x86/kernel/cpu/amd.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/amd.c +12 -7
@@ -1039,6 +1039,16 @@ static void init_amd_zen1(struct cpuinfopr_notice_once ("AMD Zen1 DIV0 bug detected. Disable SMT for full protection.\n" );setup_force_cpu_bug (X86_BUG_DIV0 ); + +/* +* Turn off the Instructions Retired free counter on machines that are +* susceptible to erratum #1054 "Instructions Retired Performance +* Counter May Be Inaccurate". +*/ +if (c->x86_model <0x30 ) { +msr_clear_bit (MSR_K7_HWCR ,MSR_K7_HWCR_IRPERF_EN_BIT ); +clear_cpu_cap (c,X86_FEATURE_IRPERF ); + } }static bool cpu_has_zenbleed_microcode (void )
@@ -1185,13 +1195,8 @@ static void init_amd(struct cpuinfo_x86if (!cpu_feature_enabled (X86_FEATURE_XENPV ))set_cpu_bug (c,X86_BUG_SYSRET_SS_ATTRS ); -/* -* Turn on the Instructions Retired free counter on machines not -* susceptible to erratum #1054 "Instructions Retired Performance -* Counter May Be Inaccurate". -*/ -if (cpu_has (c,X86_FEATURE_IRPERF ) && - (boot_cpu_has (X86_FEATURE_ZEN1 ) && c->x86_model >0x2f )) +/* Enable the Instructions Retired free counter */ +if (cpu_has (c,X86_FEATURE_IRPERF ))msr_set_bit (MSR_K7_HWCR ,MSR_K7_HWCR_IRPERF_EN_BIT );check_null_seg_clears_base (c);
Greg Kroah-Hartman
maintainerPATCH 338/393 x86/boot/sev: Avoid shared GHCB page for early memory acceptance
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit d54d610243a4508183978871e5faff5502786cd4 upstream.
Communicating with the hypervisor using the shared GHCB page requires clearing the C bit in the mapping of that page. When executing in the context of the EFI boot services, the page tables are owned by the firmware, and this manipulation is not possible.
So switch to a different API for accepting memory in SEV-SNP guests, one which is actually supported at the point during boot where the EFI stub may need to accept memory, but the SEV-SNP init code has not executed yet.
For simplicity, also switch the memory acceptance carried out by the decompressor when not booting via EFI - this only involves the allocation for the decompressed kernel, and is generally only called after kexec, as normal boot will jump straight into the kernel from the EFI stub.
--- arch/x86/boot/compressed/mem.c | 5 ++- arch/x86/boot/compressed/sev.c | 67 +++++++++-------------------------------- arch/x86/boot/compressed/sev.h | 2 + 3 files changed, 21 insertions(+), 53 deletions(-)
arch/x86/boot/compressed/mem.c +4 -1
@@ -34,11 +34,14 @@ static bool early_is_tdx_guest(void)void arch_accept_memory (phys_addr_t start,phys_addr_t end) { +static bool sevsnp; +/* Platform-specific memory-acceptance call goes here */ if (early_is_tdx_guest ()) {if (!tdx_accept_memory (start, end))panic ("TDX: Failed to accept memory\n" ); - }else if (sev_snp_enabled ()) { + }else if (sevsnp || (sev_get_status () &MSR_AMD64_SEV_SNP_ENABLED )) { + sevsnp = true;snp_accept_memory (start, end); }else {error ("Cannot accept memory: unknown platform\n" );
arch/x86/boot/compressed/sev.c +15 -52
104 lines not on this page · raw message
arch/x86/boot/compressed/sev.h +2 -0
@@ -12,11 +12,13 @@bool sev_snp_enabled (void );void snp_accept_memory (phys_addr_t start,phys_addr_t end); +u64 sev_get_status (void );#else static inline bool sev_snp_enabled (void ) {return false; }static inline void snp_accept_memory (phys_addr_t start,phys_addr_t end) { } +static inline u64 sev_get_status (void ) {return 0 ; }#endif
Greg Kroah-Hartman
maintainerPATCH 339/393 scsi: megaraid_sas: Block zero-length ATA VPD inquiry
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
commit aad9945623ab4029ae7789609fb6166c97976c62 upstream.
A firmware bug was observed where ATA VPD inquiry commands with a zero-length data payload were not handled and failed with a non-standard status code of 0xf0.
Avoid sending ATA VPD inquiry commands without data payload by setting the device no_vpd_size flag to 1. In addition, if the firmware returns a status code of 0xf0, set scsi_cmnd->result to CHECK_CONDITION to facilitate proper error handling.
--- drivers/scsi/megaraid/megaraid_sas_base.c | 9 +++++++-- drivers/scsi/megaraid/megaraid_sas_fusion.c | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +7 -2
@@ -2101,6 +2101,9 @@ static int megasas_slave_configure(struc/* This sdev property may change post OCR */ megasas_set_dynamic_target_properties (sdev, is_target_prop); +if (!MEGASAS_IS_LOGICAL (sdev)) + sdev->no_vpd_size =1 ; +mutex_unlock (&instance->reset_mutex);return 0 ;
@@ -3660,8 +3663,10 @@ megasas_complete_cmd(struct megasas_instcase MFI_STAT_SCSI_IO_FAILED :case MFI_STAT_LD_INIT_IN_PROGRESS : - cmd->scmd->result = - (DID_ERROR <<16 ) | hdr->scsi_status; +if (hdr->scsi_status ==0xf0 ) + cmd->scmd->result = (DID_ERROR <<16 ) |SAM_STAT_CHECK_CONDITION ; +else + cmd->scmd->result = (DID_ERROR <<16 ) | hdr->scsi_status;break ;case MFI_STAT_SCSI_DONE_WITH_ERROR :
drivers/scsi/megaraid/megaraid_sas_fusion.c +4 -1
@@ -2043,7 +2043,10 @@ map_cmd_status(struct fusion_context *fucase MFI_STAT_SCSI_IO_FAILED :case MFI_STAT_LD_INIT_IN_PROGRESS : - scmd->result = (DID_ERROR <<16 ) | ext_status; +if (ext_status ==0xf0 ) + scmd->result = (DID_ERROR <<16 ) |SAM_STAT_CHECK_CONDITION ; +else + scmd->result = (DID_ERROR <<16 ) | ext_status;break ;case MFI_STAT_SCSI_DONE_WITH_ERROR :
Greg Kroah-Hartman
maintainerPATCH 340/393 scsi: ufs: exynos: Ensure consistent phy reference counts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Griffin <[email protected]>
commit 7f05fd9a3b6fb3a9abc5a748307d11831c03175f upstream.
ufshcd_link_startup() can call ufshcd_vops_link_startup_notify() multiple times when retrying. This causes the phy reference count to keep increasing and the phy to not properly re-initialize.
If the phy has already been previously powered on, first issue a phy_power_off() and phy_exit(), before re-initializing and powering on again.
--- drivers/ufs/host/ufs-exynos.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/ufs/host/ufs-exynos.c +6 -0
@@ -901,6 +901,12 @@ static int exynos_ufs_phy_init(struct ex }phy_set_bus_width (generic_phy, ufs->avail_ln_rx); + +if (generic_phy->power_count) { +phy_power_off (generic_phy); +phy_exit (generic_phy); + } + ret =phy_init (generic_phy);if (ret) { dev_err(hba->dev, "%s: phy init failed, ret = %d\n",
Greg Kroah-Hartman
maintainerPATCH 341/393 RDMA/cma: Fix workqueue crash in cma_netevent_work_handler
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sharath Srinivasan <[email protected]>
commit 45f5dcdd049719fb999393b30679605f16ebce14 upstream.
struct rdma_cm_id has member "struct work_struct net_work" that is reused for enqueuing cma_netevent_work_handler()s onto cma_wq.
Below crash[1] can occur if more than one call to cma_netevent_callback() occurs in quick succession, which further enqueues cma_netevent_work_handler()s for the same rdma_cm_id, overwriting any previously queued work-item(s) that was just scheduled to run i.e. there is no guarantee the queued work item may run between two successive calls to cma_netevent_callback() and the 2nd INIT_WORK would overwrite the 1st work item (for the same rdma_cm_id), despite grabbing id_table_lock during enqueue.
Also drgn analysis [2] indicates the work item was likely overwritten.
Fix this by moving the INIT_WORK() to __rdma_create_id(), so that it doesn't race with any existing queue_work() or its worker thread.
[1] Trimmed crash stack:
=============================================
BUG: kernel NULL pointer dereference, address: 0000000000000008 kworker/u256:6 ... 6.12.0-0... Workqueue: cma_netevent_work_handler [rdma_cm] (rdma_cm) RIP: 0010:process_one_work+0xba/0x31a Call Trace: worker_thread+0x266/0x3a0 kthread+0xcf/0x100 ret_from_fork+0x31/0x50 ret_from_fork_asm+0x1a/0x30 =============================================
[2] drgn crash analysis:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
trace = prog.crashed_thread().stack_trace()
trace
(0) crash_setup_regs (./arch/x86/include/asm/kexec.h:111:15) (1) __crash_kexec (kernel/crash_core.c:122:4) (2) panic (kernel/panic.c:399:3) (3) oops_end (arch/x86/kernel/dumpstack.c:382:3)
...
(8) process_one_work (kernel/workqueue.c:3168:2)
(9) process_scheduled_works (kernel/workqueue.c:3310:3)
(10) worker_thread (kernel/workqueue.c:3391:4)
(11) kthread (kernel/kthread.c:389:9)
Line workqueue.c:3168 for this kernel version is in process_one_work():
3168 strscpy(worker->desc, pwq->wq->name, WORKER_DESC_LEN);
Quoted 1 line
Quoted 1 line
Quoted 1 line
trace[8]["work"]
*(struct work_struct *)0xffff92577d0a21d8 = {
.data = (atomic_long_t){
.counter = (s64)536870912, <=== Note
},
.entry = (struct list_head){
.next = (struct list_head *)0xffff924d075924c0,
.prev = (struct list_head *)0xffff924d075924c0,
},
.func = (work_func_t)cma_netevent_work_handler+0x0 = 0xffffffffc2cec280,
}Suspicion is that pwq is NULL:
Quoted 1 line
Quoted 1 line
Quoted 1 line
trace[8]["pwq"]
(struct pool_workqueue *)<absent>
In process_one_work(), pwq is assigned from:
struct pool_workqueue *pwq = get_work_pwq(work);
and get_work_pwq() is:
static struct pool_workqueue *get_work_pwq(struct work_struct *work) {
unsigned long data = atomic_long_read(&work->data);
if (data & WORK_STRUCT_PWQ)
return work_struct_pwq(data);
else
return NULL;
}
WORK_STRUCT_PWQ is 0x4:
Quoted 1 line
Quoted 1 line
Quoted 1 line
print(repr(prog['WORK_STRUCT_PWQ']))
Object(prog, 'enum work_flags', value=4)
But work->data is 536870912 which is 0x20000000.
So, get_work_pwq() returns NULL and we crash in process_one_work():
3168 strscpy(worker->desc, pwq->wq->name, WORKER_DESC_LEN);
=============================================
--- drivers/infiniband/core/cma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/core/cma.c +3 -1
@@ -72,6 +72,8 @@ static const char * const cma_events[] =static void cma_iboe_set_mgid (struct sockaddr *addr,union ib_gid *mgid,enum ib_gid_type gid_type); +static void cma_netevent_work_handler (struct work_struct *_work); + const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event) {size_t index = event;
@@ -1017,6 +1019,7 @@ __rdma_create_id(struct net *net, rdma_cget_random_bytes (&id_priv->seq_num,sizeof id_priv->seq_num); id_priv->id.route.addr.dev_addr.net =get_net (net); id_priv->seq_num &=0x00ffffff ; +INIT_WORK (&id_priv->id.net_work, cma_netevent_work_handler);rdma_restrack_new (&id_priv->res,RDMA_RESTRACK_CM_ID );if (parent)
@@ -5211,7 +5214,6 @@ static int cma_netevent_callback(structif (!memcmp (current_id->id.route.addr.dev_addr.dst_dev_addr, neigh->ha,ETH_ALEN ))continue ; -INIT_WORK (¤t_id->id.net_work, cma_netevent_work_handler);cma_id_get (current_id);queue_work (cma_wq, ¤t_id->id.net_work); }
Greg Kroah-Hartman
maintainerPATCH 342/393 perf/x86/intel: Allow to update user space GPRs from PEBS records
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dapeng Mi <[email protected]>
commit 71dcc11c2cd9e434c34a63154ecadca21c135ddd upstream.
Currently when a user samples user space GPRs (--user-regs option) with PEBS, the user space GPRs actually always come from software PMI instead of from PEBS hardware. This leads to the sampled GPRs to possibly be inaccurate for single PEBS record case because of the skid between counter overflow and GPRs sampling on PMI.
For the large PEBS case, it is even worse. If user sets the exclude_kernel attribute, large PEBS would be used to sample user space GPRs, but since PEBS GPRs group is not really enabled, it leads to all samples in the large PEBS record to share the same piece of user space GPRs, like this reproducer shows:
$ perf record -e branches:pu --user-regs=ip,ax -c 100000 ./foo $ perf report -D | grep "AX"
.... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead
So enable GPRs group for user space GPRs sampling and prioritize reading GPRs from PEBS. If the PEBS sampled GPRs is not user space GPRs (single PEBS record case), perf_sample_regs_user() modifies them to user space GPRs.
[ mingo: Clarified the changelog. ]
--- arch/x86/events/intel/ds.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/x86/events/intel/ds.c +5 -3
@@ -1203,8 +1203,10 @@ static u64 pebs_update_adaptive_cfg(stru* + precise_ip < 2 for the non event IP * + For RTM TSX weight we need GPRs for the abort code. */ - gprs = (sample_type &PERF_SAMPLE_REGS_INTR ) && - (attr->sample_regs_intr &PEBS_GP_REGS ); + gprs = ((sample_type &PERF_SAMPLE_REGS_INTR ) && + (attr->sample_regs_intr &PEBS_GP_REGS )) || + ((sample_type &PERF_SAMPLE_REGS_USER ) && + (attr->sample_regs_user &PEBS_GP_REGS )); tsx_weight = (sample_type & PERF_SAMPLE_WEIGHT_TYPE) && ((attr->config & INTEL_ARCH_EVENT_MASK) ==
@@ -1856,7 +1858,7 @@ static void setup_pebs_adaptive_sample_d regs->flags &= ~PERF_EFLAGS_EXACT ; } -if (sample_type &PERF_SAMPLE_REGS_INTR ) +if (sample_type & (PERF_SAMPLE_REGS_INTR |PERF_SAMPLE_REGS_USER ))adaptive_pebs_save_regs (regs, gprs); }
Greg Kroah-Hartman
maintainerPATCH 343/393 perf/x86/intel/uncore: Fix the scale of IIO free running counters on SNR
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 96a720db59ab330c8562b2437153faa45dac705f upstream.
There was a mistake in the SNR uncore spec. The counter increments for every 32 bytes of data sent from the IO agent to the SOC, not 4 bytes which was documented in the spec.
The event list has been updated:
"EventName": "UNC_IIO_BANDWIDTH_IN.PART0_FREERUN", "BriefDescription": "Free running counter that increments for every 32
bytes of data sent from the IO agent to the SOC",
Update the scale of the IIO bandwidth in free running counters as well.
--- arch/x86/events/intel/uncore_snbep.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/x86/events/intel/uncore_snbep.c +8 -8
@@ -4882,28 +4882,28 @@ static struct uncore_event_desc snr_uncoINTEL_UNCORE_EVENT_DESC (ioclk,"event=0xff,umask=0x10" ),/* Free-Running IIO BANDWIDTH IN Counters */ INTEL_UNCORE_EVENT_DESC (bw_in_port0,"event=0xff,umask=0x20" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port0.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port0.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port0.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port1,"event=0xff,umask=0x21" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port1.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port1.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port2,"event=0xff,umask=0x22" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port2.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port2.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port3,"event=0xff,umask=0x23" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port3.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port3.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port4,"event=0xff,umask=0x24" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port4.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port4.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port5,"event=0xff,umask=0x25" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port5.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port5.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port6,"event=0xff,umask=0x26" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port6.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port6.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port7,"event=0xff,umask=0x27" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port7.scale,"3.0517578125e-5" ), INTEL_UNCORE_EVENT_DESC(bw_in_port7.unit, "MiB"), { /* end: all zeroes */ }, };
Greg Kroah-Hartman
maintainerPATCH 344/393 perf/x86/intel/uncore: Fix the scale of IIO free running counters on ICX
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 32c7f1150225694d95a51110a93be25db03bb5db upstream.
There was a mistake in the ICX uncore spec too. The counter increments for every 32 bytes rather than 4 bytes.
The same as SNR, there are 1 ioclk and 8 IIO bandwidth in free running counters. Reuse the snr_uncore_iio_freerunning_events().
--- arch/x86/events/intel/uncore_snbep.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-)
arch/x86/events/intel/uncore_snbep.c +1 -32
@@ -5476,37 +5476,6 @@ static struct freerunning_counters icx_i [ICX_IIO_MSR_BW_IN] = { 0xaa0, 0x1, 0x10, 8, 48, icx_iio_bw_freerunning_box_offsets }, }; -static struct uncore_event_desc icx_uncore_iio_freerunning_events[] = { -/* Free-Running IIO CLOCKS Counter */ -INTEL_UNCORE_EVENT_DESC (ioclk,"event=0xff,umask=0x10" ), -/* Free-Running IIO BANDWIDTH IN Counters */ -INTEL_UNCORE_EVENT_DESC (bw_in_port0,"event=0xff,umask=0x20" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port0.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port0.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1,"event=0xff,umask=0x21" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2,"event=0xff,umask=0x22" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3,"event=0xff,umask=0x23" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4,"event=0xff,umask=0x24" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5,"event=0xff,umask=0x25" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6,"event=0xff,umask=0x26" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7,"event=0xff,umask=0x27" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7.unit,"MiB" ), - {/* end: all zeroes */ }, -}; -static struct intel_uncore_type icx_uncore_iio_free_running = { .name ="iio_free_running" , .num_counters =9 ,
@@ -5514,7 +5483,7 @@ static struct intel_uncore_type icx_unco .num_freerunning_types = ICX_IIO_FREERUNNING_TYPE_MAX, .freerunning = icx_iio_freerunning, .ops = &skx_uncore_iio_freerunning_ops, - .event_descs = icx_uncore_iio_freerunning_events, + .event_descs = snr_uncore_iio_freerunning_events, .format_group = &skx_uncore_iio_freerunning_format_group, };
Greg Kroah-Hartman
maintainerPATCH 345/393 perf/x86/intel/uncore: Fix the scale of IIO free running counters on SPR
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 506f981ab40f0b03a11a640cfd77f48b09aff330 upstream.
The scale of IIO bandwidth in free running counters is inherited from the ICX. The counter increments for every 32 bytes rather than 4 bytes.
The IIO bandwidth out free running counters don't increment with a consistent size. The increment depends on the requested size. It's impossible to find a fixed increment. Remove it from the event_descs.
--- arch/x86/events/intel/uncore_snbep.c | 58 ----------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-)
arch/x86/events/intel/uncore_snbep.c +1 -57
@@ -6210,69 +6210,13 @@ static struct freerunning_counters spr_i [SPR_IIO_MSR_BW_OUT] = { 0x3808, 0x1, 0x10, 8, 48 }, }; -static struct uncore_event_desc spr_uncore_iio_freerunning_events[] = { -/* Free-Running IIO CLOCKS Counter */ -INTEL_UNCORE_EVENT_DESC (ioclk,"event=0xff,umask=0x10" ), -/* Free-Running IIO BANDWIDTH IN Counters */ -INTEL_UNCORE_EVENT_DESC (bw_in_port0,"event=0xff,umask=0x20" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port0.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port0.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1,"event=0xff,umask=0x21" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2,"event=0xff,umask=0x22" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3,"event=0xff,umask=0x23" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4,"event=0xff,umask=0x24" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5,"event=0xff,umask=0x25" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6,"event=0xff,umask=0x26" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7,"event=0xff,umask=0x27" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7.unit,"MiB" ), -/* Free-Running IIO BANDWIDTH OUT Counters */ -INTEL_UNCORE_EVENT_DESC (bw_out_port0,"event=0xff,umask=0x30" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port0.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port0.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port1,"event=0xff,umask=0x31" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port1.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port1.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port2,"event=0xff,umask=0x32" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port2.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port2.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port3,"event=0xff,umask=0x33" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port3.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port3.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port4,"event=0xff,umask=0x34" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port4.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port4.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port5,"event=0xff,umask=0x35" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port5.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port5.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port6,"event=0xff,umask=0x36" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port6.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port6.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port7,"event=0xff,umask=0x37" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port7.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port7.unit,"MiB" ), - {/* end: all zeroes */ }, -}; -static struct intel_uncore_type spr_uncore_iio_free_running = { .name ="iio_free_running" , .num_counters =17 , .num_freerunning_types =SPR_IIO_FREERUNNING_TYPE_MAX , .freerunning = spr_iio_freerunning, .ops = &skx_uncore_iio_freerunning_ops, - .event_descs = spr_uncore_iio_freerunning_events, + .event_descs = snr_uncore_iio_freerunning_events, .format_group = &skx_uncore_iio_freerunning_format_group, };
Greg Kroah-Hartman
maintainerPATCH 346/393 drm/repaper: fix integer overflows in repeat functions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
commit 4d098000ac193f359e6b8ca4801dbdbd6a27b41f upstream.
There are conditions, albeit somewhat unlikely, under which right hand expressions, calculating the end of time period in functions like repaper_frame_fixed_repeat(), may overflow.
For instance, if 'factor10x' in repaper_get_temperature() is high enough (170), as is 'epd->stage_time' in repaper_probe(), then the resulting value of 'end' will not fit in unsigned int expression.
Mitigate this by casting 'epd->factored_stage_time' to wider type before any multiplication is done.
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- drivers/gpu/drm/tiny/repaper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tiny/repaper.c +2 -2
@@ -455,7 +455,7 @@ static void repaper_frame_fixed_repeat(s enum repaper_stage stage) {u64 start =local_clock (); -u64 end = start + (epd->factored_stage_time *1000 *1000 ); +u64 end = start + ((u64 )epd->factored_stage_time *1000 *1000 ); do { repaper_frame_fixed(epd, fixed_value, stage);
@@ -466,7 +466,7 @@ static void repaper_frame_data_repeat(st const u8 *mask, enum repaper_stage stage) { u64 start = local_clock(); -u64 end = start + (epd->factored_stage_time *1000 *1000 ); +u64 end = start + ((u64 )epd->factored_stage_time *1000 *1000 ); do { repaper_frame_data(epd, image, mask, stage);
Greg Kroah-Hartman
maintainerPATCH 347/393 drm/msm/a6xx: Fix stale rpmh votes from GPU
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akhil P Oommen <[email protected]>
commit f561db72a663f8a73c2250bf3244ce1ce221bed7 upstream.
It was observed on sc7180 (A618 gpu) that GPU votes for GX rail and CNOC BCM nodes were not removed after GPU suspend. This was because we skipped sending 'prepare-slumber' request to gmu during suspend sequence in some cases. So, make sure we always call prepare-slumber hfi during suspend. Also, calling prepare-slumber without a prior oob-gpu handshake messes up gmu firmware's internal state. So, do that when required.
Patchwork: https://patchwork.freedesktop.org/patch/639569/
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 82 ++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 38 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +44 -38
@@ -1042,50 +1042,51 @@ static void a6xx_gmu_shutdown(struct a6x struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;u32 val; +int ret;/* -* The GMU may still be in slumber unless the GPU started so check and -* skip putting it back into slumber if so +* GMU firmware's internal power state gets messed up if we send "prepare_slumber" hfi when +* oob_gpu handshake wasn't done after the last wake up. So do a dummy handshake here when +* required */ - val =gmu_read (gmu,REG_A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE ); +if (adreno_gpu->base.needs_hw_init) { +if (a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_GPU_SET )) + goto force_off; -if (val !=0xf ) { -int ret =a6xx_gmu_wait_for_idle (gmu); - -/* If the GMU isn't responding assume it is hung */ -if (ret) { -a6xx_gmu_force_off (gmu); -return ; - } - -a6xx_bus_clear_pending_transactions (adreno_gpu, a6xx_gpu->hung); - -/* tell the GMU we want to slumber */ - ret =a6xx_gmu_notify_slumber (gmu); -if (ret) { -a6xx_gmu_force_off (gmu); -return ; - } - - ret =gmu_poll_timeout (gmu, -REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS , val, - !(val &A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS_GPUBUSYIGNAHB ), -100 ,10000 ); - -/* -* Let the user know we failed to slumber but don't worry too -* much because we are powering down anyway -*/ - -if (ret) -DRM_DEV_ERROR (gmu->dev, -"Unable to slumber GMU: status = 0%x/0%x\n" , -gmu_read (gmu, -REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS ), -gmu_read (gmu, -REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS2 )); +a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_GPU_SET ); } + ret =a6xx_gmu_wait_for_idle (gmu); + +/* If the GMU isn't responding assume it is hung */ +if (ret) + goto force_off; + +a6xx_bus_clear_pending_transactions (adreno_gpu, a6xx_gpu->hung); + +/* tell the GMU we want to slumber */ + ret =a6xx_gmu_notify_slumber (gmu); +if (ret) + goto force_off; + + ret =gmu_poll_timeout (gmu, +REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS , val, + !(val &A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS_GPUBUSYIGNAHB ), +100 ,10000 ); + +/* +* Let the user know we failed to slumber but don't worry too +* much because we are powering down anyway +*/ + +if (ret) +DRM_DEV_ERROR (gmu->dev, +"Unable to slumber GMU: status = 0%x/0%x\n" , +gmu_read (gmu, +REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS ), +gmu_read (gmu, +REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS2 )); +/* Turn off HFI */ a6xx_hfi_stop (gmu);
@@ -1094,6 +1095,11 @@ static void a6xx_gmu_shutdown(struct a6x/* Tell RPMh to power off the GPU */ a6xx_rpmh_stop (gmu); + +return ; + +force_off: +a6xx_gmu_force_off (gmu); }
Greg Kroah-Hartman
maintainerPATCH 348/393 drm/amd: Handle being compiled without SI or CIK support better
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 5f054ddead33c1622ea9c0c0aaf07c6843fc7ab0 upstream.
If compiled without SI or CIK support but amdgpu tries to load it will run into failures with uninitialized callbacks.
Show a nicer message in this case and fail probe instead.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 44 +++++++++++++++++--------------- 1 file changed, 24 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +24 -20
@@ -1651,7 +1651,6 @@ static const u16 amdgpu_unsupported_pcii };static const struct pci_device_id pciidlist[] = { -#ifdef CONFIG_DRM_AMDGPU_SI {0x1002 ,0x6780 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,CHIP_TAHITI }, {0x1002 ,0x6784 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,CHIP_TAHITI }, {0x1002 ,0x6788 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,CHIP_TAHITI },
@@ -1724,8 +1723,6 @@ static const struct pci_device_id pciidl {0x1002, 0x6665, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY}, {0x1002, 0x6667, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY}, {0x1002, 0x666F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY}, -#endif -#ifdef CONFIG_DRM_AMDGPU_CIK/* Kaveri */ {0x1002, 0x1304, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU}, {0x1002, 0x1305, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
@@ -1808,7 +1805,6 @@ static const struct pci_device_id pciidl {0x1002, 0x985D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU}, {0x1002, 0x985E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU}, {0x1002, 0x985F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU}, -#endif/* topaz */ {0x1002, 0x6900, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ}, {0x1002, 0x6901, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
@@ -2090,14 +2086,14 @@ static int amdgpu_pci_probe(struct pci_dreturn -ENOTSUPP ; } +switch (flags &AMD_ASIC_MASK ) { +case CHIP_TAHITI : +case CHIP_PITCAIRN : +case CHIP_VERDE : +case CHIP_OLAND : +case CHIP_HAINAN :#ifdef CONFIG_DRM_AMDGPU_SI -if (!amdgpu_si_support) { -switch (flags &AMD_ASIC_MASK ) { -case CHIP_TAHITI : -case CHIP_PITCAIRN : -case CHIP_VERDE : -case CHIP_OLAND : -case CHIP_HAINAN : +if (!amdgpu_si_support) {dev_info (&pdev->dev,"SI support provided by radeon.\n" ); dev_info(&pdev->dev,
@@ -2105,16 +2101,18 @@ static int amdgpu_pci_probe(struct pci_d );return -ENODEV ; } - } +break ; +#else +dev_info (&pdev->dev,"amdgpu is built without SI support.\n" ); +return -ENODEV ;#endif +case CHIP_KAVERI : +case CHIP_BONAIRE : +case CHIP_HAWAII : +case CHIP_KABINI : +case CHIP_MULLINS :#ifdef CONFIG_DRM_AMDGPU_CIK -if (!amdgpu_cik_support) { -switch (flags &AMD_ASIC_MASK ) { -case CHIP_KAVERI : -case CHIP_BONAIRE : -case CHIP_HAWAII : -case CHIP_KABINI : -case CHIP_MULLINS : +if (!amdgpu_cik_support) {dev_info (&pdev->dev,"CIK support provided by radeon.\n" ); dev_info(&pdev->dev,
@@ -2122,8 +2120,14 @@ static int amdgpu_pci_probe(struct pci_d ); return -ENODEV; } - } +break ; +#else +dev_info (&pdev->dev,"amdgpu is built without CIK support.\n" ); +return -ENODEV ;#endif +default : +break ; + } adev =devm_drm_dev_alloc (&pdev->dev, &amdgpu_kms_driver,typeof (*adev), ddev);if (IS_ERR (adev))
Greg Kroah-Hartman
maintainerPATCH 349/393 drm/amd/pm: Prevent division by zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 7d641c2b83275d3b0424127b2e0d2d0f7dd82aef upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +3 -0
@@ -1274,6 +1274,9 @@ static int arcturus_set_fan_speed_rpm(stuint32_t crystal_clock_freq =2500 ;uint32_t tach_period; +if (!speed || speed >UINT_MAX /8 ) +return -EINVAL ; + tach_period =60 * crystal_clock_freq *10000 / (8 * speed); WREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT, REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT),
Greg Kroah-Hartman
maintainerPATCH 350/393 drm/amd/pm/powerplay: Prevent division by zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 4b8c3c0d17c07f301011e2908fecd2ebdcfe3d1c upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.c +2 -2
@@ -307,10 +307,10 @@ int vega10_fan_ctrl_set_fan_speed_rpm(stint result =0 ;if (hwmgr->thermal_controller.fanInfo.bNoFan || - speed ==0 || + (!speed || speed >UINT_MAX /8 ) || (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) -return -1 ; +return -EINVAL ;if (PP_CAP (PHM_PlatformCaps_MicrocodeFanControl)) result =vega10_fan_ctrl_stop_smc_fan_control (hwmgr);
Greg Kroah-Hartman
maintainerPATCH 351/393 drm/amd/pm/smu11: Prevent division by zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 7ba88b5cccc1a99c1afb96e31e7eedac9907704c upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +1 -1
@@ -1202,7 +1202,7 @@ int smu_v11_0_set_fan_speed_rpm(struct suint32_t crystal_clock_freq =2500 ;uint32_t tach_period; -if (speed ==0 ) +if (!speed || speed >UINT_MAX /8 )return -EINVAL ;/* * To prevent from possible overheat, some ASICs may have requirement
Greg Kroah-Hartman
maintainerPATCH 352/393 drm/amd/pm/powerplay/hwmgr/smu7_thermal: Prevent division by zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 7c246a05df51c52fe0852ce56ba10c41e6ed1f39 upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.c +2 -2
@@ -267,10 +267,10 @@ int smu7_fan_ctrl_set_fan_speed_rpm(struif (hwmgr->thermal_controller.fanInfo.bNoFan || (hwmgr->thermal_controller.fanInfo. ucTachometerPulsesPerRevolution ==0 ) || - speed ==0 || + (!speed || speed >UINT_MAX /8 ) || (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) -return 0 ; +return -EINVAL ;if (PP_CAP (PHM_PlatformCaps_MicrocodeFanControl))smu7_fan_ctrl_stop_smc_fan_control (hwmgr);
Greg Kroah-Hartman
maintainerPATCH 353/393 drm/amd/pm/swsmu/smu13/smu_v13_0: Prevent division by zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit f23e9116ebb71b63fe9cec0dcac792aa9af30b0c upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1 -1
@@ -1227,7 +1227,7 @@ int smu_v13_0_set_fan_speed_rpm(struct suint32_t tach_period;int ret; -if (!speed) +if (!speed || speed >UINT_MAX /8 )return -EINVAL ; ret =smu_v13_0_auto_fan_control (smu,0 );
Greg Kroah-Hartman
maintainerPATCH 354/393 drm/amd/pm/powerplay/hwmgr/vega20_thermal: Prevent division by zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 4e3d9508c056d7e0a56b58d5c81253e2a0d22b6c upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c +1 -1
@@ -191,7 +191,7 @@ int vega20_fan_ctrl_set_fan_speed_rpm(stuint32_t tach_period, crystal_clock_freq;int result =0 ; -if (!speed) +if (!speed || speed >UINT_MAX /8 )return -EINVAL ;if (PP_CAP (PHM_PlatformCaps_MicrocodeFanControl)) {
Greg Kroah-Hartman
maintainerPATCH 355/393 drm/amdgpu/dma_buf: fix page_link check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <[email protected]>
commit c0dd8a9253fadfb8e5357217d085f1989da4ef0a upstream.
The page_link lower bits of the first sg could contain something like SG_END, if we are mapping a single VRAM page or contiguous blob which fits into one sg entry. Rather pull out the struct page, and use that in our check to know if we mapped struct pages vs VRAM.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +1 -1
@@ -211,7 +211,7 @@ static void amdgpu_dma_buf_unmap(struct struct sg_table *sgt, enum dma_data_direction dir) { -if (sgt->sgl->page_link) { + if (sg_page(sgt->sgl)) {dma_unmap_sgtable (attach->dev, sgt, dir,0 );sg_free_table (sgt);kfree (sgt);
Greg Kroah-Hartman
maintainerPATCH 356/393 drm/nouveau: prime: fix ttm_bo_delayed_delete oops
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Bainbridge <[email protected]>
commit 8ec0fbb28d049273bfd4f1e7a5ae4c74884beed3 upstream.
Fix an oops in ttm_bo_delayed_delete which results from dererencing a dangling pointer:
Oops: general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6b7b: 0000 [#1] PREEMPT SMP CPU: 4 UID: 0 PID: 1082 Comm: kworker/u65:2 Not tainted 6.14.0-rc4-00267-g505460b44513-dirty #216 Hardware name: LENOVO 82N6/LNVNB161216, BIOS GKCN65WW 01/16/2024 Workqueue: ttm ttm_bo_delayed_delete [ttm] RIP: 0010:dma_resv_iter_first_unlocked+0x55/0x290 Code: 31 f6 48 c7 c7 00 2b fa aa e8 97 bd 52 ff e8 a2 c1 53 00 5a 85 c0 74 48 e9 88 01 00 00 4c 89 63 20 4d 85 e4 0f 84 30 01 00 00 <41> 8b 44 24 10 c6 43 2c 01 48 89 df 89 43 28 e8 97 fd ff ff 4c 8b RSP: 0018:ffffbf9383473d60 EFLAGS: 00010202 RAX: 0000000000000001 RBX: ffffbf9383473d88 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffbf9383473d78 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 6b6b6b6b6b6b6b6b R13: ffffa003bbf78580 R14: ffffa003a6728040 R15: 00000000000383cc FS: 0000000000000000(0000) GS:ffffa00991c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000758348024dd0 CR3: 000000012c259000 CR4: 0000000000f50ef0 PKRU: 55555554 Call Trace: <TASK> ? __die_body.cold+0x19/0x26 ? die_addr+0x3d/0x70 ? exc_general_protection+0x159/0x460 ? asm_exc_general_protection+0x27/0x30 ? dma_resv_iter_first_unlocked+0x55/0x290 dma_resv_wait_timeout+0x56/0x100 ttm_bo_delayed_delete+0x69/0xb0 [ttm] process_one_work+0x217/0x5c0 worker_thread+0x1c8/0x3d0 ? apply_wqattrs_cleanup.part.0+0xc0/0xc0 kthread+0x10b/0x240 ? kthreads_online_cpu+0x140/0x140 ret_from_fork+0x40/0x70 ? kthreads_online_cpu+0x140/0x140 ret_from_fork_asm+0x11/0x20 </TASK>
The cause of this is:
- drm_prime_gem_destroy calls dma_buf_put(dma_buf) which releases the reference to the shared dma_buf. The reference count is 0, so the dma_buf is destroyed, which in turn decrements the corresponding amdgpu_bo reference count to 0, and the amdgpu_bo is destroyed - calling drm_gem_object_release then dma_resv_fini (which destroys the reservation object), then finally freeing the amdgpu_bo.
- nouveau_bo obj->bo.base.resv is now a dangling pointer to the memory formerly allocated to the amdgpu_bo.
- nouveau_gem_object_del calls ttm_bo_put(&nvbo->bo) which calls ttm_bo_release, which schedules ttm_bo_delayed_delete.
- ttm_bo_delayed_delete runs and dereferences the dangling resv pointer, resulting in a general protection fault.
Fix this by moving the drm_prime_gem_destroy call from nouveau_gem_object_del to nouveau_bo_del_ttm. This ensures that it will be run after ttm_bo_delayed_delete.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 3 +++ drivers/gpu/drm/nouveau/nouveau_gem.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +3 -0
@@ -144,6 +144,9 @@ nouveau_bo_del_ttm(struct ttm_buffer_objnouveau_bo_del_io_reserve_lru (bo);nv10_bo_put_tile_region (dev, nvbo->tile,NULL ); +if (bo->base.import_attach) +drm_prime_gem_destroy (&bo->base, bo->sg); +/* * If nouveau_bo_new() allocated this buffer, the GEM object was never * initialized, so don't attempt to release it.
drivers/gpu/drm/nouveau/nouveau_gem.c +0 -3
@@ -87,9 +87,6 @@ nouveau_gem_object_del(struct drm_gem_obreturn ; } -if (gem->import_attach) -drm_prime_gem_destroy (gem, nvbo->bo.sg); -ttm_bo_put (&nvbo->bo);pm_runtime_mark_last_busy (dev);
Greg Kroah-Hartman
maintainerPATCH 357/393 drm/sti: remove duplicate object names
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rolf Eike Beer <[email protected]>
commit 7fb6afa9125fc111478615e24231943c4f76cc2e upstream.
When merging 2 drivers common object files were not deduplicated.
--- drivers/gpu/drm/sti/Makefile | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/sti/Makefile +0 -2
@@ -7,8 +7,6 @@ sti-drm-y := \ sti_compositor.o \ sti_crtc.o \ sti_plane.o \ - sti_crtc.o \ - sti_plane.o \ sti_hdmi.o \ sti_hdmi_tx3g4c28phy.o \ sti_dvo.o \
Greg Kroah-Hartman
maintainerPATCH 358/393 drm/i915/gvt: fix unterminated-string-initialization warning
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
commit 2e43ae7dd71cd9bb0d1bce1d3306bf77523feb81 upstream.
Initializing const char opregion_signature[16] = OPREGION_SIGNATURE (which is "IntelGraphicsMem") drops the NUL termination of the string. This is intentional, but the compiler doesn't know this.
Switch to initializing header->signature directly from the string litaral, with sizeof destination rather than source. We don't treat the signature as a string other than for initialization; it's really just a blob of binary data.
Add a static assert for good measure to cross-check the sizes.
--- drivers/gpu/drm/i915/gvt/opregion.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gvt/opregion.c +4 -3
@@ -222,7 +222,6 @@ int intel_vgpu_init_opregion(struct inteu8 *buf;struct opregion_header *header;struct vbt v; -const char opregion_signature[16 ] =OPREGION_SIGNATURE ;gvt_dbg_core ("init vgpu%d opregion\n" , vgpu->id); vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
@@ -236,8 +235,10 @@ int intel_vgpu_init_opregion(struct inte/* emulated opregion with VBT mailbox only */ buf = (u8 *)vgpu_opregion (vgpu)->va; header = (struct opregion_header *)buf; -memcpy (header->signature, opregion_signature, -sizeof (opregion_signature)); + +static_assert (sizeof (header->signature) ==sizeof (OPREGION_SIGNATURE ) -1 ); +memcpy (header->signature,OPREGION_SIGNATURE ,sizeof (header->signature)); + header->size =0x8 ; header->opregion_ver =0x02000000 ; header->mboxes =MBOX_VBT ;
Greg Kroah-Hartman
maintainerPATCH 359/393 io_uring/net: fix accept multishot handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
Commit f6a89bf5278d6e15016a736db67043560d1b50d5 upstream.
REQ_F_APOLL_MULTISHOT doesn't guarantee it's executed from the multishot context, so a multishot accept may get executed inline, fail io_req_post_cqe(), and ask the core code to kill the request with -ECANCELED by returning IOU_STOP_MULTISHOT even when a socket has been accepted and installed.
--- io_uring/net.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/net.c +2 -0
@@ -1438,6 +1438,8 @@ retry: goto retry;io_req_set_res (req, ret,0 ); +if (!(issue_flags &IO_URING_F_MULTISHOT )) +return IOU_OK ;return IOU_STOP_MULTISHOT ; }
Greg Kroah-Hartman
maintainerPATCH 360/393 cpufreq: Reference count policy in cpufreq_update_limits()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit 9e4e249018d208678888bdf22f6b652728106528 upstream.
Since acpi_processor_notify() can be called before registering a cpufreq driver or even in cases when a cpufreq driver is not registered at all, cpufreq_update_limits() needs to check if a cpufreq driver is present and prevent it from being unregistered.
For this purpose, make it call cpufreq_cpu_get() to obtain a cpufreq policy pointer for the given CPU and reference count the corresponding policy object, if present.
--- drivers/cpufreq/cpufreq.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/cpufreq/cpufreq.c +8 -0
@@ -2743,10 +2743,18 @@ EXPORT_SYMBOL(cpufreq_update_policy);*/ void cpufreq_update_limits (unsigned int cpu) { +struct cpufreq_policy *policy; + + policy =cpufreq_cpu_get (cpu); +if (!policy) +return ; +if (cpufreq_driver->update_limits) cpufreq_driver->update_limits (cpu);else cpufreq_update_policy (cpu); + +cpufreq_cpu_put (policy); }EXPORT_SYMBOL_GPL (cpufreq_update_limits);
Greg Kroah-Hartman
maintainerPATCH 361/393 kbuild: Add -fno-builtin-wcslen
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 84ffc79bfbf70c779e60218563f2f3ad45288671 upstream.
A recent optimization change in LLVM [1] aims to transform certain loop idioms into calls to strlen() or wcslen(). This change transforms the first while loop in UniStrcat() into a call to wcslen(), breaking the build when UniStrcat() gets inlined into alloc_path_with_tree_prefix():
ld.lld: error: undefined symbol: wcslen
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
referenced by nls_ucs2_utils.h:54 (
fs/smb/client/../../nls/nls_ucs2_utils.h:54)
vmlinux.o:(alloc_path_with_tree_prefix)
referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
vmlinux.o:(alloc_path_with_tree_prefix)
Disable this optimization with '-fno-builtin-wcslen', which prevents the compiler from assuming that wcslen() is available in the kernel's C library.
[ More to the point - it's not that we couldn't implement wcslen(), it's
that this isn't an optimization at all in the context of the kernel.
Replacing a simple inlined loop with a function call to the same loop is just stupid and pointless if you don't have long strings and fancy libraries with vectorization support etc.
For the regular 'strlen()' cases, we want the compiler to do this in order to handle the trivial case of constant strings. And we do have optimized versions of 'strlen()' on some architectures. But for
wcslen? Just no. - Linus ]
--- Makefile | 3 +++ 1 file changed, 3 insertions(+)
Makefile +3 -0
@@ -1004,6 +1004,9 @@ ifdef CONFIG_CC_IS_GCC KBUILD_CFLAGS += -fconserve-stack endif +# Ensure compilers do not transform certain loops into calls to wcslen() +KBUILD_CFLAGS += -fno-builtin-wcslen + # change __FILE__ to the relative path from the srctree KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
Greg Kroah-Hartman
maintainerPATCH 362/393 md: fix mddev uaf while iterating all_mddevs list
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit 8542870237c3a48ff049b6c5df5f50c8728284fa upstream.
While iterating all_mddevs list from md_notify_reboot() and md_exit(), list_for_each_entry_safe is used, and this can race with deletint the next mddev, causing UAF:
t1:spin_lock
//list_for_each_entry_safe(mddev, n, ...)
mddev_get(mddev1)
// assume mddev2 is the next entry
spin_unlock
t2:
//remove mddev2
...
mddev_free
spin_lock
list_del
spin_unlock
kfree(mddev2) mddev_put(mddev1)
spin_lock
//continue dereference mddev2->all_mddevs
The old helper for_each_mddev() actually grab the reference of mddev2 while holding the lock, to prevent from being freed. This problem can be fixed the same way, however, the code will be complex.
Hence switch to use list_for_each_entry, in this case mddev_put() can free the mddev1 and it's not safe as well. Refer to md_seq_show(), also factor out a helper mddev_put_locked() to fix this problem.
--- drivers/md/md.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/md/md.c +13 -9
@@ -649,6 +649,12 @@ static void __mddev_put(struct mddev *mdqueue_work (md_misc_wq, &mddev->del_work); } +static void mddev_put_locked (struct mddev *mddev) +{ +if (atomic_dec_and_test (&mddev->active)) +__mddev_put (mddev); +} +void mddev_put (struct mddev *mddev) {if (!atomic_dec_and_lock (&mddev->active, &all_mddevs_lock))
@@ -8417,9 +8423,7 @@ static int md_seq_show(struct seq_file * if (mddev == list_last_entry(&all_mddevs, struct mddev, all_mddevs))status_unused (seq); -if (atomic_dec_and_test (&mddev->active)) -__mddev_put (mddev); - +mddev_put_locked (mddev);return 0 ; }
@@ -9699,11 +9703,11 @@ EXPORT_SYMBOL_GPL(rdev_clear_badblocks);static int md_notify_reboot (struct notifier_block *this,unsigned long code,void *x) { -struct mddev *mddev, *n; +struct mddev *mddev;int need_delay =0 ;spin_lock (&all_mddevs_lock); -list_for_each_entry_safe (mddev, n, &all_mddevs, all_mddevs) { +list_for_each_entry (mddev, &all_mddevs, all_mddevs) {if (!mddev_get (mddev))continue ;spin_unlock (&all_mddevs_lock);
@@ -9715,8 +9719,8 @@ static int md_notify_reboot(struct notifmddev_unlock (mddev); } need_delay =1 ; -mddev_put (mddev);spin_lock (&all_mddevs_lock); +mddev_put_locked (mddev); }spin_unlock (&all_mddevs_lock);
@@ -10039,7 +10043,7 @@ void md_autostart_arrays(int part) static __exit void md_exit(void) { -struct mddev *mddev, *n; +struct mddev *mddev;int delay =1 ;unregister_blkdev (MD_MAJOR ,"md" );
@@ -10060,7 +10064,7 @@ static __exit void md_exit(void)remove_proc_entry ("mdstat" ,NULL );spin_lock (&all_mddevs_lock); -list_for_each_entry_safe (mddev, n, &all_mddevs, all_mddevs) { +list_for_each_entry (mddev, &all_mddevs, all_mddevs) {if (!mddev_get (mddev))continue ;spin_unlock (&all_mddevs_lock);
@@ -10072,8 +10076,8 @@ static __exit void md_exit(void)* the mddev for destruction by a workqueue, and the * destroy_workqueue() below will wait for that to complete. */ -mddev_put (mddev);spin_lock (&all_mddevs_lock); +mddev_put_locked (mddev); }spin_unlock (&all_mddevs_lock);
Greg Kroah-Hartman
maintainerPATCH 363/393 mptcp: sockopt: fix getting freebind & transparent
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit e2f4ac7bab2205d3c4dd9464e6ffd82502177c51 upstream.
When adding a socket option support in MPTCP, both the get and set parts are supposed to be implemented.
IP(V6)_FREEBIND and IP(V6)_TRANSPARENT support for the setsockopt part has been added a while ago, but it looks like the get part got forgotten. It should have been present as a way to verify a setting has been set as expected, and not to act differently from TCP or any other socket types.
Everything was in place to expose it, just the last step was missing. Only new code is added to cover these specific getsockopt(), that seems safe.
[ Conflict in sockopt.c due to commit e08d0b3d1723 ("inet: implement
lockless IP_TOS") not being in this version. The conflict is in the context and the modification can still be applied in mptcp_getsockopt_v4() after the IP_TOS case. ]
--- net/mptcp/sockopt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/mptcp/sockopt.c +12 -0
@@ -1388,6 +1388,12 @@ static int mptcp_getsockopt_v4(struct mpswitch (optname) {case IP_TOS :return mptcp_put_int_option (msk, optval, optlen,inet_sk (sk)->tos); +case IP_FREEBIND : +return mptcp_put_int_option (msk, optval, optlen, +inet_test_bit (FREEBIND , sk)); +case IP_TRANSPARENT : +return mptcp_put_int_option (msk, optval, optlen, +inet_test_bit (TRANSPARENT , sk)); }return -EOPNOTSUPP ;
@@ -1402,6 +1408,12 @@ static int mptcp_getsockopt_v6(struct mpcase IPV6_V6ONLY :return mptcp_put_int_option (msk, optval, optlen, sk->sk_ipv6only); +case IPV6_TRANSPARENT : +return mptcp_put_int_option (msk, optval, optlen, +inet_test_bit (TRANSPARENT , sk)); +case IPV6_FREEBIND : +return mptcp_put_int_option (msk, optval, optlen, +inet_test_bit (FREEBIND , sk)); }return -EOPNOTSUPP ;
Greg Kroah-Hartman
maintainerPATCH 364/393 selftests: mptcp: add mptcp_lib_wait_local_port_listen
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
commit 9369777c29395730cec967e7d0f48aed872b7110 upstream.
To avoid duplicated code in different MPTCP selftests, we can add and use helpers defined in mptcp_lib.sh.
wait_local_port_listen() helper is defined in diag.sh, mptcp_connect.sh, mptcp_join.sh and simult_flows.sh, export it into mptcp_lib.sh and rename it with mptcp_lib_ prefix. Use this new helper in all these scripts.
Note: We only have IPv4 connections in this helper, not looking at IPv6 (tcp6) but that's OK because we only have IPv4 connections here in diag.sh.
Stable-dep-of: 5afca7e996c4 ("selftests: mptcp: join: test for prohibited MPC to port-based endp") [ Conflict in diag.sh, because commit 1f24ba67ba49 ("selftests: mptcp:
diag: check CURRESTAB counters") that is more recent that the one
here, has been backported in this kernel version before, introducing chk_msk_cestab() helper in the same context. wait_local_port_listen()
was still the same as in the original, and can then be simply removed
from diag.sh. ]
--- tools/testing/selftests/net/mptcp/diag.sh | 23 ++------------------- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 19 ----------------- tools/testing/selftests/net/mptcp/mptcp_join.sh | 20 ------------------ tools/testing/selftests/net/mptcp/mptcp_lib.sh | 18 ++++++++++++++++ tools/testing/selftests/net/mptcp/simult_flows.sh | 19 ----------------- 5 files changed, 24 insertions(+), 75 deletions(-)
tools/testing/selftests/net/mptcp/diag.sh +3 -20
@@ -186,23 +186,6 @@ chk_msk_inuse() __chk_nr get_msk_inuse $expected "${msg}" 0 } -# $1: ns, $2: port -wait_local_port_listen() -{ - local listener_ns="${1}" - local port="${2}" - - local port_hex i - - port_hex="$(printf "%04X" "${port}")" - for i in $(seq 10); do - ip netns exec "${listener_ns}" cat /proc/net/tcp | \ - awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" && - break - sleep 0.1 - done -} - # $1: cestab nr chk_msk_cestab() {
@@ -240,7 +223,7 @@ echo "a" | \ ip netns exec $ns \ ./mptcp_connect -p 10000 -l -t ${timeout_poll} -w 20 \ 0.0.0.0 >/dev/null & -wait_local_port_listen $ns 10000 +mptcp_lib_wait_local_port_listen $ns 10000 chk_msk_nr 0 "no msk on netns creation" chk_msk_listen 10000
@@ -265,7 +248,7 @@ echo "a" | \ ip netns exec $ns \ ./mptcp_connect -p 10001 -l -s TCP -t ${timeout_poll} -w 20 \ 0.0.0.0 >/dev/null & -wait_local_port_listen $ns 10001 +mptcp_lib_wait_local_port_listen $ns 10001 echo "b" | \ timeout ${timeout_test} \ ip netns exec $ns \
@@ -288,7 +271,7 @@ for I in `seq 1 $NR_CLIENTS`; do ./mptcp_connect -p $((I+10001)) -l -w 20 \ -t ${timeout_poll} 0.0.0.0 >/dev/null & done -wait_local_port_listen $ns $((NR_CLIENTS + 10001)) +mptcp_lib_wait_local_port_listen $ns $((NR_CLIENTS + 10001)) for I in `seq 1 $NR_CLIENTS`; do echo "b" | \
tools/testing/selftests/net/mptcp/mptcp_connect.sh +1 -18
@@ -342,23 +342,6 @@ do_ping() return 0 } -# $1: ns, $2: port -wait_local_port_listen() -{ - local listener_ns="${1}" - local port="${2}" - - local port_hex i - - port_hex="$(printf "%04X" "${port}")" - for i in $(seq 10); do - ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ - awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" && - break - sleep 0.1 - done -} - do_transfer() { local listener_ns="$1"
@@ -448,7 +431,7 @@ do_transfer() $extra_args $local_addr < "$sin" > "$sout" & local spid=$! - wait_local_port_listen "${listener_ns}" "${port}" + mptcp_lib_wait_local_port_listen "${listener_ns}" "${port}" local start start=$(date +%s%3N)
tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -19
@@ -598,24 +598,6 @@ link_failure() done } -# $1: ns, $2: port -wait_local_port_listen() -{ - local listener_ns="${1}" - local port="${2}" - - local port_hex - port_hex="$(printf "%04X" "${port}")" - - local i - for i in $(seq 10); do - ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ - awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" && - break - sleep 0.1 - done -} - rm_addr_count() { mptcp_lib_get_counter "${1}" "MPTcpExtRmAddr"
@@ -1117,7 +1099,7 @@ do_transfer() fi local spid=$! - wait_local_port_listen "${listener_ns}" "${port}" + mptcp_lib_wait_local_port_listen "${listener_ns}" "${port}" extra_cl_args="$extra_args $extra_cl_args" if [ "$test_linkfail" -eq 0 ];then
tools/testing/selftests/net/mptcp/mptcp_lib.sh +18 -0
@@ -274,3 +274,21 @@ mptcp_lib_events() { ip netns exec "${ns}" ./pm_nl_ctl events >> "${evts}" 2>&1 & pid=$! } + +# $1: ns, $2: port +mptcp_lib_wait_local_port_listen() { + local listener_ns="${1}" + local port="${2}" + + local port_hex + port_hex="$(printf "%04X" "${port}")" + + local _ + for _ in $(seq 10); do + ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ + awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) \ + {rc=0; exit}} END {exit rc}" && + break + sleep 0.1 + done +}
tools/testing/selftests/net/mptcp/simult_flows.sh +1 -18
@@ -123,23 +123,6 @@ setup() grep -q ' kmemleak_init$\| lockdep_init$\| kasan_init$\| prove_locking$' /proc/kallsyms && slack=$((slack+550)) } -# $1: ns, $2: port -wait_local_port_listen() -{ - local listener_ns="${1}" - local port="${2}" - - local port_hex i - - port_hex="$(printf "%04X" "${port}")" - for i in $(seq 10); do - ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ - awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" && - break - sleep 0.1 - done -} - do_transfer() { local cin=$1
@@ -179,7 +162,7 @@ do_transfer() 0.0.0.0 < "$sin" > "$sout" & local spid=$! - wait_local_port_listen "${ns3}" "${port}" + mptcp_lib_wait_local_port_listen "${ns3}" "${port}" timeout ${timeout_test} \ ip netns exec ${ns1} \
Greg Kroah-Hartman
maintainerPATCH 365/393 misc: pci_endpoint_test: Avoid issue of interrupts remaining after request_irq error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <[email protected]>
commit f6cb7828c8e17520d4f5afb416515d3fae1af9a9 upstream.
After devm_request_irq() fails with error in pci_endpoint_test_request_irq(), the pci_endpoint_test_free_irq_vectors() is called assuming that all IRQs have been released.
However, some requested IRQs remain unreleased, so there are still /proc/irq/* entries remaining, and this results in WARN() with the following message:
remove_proc_entry: removing non-empty directory 'irq/30', leaking at least 'pci-endpoint-test.0'
WARNING: CPU: 0 PID: 202 at fs/proc/generic.c:719 remove_proc_entry +0x190/0x19c
To solve this issue, set the number of remaining IRQs to test->num_irqs, and release IRQs in advance by calling pci_endpoint_test_release_irq().
--- drivers/misc/pci_endpoint_test.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/pci_endpoint_test.c +3 -0
@@ -260,6 +260,9 @@ fail:break ; } + test->num_irqs = i; +pci_endpoint_test_release_irq (test); +return false; }
Greg Kroah-Hartman
maintainerPATCH 366/393 misc: pci_endpoint_test: Fix displaying irq_type after request_irq error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <[email protected]>
commit 919d14603dab6a9cf03ebbeb2cfa556df48737c8 upstream.
There are two variables that indicate the interrupt type to be used in the next test execution, global "irq_type" and "test->irq_type".
The former is referenced from pci_endpoint_test_get_irq() to preserve the current type for ioctl(PCITEST_GET_IRQTYPE).
In the pci_endpoint_test_request_irq(), since this global variable is referenced when an error occurs, the unintended error message is displayed.
For example, after running "pcitest -i 2", the following message shows "MSI 3" even if the current IRQ type becomes "MSI-X":
pci-endpoint-test 0000:01:00.0: Failed to request IRQ 30 for MSI 3
SET IRQ TYPE TO MSI-X: NOT OKAY
Fix this issue by using "test->irq_type" instead of global "irq_type".
--- drivers/misc/pci_endpoint_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/pci_endpoint_test.c +1 -1
@@ -243,7 +243,7 @@ static bool pci_endpoint_test_request_irreturn true; fail: -switch (irq_type) { +switch (test->irq_type) {case IRQ_TYPE_LEGACY :dev_err (dev,"Failed to request IRQ %d for Legacy\n" ,pci_irq_vector (pdev, i));
Greg Kroah-Hartman
maintainerPATCH 367/393 misc: pci_endpoint_test: Fix irq_type to convey the correct type
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <[email protected]>
commit baaef0a274cfb75f9b50eab3ef93205e604f662c upstream.
There are two variables that indicate the interrupt type to be used in the next test execution, "irq_type" as global and "test->irq_type".
The global is referenced from pci_endpoint_test_get_irq() to preserve the current type for ioctl(PCITEST_GET_IRQTYPE).
The type set in this function isn't reflected in the global "irq_type", so ioctl(PCITEST_GET_IRQTYPE) returns the previous type.
As a result, the wrong type is displayed in old version of "pcitest" as follows:
- Result of running "pcitest -i 0"
SET IRQ TYPE TO LEGACY: OKAY
- Result of running "pcitest -I"
GET IRQ TYPE: MSI
Whereas running the new version of "pcitest" in kselftest results in an error as follows:
# RUN pci_ep_basic.LEGACY_IRQ_TEST ...
# pci_endpoint_test.c:104:LEGACY_IRQ_TEST:Expected 0 (0) == ret (1) # pci_endpoint_test.c:104:LEGACY_IRQ_TEST:Can't get Legacy IRQ type
Fix this issue by propagating the current type to the global "irq_type".
--- drivers/misc/pci_endpoint_test.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/pci_endpoint_test.c +1 -0
@@ -711,6 +711,7 @@ static bool pci_endpoint_test_set_irq(stif (!pci_endpoint_test_request_irq (test)) goto err; + irq_type = test->irq_type;return true; err:
Greg Kroah-Hartman
maintainerPATCH 368/393 Fix mmu notifiers for range-based invalidates
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Piotr Jaroszynski <[email protected]>
commit f7edb07ad7c66eab3dce57384f33b9799d579133 upstream.
Update the __flush_tlb_range_op macro not to modify its parameters as these are unexepcted semantics. In practice, this fixes the call to mmu_notifier_arch_invalidate_secondary_tlbs() in __flush_tlb_range_nosync() to use the correct range instead of an empty range with start=end. The empty range was (un)lucky as it results in taking the invalidate-all path that doesn't cause correctness issues, but can certainly result in suboptimal perf.
This has been broken since commit 6bbd42e2df8f ("mmu_notifiers: call invalidate_range() when invalidating TLBs") when the call to the notifiers was added to __flush_tlb_range(). It predates the addition of the __flush_tlb_range_op() macro from commit 360839027a6e ("arm64: tlb:
Refactor the core flush algorithm of __flush_tlb_range") that made the bug hard to spot.
--- arch/arm64/include/asm/tlbflush.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
arch/arm64/include/asm/tlbflush.h +12 -10
@@ -369,31 +369,33 @@ static inline void arch_tlbbatch_flush(s#define __flush_tlb_range_op (op, start, pages, stride, \ asid, tlb_level, tlbi_user) \ do { \ + typeof(start) __flush_start = start; \ + typeof(pages) __flush_pages = pages; \ int num = 0; \ int scale = 3; \ unsigned long addr; \ \ - while (pages > 0) { \ + while (__flush_pages > 0) { \ if (!system_supports_tlb_range() || \ - pages == 1) { \ - addr = __TLBI_VADDR(start, asid); \ + __flush_pages == 1) { \ + addr = __TLBI_VADDR(__flush_start, asid); \ __tlbi_level(op, addr, tlb_level); \ if (tlbi_user) \ __tlbi_user_level(op, addr, tlb_level); \ - start += stride; \ - pages -= stride >> PAGE_SHIFT; \ + __flush_start += stride; \ + __flush_pages -= stride >> PAGE_SHIFT; \ continue; \ } \ \ - num = __TLBI_RANGE_NUM(pages, scale); \ + num = __TLBI_RANGE_NUM(__flush_pages, scale); \ if (num >= 0) { \ - addr = __TLBI_VADDR_RANGE(start, asid, scale, \ - num, tlb_level); \ + addr = __TLBI_VADDR_RANGE(__flush_start, asid, \ + scale, num, tlb_level); \ __tlbi(r##op, addr); \ if (tlbi_user) \ __tlbi_user(r##op, addr); \ - start += __TLBI_RANGE_PAGES(num, scale) << PAGE_SHIFT; \ - pages -= __TLBI_RANGE_PAGES(num, scale); \ + __flush_start += __TLBI_RANGE_PAGES(num, scale) << PAGE_SHIFT; \ + __flush_pages -= __TLBI_RANGE_PAGES(num, scale);\ } \ scale--; \ } \
Greg Kroah-Hartman
maintainerPATCH 369/393 efi/libstub: Bump up EFI_MMAP_NR_SLACK_SLOTS to 32
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hamza Mahfooz <[email protected]>
commit ec4696925da6b9baec38345184403ce9e29a2e48 upstream.
Recent platforms require more slack slots than the current value of EFI_MMAP_NR_SLACK_SLOTS, otherwise they fail to boot. The current workaround is to append efi=disable_early_pci_dma to the kernel's cmdline. So, bump up EFI_MMAP_NR_SLACK_SLOTS to 32 to allow those platforms to boot with the aforementioned workaround.
--- drivers/firmware/efi/libstub/efistub.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/efistub.h +1 -1
@@ -171,7 +171,7 @@ void efi_set_u64_split(u64 data, u32 *lo* the EFI memory map. Other related structures, e.g. x86 e820ext, need * to factor in this headroom requirement as well. */ -#define EFI_MMAP_NR_SLACK_SLOTS 8 +#define EFI_MMAP_NR_SLACK_SLOTS 32typedef struct efi_generic_dev_path efi_device_path_protocol_t ;
Greg Kroah-Hartman
maintainerPATCH 370/393 x86/xen: move xen_reserve_extra_memory()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roger Pau Monne <[email protected]>
commit fc05ea89c9ab45e70cb73e70bc0b9cdd403e0ee1 upstream.
In preparation for making the function static.
No functional change.
Message-ID: <[email protected]>
--- arch/x86/xen/enlighten_pvh.c | 82 +++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 41 deletions(-)
arch/x86/xen/enlighten_pvh.c +41 -41
@@ -26,47 +26,6 @@bool __ro_after_init xen_pvh;EXPORT_SYMBOL_GPL (xen_pvh); -void __init xen_pvh_init (struct boot_params *boot_params) -{ - xen_pvh =1 ; - xen_domain_type =XEN_HVM_DOMAIN ; - xen_start_flags = pvh_start_info.flags; - -if (xen_initial_domain ()) - x86_init.oem.arch_setup = xen_add_preferred_consoles; - x86_init.oem.banner = xen_banner; - -xen_efi_init (boot_params); - -if (xen_initial_domain ()) { -struct xen_platform_op op = { - .cmd = XENPF_get_dom0_console, - }; -int ret =HYPERVISOR_platform_op (&op); - -if (ret >0 ) -xen_init_vga (&op.u.dom0_console, -min (ret *sizeof (char ), -sizeof (op.u.dom0_console)), - &boot_params->screen_info); - } -} - -void __init mem_map_via_hcall (struct boot_params *boot_params_p) -{ -struct xen_memory_map memmap; -int rc; - - memmap.nr_entries =ARRAY_SIZE (boot_params_p->e820_table); -set_xen_guest_handle (memmap.buffer, boot_params_p->e820_table); - rc =HYPERVISOR_memory_op (XENMEM_memory_map, &memmap); -if (rc) { -xen_raw_printk ("XENMEM_memory_map failed (%d)\n" , rc); -BUG (); - } - boot_params_p->e820_entries = memmap.nr_entries; -} -/* * Reserve e820 UNUSABLE regions to inflate the memory balloon. *
@@ -133,3 +92,44 @@ void __init xen_reserve_extra_memory(strxen_add_extra_mem (PFN_UP (e->addr), pages); } } + +void __init xen_pvh_init (struct boot_params *boot_params) +{ + xen_pvh =1 ; + xen_domain_type =XEN_HVM_DOMAIN ; + xen_start_flags = pvh_start_info.flags; + +if (xen_initial_domain ()) + x86_init.oem.arch_setup = xen_add_preferred_consoles; + x86_init.oem.banner = xen_banner; + +xen_efi_init (boot_params); + +if (xen_initial_domain ()) { +struct xen_platform_op op = { + .cmd = XENPF_get_dom0_console, + }; +int ret =HYPERVISOR_platform_op (&op); + +if (ret >0 ) +xen_init_vga (&op.u.dom0_console, +min (ret *sizeof (char ), +sizeof (op.u.dom0_console)), + &boot_params->screen_info); + } +} + +void __init mem_map_via_hcall (struct boot_params *boot_params_p) +{ +struct xen_memory_map memmap; +int rc; + + memmap.nr_entries =ARRAY_SIZE (boot_params_p->e820_table); +set_xen_guest_handle (memmap.buffer, boot_params_p->e820_table); + rc =HYPERVISOR_memory_op (XENMEM_memory_map, &memmap); +if (rc) { +xen_raw_printk ("XENMEM_memory_map failed (%d)\n" , rc); +BUG (); + } + boot_params_p->e820_entries = memmap.nr_entries; +}
Greg Kroah-Hartman
maintainerPATCH 371/393 x86/xen: fix memblock_reserve() usage on PVH
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roger Pau Monne <[email protected]>
commit 4c006734898a113a64a528027274a571b04af95a upstream.
The current usage of memblock_reserve() in init_pvh_bootparams() is done before the .bss is zeroed, and that used to be fine when memblock_reserved_init_regions implicitly ended up in the .meminit.data section. However after commit 73db3abdca58c memblock_reserved_init_regions ends up in the .bss section, thus breaking it's usage before the .bss is cleared.
Move and rename the call to xen_reserve_extra_memory() so it's done in the x86_init.oem.arch_setup hook, which gets executed after the .bss has been zeroed, but before calling e820__memory_setup().
Message-ID: <[email protected]>
--- arch/x86/include/asm/xen/hypervisor.h | 5 ----- arch/x86/platform/pvh/enlighten.c | 3 --- arch/x86/xen/enlighten_pvh.c | 15 ++++++++++++--- 3 files changed, 12 insertions(+), 11 deletions(-)
arch/x86/include/asm/xen/hypervisor.h +0 -5
@@ -62,11 +62,6 @@ void xen_arch_unregister_cpu(int num);#ifdef CONFIG_PVH void __init xen_pvh_init (struct boot_params *boot_params);void __init mem_map_via_hcall (struct boot_params *boot_params_p); -#ifdef CONFIG_XEN_PVH -void __init xen_reserve_extra_memory (struct boot_params *bootp); -#else -static inline void xen_reserve_extra_memory (struct boot_params *bootp) { } -#endif #endif /* Lazy mode for batching updates / context switch */
arch/x86/platform/pvh/enlighten.c +0 -3
@@ -74,9 +74,6 @@ static void __init init_pvh_bootparams(b }else xen_raw_printk ("Warning: Can fit ISA range into e820\n" ); -if (xen_guest) -xen_reserve_extra_memory (&pvh_bootparams); - pvh_bootparams.hdr.cmd_line_ptr = pvh_start_info.cmdline_paddr;
arch/x86/xen/enlighten_pvh.c +12 -3
@@ -8,6 +8,7 @@#include <asm/io_apic.h> #include <asm/hypervisor.h> #include <asm/e820/api.h> +#include <asm/setup.h> #include <xen/xen.h> #include <asm/xen/interface.h>
@@ -40,8 +41,9 @@ EXPORT_SYMBOL_GPL(xen_pvh);* hypervisor should notify us which memory ranges are suitable for creating * foreign mappings, but that's not yet implemented. */ -void __init xen_reserve_extra_memory (struct boot_params *bootp) +static void __init pvh_reserve_extra_memory (void ) { +struct boot_params *bootp = &boot_params;unsigned int i, ram_pages =0 , extra_pages;for (i =0 ; i < bootp->e820_entries; i++) {
@@ -93,14 +95,21 @@ void __init xen_reserve_extra_memory(str } } +static void __init pvh_arch_setup (void ) +{ +pvh_reserve_extra_memory (); + +if (xen_initial_domain ()) +xen_add_preferred_consoles (); +} +void __init xen_pvh_init (struct boot_params *boot_params) { xen_pvh =1 ; xen_domain_type =XEN_HVM_DOMAIN ; xen_start_flags = pvh_start_info.flags; -if (xen_initial_domain ()) - x86_init.oem.arch_setup = xen_add_preferred_consoles; + x86_init.oem.arch_setup = pvh_arch_setup; x86_init.oem.banner = xen_banner;xen_efi_init (boot_params);
Greg Kroah-Hartman
maintainerPATCH 372/393 x86/tdx: Fix arch_safe_halt() execution for TDX VMs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishal Annapurve <[email protected]>
commit 9f98a4f4e7216dbe366010b4cdcab6b220f229c4 upstream.
Direct HLT instruction execution causes #VEs for TDX VMs which is routed to hypervisor via TDCALL. If HLT is executed in STI-shadow, resulting #VE handler will enable interrupts before TDCALL is routed to hypervisor leading to missed wakeup events, as current TDX spec doesn't expose interruptibility state information to allow #VE handler to selectively enable interrupts.
Commit bfe6ed0c6727 ("x86/tdx: Add HLT support for TDX guests") prevented the idle routines from executing HLT instruction in STI-shadow. But it missed the paravirt routine which can be reached via this path as an example:
kvm_wait() =>
safe_halt() =>
raw_safe_halt() =>
arch_safe_halt() =>
irq.safe_halt() =>
pv_native_safe_halt()To reliably handle arch_safe_halt() for TDX VMs, introduce explicit dependency on CONFIG_PARAVIRT and override paravirt halt()/safe_halt() routines with TDX-safe versions that execute direct TDCALL and needed interrupt flag updates. Executing direct TDCALL brings in additional benefit of avoiding HLT related #VEs altogether.
As tested by Ryan Afranji:
"Tested with the specjbb2015 benchmark. It has heavy lock contention which leads
to many halt calls. TDX VMs suffered a poor score before this patchset.
Verified the major performance improvement with this patchset applied."
--- arch/x86/Kconfig | 1 + arch/x86/coco/tdx/tdx.c | 26 +++++++++++++++++++++++++- arch/x86/include/asm/tdx.h | 4 ++-- arch/x86/kernel/process.c | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-)
arch/x86/Kconfig +1 -0
@@ -881,6 +881,7 @@ config INTEL_TDX_GUEST depends on X86_64 && CPU_SUP_INTEL depends on X86_X2APIC depends on EFI_STUB + depends on PARAVIRT select ARCH_HAS_CC_PLATFORM select X86_MEM_ENCRYPT select X86_MCE
arch/x86/coco/tdx/tdx.c +25 -1
@@ -13,6 +13,7 @@#include <asm/ia32.h> #include <asm/insn.h> #include <asm/insn-eval.h> +#include <asm/paravirt_types.h> #include <asm/pgtable.h> #include <asm/traps.h>
@@ -334,7 +335,7 @@ static int handle_halt(struct ve_info *vreturn ve_instr_len (ve); } -void __cpuidle tdx_safe_halt(void) +void __cpuidle tdx_halt(void) {const bool irq_disabled = false;
@@ -345,6 +346,16 @@ void __cpuidle tdx_safe_halt(void)WARN_ONCE (1 ,"HLT instruction emulation failed\n" ); } +static void __cpuidle tdx_safe_halt(void) +{ +tdx_halt (); +/* +* "__cpuidle" section doesn't support instrumentation, so stick +* with raw_* variant that avoids tracing hooks. +*/ +raw_local_irq_enable (); +} +static int read_msr (struct pt_regs *regs,struct ve_info *ve) {struct tdx_hypercall_args args = {
@@ -889,6 +900,19 @@ void __init tdx_early_init(void) x86_platform.guest.enc_tlb_flush_required = tdx_tlb_flush_required;/* +* Avoid "sti;hlt" execution in TDX guests as HLT induces a #VE that +* will enable interrupts before HLT TDCALL invocation if executed +* in STI-shadow, possibly resulting in missed wakeup events. +* +* Modify all possible HLT execution paths to use TDX specific routines +* that directly execute TDCALL and toggle the interrupt state as +* needed after TDCALL completion. This also reduces HLT related #VEs +* in addition to having a reliable halt logic execution. +*/ + pv_ops.irq.safe_halt = tdx_safe_halt; + pv_ops.irq.halt = tdx_halt; + +/* * TDX intercepts the RDMSR to read the X2APIC ID in the parallel * bringup low level code. That raises #VE which cannot be handled * there.
arch/x86/include/asm/tdx.h +2 -2
@@ -46,7 +46,7 @@ void tdx_get_ve_info(struct ve_info *ve)bool tdx_handle_virt_exception (struct pt_regs *regs,struct ve_info *ve); -void tdx_safe_halt (void ); +void tdx_halt (void );bool tdx_early_handle_ve (struct pt_regs *regs);
@@ -55,7 +55,7 @@ int tdx_mcall_get_report0(u8 *reportdata#else static inline void tdx_early_init (void ) { }; -static inline void tdx_safe_halt (void ) { }; +static inline void tdx_halt (void ) { };static inline bool tdx_early_handle_ve (struct pt_regs *regs) {return false; }
arch/x86/kernel/process.c +1 -1
@@ -955,7 +955,7 @@ void select_idle_routine(const struct cpstatic_call_update (x86_idle, mwait_idle); }else if (cpu_feature_enabled (X86_FEATURE_TDX_GUEST )) {pr_info ("using TDX aware idle routine\n" ); -static_call_update (x86_idle, tdx_safe_halt); +static_call_update (x86_idle, tdx_halt); }else static_call_update (x86_idle, default_idle); }
Greg Kroah-Hartman
maintainerPATCH 373/393 x86/split_lock: Fix the delayed detection logic
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maksim Davydov <[email protected]>
commit c929d08df8bee855528b9d15b853c892c54e1eee upstream.
If the warning mode with disabled mitigation mode is used, then on each CPU where the split lock occurred detection will be disabled in order to make progress and delayed work will be scheduled, which then will enable detection back.
Now it turns out that all CPUs use one global delayed work structure. This leads to the fact that if a split lock occurs on several CPUs at the same time (within 2 jiffies), only one CPU will schedule delayed work, but the rest will not.
The return value of schedule_delayed_work_on() would have shown this, but it is not checked in the code.
A diagram that can help to understand the bug reproduction:
- sld_update_msr() enables/disables SLD on both CPUs on the same core
- schedule_delayed_work_on() internally checks WORK_STRUCT_PENDING_BIT. If a work has the 'pending' status, then schedule_delayed_work_on() will return an error code and, most importantly, the work will not be placed in the workqueue.
Let's say we have a multicore system on which split_lock_mitigate=0 and a multithreaded application is running that calls splitlock in multiple threads. Due to the fact that sld_update_msr() affects the entire core (both CPUs), we will consider 2 CPUs from different cores. Let the 2 threads of this application schedule to CPU0 (core 0) and to CPU 2 (core 1), then:
| || | | CPU 0 (core 0) || CPU 2 (core 1) | |_________________________________||___________________________________| | || | | 1) SPLIT LOCK occured || | | || | | 2) split_lock_warn() || | | || | | 3) sysctl_sld_mitigate == 0 || | | (work = &sl_reenable) || | | || | | 4) schedule_delayed_work_on() || | | (reenable will be called || | | after 2 jiffies on CPU 0) || | | || | | 5) disable SLD for core 0 || | | || | | ------------------------- || | | || | | || 6) SPLIT LOCK occured | | || | | || 7) split_lock_warn() | | || | | || 8) sysctl_sld_mitigate == 0 | | || (work = &sl_reenable, | | || the same address as in 3) ) | | || | | 2 jiffies || 9) schedule_delayed_work_on() | | || fials because the work is in | | || the pending state since 4). | | || The work wasn't placed to the | | || workqueue. reenable won't be | | || called on CPU 2 | | || | | || 10) disable SLD for core 0 | | || | | || From now on SLD will | | || never be reenabled on core 1 | | || | | ------------------------- || | | || | | 11) enable SLD for core 0 by || | | __split_lock_reenable || | | || |
If the application threads can be scheduled to all processor cores, then over time there will be only one core left, on which SLD will be enabled and split lock will be able to be detected; and on all other cores SLD will be disabled all the time.
Most likely, this bug has not been noticed for so long because sysctl_sld_mitigate default value is 1, and in this case a semaphore is used that does not allow 2 different cores to have SLD disabled at the same time, that is, strictly only one work is placed in the workqueue.
In order to fix the warning mode with disabled mitigation mode, delayed work has to be per-CPU. Implement it.
--- arch/x86/kernel/cpu/intel.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/intel.c +16 -4
@@ -1168,7 +1168,13 @@ static void __split_lock_reenable(struct {sld_update_msr (true); } -static DECLARE_DELAYED_WORK(sl_reenable, __split_lock_reenable); +/* +* In order for each CPU to schedule its delayed work independently of the +* others, delayed work struct must be per-CPU. This is not required when +* sysctl_sld_mitigate is enabled because of the semaphore that limits +* the number of simultaneously scheduled delayed works to 1. +*/ +static DEFINE_PER_CPU(struct delayed_work, sl_reenable);/* * If a CPU goes offline with pending delayed work to re-enable split lock
@@ -1189,7 +1195,7 @@ static int splitlock_cpu_offline(unsignestatic void split_lock_warn (unsigned long ip) { -struct delayed_work *work; +struct delayed_work *work =NULL ;int cpu;if (!current->reported_split_lock)
@@ -1211,11 +1217,17 @@ static void split_lock_warn(unsigned lonif (down_interruptible (&buslock_sem) == -EINTR )return ; work = &sl_reenable_unlock; - }else { - work = &sl_reenable; } cpu =get_cpu (); + +if (!work) { + work =this_cpu_ptr (&sl_reenable); +/* Deferred initialization of per-CPU struct */ +if (!work->work.func) +INIT_DELAYED_WORK (work, __split_lock_reenable); + } +schedule_delayed_work_on (cpu, work,2 );/* Disable split lock detection on this CPU to make progress */
Greg Kroah-Hartman
maintainerPATCH 374/393 nvme-rdma: unquiesce admin_q before destroy it
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chunguang.xu <[email protected]>
commit 5858b687559809f05393af745cbadf06dee61295 upstream.
Kernel will hang on destroy admin_q while we create ctrl failed, such as following calltrace:
PID: 23644 TASK: ff2d52b40f439fc0 CPU: 2 COMMAND: "nvme"
#0 [ff61d23de260fb78] __schedule at ffffffff8323bc15
#1 [ff61d23de260fc08] schedule at ffffffff8323c014
#2 [ff61d23de260fc28] blk_mq_freeze_queue_wait at ffffffff82a3dba1 #3 [ff61d23de260fc78] blk_freeze_queue at ffffffff82a4113a #4 [ff61d23de260fc90] blk_cleanup_queue at ffffffff82a33006 #5 [ff61d23de260fcb0] nvme_rdma_destroy_admin_queue at ffffffffc12686ce #6 [ff61d23de260fcc8] nvme_rdma_setup_ctrl at ffffffffc1268ced #7 [ff61d23de260fd28] nvme_rdma_create_ctrl at ffffffffc126919b #8 [ff61d23de260fd68] nvmf_dev_write at ffffffffc024f362
#9 [ff61d23de260fe38] vfs_write at ffffffff827d5f25
RIP: 00007fda7891d574 RSP: 00007ffe2ef06958 RFLAGS: 00000202
RAX: ffffffffffffffda RBX: 000055e8122a4d90 RCX: 00007fda7891d574
RDX: 000000000000012b RSI: 000055e8122a4d90 RDI: 0000000000000004
RBP: 00007ffe2ef079c0 R8: 000000000000012b R9: 000055e8122a4d90
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000004
R13: 000055e8122923c0 R14: 000000000000012b R15: 00007fda78a54500
ORIG_RAX: 0000000000000001 CS: 0033 SS: 002bThis due to we have quiesced admi_q before cancel requests, but forgot to unquiesce before destroy it, as a result we fail to drain the pending requests, and hang on blk_mq_freeze_queue_wait() forever. Here try to reuse nvme_rdma_teardown_admin_queue() to fix this issue and simplify the code.
--- drivers/nvme/host/rdma.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/nvme/host/rdma.c +1 -7
@@ -1083,13 +1083,7 @@ destroy_io:nvme_rdma_free_io_queues (ctrl); } destroy_admin: -nvme_quiesce_admin_queue (&ctrl->ctrl); -blk_sync_queue (ctrl->ctrl.admin_q); -nvme_rdma_stop_queue (&ctrl->queues[0 ]); -nvme_cancel_admin_tagset (&ctrl->ctrl); -if (new) -nvme_remove_admin_tag_set (&ctrl->ctrl); -nvme_rdma_destroy_admin_queue (ctrl); +nvme_rdma_teardown_admin_queue (ctrl, new);return ret; }
Greg Kroah-Hartman
maintainerPATCH 375/393 powerpc/rtas: Prevent Spectre v1 gadget construction in sys_rtas()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Lynch <[email protected]>
commit 0974d03eb479384466d828d65637814bee6b26d7 upstream.
Smatch warns:
arch/powerpc/kernel/rtas.c:1932 __do_sys_rtas() warn: potential spectre issue 'args.args' [r] (local cap)
The 'nargs' and 'nret' locals come directly from a user-supplied buffer and are used as indexes into a small stack-based array and as inputs to copy_to_user() after they are subject to bounds checks.
Use array_index_nospec() after the bounds checks to clamp these values for speculative execution.
--- arch/powerpc/kernel/rtas.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/kernel/rtas.c +4 -0
@@ -18,6 +18,7 @@#include <linux/kernel.h> #include <linux/lockdep.h> #include <linux/memblock.h> +#include <linux/nospec.h> #include <linux/of.h> #include <linux/of_fdt.h> #include <linux/reboot.h>
@@ -1839,6 +1840,9 @@ SYSCALL_DEFINE1(rtas, struct rtas_args _ || nargs + nret > ARRAY_SIZE(args.args))return -EINVAL ; + nargs =array_index_nospec (nargs,ARRAY_SIZE (args.args)); + nret =array_index_nospec (nret,ARRAY_SIZE (args.args) - nargs); +/* Copy in args. */ if (copy_from_user (args.args, uargs->args, nargs *sizeof (rtas_arg_t)) !=0 )
Greg Kroah-Hartman
maintainerPATCH 376/393 LoongArch: Eliminate superfluous get_numa_distances_cnt()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuli Wang <[email protected]>
commit a0d3c8bcb9206ac207c7ad3182027c6b0a1319bb upstream.
In LoongArch, get_numa_distances_cnt() isn't in use, resulting in a compiler warning.
Fix follow errors with clang-18 when W=1e:
arch/loongarch/kernel/acpi.c:259:28: error: unused function 'get_numa_distances_cnt' [-Werror,-Wunused-function]
259 | static inline unsigned int get_numa_distances_cnt(struct acpi_table_slit *slit)
| ^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
--- arch/loongarch/kernel/acpi.c | 12 ------------ 1 file changed, 12 deletions(-)
arch/loongarch/kernel/acpi.c +0 -12
@@ -216,18 +216,6 @@ static __init int setup_node(int pxm)return acpi_map_pxm_to_node (pxm); } -/* -* Callback for SLIT parsing. pxm_to_node() returns NUMA_NO_NODE for -* I/O localities since SRAT does not list them. I/O localities are -* not supported at this point. -*/ -unsigned int numa_distance_cnt; - -static inline unsigned int get_numa_distances_cnt (struct acpi_table_slit *slit) -{ -return slit->locality_count; -} -void __init numa_set_distance (int from,int to,int distance) {if ((u8 )distance != distance || (from == to && distance !=LOCAL_DISTANCE )) {
Greg Kroah-Hartman
maintainerPATCH 377/393 usb: typec: fix potential array underflow in ucsi_ccg_sync_control()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit e56aac6e5a25630645607b6856d4b2a17b2311a5 upstream.
The "command" variable can be controlled by the user via debugfs. The worry is that if con_index is zero then "&uc->ucsi->connector[con_index
- 1]" would be an array underflow.
[Minor context change fixed.
13f2ec3115c8 ("usb: typec: ucsi: simplify command sending API") rename ucsi_ccg_sync_write to ucsi_ccg_sync_control in v6.11, so this patch is applied in ucsi_ccg_sync_write in v6.6.]
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +5 -0
@@ -585,6 +585,10 @@ static int ucsi_ccg_sync_write(struct uc uc->has_multiple_dp) { con_index = (uc->last_cmd_sent >>16 ) &UCSI_CMD_CONNECTOR_MASK ; +if (con_index ==0 ) { + ret = -EINVAL ; + goto unlock; + } con = &uc->ucsi->connector[con_index -1 ];ucsi_ccg_update_set_new_cam_cmd (uc, con, (u64 *)val); }
@@ -600,6 +604,7 @@ static int ucsi_ccg_sync_write(struct uc err_clear_bit:clear_bit (DEV_CMD_PENDING , &uc->flags);pm_runtime_put_sync (uc->dev); +unlock:mutex_unlock (&uc->lock);return ret;
Greg Kroah-Hartman
maintainerPATCH 378/393 usb: typec: fix pm usage counter imbalance in ucsi_ccg_sync_control()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: GONG Ruiqi <[email protected]>
commit b0e525d7a22ea350e75e2aec22e47fcfafa4cacd upstream.
The error handling for the case con_index == 0 should involve dropping the pm usage counter, as ucsi_ccg_sync_control() gets it at the beginning. Fix it.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +2 -2
@@ -587,7 +587,7 @@ static int ucsi_ccg_sync_write(struct ucUCSI_CMD_CONNECTOR_MASK ;if (con_index ==0 ) { ret = -EINVAL ; - goto unlock; + goto err_put; } con = &uc->ucsi->connector[con_index -1 ];ucsi_ccg_update_set_new_cam_cmd (uc, con, (u64 *)val);
@@ -603,8 +603,8 @@ static int ucsi_ccg_sync_write(struct uc err_clear_bit:clear_bit (DEV_CMD_PENDING , &uc->flags); +err_put:pm_runtime_put_sync (uc->dev); -unlock:mutex_unlock (&uc->lock);return ret;
Greg Kroah-Hartman
maintainerPATCH 379/393 btrfs: fix qgroup reserve leaks in cow_file_range
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <[email protected]>
commit 30479f31d44d47ed00ae0c7453d9b253537005b2 upstream.
In the buffered write path, the dirty page owns the qgroup reserve until it creates an ordered_extent.
Therefore, any errors that occur before the ordered_extent is created must free that reservation, or else the space is leaked. The fstest generic/475 exercises various IO error paths, and is able to trigger errors in cow_file_range where we fail to get to allocating the ordered extent. Note that because we *do* clear delalloc, we are likely to remove the inode from the delalloc list, so the inodes/pages to not have invalidate/launder called on them in the commit abort path.
This results in failures at the unmount stage of the test that look like:
BTRFS: error (device dm-8 state EA) in cleanup_transaction:2018: errno=-5 IO failure
BTRFS: error (device dm-8 state EA) in btrfs_replace_file_extents:2416: errno=-5 IO failure BTRFS warning (device dm-8 state EA): qgroup 0/5 has unreleased space, type 0 rsv 28672
------------[ cut here ]------------ WARNING: CPU: 3 PID: 22588 at fs/btrfs/disk-io.c:4333 close_ctree+0x222/0x4d0 [btrfs] Modules linked in: btrfs blake2b_generic libcrc32c xor zstd_compress raid6_pq CPU: 3 PID: 22588 Comm: umount Kdump: loaded Tainted: G W 6.10.0-rc7-gab56fde445b8 #21 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Arch Linux 1.16.3-1-1 04/01/2014 RIP: 0010:close_ctree+0x222/0x4d0 [btrfs] RSP: 0018:ffffb4465283be00 EFLAGS: 00010202 RAX: 0000000000000001 RBX: ffffa1a1818e1000 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffffb4465283bbe0 RDI: ffffa1a19374fcb8 RBP: ffffa1a1818e13c0 R08: 0000000100028b16 R09: 0000000000000000 R10: 0000000000000003 R11: 0000000000000003 R12: ffffa1a18ad7972c R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 FS: 00007f9168312b80(0000) GS:ffffa1a4afcc0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f91683c9140 CR3: 000000010acaa000 CR4: 00000000000006f0 Call Trace: <TASK> ? close_ctree+0x222/0x4d0 [btrfs] ? __warn.cold+0x8e/0xea ? close_ctree+0x222/0x4d0 [btrfs] ? report_bug+0xff/0x140 ? handle_bug+0x3b/0x70 ? exc_invalid_op+0x17/0x70 ? asm_exc_invalid_op+0x1a/0x20 ? close_ctree+0x222/0x4d0 [btrfs] generic_shutdown_super+0x70/0x160 kill_anon_super+0x11/0x40 btrfs_kill_super+0x11/0x20 [btrfs] deactivate_locked_super+0x2e/0xa0 cleanup_mnt+0xb5/0x150 task_work_run+0x57/0x80 syscall_exit_to_user_mode+0x121/0x130 do_syscall_64+0xab/0x1a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f916847a887 ---[ end trace 0000000000000000 ]--- BTRFS error (device dm-8 state EA): qgroup reserved space leaked
Cases 2 and 3 in the out_reserve path both pertain to this type of leak and must free the reserved qgroup data. Because it is already an error path, I opted not to handle the possible errors in btrfs_free_qgroup_data.
--- fs/btrfs/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +5 -1
@@ -1546,6 +1546,7 @@ out_unlock: locked_page, clear_bits, page_ops); +btrfs_qgroup_free_data (inode,NULL , start, cur_alloc_size,NULL ); start += cur_alloc_size; }
@@ -1559,6 +1560,7 @@ out_unlock: clear_bits |=EXTENT_CLEAR_DATA_RESV ;extent_clear_unlock_delalloc (inode, start, end, locked_page, clear_bits, page_ops); +btrfs_qgroup_free_data (inode,NULL , start, cur_alloc_size,NULL ); }return ret; }
@@ -2222,13 +2224,15 @@ error:*/ if (cow_start != (u64)-1 ) cur_offset = cow_start; -if (cur_offset < end) +if (cur_offset < end) {extent_clear_unlock_delalloc (inode, cur_offset, end, locked_page,EXTENT_LOCKED |EXTENT_DELALLOC |EXTENT_DEFRAG |EXTENT_DO_ACCOUNTING ,PAGE_UNLOCK |PAGE_START_WRITEBACK |PAGE_END_WRITEBACK ); +btrfs_qgroup_free_data (inode,NULL , cur_offset, end - cur_offset +1 ,NULL ); + }btrfs_free_path (path);return ret; }
Greg Kroah-Hartman
maintainerPATCH 380/393 wifi: rtw89: pci: add pre_deinit to be called after probe complete
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ping-Ke Shih <[email protected]>
commit 9e1aff437a560cd72cb6a60ee33fe162b0afdaf1 upstream.
At probe stage, we only do partial initialization to enable ability to download firmware and read capabilities. After that, we use this pre_deinit to disable HCI to save power.
[ Zenm: The rtw89 driver in recent kernel versions supports both Wi-Fi 6/6E
and Wi-Fi 7, however the rtw89 driver in kernel 6.6 supports Wi-Fi 6/6E only, so remove the unnecessary code for Wi-Fi 7 from the upstream patch to make it apply on 6.6.y. ]
--- drivers/net/wireless/realtek/rtw89/core.c | 2 ++ drivers/net/wireless/realtek/rtw89/core.h | 6 ++++++ drivers/net/wireless/realtek/rtw89/pci.c | 8 ++++++++ 3 files changed, 16 insertions(+)
drivers/net/wireless/realtek/rtw89/core.c +2 -0
@@ -3807,6 +3807,8 @@ static int rtw89_chip_efuse_info_setup(srtw89_core_setup_phycap (rtwdev);rtw89_core_setup_rfe_parms (rtwdev); +rtw89_hci_mac_pre_deinit (rtwdev); +rtw89_mac_pwr_off (rtwdev);return 0 ;
drivers/net/wireless/realtek/rtw89/core.h +6 -0
@@ -2989,6 +2989,7 @@ struct rtw89_hci_ops {void (*write32)(struct rtw89_dev *rtwdev,u32 addr,u32 data);int (*mac_pre_init)(struct rtw89_dev *rtwdev); +int (*mac_pre_deinit)(struct rtw89_dev *rtwdev);int (*mac_post_init)(struct rtw89_dev *rtwdev);int (*deinit)(struct rtw89_dev *rtwdev);
@@ -4515,6 +4516,11 @@ static inline void rtw89_hci_tx_kick_offreturn rtwdev->hci.ops->tx_kick_off (rtwdev, txch); } +static inline int rtw89_hci_mac_pre_deinit (struct rtw89_dev *rtwdev) +{ +return rtwdev->hci.ops->mac_pre_deinit (rtwdev); +} +static inline void rtw89_hci_flush_queues (struct rtw89_dev *rtwdev,u32 queues,bool drop) {
drivers/net/wireless/realtek/rtw89/pci.c +8 -0
@@ -2568,6 +2568,13 @@ static int rtw89_pci_ops_mac_pre_init(streturn 0 ; } +static int rtw89_pci_ops_mac_pre_deinit (struct rtw89_dev *rtwdev) +{ +rtw89_pci_power_wake (rtwdev, false); + +return 0 ; +} +int rtw89_pci_ltr_set (struct rtw89_dev *rtwdev,bool en) {u32 val;
@@ -3812,6 +3819,7 @@ static const struct rtw89_hci_ops rtw89_ .write32 = rtw89_pci_ops_write32, .mac_pre_init = rtw89_pci_ops_mac_pre_init, + .mac_pre_deinit = rtw89_pci_ops_mac_pre_deinit, .mac_post_init = rtw89_pci_ops_mac_post_init, .deinit = rtw89_pci_ops_deinit,
Greg Kroah-Hartman
maintainerPATCH 381/393 wifi: rtw89: pci: disable PCIE wake bit when PCIE deinit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ping-Ke Shih <[email protected]>
commit 9c1df813e08832c3836c254bc8a2f83ff22dbc06 upstream.
The PCIE wake bit is to control PCIE wake signal to host. When PCIE is going down, clear this bit to prevent waking up host unexpectedly.
[ Zenm: The rtw89 driver in recent kernel versions supports both Wi-Fi 6/6E
and Wi-Fi 7, however the rtw89 driver in kernel 6.6 supports Wi-Fi 6/6E only, so remove the unnecessary code for Wi-Fi 7 from the upstream patch to make it apply on 6.6.y. ]
--- drivers/net/wireless/realtek/rtw89/pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/realtek/rtw89/pci.c +2 -0
@@ -2482,6 +2482,8 @@ static int rtw89_pci_ops_deinit(struct r {const struct rtw89_pci_info *info = rtwdev->pci_info; +rtw89_pci_power_wake (rtwdev, false); +if (rtwdev->chip->chip_id ==RTL8852A ) {/* ltr sw trigger */ rtw89_write32_set (rtwdev,R_AX_LTR_CTRL_0 ,B_AX_APP_LTR_IDLE );
Greg Kroah-Hartman
maintainerPATCH 382/393 drm/amd/display: Stop amdgpu_dm initialize when link nums greater than max_links
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hersen Wu <[email protected]>
commit cf8b16857db702ceb8d52f9219a4613363e2b1cf upstream.
[Why]
Coverity report OVERRUN warning. There are only max_links elements within dc->links. link count could up to AMDGPU_DM_MAX_DISPLAY_INDEX 31.
[How]
Make sure link count less than max_links.
[Minor conflict resolved due to code context change. And the macro MAX_LINKS
is introduced by Commit 60df5628144b ("drm/amd/display: handle invalid connector indices") after 6.10. So here we still use the original array length MAX_PIPES * 2]
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -7
@@ -4484,17 +4484,17 @@ static int amdgpu_dm_initialize_drm_devi } } +if (link_cnt > (MAX_PIPES *2 )) { +DRM_ERROR ( +"KMS: Cannot support more than %d display indexes\n" , +MAX_PIPES *2 ); + goto fail; + } +/* loops over all connectors on the board */ for (i =0 ; i < link_cnt; i++) {struct dc_link *link =NULL ; -if (i >AMDGPU_DM_MAX_DISPLAY_INDEX ) { -DRM_ERROR ( -"KMS: Cannot support more than %d display indexes\n" , -AMDGPU_DM_MAX_DISPLAY_INDEX ); -continue ; - } - aconnector =kzalloc (sizeof (*aconnector),GFP_KERNEL );if (!aconnector) goto fail;
Greg Kroah-Hartman
maintainerPATCH 383/393 landlock: Add the errata interface
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <[email protected]>
commit 15383a0d63dbcd63dc7e8d9ec1bf3a0f7ebf64ac upstream.
Some fixes may require user space to check if they are applied on the running kernel before using a specific feature. For instance, this applies when a restriction was previously too restrictive and is now getting relaxed (e.g. for compatibility reasons). However, non-visible changes for legitimate use (e.g. security fixes) do not require an erratum.
Because fixes are backported down to a specific Landlock ABI, we need a way to avoid cherry-pick conflicts. The solution is to only update a file related to the lower ABI impacted by this issue. All the ABI files are then used to create a bitmask of fixes.
The new errata interface is similar to the one used to get the supported Landlock ABI version, but it returns a bitmask instead because the order of fixes may not match the order of versions, and not all fixes may apply to all versions.
The actual errata will come with dedicated commits. The description is not actually used in the code but serves as documentation.
Create the landlock_abi_version symbol and use its value to check errata consistency.
Update test_base's create_ruleset_checks_ordering tests and add errata tests.
This commit is backportable down to the first version of Landlock.
--- include/uapi/linux/landlock.h | 2 security/landlock/errata.h | 87 +++++++++++++++++++++++++++ security/landlock/setup.c | 30 +++++++++ security/landlock/setup.h | 3 security/landlock/syscalls.c | 22 +++++- tools/testing/selftests/landlock/base_test.c | 46 +++++++++++++- 6 files changed, 185 insertions(+), 5 deletions(-) create mode 100644 security/landlock/errata.h
include/uapi/linux/landlock.h +2 -0
@@ -38,9 +38,11 @@ struct landlock_ruleset_attr {* * - %LANDLOCK_CREATE_RULESET_VERSION: Get the highest supported Landlock ABI * version. +* - %LANDLOCK_CREATE_RULESET_ERRATA: Get a bitmask of fixed issues. */ /* clang-format off */ #define LANDLOCK_CREATE_RULESET_VERSION (1U << 0) +#define LANDLOCK_CREATE_RULESET_ERRATA (1U << 1)/* clang-format on */ /**
security/landlock/errata.h new file +87 -0
87 lines not on this page · raw message
security/landlock/setup.c +30 -0
@@ -6,11 +6,13 @@* Copyright © 2018-2020 ANSSI */ +#include <linux/bits.h> #include <linux/init.h> #include <linux/lsm_hooks.h> #include "common.h" #include "cred.h" +#include "errata.h" #include "fs.h" #include "ptrace.h" #include "setup.h"
@@ -24,8 +26,36 @@ struct lsm_blob_sizes landlock_blob_size .lbs_superblock = sizeof(struct landlock_superblock_security), }; +int landlock_errata__ro_after_init ; + +static void __init compute_errata (void ) +{ +size_t i; + +#ifndef __has_include +/* +* This is a safeguard to make sure the compiler implements +* __has_include (see errata.h). +*/ +WARN_ON_ONCE (1 ); +return ; +#endif + +for (i =0 ; landlock_errata_init[i].number; i++) { +const int prev_errata = landlock_errata; + +if (WARN_ON_ONCE (landlock_errata_init[i].abi > + landlock_abi_version)) +continue ; + + landlock_errata |=BIT (landlock_errata_init[i].number -1 ); +WARN_ON_ONCE (prev_errata == landlock_errata); + } +} +static int __init landlock_init (void ) { +compute_errata ();landlock_add_cred_hooks ();landlock_add_ptrace_hooks ();landlock_add_fs_hooks ();
security/landlock/setup.h +3 -0
@@ -11,7 +11,10 @@#include <linux/lsm_hooks.h> +extern const int landlock_abi_version; +extern bool landlock_initialized; +extern int landlock_errata;extern struct lsm_blob_sizes landlock_blob_sizes;
security/landlock/syscalls.c +18 -4
@@ -150,7 +150,9 @@ static const struct file_operations rule* the new ruleset. * @size: Size of the pointed &struct landlock_ruleset_attr (needed for * backward and forward compatibility). -* @flags: Supported value: %LANDLOCK_CREATE_RULESET_VERSION. +* @flags: Supported value: +* - %LANDLOCK_CREATE_RULESET_VERSION +* - %LANDLOCK_CREATE_RULESET_ERRATA * * This system call enables to create a new Landlock ruleset, and returns the * related file descriptor on success.
@@ -159,6 +161,10 @@ static const struct file_operations rule* 0, then the returned value is the highest supported Landlock ABI version * (starting at 1). * +* If @flags is %LANDLOCK_CREATE_RULESET_ERRATA and @attr is NULL and @size is +* 0, then the returned value is a bitmask of fixed issues for the current +* Landlock ABI version. +* * Possible returned errors are: * * - %EOPNOTSUPP: Landlock is supported by the kernel but disabled at boot time;
@@ -181,9 +187,15 @@ SYSCALL_DEFINE3(landlock_create_ruleset,return -EOPNOTSUPP ;if (flags) { -if ((flags ==LANDLOCK_CREATE_RULESET_VERSION ) && !attr && - !size) -return LANDLOCK_ABI_VERSION ; +if (attr || size) +return -EINVAL ; + +if (flags ==LANDLOCK_CREATE_RULESET_VERSION ) +return landlock_abi_version; + +if (flags ==LANDLOCK_CREATE_RULESET_ERRATA ) +return landlock_errata; +return -EINVAL ; }
@@ -213,6 +225,8 @@ SYSCALL_DEFINE3(landlock_create_ruleset,return ruleset_fd; } +const int landlock_abi_version =LANDLOCK_ABI_VERSION ; +/* * Returns an owned ruleset from a FD. It is thus needed to call * landlock_put_ruleset() on the return value.
tools/testing/selftests/landlock/base_test.c +45 -1
55 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 384/393 nvmet-fc: Remove unused functions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit 1b304c006b0fb4f0517a8c4ba8c46e88f48a069c upstream.
The functions nvmet_fc_iodnum() and nvmet_fc_fodnum() are currently unutilized.
Following commit c53432030d86 ("nvme-fabrics: Add target support for FC transport"), which introduced these two functions, they have not been used at all in practice.
Remove them to resolve the compiler warnings.
Fix follow errors with clang-19 when W=1e:
drivers/nvme/target/fc.c:177:1: error: unused function 'nvmet_fc_iodnum' [-Werror,-Wunused-function]
177 | nvmet_fc_iodnum(struct nvmet_fc_ls_iod *iodptr)
| ^~~~~~~~~~~~~~~
drivers/nvme/target/fc.c:183:1: error: unused function 'nvmet_fc_fodnum' [-Werror,-Wunused-function]
183 | nvmet_fc_fodnum(struct nvmet_fc_fcp_iod *fodptr)
| ^~~~~~~~~~~~~~~
2 errors generated.
make[8]: *** [scripts/Makefile.build:207: drivers/nvme/target/fc.o] Error 1 make[7]: *** [scripts/Makefile.build:465: drivers/nvme/target] Error 2
make[6]: *** [scripts/Makefile.build:465: drivers/nvme] Error 2
make[6]: *** Waiting for unfinished jobs....
--- drivers/nvme/target/fc.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/nvme/target/fc.c +0 -14
@@ -173,20 +173,6 @@ struct nvmet_fc_tgt_assoc {struct rcu_head rcu; }; - -static inline int -nvmet_fc_iodnum (struct nvmet_fc_ls_iod *iodptr) -{ -return (iodptr - iodptr->tgtport->iod); -} - -static inline int -nvmet_fc_fodnum (struct nvmet_fc_fcp_iod *fodptr) -{ -return (fodptr - fodptr->queue->fod); -} - -/* * Association and Connection IDs: *
Greg Kroah-Hartman
maintainerPATCH 385/393 xdp: Reset bpf_redirect_info before running a xdps BPF prog.
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
Ricardo reported a KASAN discovered use after free in v6.6-stable.
The syzbot starts a BPF program via xdp_test_run_batch() which assigns ri->tgt_value via dev_hash_map_redirect() and the return code isn't XDP_REDIRECT it looks like nonsense. So the output in bpf_warn_invalid_xdp_action() appears once.
Then the TUN driver runs another BPF program (on the same CPU) which returns XDP_REDIRECT without setting ri->tgt_value first. It invokes bpf_trace_printk() to print four characters and obtain the required return value. This is enough to get xdp_do_redirect() invoked which then accesses the pointer in tgt_value which might have been already deallocated.
This problem does not affect upstream because since commit
401cb7dae8130 ("net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.")
the per-CPU variable is referenced via task's task_struct and exists on the stack during NAPI callback. Therefore it is cleared once before the first invocation and remains valid within the RCU section of the NAPI callback.
Instead of performing the huge backport of the commit (plus its fix ups) here is an alternative version which only resets the variable in question prior invoking the BPF program.
--- include/net/xdp.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
include/net/xdp.h +8 -1
@@ -486,7 +486,14 @@ static __always_inline u32 bpf_prog_run_* under local_bh_disable(), which provides the needed RCU protection * for accessing map entries. */ -u32 act =__bpf_prog_run (prog, xdp,BPF_DISPATCHER_FUNC (xdp)); +struct bpf_redirect_info *ri =this_cpu_ptr (&bpf_redirect_info); +u32 act; + +if (ri->map_id || ri->map_type) { + ri->map_id =0 ; + ri->map_type =BPF_MAP_TYPE_UNSPEC ; + } + act =__bpf_prog_run (prog, xdp,BPF_DISPATCHER_FUNC (xdp));if (static_branch_unlikely (&bpf_master_redirect_enabled_key)) {if (act ==XDP_TX &&netif_is_bond_slave (xdp->rxq->dev))
Greg Kroah-Hartman
maintainerPATCH 386/393 sign-file,extract-cert: move common SSL helper functions to a header
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Stancek <[email protected]>
commit 300e6d4116f956b035281ec94297dc4dc8d4e1d3 upstream.
Couple error handling helpers are repeated in both tools, so move them to a common header.
--- MAINTAINERS | 1 + certs/Makefile | 2 +- certs/extract-cert.c | 37 ++----------------------------------- scripts/sign-file.c | 37 ++----------------------------------- scripts/ssl-common.h | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 71 deletions(-) create mode 100644 scripts/ssl-common.h
MAINTAINERS +1 -0
@@ -4784,6 +4784,7 @@ S: Maintained F: Documentation/admin-guide/module-signing.rst F: certs/ F: scripts/sign-file.c +F: scripts/ssl-common.h F: tools/certs/ CFAG12864B LCD DRIVER
certs/Makefile +1 -1
@@ -84,5 +84,5 @@ targets += x509_revocation_list hostprogs := extract-cert -HOSTCFLAGS_extract-cert.o = $(shell $(HOSTPKG_CONFIG) --cflags libcrypto 2> /dev/null) +HOSTCFLAGS_extract-cert.o = $(shell $(HOSTPKG_CONFIG) --cflags libcrypto 2> /dev/null) -I$(srctree)/scripts HOSTLDLIBS_extract-cert = $(shell $(HOSTPKG_CONFIG) --libs libcrypto 2> /dev/null || echo -lcrypto)
certs/extract-cert.c +2 -35
@@ -23,6 +23,8 @@#include <openssl/err.h> #include <openssl/engine.h> +#include "ssl-common.h" +/* * OpenSSL 3.0 deprecates the OpenSSL's ENGINE API. *
@@ -40,41 +42,6 @@ void format(void)exit (2 ); } -static void display_openssl_errors (int l) -{ -const char *file; -char buf[120 ]; -int e, line; - -if (ERR_peek_error () ==0 ) -return ; -fprintf (stderr,"At main.c:%d:\n" , l); - -while ((e =ERR_get_error_line (&file, &line))) { -ERR_error_string (e, buf); -fprintf (stderr,"- SSL %s: %s:%d\n" , buf, file, line); - } -} - -static void drain_openssl_errors (void ) -{ -const char *file; -int line; - -if (ERR_peek_error () ==0 ) -return ; -while (ERR_get_error_line (&file, &line)) {} -} - -#define ERR (cond, fmt, ...) \ - do { \ - bool __cond = (cond); \ - display_openssl_errors(__LINE__); \ - if (__cond) { \ - err(1, fmt, ## __VA_ARGS__); \ - } \ - } while(0) -static const char *key_pass;static BIO *wb;static char *cert_dst;
scripts/sign-file.c +2 -35
@@ -29,6 +29,8 @@#include <openssl/err.h> #include <openssl/engine.h> +#include "ssl-common.h" +/* * OpenSSL 3.0 deprecates the OpenSSL's ENGINE API. *
@@ -83,41 +85,6 @@ void format(void)exit (2 ); } -static void display_openssl_errors (int l) -{ -const char *file; -char buf[120 ]; -int e, line; - -if (ERR_peek_error () ==0 ) -return ; -fprintf (stderr,"At main.c:%d:\n" , l); - -while ((e =ERR_get_error_line (&file, &line))) { -ERR_error_string (e, buf); -fprintf (stderr,"- SSL %s: %s:%d\n" , buf, file, line); - } -} - -static void drain_openssl_errors (void ) -{ -const char *file; -int line; - -if (ERR_peek_error () ==0 ) -return ; -while (ERR_get_error_line (&file, &line)) {} -} - -#define ERR (cond, fmt, ...) \ - do { \ - bool __cond = (cond); \ - display_openssl_errors(__LINE__); \ - if (__cond) { \ - errx(1, fmt, ## __VA_ARGS__); \ - } \ - } while(0) -static const char *key_pass;static int pem_pw_cb (char *buf,int len,int w,void *v)
scripts/ssl-common.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ +/* +* SSL helper functions shared by sign-file and extract-cert. +*/ + +static void display_openssl_errors (int l) +{ +const char *file; +char buf[120 ]; +int e, line; + +if (ERR_peek_error () ==0 ) +return ; +fprintf (stderr,"At main.c:%d:\n" , l); + +while ((e =ERR_get_error_line (&file, &line))) { +ERR_error_string (e, buf); +fprintf (stderr,"- SSL %s: %s:%d\n" , buf, file, line); + } +} + +static void drain_openssl_errors (void ) +{ +const char *file; +int line; + +if (ERR_peek_error () ==0 ) +return ; +while (ERR_get_error_line (&file, &line)) {} +} + +#define ERR (cond, fmt, ...) \ + do { \ + bool __cond = (cond); \ + display_openssl_errors(__LINE__); \ + if (__cond) { \ + errx(1, fmt, ## __VA_ARGS__); \ + } \ + } while (0)
Greg Kroah-Hartman
maintainerPATCH 387/393 sign-file,extract-cert: avoid using deprecated ERR_get_error_line()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Stancek <[email protected]>
commit 467d60eddf55588add232feda325da7215ddaf30 upstream.
ERR_get_error_line() is deprecated since OpenSSL 3.0.
Use ERR_peek_error_line() instead, and combine display_openssl_errors() and drain_openssl_errors() to a single function where parameter decides if it should consume errors silently.
--- certs/extract-cert.c | 4 ++-- scripts/sign-file.c | 6 +++--- scripts/ssl-common.h | 23 ++++++++--------------- 3 files changed, 13 insertions(+), 20 deletions(-)
certs/extract-cert.c +2 -2
@@ -99,11 +99,11 @@ int main(int argc, char **argv) parms.cert =NULL ;ENGINE_load_builtin_engines (); -drain_openssl_errors (); +drain_openssl_errors (__LINE__,1 ); e =ENGINE_by_id ("pkcs11" );ERR (!e,"Load PKCS#11 ENGINE" );if (ENGINE_init (e)) -drain_openssl_errors (); +drain_openssl_errors (__LINE__,1 );else ERR (1 ,"ENGINE_init" );if (key_pass)
scripts/sign-file.c +3 -3
@@ -114,11 +114,11 @@ static EVP_PKEY *read_private_key(constENGINE *e;ENGINE_load_builtin_engines (); -drain_openssl_errors (); +drain_openssl_errors (__LINE__,1 ); e =ENGINE_by_id ("pkcs11" );ERR (!e,"Load PKCS#11 ENGINE" );if (ENGINE_init (e)) -drain_openssl_errors (); +drain_openssl_errors (__LINE__,1 );else ERR (1 ,"ENGINE_init" );if (key_pass)
@@ -273,7 +273,7 @@ int main(int argc, char **argv)/* Digest the module data. */ OpenSSL_add_all_digests (); -display_openssl_errors (__LINE__); +drain_openssl_errors (__LINE__,0 ); digest_algo =EVP_get_digestbyname (hash_algo);ERR (!digest_algo,"EVP_get_digestbyname" );
scripts/ssl-common.h +8 -15
@@ -3,7 +3,7 @@* SSL helper functions shared by sign-file and extract-cert. */ -static void display_openssl_errors (int l) +static void drain_openssl_errors (int l,int silent) {const char *file;char buf[120 ];
@@ -11,28 +11,21 @@ static void display_openssl_errors(int lif (ERR_peek_error () ==0 )return ; -fprintf (stderr,"At main.c:%d:\n" , l); +if (!silent) +fprintf (stderr,"At main.c:%d:\n" , l); -while ((e =ERR_get_error_line (&file, &line))) { +while ((e =ERR_peek_error_line (&file, &line))) {ERR_error_string (e, buf); -fprintf (stderr,"- SSL %s: %s:%d\n" , buf, file, line); +if (!silent) +fprintf (stderr,"- SSL %s: %s:%d\n" , buf, file, line); +ERR_get_error (); } } -static void drain_openssl_errors (void ) -{ -const char *file; -int line; - -if (ERR_peek_error () ==0 ) -return ; -while (ERR_get_error_line (&file, &line)) {} -} -#define ERR (cond, fmt, ...) \ do { \ bool __cond = (cond); \ - display_openssl_errors(__LINE__); \ + drain_openssl_errors(__LINE__, 0); \ if (__cond) { \ errx(1, fmt, ## __VA_ARGS__); \ } \
Greg Kroah-Hartman
maintainerPATCH 388/393 sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Stancek <[email protected]>
commit 558bdc45dfb2669e1741384a0c80be9c82fa052c upstream.
ENGINE API has been deprecated since OpenSSL version 3.0 [1]. Distros have started dropping support from headers and in future it will likely disappear also from library.
It has been superseded by the PROVIDER API, so use it instead for OPENSSL MAJOR >= 3.
[1] https://github.com/openssl/openssl/blob/master/README-ENGINES.md
[jarkko: fixed up alignment issues reported by checkpatch.pl --strict]
--- certs/extract-cert.c | 103 ++++++++++++++++++++++++++++++++++++--------------- scripts/sign-file.c | 95 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 139 insertions(+), 59 deletions(-)
certs/extract-cert.c +73 -30
@@ -21,17 +21,18 @@#include <openssl/bio.h> #include <openssl/pem.h> #include <openssl/err.h> -#include <openssl/engine.h> - +#if OPENSSL_VERSION_MAJOR >=3 +# define USE_PKCS11_PROVIDER +# include <openssl/provider.h> +# include <openssl/store.h> +#else +# if !defined(OPENSSL_NO_ENGINE ) && !defined(OPENSSL_NO_DEPRECATED_3_0 ) +# define USE_PKCS11_ENGINE +# include <openssl/engine.h> +# endif +#endif #include "ssl-common.h" -/* -* OpenSSL 3.0 deprecates the OpenSSL's ENGINE API. -* -* Remove this if/when that API is no longer used -*/ -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#define PKEY_ID_PKCS7 2 static __attribute__((noreturn))
@@ -61,6 +62,66 @@ static void write_cert(X509 *x509)fprintf (stderr,"Extracted cert: %s\n" , buf); } +static X509 *load_cert_pkcs11 (const char *cert_src) +{ +X509 *cert =NULL ; +#ifdef USE_PKCS11_PROVIDER +OSSL_STORE_CTX *store; + +if (!OSSL_PROVIDER_try_load (NULL ,"pkcs11" , true)) +ERR (1 ,"OSSL_PROVIDER_try_load(pkcs11)" ); +if (!OSSL_PROVIDER_try_load (NULL ,"default" , true)) +ERR (1 ,"OSSL_PROVIDER_try_load(default)" ); + + store =OSSL_STORE_open (cert_src,NULL ,NULL ,NULL ,NULL ); +ERR (!store,"OSSL_STORE_open" ); + +while (!OSSL_STORE_eof (store)) { +OSSL_STORE_INFO *info =OSSL_STORE_load (store); + +if (!info) { +drain_openssl_errors (__LINE__,0 ); +continue ; + } +if (OSSL_STORE_INFO_get_type (info) ==OSSL_STORE_INFO_CERT ) { + cert =OSSL_STORE_INFO_get1_CERT (info); +ERR (!cert,"OSSL_STORE_INFO_get1_CERT" ); + } +OSSL_STORE_INFO_free (info); +if (cert) +break ; + } +OSSL_STORE_close (store); +#elif defined(USE_PKCS11_ENGINE ) +ENGINE *e; +struct { +const char *cert_id; +X509 *cert; + } parms; + + parms.cert_id = cert_src; + parms.cert =NULL ; + +ENGINE_load_builtin_engines (); +drain_openssl_errors (__LINE__,1 ); + e =ENGINE_by_id ("pkcs11" ); +ERR (!e,"Load PKCS#11 ENGINE" ); +if (ENGINE_init (e)) +drain_openssl_errors (__LINE__,1 ); +else +ERR (1 ,"ENGINE_init" ); +if (key_pass) +ERR (!ENGINE_ctrl_cmd_string (e,"PIN" , key_pass,0 ),"Set PKCS#11 PIN" ); +ENGINE_ctrl_cmd (e,"LOAD_CERT_CTRL" ,0 , &parms,NULL ,1 ); +ERR (!parms.cert,"Get X.509 from PKCS#11" ); + cert = parms.cert; +#else +fprintf (stderr,"no pkcs11 engine/provider available\n" ); +exit (1 ); +#endif +return cert; +} +int main (int argc,char **argv) {char *cert_src;
@@ -89,28 +150,10 @@ int main(int argc, char **argv)fclose (f);exit (0 ); }else if (!strncmp (cert_src,"pkcs11:" ,7 )) { -ENGINE *e; -struct { -const char *cert_id; -X509 *cert; - } parms; - - parms.cert_id = cert_src; - parms.cert =NULL ; +X509 *cert =load_cert_pkcs11 (cert_src); -ENGINE_load_builtin_engines (); -drain_openssl_errors (__LINE__,1 ); - e =ENGINE_by_id ("pkcs11" ); -ERR (!e,"Load PKCS#11 ENGINE" ); -if (ENGINE_init (e)) -drain_openssl_errors (__LINE__,1 ); -else -ERR (1 ,"ENGINE_init" ); -if (key_pass) -ERR (!ENGINE_ctrl_cmd_string (e,"PIN" , key_pass,0 ),"Set PKCS#11 PIN" ); -ENGINE_ctrl_cmd (e,"LOAD_CERT_CTRL" ,0 , &parms,NULL ,1 ); -ERR (!parms.cert,"Get X.509 from PKCS#11" ); -write_cert (parms.cert); +ERR (!cert,"load_cert_pkcs11 failed" ); +write_cert (cert); }else {BIO *b;X509 *x509;
scripts/sign-file.c +66 -29
121 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 389/393 MIPS: dec: Declare which_prom() as static
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit 55fa5868519bc48a7344a4c070efa2f4468f2167 upstream.
Declare which_prom() as static to suppress gcc compiler warning that 'missing-prototypes'. This function is not intended to be called from other parts.
Fix follow error with gcc-14 when -Werror:
arch/mips/dec/prom/init.c:45:13: error: no previous prototype for ‘which_prom’ [-Werror=missing-prototypes]
45 | void __init which_prom(s32 magic, s32 *prom_vec)
| ^~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:207: arch/mips/dec/prom/init.o] Error 1 make[5]: *** [scripts/Makefile.build:465: arch/mips/dec/prom] Error 2 make[5]: *** Waiting for unfinished jobs....
--- arch/mips/dec/prom/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/dec/prom/init.c +1 -1
@@ -42,7 +42,7 @@ int (*__pmax_close)(int);* Detect which PROM the DECSTATION has, and set the callback vectors * appropriately. */ -void __init which_prom (s32 magic,s32 *prom_vec) +static void __init which_prom (s32 magic,s32 *prom_vec) {/* * No sign of the REX PROM's magic number means we assume a non-REX
Greg Kroah-Hartman
maintainerPATCH 390/393 MIPS: cevt-ds1287: Add missing ds1287.h include
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit f3be225f338a578851a7b607a409f476354a8deb upstream.
Address the issue of cevt-ds1287.c not including the ds1287.h header file.
Fix follow errors with gcc-14 when -Werror:
arch/mips/kernel/cevt-ds1287.c:15:5: error: no previous prototype for ‘ds1287_timer_state’ [-Werror=missing-prototypes]
15 | int ds1287_timer_state(void)
| ^~~~~~~~~~~~~~~~~~
arch/mips/kernel/cevt-ds1287.c:20:5: error: no previous prototype for ‘ds1287_set_base_clock’ [-Werror=missing-prototypes]
20 | int ds1287_set_base_clock(unsigned int hz)
| ^~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/cevt-ds1287.c:103:12: error: no previous prototype for ‘ds1287_clockevent_init’ [-Werror=missing-prototypes]
103 | int __init ds1287_clockevent_init(int irq)
| ^~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
make[7]: *** [scripts/Makefile.build:207: arch/mips/kernel/cevt-ds1287.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [scripts/Makefile.build:465: arch/mips/kernel] Error 2 make[6]: *** Waiting for unfinished jobs....
--- arch/mips/kernel/cevt-ds1287.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/kernel/cevt-ds1287.c +1 -0
@@ -10,6 +10,7 @@#include <linux/mc146818rtc.h> #include <linux/irq.h> +#include <asm/ds1287.h> #include <asm/time.h> int ds1287_timer_state (void )
Greg Kroah-Hartman
maintainerPATCH 391/393 MIPS: ds1287: Match ds1287_set_base_clock() function types
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit a759109b234385b74d2f5f4c86b5f59b3201ec12 upstream.
Synchronize the declaration of ds1287_set_base_clock() between cevt-ds1287.c and ds1287.h.
Fix follow error with gcc-14 when -Werror:
arch/mips/kernel/cevt-ds1287.c:21:5: error: conflicting types for ‘ds1287_set_base_clock’; have ‘int(unsigned int)’
21 | int ds1287_set_base_clock(unsigned int hz)
| ^~~~~~~~~~~~~~~~~~~~~
In file included from arch/mips/kernel/cevt-ds1287.c:13:
./arch/mips/include/asm/ds1287.h:11:13: note: previous declaration of ‘ds1287_set_base_clock’ with type ‘void(unsigned int)’
11 | extern void ds1287_set_base_clock(unsigned int clock);
| ^~~~~~~~~~~~~~~~~~~~~make[7]: *** [scripts/Makefile.build:207: arch/mips/kernel/cevt-ds1287.o] Error 1 make[6]: *** [scripts/Makefile.build:465: arch/mips/kernel] Error 2 make[6]: *** Waiting for unfinished jobs....
--- arch/mips/include/asm/ds1287.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/ds1287.h +1 -1
@@ -8,7 +8,7 @@#define __ASM_DS1287_Hextern int ds1287_timer_state (void ); -extern void ds1287_set_base_clock (unsigned int clock); +extern int ds1287_set_base_clock (unsigned int hz);extern int ds1287_clockevent_init (int irq);#endif
Greg Kroah-Hartman
maintainerPATCH 392/393 btrfs: fix the length of reserved qgroup to free
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haisu Wang <[email protected]>
commit 2b084d8205949dd804e279df8e68531da78be1e8 upstream.
The dealloc flag may be cleared and the extent won't reach the disk in cow_file_range when errors path. The reserved qgroup space is freed in commit 30479f31d44d ("btrfs: fix qgroup reserve leaks in cow_file_range"). However, the length of untouched region to free needs to be adjusted with the correct remaining region size.
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -1560,7 +1560,7 @@ out_unlock: clear_bits |=EXTENT_CLEAR_DATA_RESV ;extent_clear_unlock_delalloc (inode, start, end, locked_page, clear_bits, page_ops); -btrfs_qgroup_free_data (inode,NULL , start, cur_alloc_size,NULL ); +btrfs_qgroup_free_data (inode,NULL , start, end - start +1 ,NULL ); }return ret; }
Greg Kroah-Hartman
maintainerPATCH 393/393 drm/tests: Build KMS helpers when DRM_KUNIT_TEST_HELPERS is enabled
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karolina Stolarek <[email protected]>
commit f1a785101d50f5844ed29341142e7224b87f705d upstream.
Commit 66671944e176 ("drm/tests: helpers: Add atomic helpers") introduced a dependency on CRTC helpers in KUnit test helpers. Select the former when building KUnit test helpers to avoid linker errors.
--- drivers/gpu/drm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/Kconfig +1 -1
@@ -69,6 +69,7 @@ config DRM_USE_DYNAMIC_DEBUG config DRM_KUNIT_TEST_HELPERS tristate depends on DRM && KUNIT + select DRM_KMS_HELPER help KUnit Helpers for KMS drivers.
@@ -79,7 +80,6 @@ config DRM_KUNIT_TEST select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HELPER select DRM_LIB_RANDOM - select DRM_KMS_HELPER select DRM_BUDDY select DRM_EXPORT_FOR_TESTS if m select DRM_KUNIT_TEST_HELPERS
Am 23.04.2025 um 16:38 schrieb Greg Kroah-Hartman:
Quoted 4 lines
This is the start of the stable review cycle for the 6.6.88 release. There are 393 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Builds, boots and works on my 2-socket Ivy Bridge Xeon E5-2697 v2 server. No dmesg oddities or regressions found.
Beste Grüße,
Peter Schneider
Signature · 8 lines
Climb the mountain not to plant your flag, but to embrace the challenge, enjoy the air and behold the view. Climb it so you can see the world, not so the world can see you. -- David McCullough Jr. OpenPGP: 0xA3828BD796CCE11A8CADE8866E3A92C92C3FF244 Download: https://www.peters-netzplatz.de/download/pschneider1968_pub.asc https://keys.mailvelope.com/pks/lookup?op=get&[email protected] https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.88 release. There are 393 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Apr 2025 14:25:27 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.88-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.88 release. There are 393 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Apr 2025 14:25:27 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.88-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.88 release. There are 393 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Apr 2025 14:25:27 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.88-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v6.6:
10 builds: 10 pass, 0 fail
28 boots: 28 pass, 0 fail
116 tests: 116 pass, 0 failLinux version: 6.6.88-rc1-g2b9f423a149b
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra186-p3509-0000+p3636-0001, tegra194-p2972-0000,
tegra194-p3509-0000+p3668-0000, tegra20-ventana,
tegra210-p2371-2180, tegra210-p3450-0000,
tegra30-cardhu-a04Jon
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.88 release. There are 393 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.88 release. There are 393 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Apr 2025 14:25:27 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.88-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
--
Florian
Quoted 8 lines · On Wed, 23 Apr 2025 16:38:16 +0200 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.6.88 release. There are 393 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Apr 2025 14:25:27 +0000. Anything received after that time might be too late.
Boot-tested under QEMU for Rust x86_64:
Thanks!
Cheers,
Miguel
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.88 release. There are 393 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Apr 2025 14:25:27 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.88-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 6.6.88-rc1
* git: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
* git commit: 2b9f423a149b8cc7f21741efb02e56cac442bb92
* git describe: v6.6.87-394-g2b9f423a149b
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.6.y/build/v6.6.87-394-g2b9f423a149b
## Test Regressions (compared to v6.6.87-1-g268d2a7e4698)
## Metric Regressions (compared to v6.6.87-1-g268d2a7e4698)
## Test Fixes (compared to v6.6.87-1-g268d2a7e4698)
## Metric Fixes (compared to v6.6.87-1-g268d2a7e4698)
## Test result summary
total: 123381, pass: 103202, fail: 3126, skip: 16595, xfail: 458
## Build Summary
* arc: 5 total, 5 passed, 0 failed
* arm: 129 total, 129 passed, 0 failed
* arm64: 44 total, 44 passed, 0 failed
* i386: 27 total, 23 passed, 4 failed
* mips: 26 total, 25 passed, 1 failed
* parisc: 4 total, 4 passed, 0 failed
* powerpc: 32 total, 31 passed, 1 failed
* riscv: 20 total, 20 passed, 0 failed
* s390: 14 total, 13 passed, 1 failed
* sh: 10 total, 10 passed, 0 failed
* sparc: 7 total, 7 passed, 0 failed
* x86_64: 37 total, 36 passed, 0 failed, 1 skipped
## Test suites summary
* boot
* commands
* kselftest-arm64
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-efivarfs
* kselftest-exec
* kselftest-fpu
* kselftest-ftrace
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-kcmp
* kselftest-kvm
* kselftest-livepatch
* kselftest-membarrier
* kselftest-memfd
* kselftest-mincore
* kselftest-mqueue
* kselftest-net
* kselftest-net-mptcp
* kselftest-openat2
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-tc-testing
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user_events
* kselftest-vDSO
* kselftest-x86
* kunit
* kvm-unit-tests
* lava
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-build-clang
* log-parser-build-gcc
* log-parser-test
* ltp-capability
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-hugetlb
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-pty
* ltp-sched
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* perf
* rcutorture
--
Linaro LKFT
https://lkft.linaro.org