From: Sasha Levin Date: Mon, 3 Feb 2025 16:25:49 +0000 (-0500) Subject: Fixes for 6.1 X-Git-Tag: v6.6.76~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=afafe9f7503e9beb49301e8719e45af7af73902f;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.1 Signed-off-by: Sasha Levin --- diff --git a/queue-6.1/asoc-rockchip-i2s_tdm-re-add-the-set_sysclk-callback.patch b/queue-6.1/asoc-rockchip-i2s_tdm-re-add-the-set_sysclk-callback.patch new file mode 100644 index 0000000000..b3cbee907c --- /dev/null +++ b/queue-6.1/asoc-rockchip-i2s_tdm-re-add-the-set_sysclk-callback.patch @@ -0,0 +1,121 @@ +From 67581204e7597e04913aae560e3762118a932ee8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 17 Jan 2025 11:31:02 -0500 +Subject: ASoC: rockchip: i2s_tdm: Re-add the set_sysclk callback + +From: Detlev Casanova + +[ Upstream commit 5323186e2e8d33c073fad51e24f18e2d6dbae2da ] + +In commit +9e2ab4b18ebd ("ASoC: rockchip: i2s-tdm: Fix inaccurate sampling rates"), +the set_sysclk callback was removed as considered unused as the mclk rate +can be set in the hw_params callback. +The difference between hw_params and set_sysclk is that the former is +called with the audio sampling rate set in the params (e.g.: 48000 Hz) +while the latter is called with a clock rate already computed with + sampling_rate * mclk-fs (e.g.: 48000 * 256) + +For HDMI audio using the Rockchip I2S TDM driver, the mclk-fs value must +be set to 128 instead of the default 256, and that value is set in the +device tree at the machine driver level (like a simple-audio-card +compatible node). +Therefore, the i2s_tdm driver has no idea that another mclk-fs value can +be configured and simply computes the mclk rate in the hw_params callback +with DEFAULT_MCLK_FS * params_rate(params), which is wrong for HDMI +audio. + +Re-add the set_sysclk callback so that the mclk rate is computed by the +machine driver which has the correct mclk-fs value set in its device tree +node. + +Fixes: 9e2ab4b18ebd ("ASoC: rockchip: i2s-tdm: Fix inaccurate sampling rates") +Signed-off-by: Detlev Casanova +Link: https://patch.msgid.link/20250117163102.65807-1-detlev.casanova@collabora.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/rockchip/rockchip_i2s_tdm.c | 31 +++++++++++++++++++++++++-- + 1 file changed, 29 insertions(+), 2 deletions(-) + +diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip_i2s_tdm.c +index bcea52fa45a50..d20438cf8fc4a 100644 +--- a/sound/soc/rockchip/rockchip_i2s_tdm.c ++++ b/sound/soc/rockchip/rockchip_i2s_tdm.c +@@ -24,7 +24,6 @@ + + #define DRV_NAME "rockchip-i2s-tdm" + +-#define DEFAULT_MCLK_FS 256 + #define CH_GRP_MAX 4 /* The max channel 8 / 2 */ + #define MULTIPLEX_CH_MAX 10 + +@@ -72,6 +71,8 @@ struct rk_i2s_tdm_dev { + bool has_playback; + bool has_capture; + struct snd_soc_dai_driver *dai; ++ unsigned int mclk_rx_freq; ++ unsigned int mclk_tx_freq; + }; + + static int to_ch_num(unsigned int val) +@@ -641,6 +642,27 @@ static int rockchip_i2s_trcm_mode(struct snd_pcm_substream *substream, + return 0; + } + ++static int rockchip_i2s_tdm_set_sysclk(struct snd_soc_dai *cpu_dai, int stream, ++ unsigned int freq, int dir) ++{ ++ struct rk_i2s_tdm_dev *i2s_tdm = to_info(cpu_dai); ++ ++ if (i2s_tdm->clk_trcm) { ++ i2s_tdm->mclk_tx_freq = freq; ++ i2s_tdm->mclk_rx_freq = freq; ++ } else { ++ if (stream == SNDRV_PCM_STREAM_PLAYBACK) ++ i2s_tdm->mclk_tx_freq = freq; ++ else ++ i2s_tdm->mclk_rx_freq = freq; ++ } ++ ++ dev_dbg(i2s_tdm->dev, "The target mclk_%s freq is: %d\n", ++ stream ? "rx" : "tx", freq); ++ ++ return 0; ++} ++ + static int rockchip_i2s_tdm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +@@ -655,15 +677,19 @@ static int rockchip_i2s_tdm_hw_params(struct snd_pcm_substream *substream, + + if (i2s_tdm->clk_trcm == TRCM_TX) { + mclk = i2s_tdm->mclk_tx; ++ mclk_rate = i2s_tdm->mclk_tx_freq; + } else if (i2s_tdm->clk_trcm == TRCM_RX) { + mclk = i2s_tdm->mclk_rx; ++ mclk_rate = i2s_tdm->mclk_rx_freq; + } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + mclk = i2s_tdm->mclk_tx; ++ mclk_rate = i2s_tdm->mclk_tx_freq; + } else { + mclk = i2s_tdm->mclk_rx; ++ mclk_rate = i2s_tdm->mclk_rx_freq; + } + +- err = clk_set_rate(mclk, DEFAULT_MCLK_FS * params_rate(params)); ++ err = clk_set_rate(mclk, mclk_rate); + if (err) + return err; + +@@ -822,6 +848,7 @@ static const struct snd_soc_dai_ops rockchip_i2s_tdm_dai_ops = { + .hw_params = rockchip_i2s_tdm_hw_params, + .set_bclk_ratio = rockchip_i2s_tdm_set_bclk_ratio, + .set_fmt = rockchip_i2s_tdm_set_fmt, ++ .set_sysclk = rockchip_i2s_tdm_set_sysclk, + .set_tdm_slot = rockchip_dai_tdm_slot, + .trigger = rockchip_i2s_tdm_trigger, + }; +-- +2.39.5 + diff --git a/queue-6.1/genksyms-fix-memory-leak-when-the-same-symbol-is-add.patch b/queue-6.1/genksyms-fix-memory-leak-when-the-same-symbol-is-add.patch new file mode 100644 index 0000000000..171d977ee2 --- /dev/null +++ b/queue-6.1/genksyms-fix-memory-leak-when-the-same-symbol-is-add.patch @@ -0,0 +1,149 @@ +From 5058ab4038753489b62450a0a22de831bb7fc7ab Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 3 Jan 2025 16:30:38 +0900 +Subject: genksyms: fix memory leak when the same symbol is added from source + +From: Masahiro Yamada + +[ Upstream commit 45c9c4101d3d2fdfa00852274bbebba65fcc3cf2 ] + +When a symbol that is already registered is added again, __add_symbol() +returns without freeing the symbol definition, making it unreachable. + +The following test cases demonstrate different memory leak points. + +[Test Case 1] + +Forward declaration with exactly the same definition + + $ cat foo.c + #include + void foo(void); + void foo(void) {} + EXPORT_SYMBOL(foo); + +[Test Case 2] + +Forward declaration with a different definition (e.g. attribute) + + $ cat foo.c + #include + void foo(void); + __attribute__((__section__(".ref.text"))) void foo(void) {} + EXPORT_SYMBOL(foo); + +[Test Case 3] + +Preserving an overridden symbol (compile with KBUILD_PRESERVE=1) + + $ cat foo.c + #include + void foo(void); + void foo(void) { } + EXPORT_SYMBOL(foo); + + $ cat foo.symref + override foo void foo ( int ) + +The memory leaks in Test Case 1 and 2 have existed since the introduction +of genksyms into the kernel tree. [1] + +The memory leak in Test Case 3 was introduced by commit 5dae9a550a74 +("genksyms: allow to ignore symbol checksum changes"). + +When multiple init_declarators are reduced to an init_declarator_list, +the decl_spec must be duplicated. Otherwise, the following Test Case 4 +would result in a double-free bug. + +[Test Case 4] + + $ cat foo.c + #include + + extern int foo, bar; + + int foo, bar; + EXPORT_SYMBOL(foo); + +In this case, 'foo' and 'bar' share the same decl_spec, 'int'. It must +be unshared before being passed to add_symbol(). + +[1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=46bd1da672d66ccd8a639d3c1f8a166048cca608 + +Fixes: 5dae9a550a74 ("genksyms: allow to ignore symbol checksum changes") +Signed-off-by: Masahiro Yamada +Signed-off-by: Sasha Levin +--- + scripts/genksyms/genksyms.c | 3 +++ + scripts/genksyms/parse.y | 14 ++++++++++++-- + 2 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c +index f5dfdb9d80e9d..6ddc8f406c75f 100644 +--- a/scripts/genksyms/genksyms.c ++++ b/scripts/genksyms/genksyms.c +@@ -241,6 +241,7 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type, + "unchanged\n"); + } + sym->is_declared = 1; ++ free_list(defn, NULL); + return sym; + } else if (!sym->is_declared) { + if (sym->is_override && flag_preserve) { +@@ -249,6 +250,7 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type, + print_type_name(type, name); + fprintf(stderr, " modversion change\n"); + sym->is_declared = 1; ++ free_list(defn, NULL); + return sym; + } else { + status = is_unknown_symbol(sym) ? +@@ -256,6 +258,7 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type, + } + } else { + error_with_pos("redefinition of %s", name); ++ free_list(defn, NULL); + return sym; + } + break; +diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y +index 8e9b5e69e8f01..840371d01bf48 100644 +--- a/scripts/genksyms/parse.y ++++ b/scripts/genksyms/parse.y +@@ -152,14 +152,19 @@ simple_declaration: + ; + + init_declarator_list_opt: +- /* empty */ { $$ = NULL; } +- | init_declarator_list ++ /* empty */ { $$ = NULL; } ++ | init_declarator_list { free_list(decl_spec, NULL); $$ = $1; } + ; + + init_declarator_list: + init_declarator + { struct string_list *decl = *$1; + *$1 = NULL; ++ ++ /* avoid sharing among multiple init_declarators */ ++ if (decl_spec) ++ decl_spec = copy_list_range(decl_spec, NULL); ++ + add_symbol(current_name, + is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); + current_name = NULL; +@@ -170,6 +175,11 @@ init_declarator_list: + *$3 = NULL; + free_list(*$2, NULL); + *$2 = decl_spec; ++ ++ /* avoid sharing among multiple init_declarators */ ++ if (decl_spec) ++ decl_spec = copy_list_range(decl_spec, NULL); ++ + add_symbol(current_name, + is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); + current_name = NULL; +-- +2.39.5 + diff --git a/queue-6.1/genksyms-fix-memory-leak-when-the-same-symbol-is-rea.patch b/queue-6.1/genksyms-fix-memory-leak-when-the-same-symbol-is-rea.patch new file mode 100644 index 0000000000..dd922b8acd --- /dev/null +++ b/queue-6.1/genksyms-fix-memory-leak-when-the-same-symbol-is-rea.patch @@ -0,0 +1,108 @@ +From 8d674b8609b246bba14b9035fc1ac45bb59af68f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 3 Jan 2025 16:30:39 +0900 +Subject: genksyms: fix memory leak when the same symbol is read from *.symref + file + +From: Masahiro Yamada + +[ Upstream commit be2fa44b5180a1f021efb40c55fdf63c249c3209 ] + +When a symbol that is already registered is read again from *.symref +file, __add_symbol() removes the previous one from the hash table without +freeing it. + +[Test Case] + + $ cat foo.c + #include + void foo(void); + void foo(void) {} + EXPORT_SYMBOL(foo); + + $ cat foo.symref + foo void foo ( void ) + foo void foo ( void ) + +When a symbol is removed from the hash table, it must be freed along +with its ->name and ->defn members. However, sym->name cannot be freed +because it is sometimes shared with node->string, but not always. If +sym->name and node->string share the same memory, free(sym->name) could +lead to a double-free bug. + +To resolve this issue, always assign a strdup'ed string to sym->name. + +Fixes: 64e6c1e12372 ("genksyms: track symbol checksum changes") +Signed-off-by: Masahiro Yamada +Signed-off-by: Sasha Levin +--- + scripts/genksyms/genksyms.c | 8 ++++++-- + scripts/genksyms/genksyms.h | 2 +- + scripts/genksyms/parse.y | 4 ++-- + 3 files changed, 9 insertions(+), 5 deletions(-) + +diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c +index 6ddc8f406c75f..6b0eb3898e4ec 100644 +--- a/scripts/genksyms/genksyms.c ++++ b/scripts/genksyms/genksyms.c +@@ -274,11 +274,15 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type, + break; + } + } ++ ++ free_list(sym->defn, NULL); ++ free(sym->name); ++ free(sym); + --nsyms; + } + + sym = xmalloc(sizeof(*sym)); +- sym->name = name; ++ sym->name = xstrdup(name); + sym->type = type; + sym->defn = defn; + sym->expansion_trail = NULL; +@@ -485,7 +489,7 @@ static void read_reference(FILE *f) + defn = def; + def = read_node(f); + } +- subsym = add_reference_symbol(xstrdup(sym->string), sym->tag, ++ subsym = add_reference_symbol(sym->string, sym->tag, + defn, is_extern); + subsym->is_override = is_override; + free_node(sym); +diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h +index 21ed2ec2d98ca..5621533dcb8e4 100644 +--- a/scripts/genksyms/genksyms.h ++++ b/scripts/genksyms/genksyms.h +@@ -32,7 +32,7 @@ struct string_list { + + struct symbol { + struct symbol *hash_next; +- const char *name; ++ char *name; + enum symbol_type type; + struct string_list *defn; + struct symbol *expansion_trail; +diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y +index 840371d01bf48..689cb6bb40b65 100644 +--- a/scripts/genksyms/parse.y ++++ b/scripts/genksyms/parse.y +@@ -482,12 +482,12 @@ enumerator_list: + enumerator: + IDENT + { +- const char *name = strdup((*$1)->string); ++ const char *name = (*$1)->string; + add_symbol(name, SYM_ENUM_CONST, NULL, 0); + } + | IDENT '=' EXPRESSION_PHRASE + { +- const char *name = strdup((*$1)->string); ++ const char *name = (*$1)->string; + struct string_list *expr = copy_list_range(*$3, *$2); + add_symbol(name, SYM_ENUM_CONST, expr, 0); + } +-- +2.39.5 + diff --git a/queue-6.1/hexagon-fix-unbalanced-spinlock-in-die.patch b/queue-6.1/hexagon-fix-unbalanced-spinlock-in-die.patch new file mode 100644 index 0000000000..102dbde361 --- /dev/null +++ b/queue-6.1/hexagon-fix-unbalanced-spinlock-in-die.patch @@ -0,0 +1,45 @@ +From 4fc02cfe7b12602a339886e209ff0cb433f4dea1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 22 May 2023 02:56:08 +0000 +Subject: hexagon: Fix unbalanced spinlock in die() + +From: Lin Yujun + +[ Upstream commit 03410e87563a122075c3721acc7d5510e41d8332 ] + +die executes holding the spinlock of &die.lock and unlock +it after printing the oops message. +However in the code if the notify_die() returns NOTIFY_STOP +, die() exit with returning 1 but never unlocked the spinlock. + +Fix this by adding spin_unlock_irq(&die.lock) before returning. + +Fixes: cf9750bae262 ("Hexagon: Provide basic debugging and system trap support.") +Signed-off-by: Lin Yujun +Link: https://lore.kernel.org/r/20230522025608.2515558-1-linyujun809@huawei.com +Signed-off-by: Brian Cain +Signed-off-by: Brian Cain +Signed-off-by: Sasha Levin +--- + arch/hexagon/kernel/traps.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/arch/hexagon/kernel/traps.c b/arch/hexagon/kernel/traps.c +index 6447763ce5a94..b7e394cebe20d 100644 +--- a/arch/hexagon/kernel/traps.c ++++ b/arch/hexagon/kernel/traps.c +@@ -195,8 +195,10 @@ int die(const char *str, struct pt_regs *regs, long err) + printk(KERN_EMERG "Oops: %s[#%d]:\n", str, ++die.counter); + + if (notify_die(DIE_OOPS, str, regs, err, pt_cause(regs), SIGSEGV) == +- NOTIFY_STOP) ++ NOTIFY_STOP) { ++ spin_unlock_irq(&die.lock); + return 1; ++ } + + print_modules(); + show_regs(regs); +-- +2.39.5 + diff --git a/queue-6.1/hexagon-fix-using-plain-integer-as-null-pointer-warn.patch b/queue-6.1/hexagon-fix-using-plain-integer-as-null-pointer-warn.patch new file mode 100644 index 0000000000..3aa6589166 --- /dev/null +++ b/queue-6.1/hexagon-fix-using-plain-integer-as-null-pointer-warn.patch @@ -0,0 +1,61 @@ +From d746a2af9da6260268166caebfeeac393b19ecf7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 3 Dec 2024 17:17:34 -0500 +Subject: hexagon: fix using plain integer as NULL pointer warning in cmpxchg + +From: Willem de Bruijn + +[ Upstream commit 8a20030038742b9915c6d811a4e6c14b126cafb4 ] + +Sparse reports + + net/ipv4/inet_diag.c:1511:17: sparse: sparse: Using plain integer as NULL pointer + +Due to this code calling cmpxchg on a non-integer type +struct inet_diag_handler * + + return !cmpxchg((const struct inet_diag_handler**)&inet_diag_table[type], + NULL, h) ? 0 : -EEXIST; + +While hexagon's cmpxchg assigns an integer value to a variable of this +type. + + __typeof__(*(ptr)) __oldval = 0; + +Update this assignment to cast 0 to the correct type. + +The original issue is easily reproduced at head with the below block, +and is absent after this change. + + make LLVM=1 ARCH=hexagon defconfig + make C=1 LLVM=1 ARCH=hexagon net/ipv4/inet_diag.o + +Fixes: 99a70aa051d2 ("Hexagon: Add processor and system headers") +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202411091538.PGSTqUBi-lkp@intel.com/ +Signed-off-by: Willem de Bruijn +Tested-by: Christian Gmeiner +Link: https://lore.kernel.org/r/20241203221736.282020-1-willemdebruijn.kernel@gmail.com +Signed-off-by: Brian Cain +Signed-off-by: Brian Cain +Signed-off-by: Sasha Levin +--- + arch/hexagon/include/asm/cmpxchg.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/hexagon/include/asm/cmpxchg.h b/arch/hexagon/include/asm/cmpxchg.h +index cdb705e1496af..72c6e16c3f237 100644 +--- a/arch/hexagon/include/asm/cmpxchg.h ++++ b/arch/hexagon/include/asm/cmpxchg.h +@@ -56,7 +56,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, + __typeof__(ptr) __ptr = (ptr); \ + __typeof__(*(ptr)) __old = (old); \ + __typeof__(*(ptr)) __new = (new); \ +- __typeof__(*(ptr)) __oldval = 0; \ ++ __typeof__(*(ptr)) __oldval = (__typeof__(*(ptr))) 0; \ + \ + asm volatile( \ + "1: %0 = memw_locked(%1);\n" \ +-- +2.39.5 + diff --git a/queue-6.1/kconfig-add-warn-unknown-symbols-sanity-check.patch b/queue-6.1/kconfig-add-warn-unknown-symbols-sanity-check.patch new file mode 100644 index 0000000000..0d31e6240e --- /dev/null +++ b/queue-6.1/kconfig-add-warn-unknown-symbols-sanity-check.patch @@ -0,0 +1,115 @@ +From 1af59b231d8628d52a66f45fd98a61265158cf2a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 30 Aug 2023 09:49:36 +0900 +Subject: kconfig: add warn-unknown-symbols sanity check + +From: Sergey Senozhatsky + +[ Upstream commit 7cd343008b967423b06af8f6d3236749c67d12e8 ] + +Introduce KCONFIG_WARN_UNKNOWN_SYMBOLS environment variable, +which makes Kconfig warn about unknown config symbols. + +This is especially useful for continuous kernel uprevs when +some symbols can be either removed or renamed between kernel +releases (which can go unnoticed otherwise). + +By default KCONFIG_WARN_UNKNOWN_SYMBOLS generates warnings, +which are non-terminal. There is an additional environment +variable KCONFIG_WERROR that overrides this behaviour and +turns warnings into errors. + +Signed-off-by: Sergey Senozhatsky +Signed-off-by: Masahiro Yamada +Stable-dep-of: a409fc1463d6 ("kconfig: fix memory leak in sym_warn_unmet_dep()") +Signed-off-by: Sasha Levin +--- + Documentation/kbuild/kconfig.rst | 9 +++++++++ + scripts/kconfig/confdata.c | 21 +++++++++++++++++++-- + 2 files changed, 28 insertions(+), 2 deletions(-) + +diff --git a/Documentation/kbuild/kconfig.rst b/Documentation/kbuild/kconfig.rst +index 5967c79c3baa7..eee0d298774ab 100644 +--- a/Documentation/kbuild/kconfig.rst ++++ b/Documentation/kbuild/kconfig.rst +@@ -54,6 +54,15 @@ KCONFIG_OVERWRITECONFIG + If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not + break symlinks when .config is a symlink to somewhere else. + ++KCONFIG_WARN_UNKNOWN_SYMBOLS ++---------------------------- ++This environment variable makes Kconfig warn about all unrecognized ++symbols in the config input. ++ ++KCONFIG_WERROR ++-------------- ++If set, Kconfig treats warnings as errors. ++ + `CONFIG_` + --------- + If you set `CONFIG_` in the environment, Kconfig will prefix all symbols +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c +index 886698a5afba1..02ac250b8fe9e 100644 +--- a/scripts/kconfig/confdata.c ++++ b/scripts/kconfig/confdata.c +@@ -349,7 +349,11 @@ int conf_read_simple(const char *name, int def) + char *p, *p2; + struct symbol *sym; + int i, def_flags; ++ const char *warn_unknown; ++ const char *werror; + ++ warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS"); ++ werror = getenv("KCONFIG_WERROR"); + if (name) { + in = zconf_fopen(name); + } else { +@@ -439,6 +443,10 @@ int conf_read_simple(const char *name, int def) + if (def == S_DEF_USER) { + sym = sym_find(line + 2 + strlen(CONFIG_)); + if (!sym) { ++ if (warn_unknown) ++ conf_warning("unknown symbol: %s", ++ line + 2 + strlen(CONFIG_)); ++ + conf_set_changed(true); + continue; + } +@@ -473,7 +481,7 @@ int conf_read_simple(const char *name, int def) + + sym = sym_find(line + strlen(CONFIG_)); + if (!sym) { +- if (def == S_DEF_AUTO) ++ if (def == S_DEF_AUTO) { + /* + * Reading from include/config/auto.conf + * If CONFIG_FOO previously existed in +@@ -481,8 +489,13 @@ int conf_read_simple(const char *name, int def) + * include/config/FOO must be touched. + */ + conf_touch_dep(line + strlen(CONFIG_)); +- else ++ } else { ++ if (warn_unknown) ++ conf_warning("unknown symbol: %s", ++ line + strlen(CONFIG_)); ++ + conf_set_changed(true); ++ } + continue; + } + +@@ -521,6 +534,10 @@ int conf_read_simple(const char *name, int def) + } + free(line); + fclose(in); ++ ++ if (conf_warnings && werror) ++ exit(1); ++ + return 0; + } + +-- +2.39.5 + diff --git a/queue-6.1/kconfig-deduplicate-code-in-conf_read_simple.patch b/queue-6.1/kconfig-deduplicate-code-in-conf_read_simple.patch new file mode 100644 index 0000000000..f05ed3f79a --- /dev/null +++ b/queue-6.1/kconfig-deduplicate-code-in-conf_read_simple.patch @@ -0,0 +1,159 @@ +From 8d8d4dd10a8201f7cf49ffcc077b1638f0fced56 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 18 Nov 2023 16:59:09 +0900 +Subject: kconfig: deduplicate code in conf_read_simple() + +From: Masahiro Yamada + +[ Upstream commit d854b4b21de684a16a7d6163c7b0e9c5ff8a09d3 ] + +Kconfig accepts both "# CONFIG_FOO is not set" and "CONFIG_FOO=n" as +a valid input, but conf_read_simple() duplicates similar code to handle +them. Factor out the common code. + +Signed-off-by: Masahiro Yamada +Stable-dep-of: a409fc1463d6 ("kconfig: fix memory leak in sym_warn_unmet_dep()") +Signed-off-by: Sasha Levin +--- + scripts/kconfig/confdata.c | 89 +++++++++++++++----------------------- + 1 file changed, 35 insertions(+), 54 deletions(-) + +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c +index 21a65ffe7c3db..7e799060b6fe2 100644 +--- a/scripts/kconfig/confdata.c ++++ b/scripts/kconfig/confdata.c +@@ -346,11 +346,10 @@ int conf_read_simple(const char *name, int def) + FILE *in = NULL; + char *line = NULL; + size_t line_asize = 0; +- char *p, *p2; ++ char *p, *p2, *val; + struct symbol *sym; + int i, def_flags; +- const char *warn_unknown; +- const char *werror; ++ const char *warn_unknown, *werror, *sym_name; + + warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS"); + werror = getenv("KCONFIG_WERROR"); +@@ -430,77 +429,34 @@ int conf_read_simple(const char *name, int def) + + while (compat_getline(&line, &line_asize, in) != -1) { + conf_lineno++; +- sym = NULL; + if (line[0] == '#') { + if (line[1] != ' ') + continue; +- if (memcmp(line + 2, CONFIG_, strlen(CONFIG_))) ++ p = line + 2; ++ if (memcmp(p, CONFIG_, strlen(CONFIG_))) + continue; +- p = strchr(line + 2 + strlen(CONFIG_), ' '); ++ sym_name = p + strlen(CONFIG_); ++ p = strchr(sym_name, ' '); + if (!p) + continue; + *p++ = 0; + if (strncmp(p, "is not set", 10)) + continue; + +- sym = sym_find(line + 2 + strlen(CONFIG_)); +- if (!sym) { +- if (warn_unknown) +- conf_warning("unknown symbol: %s", +- line + 2 + strlen(CONFIG_)); +- +- conf_set_changed(true); +- continue; +- } +- if (sym->flags & def_flags) { +- conf_warning("override: reassigning to symbol %s", sym->name); +- } +- switch (sym->type) { +- case S_BOOLEAN: +- case S_TRISTATE: +- sym->def[def].tri = no; +- sym->flags |= def_flags; +- break; +- default: +- ; +- } ++ val = "n"; + } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) { +- p = strchr(line + strlen(CONFIG_), '='); ++ sym_name = line + strlen(CONFIG_); ++ p = strchr(sym_name, '='); + if (!p) + continue; + *p++ = 0; ++ val = p; + p2 = strchr(p, '\n'); + if (p2) { + *p2-- = 0; + if (*p2 == '\r') + *p2 = 0; + } +- +- sym = sym_find(line + strlen(CONFIG_)); +- if (!sym) { +- if (def == S_DEF_AUTO) { +- /* +- * Reading from include/config/auto.conf +- * If CONFIG_FOO previously existed in +- * auto.conf but it is missing now, +- * include/config/FOO must be touched. +- */ +- conf_touch_dep(line + strlen(CONFIG_)); +- } else { +- if (warn_unknown) +- conf_warning("unknown symbol: %s", +- line + strlen(CONFIG_)); +- +- conf_set_changed(true); +- } +- continue; +- } +- +- if (sym->flags & def_flags) { +- conf_warning("override: reassigning to symbol %s", sym->name); +- } +- if (conf_set_sym_val(sym, def, def_flags, p)) +- continue; + } else { + if (line[0] != '\r' && line[0] != '\n') + conf_warning("unexpected data: %.*s", +@@ -509,6 +465,31 @@ int conf_read_simple(const char *name, int def) + continue; + } + ++ sym = sym_find(sym_name); ++ if (!sym) { ++ if (def == S_DEF_AUTO) { ++ /* ++ * Reading from include/config/auto.conf. ++ * If CONFIG_FOO previously existed in auto.conf ++ * but it is missing now, include/config/FOO ++ * must be touched. ++ */ ++ conf_touch_dep(sym_name); ++ } else { ++ if (warn_unknown) ++ conf_warning("unknown symbol: %s", sym_name); ++ ++ conf_set_changed(true); ++ } ++ continue; ++ } ++ ++ if (sym->flags & def_flags) ++ conf_warning("override: reassigning to symbol %s", sym->name); ++ ++ if (conf_set_sym_val(sym, def, def_flags, val)) ++ continue; ++ + if (sym && sym_is_choice_value(sym)) { + struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); + switch (sym->def[def].tri) { +-- +2.39.5 + diff --git a/queue-6.1/kconfig-fix-file-name-in-warnings-when-loading-kconf.patch b/queue-6.1/kconfig-fix-file-name-in-warnings-when-loading-kconf.patch new file mode 100644 index 0000000000..cb6259b053 --- /dev/null +++ b/queue-6.1/kconfig-fix-file-name-in-warnings-when-loading-kconf.patch @@ -0,0 +1,74 @@ +From d6d86cd93ed114bd606183af33023fca87b6fef4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 20 Jan 2025 16:59:14 +0900 +Subject: kconfig: fix file name in warnings when loading + KCONFIG_DEFCONFIG_LIST + +From: Masahiro Yamada + +[ Upstream commit a314f52a0210730d0d556de76bb7388e76d4597d ] + +Most 'make *config' commands use .config as the base configuration file. + +When .config does not exist, Kconfig tries to load a file listed in +KCONFIG_DEFCONFIG_LIST instead. + +However, since commit b75b0a819af9 ("kconfig: change defconfig_list +option to environment variable"), warning messages have displayed an +incorrect file name in such cases. + +Below is a demonstration using Debian Trixie. While loading +/boot/config-6.12.9-amd64, the warning messages incorrectly show .config +as the file name. + +With this commit, the correct file name is displayed in warnings. + +[Before] + + $ rm -f .config + $ make config + # + # using defaults found in /boot/config-6.12.9-amd64 + # + .config:6804:warning: symbol value 'm' invalid for FB_BACKLIGHT + .config:9895:warning: symbol value 'm' invalid for ANDROID_BINDER_IPC + +[After] + + $ rm -f .config + $ make config + # + # using defaults found in /boot/config-6.12.9-amd64 + # + /boot/config-6.12.9-amd64:6804:warning: symbol value 'm' invalid for FB_BACKLIGHT + /boot/config-6.12.9-amd64:9895:warning: symbol value 'm' invalid for ANDROID_BINDER_IPC + +Fixes: b75b0a819af9 ("kconfig: change defconfig_list option to environment variable") +Signed-off-by: Masahiro Yamada +Signed-off-by: Sasha Levin +--- + scripts/kconfig/confdata.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c +index 992575f1e9769..886698a5afba1 100644 +--- a/scripts/kconfig/confdata.c ++++ b/scripts/kconfig/confdata.c +@@ -382,10 +382,12 @@ int conf_read_simple(const char *name, int def) + + *p = '\0'; + +- in = zconf_fopen(env); ++ name = env; ++ ++ in = zconf_fopen(name); + if (in) { + conf_message("using defaults found in %s", +- env); ++ name); + goto load; + } + +-- +2.39.5 + diff --git a/queue-6.1/kconfig-fix-memory-leak-in-sym_warn_unmet_dep.patch b/queue-6.1/kconfig-fix-memory-leak-in-sym_warn_unmet_dep.patch new file mode 100644 index 0000000000..fb7d5a21f1 --- /dev/null +++ b/queue-6.1/kconfig-fix-memory-leak-in-sym_warn_unmet_dep.patch @@ -0,0 +1,35 @@ +From b935baee88fe6d46b50c97b45f3cbd592e24189f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 20 Jan 2025 17:10:31 +0900 +Subject: kconfig: fix memory leak in sym_warn_unmet_dep() + +From: Masahiro Yamada + +[ Upstream commit a409fc1463d664002ea9bf700ae4674df03de111 ] + +The string allocated in sym_warn_unmet_dep() is never freed, leading +to a memory leak when an unmet dependency is detected. + +Fixes: f8f69dc0b4e0 ("kconfig: make unmet dependency warnings readable") +Signed-off-by: Masahiro Yamada +Reviewed-by: Petr Vorel +Signed-off-by: Sasha Levin +--- + scripts/kconfig/symbol.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c +index 758c42621f7a1..1c0306c9d74e2 100644 +--- a/scripts/kconfig/symbol.c ++++ b/scripts/kconfig/symbol.c +@@ -321,6 +321,7 @@ static void sym_warn_unmet_dep(struct symbol *sym) + " Selected by [m]:\n"); + + fputs(str_get(&gs), stderr); ++ str_free(&gs); + sym_warnings++; + } + +-- +2.39.5 + diff --git a/queue-6.1/kconfig-remove-unused-code-for-s_def_auto-in-conf_re.patch b/queue-6.1/kconfig-remove-unused-code-for-s_def_auto-in-conf_re.patch new file mode 100644 index 0000000000..6e74897763 --- /dev/null +++ b/queue-6.1/kconfig-remove-unused-code-for-s_def_auto-in-conf_re.patch @@ -0,0 +1,57 @@ +From 9c0a491ebf3b6cb974742ea1fdd7ae18d114d558 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 18 Nov 2023 16:59:08 +0900 +Subject: kconfig: remove unused code for S_DEF_AUTO in conf_read_simple() + +From: Masahiro Yamada + +[ Upstream commit 92d4fe0a48f1ab6cf20143dd0b376f4fe842854b ] + +The 'else' arm here is unreachable in practical use cases. + +include/config/auto.conf does not include "# CONFIG_... is not set" +line unless it is manually hacked. + +Signed-off-by: Masahiro Yamada +Stable-dep-of: a409fc1463d6 ("kconfig: fix memory leak in sym_warn_unmet_dep()") +Signed-off-by: Sasha Levin +--- + scripts/kconfig/confdata.c | 21 ++++++++------------- + 1 file changed, 8 insertions(+), 13 deletions(-) + +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c +index 8694ab1e04067..21a65ffe7c3db 100644 +--- a/scripts/kconfig/confdata.c ++++ b/scripts/kconfig/confdata.c +@@ -442,20 +442,15 @@ int conf_read_simple(const char *name, int def) + *p++ = 0; + if (strncmp(p, "is not set", 10)) + continue; +- if (def == S_DEF_USER) { +- sym = sym_find(line + 2 + strlen(CONFIG_)); +- if (!sym) { +- if (warn_unknown) +- conf_warning("unknown symbol: %s", +- line + 2 + strlen(CONFIG_)); + +- conf_set_changed(true); +- continue; +- } +- } else { +- sym = sym_lookup(line + 2 + strlen(CONFIG_), 0); +- if (sym->type == S_UNKNOWN) +- sym->type = S_BOOLEAN; ++ sym = sym_find(line + 2 + strlen(CONFIG_)); ++ if (!sym) { ++ if (warn_unknown) ++ conf_warning("unknown symbol: %s", ++ line + 2 + strlen(CONFIG_)); ++ ++ conf_set_changed(true); ++ continue; + } + if (sym->flags & def_flags) { + conf_warning("override: reassigning to symbol %s", sym->name); +-- +2.39.5 + diff --git a/queue-6.1/kconfig-require-a-space-after-for-valid-input.patch b/queue-6.1/kconfig-require-a-space-after-for-valid-input.patch new file mode 100644 index 0000000000..e6bc8a8f63 --- /dev/null +++ b/queue-6.1/kconfig-require-a-space-after-for-valid-input.patch @@ -0,0 +1,45 @@ +From a1b9528f89fe897aaf11157f02d14b9622165a0a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 18 Nov 2023 16:59:07 +0900 +Subject: kconfig: require a space after '#' for valid input + +From: Masahiro Yamada + +[ Upstream commit 4d137ab0107ead0f2590fc0314e627431e3b9e3f ] + +Currently, when an input line starts with '#', (line + 2) is passed to +memcmp() without checking line[1]. + +It means that line[1] can be any arbitrary character. For example, +"#KCONFIG_FOO is not set" is accepted as valid input, functioning the +same as "# CONFIG_FOO is not set". + +More importantly, this can potentially lead to a buffer overrun if +line[1] == '\0'. It occurs if the input only contains '#', as +(line + 2) points to an uninitialized buffer. + +Check line[1], and skip the line if it is not a space. + +Signed-off-by: Masahiro Yamada +Stable-dep-of: a409fc1463d6 ("kconfig: fix memory leak in sym_warn_unmet_dep()") +Signed-off-by: Sasha Levin +--- + scripts/kconfig/confdata.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c +index 02ac250b8fe9e..8694ab1e04067 100644 +--- a/scripts/kconfig/confdata.c ++++ b/scripts/kconfig/confdata.c +@@ -432,6 +432,8 @@ int conf_read_simple(const char *name, int def) + conf_lineno++; + sym = NULL; + if (line[0] == '#') { ++ if (line[1] != ' ') ++ continue; + if (memcmp(line + 2, CONFIG_, strlen(CONFIG_))) + continue; + p = strchr(line + 2 + strlen(CONFIG_), ' '); +-- +2.39.5 + diff --git a/queue-6.1/kconfig-werror-unmet-symbol-dependency.patch b/queue-6.1/kconfig-werror-unmet-symbol-dependency.patch new file mode 100644 index 0000000000..d6628fa2a3 --- /dev/null +++ b/queue-6.1/kconfig-werror-unmet-symbol-dependency.patch @@ -0,0 +1,138 @@ +From 2c8762f2146f9996af042dc2184fa8423cdc58f5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 22 Nov 2023 12:47:45 +0900 +Subject: kconfig: WERROR unmet symbol dependency + +From: Sergey Senozhatsky + +[ Upstream commit 15d3f7664d2776c086f813f1efbfe2ae20a85e89 ] + +When KCONFIG_WERROR env variable is set treat unmet direct +symbol dependency as a terminal condition (error). + +Suggested-by: Stefan Reinauer +Signed-off-by: Sergey Senozhatsky +Signed-off-by: Masahiro Yamada +Stable-dep-of: a409fc1463d6 ("kconfig: fix memory leak in sym_warn_unmet_dep()") +Signed-off-by: Sasha Levin +--- + scripts/kconfig/conf.c | 6 ++++++ + scripts/kconfig/confdata.c | 13 ++++++++----- + scripts/kconfig/lkc_proto.h | 2 ++ + scripts/kconfig/symbol.c | 9 +++++++++ + 4 files changed, 25 insertions(+), 5 deletions(-) + +diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c +index 33d19e419908b..662a5e7c37c28 100644 +--- a/scripts/kconfig/conf.c ++++ b/scripts/kconfig/conf.c +@@ -827,6 +827,9 @@ int main(int ac, char **av) + break; + } + ++ if (conf_errors()) ++ exit(1); ++ + if (sync_kconfig) { + name = getenv("KCONFIG_NOSILENTUPDATE"); + if (name && *name) { +@@ -890,6 +893,9 @@ int main(int ac, char **av) + break; + } + ++ if (sym_dep_errors()) ++ exit(1); ++ + if (input_mode == savedefconfig) { + if (conf_write_defconfig(defconfig_file)) { + fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n", +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c +index 7e799060b6fe2..f214e8d3762e0 100644 +--- a/scripts/kconfig/confdata.c ++++ b/scripts/kconfig/confdata.c +@@ -155,6 +155,13 @@ static void conf_message(const char *fmt, ...) + static const char *conf_filename; + static int conf_lineno, conf_warnings; + ++bool conf_errors(void) ++{ ++ if (conf_warnings) ++ return getenv("KCONFIG_WERROR"); ++ return false; ++} ++ + static void conf_warning(const char *fmt, ...) + { + va_list ap; +@@ -349,10 +356,9 @@ int conf_read_simple(const char *name, int def) + char *p, *p2, *val; + struct symbol *sym; + int i, def_flags; +- const char *warn_unknown, *werror, *sym_name; ++ const char *warn_unknown, *sym_name; + + warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS"); +- werror = getenv("KCONFIG_WERROR"); + if (name) { + in = zconf_fopen(name); + } else { +@@ -513,9 +519,6 @@ int conf_read_simple(const char *name, int def) + free(line); + fclose(in); + +- if (conf_warnings && werror) +- exit(1); +- + return 0; + } + +diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h +index edd1e617b25c5..e4931bde7ca76 100644 +--- a/scripts/kconfig/lkc_proto.h ++++ b/scripts/kconfig/lkc_proto.h +@@ -12,6 +12,7 @@ void conf_set_changed(bool val); + bool conf_get_changed(void); + void conf_set_changed_callback(void (*fn)(void)); + void conf_set_message_callback(void (*fn)(const char *s)); ++bool conf_errors(void); + + /* symbol.c */ + extern struct symbol * symbol_hash[SYMBOL_HASHSIZE]; +@@ -22,6 +23,7 @@ void print_symbol_for_listconfig(struct symbol *sym); + struct symbol ** sym_re_search(const char *pattern); + const char * sym_type_name(enum symbol_type type); + void sym_calc_value(struct symbol *sym); ++bool sym_dep_errors(void); + enum symbol_type sym_get_type(struct symbol *sym); + bool sym_tristate_within_range(struct symbol *sym,tristate tri); + bool sym_set_tristate_value(struct symbol *sym,tristate tri); +diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c +index 7b1df55b01767..758c42621f7a1 100644 +--- a/scripts/kconfig/symbol.c ++++ b/scripts/kconfig/symbol.c +@@ -40,6 +40,7 @@ static struct symbol symbol_empty = { + + struct symbol *modules_sym; + static tristate modules_val; ++static int sym_warnings; + + enum symbol_type sym_get_type(struct symbol *sym) + { +@@ -320,6 +321,14 @@ static void sym_warn_unmet_dep(struct symbol *sym) + " Selected by [m]:\n"); + + fputs(str_get(&gs), stderr); ++ sym_warnings++; ++} ++ ++bool sym_dep_errors(void) ++{ ++ if (sym_warnings) ++ return getenv("KCONFIG_WERROR"); ++ return false; + } + + void sym_calc_value(struct symbol *sym) +-- +2.39.5 + diff --git a/queue-6.1/series b/queue-6.1/series index 2bb0c34ad1..150016722e 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -245,3 +245,15 @@ vsock-allow-retrying-on-connect-failure.patch bgmac-reduce-max-frame-size-to-support-just-mtu-1500.patch net-sh_eth-fix-missing-rtnl-lock-in-suspend-resume-p.patch net-hsr-fix-fill_frame_info-regression-vs-vlan-packe.patch +genksyms-fix-memory-leak-when-the-same-symbol-is-add.patch +genksyms-fix-memory-leak-when-the-same-symbol-is-rea.patch +asoc-rockchip-i2s_tdm-re-add-the-set_sysclk-callback.patch +kconfig-fix-file-name-in-warnings-when-loading-kconf.patch +kconfig-add-warn-unknown-symbols-sanity-check.patch +kconfig-require-a-space-after-for-valid-input.patch +kconfig-remove-unused-code-for-s_def_auto-in-conf_re.patch +kconfig-deduplicate-code-in-conf_read_simple.patch +kconfig-werror-unmet-symbol-dependency.patch +kconfig-fix-memory-leak-in-sym_warn_unmet_dep.patch +hexagon-fix-using-plain-integer-as-null-pointer-warn.patch +hexagon-fix-unbalanced-spinlock-in-die.patch