From: Sasha Levin Date: Mon, 21 Apr 2025 11:19:44 +0000 (-0400) Subject: Fixes for 6.6 X-Git-Tag: v6.1.135~133^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f8198e631f8cfc5ee3c43fb47291d70b32547d27;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.6 Signed-off-by: Sasha Levin --- diff --git a/queue-6.6/ftrace-fix-incorrect-hash-size-in-register_ftrace_di.patch b/queue-6.6/ftrace-fix-incorrect-hash-size-in-register_ftrace_di.patch new file mode 100644 index 0000000000..8dc9bdcafd --- /dev/null +++ b/queue-6.6/ftrace-fix-incorrect-hash-size-in-register_ftrace_di.patch @@ -0,0 +1,44 @@ +From 2da722d2ce1d731f9e17b7e534275d7312f9007f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 13 Apr 2025 09:44:44 +0800 +Subject: ftrace: fix incorrect hash size in register_ftrace_direct() + +From: Menglong Dong + +[ 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. + +Link: https://lore.kernel.org/20250413014444.36724-1-dongml2@chinatelecom.cn +Fixes: d05cb470663a ("ftrace: Fix modification of direct_function hash while in use") +Signed-off-by: Menglong Dong +Acked-by: Masami Hiramatsu (Google) +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Sasha Levin +--- + kernel/trace/ftrace.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c +index 580ceb75f8c38..650493ed76cd4 100644 +--- a/kernel/trace/ftrace.c ++++ b/kernel/trace/ftrace.c +@@ -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; + +-- +2.39.5 + diff --git a/queue-6.6/i2c-atr-fix-wrong-include.patch b/queue-6.6/i2c-atr-fix-wrong-include.patch new file mode 100644 index 0000000000..5fb284dd3c --- /dev/null +++ b/queue-6.6/i2c-atr-fix-wrong-include.patch @@ -0,0 +1,49 @@ +From 0da045edafd1806d84518eddcca1a3900dd67ce1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 31 Mar 2025 10:16:46 +0300 +Subject: i2c: atr: Fix wrong include + +From: Andy Shevchenko + +[ 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. + +Fixes: a076a860acae ("media: i2c: add I2C Address Translator (ATR) support") +Signed-off-by: Andy Shevchenko +Acked-by: Mukesh Kumar Savaliya +Reviewed-by: Luca Ceresoli +Reviewed-by: Tomi Valkeinen +[wsa: reworded subject] +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/i2c-atr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/i2c/i2c-atr.c b/drivers/i2c/i2c-atr.c +index c03196da11635..03caa4ef012f1 100644 +--- a/drivers/i2c/i2c-atr.c ++++ b/drivers/i2c/i2c-atr.c +@@ -8,12 +8,12 @@ + * Originally based on i2c-mux.c + */ + +-#include + #include + #include + #include + #include + #include ++#include + #include + #include + +-- +2.39.5 + diff --git a/queue-6.6/nfs-add-missing-selections-of-config_crc32.patch b/queue-6.6/nfs-add-missing-selections-of-config_crc32.patch new file mode 100644 index 0000000000..f9cd0942d7 --- /dev/null +++ b/queue-6.6/nfs-add-missing-selections-of-config_crc32.patch @@ -0,0 +1,179 @@ +From 0534aa76a9b24a047e676be3f23d8e6fd2b33d9a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 1 Apr 2025 15:02:21 -0700 +Subject: nfs: add missing selections of CONFIG_CRC32 + +From: Eric Biggers + +[ 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. + +Fixes: 1264a2f053a3 ("NFS: refactor code for calculating the crc32 hash of a filehandle") +Signed-off-by: Eric Biggers +Acked-by: Anna Schumaker +Signed-off-by: Chuck Lever +Signed-off-by: Sasha Levin +--- + 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(-) + +diff --git a/fs/Kconfig b/fs/Kconfig +index 02a9237807a77..85ae4953f2d7b 100644 +--- a/fs/Kconfig ++++ b/fs/Kconfig +@@ -365,6 +365,7 @@ config GRACE_PERIOD + config LOCKD + tristate + depends on FILE_LOCKING ++ select CRC32 + select GRACE_PERIOD + + config LOCKD_V4 +diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig +index 7df2503cef6c3..2d99f5e7a686b 100644 +--- a/fs/nfs/Kconfig ++++ b/fs/nfs/Kconfig +@@ -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 +diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h +index a92b234ae0870..ca49d999159eb 100644 +--- a/fs/nfs/internal.h ++++ b/fs/nfs/internal.h +@@ -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) + { +diff --git a/fs/nfs/nfs4session.h b/fs/nfs/nfs4session.h +index 351616c61df54..f9c291e2165cd 100644 +--- a/fs/nfs/nfs4session.h ++++ b/fs/nfs/nfs4session.h +@@ -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) +diff --git a/fs/nfsd/Kconfig b/fs/nfsd/Kconfig +index 43b88eaf0673a..05c10f70456cc 100644 +--- a/fs/nfsd/Kconfig ++++ b/fs/nfsd/Kconfig +@@ -4,6 +4,7 @@ config NFSD + depends on INET + depends on FILE_LOCKING + depends on FSNOTIFY ++ select CRC32 + select LOCKD + select SUNRPC + select EXPORTFS +diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h +index 40426f899e760..f1420d3510d2e 100644 +--- a/fs/nfsd/nfsfh.h ++++ b/fs/nfsd/nfsfh.h +@@ -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 +diff --git a/include/linux/nfs.h b/include/linux/nfs.h +index ceb70a926b95e..095a95c1fae82 100644 +--- a/include/linux/nfs.h ++++ b/include/linux/nfs.h +@@ -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 */ +-- +2.39.5 + diff --git a/queue-6.6/nfsd-decrease-sc_count-directly-if-fail-to-queue-dl_.patch b/queue-6.6/nfsd-decrease-sc_count-directly-if-fail-to-queue-dl_.patch new file mode 100644 index 0000000000..430abc8fa4 --- /dev/null +++ b/queue-6.6/nfsd-decrease-sc_count-directly-if-fail-to-queue-dl_.patch @@ -0,0 +1,75 @@ +From 7d96584832fce3436bf1a7ae027da63685376c3b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 10 Apr 2025 09:57:08 +0800 +Subject: nfsd: decrease sc_count directly if fail to queue dl_recall + +From: Li Lingfeng + +[ 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_lock + +When 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. + +Fixes: 230ca758453c ("nfsd: put dl_stid if fail to queue dl_recall") +Signed-off-by: Li Lingfeng +Reviewed-by: Jeff Layton +Signed-off-by: Chuck Lever +Signed-off-by: Sasha Levin +--- + fs/nfsd/nfs4state.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c +index 140784446ad22..e2875706e6bfd 100644 +--- a/fs/nfsd/nfs4state.c ++++ b/fs/nfsd/nfs4state.c +@@ -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. */ +-- +2.39.5 + diff --git a/queue-6.6/series b/queue-6.6/series index 96aed59341..f1112706e9 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -297,3 +297,7 @@ kunit-qemu_configs-sh-respect-kunit-cmdline.patch riscv-kgdb-do-not-inline-arch_kgdb_breakpoint.patch riscv-kgdb-remove-.option-norvc-.option-rvc-for-kgdb.patch cpufreq-sched-fix-the-usage-of-cpufreq_need_update_l.patch +nfs-add-missing-selections-of-config_crc32.patch +nfsd-decrease-sc_count-directly-if-fail-to-queue-dl_.patch +i2c-atr-fix-wrong-include.patch +ftrace-fix-incorrect-hash-size-in-register_ftrace_di.patch