From: Jakub Horký jakub.git@horky.net
[ Upstream commit 43c2931a95e6b295bfe9e3b90dbe0f7596933e91 ]
Fix bug where make nconfig doesn't initialize the default locale, which causes ncurses menu borders to be displayed incorrectly (lqqqqk) in UTF-8 terminals that don't support VT100 ACS by default, such as PuTTY.
Signed-off-by: Jakub Horký jakub.git@horky.net Link: https://patch.msgid.link/20251014144405.3975275-2-jakub.git@horky.net [nathan: Alphabetize locale.h include] Signed-off-by: Nathan Chancellor nathan@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
Based on my comprehensive analysis using the available tools and repository examination, here is my assessment:
## **ANSWER: YES**
This commit should be backported to stable kernel trees.
---
## Detailed Analysis:
### 1. **Code Changes Examined**
I examined the commit 707f0e1262828 (backport of upstream 43c2931a95e6b) in the repository:
- **File**: `scripts/kconfig/nconf.c` (userspace build tool, not kernel runtime code) - **Changes**: - Added `#include <locale.h>` at line 10 (alphabetically placed) - Added `setlocale(LC_ALL, "");` at line 1481 in main(), before any ncurses initialization - **Total impact**: 3 lines added (1 include, 1 function call, 1 blank line)
### 2. **Semantic Analysis Tools Used**
- **Bash/Git**: Examined commit history, identified upstream commit (43c2931a95e6b), verified it's first included in v6.18-rc4 - **Read**: Examined the main() function structure in scripts/kconfig/nconf.c:1476-1509 - **Grep**: Searched for similar locale fixes across kconfig tools, found companion mconf fix (3927c4a1084c4) - **WebSearch**: Researched the ncurses UTF-8/locale issue, confirmed this is a well-known problem with a standard solution
**Note**: I did not use mcp__semcode tools extensively because: 1. This is a userspace build tool, not kernel runtime code 2. The change is trivially small (2 effective lines) 3. The affected code has no complex call graphs or dependencies to analyze
### 3. **Impact Scope Analysis**
**What gets fixed:** - ncurses menu borders in `make nconfig` display correctly in UTF-8 terminals like PuTTY - Before: borders show as "lqqqqk" (ACS characters in wrong encoding) - After: borders show as proper box-drawing characters
**Who is affected:** - Kernel developers/builders who use `make nconfig` in UTF-8 terminals without native VT100 ACS support - Common scenario: PuTTY terminal connections
**Risk assessment:** - **Extremely low risk**: `setlocale(LC_ALL, "")` is a standard C library function - It simply initializes locale from environment variables (LANG, LC_ALL, etc.) - Called before any ncurses initialization, following best practices - No side effects on kernel build process or generated kernel
### 4. **Stable Tree Compliance Analysis**
This change meets all criteria for stable backporting:
✅ **Bug fix** - Fixes display corruption issue ✅ **Obviously correct** - Standard solution for well-known ncurses UTF-8 problem ✅ **Small scope** - Only 3 lines in one file ✅ **No new features** - Pure bug fix ✅ **User-visible improvement** - Better terminal display ✅ **Safe** - Uses standard library, no risk of regression ✅ **Self-contained** - No dependencies on other changes ✅ **Companion fix exists** - Similar fix applied to mconf (menuconfig)
### 5. **Supporting Evidence**
1. **Web research confirmed**: This is a documented ncurses issue where setlocale() must be called before initscr() for proper UTF-8 handling (Stack Overflow, multiple discussions)
2. **Pattern consistency**: Author Jakub Horký submitted matching fixes for both nconf and mconf, showing systematic resolution of the same issue across kconfig tools
3. **Already backported**: The commit shows `[ Upstream commit 43c2931a95e6b ]` indicating stable maintainers have already accepted this for backporting
4. **Historical context**: Ancient commit 442ff70223328 "[PATCH] mconf.c needs locale.h" shows this has been a known requirement since early Linux kernel history
### 6. **Recommendation Rationale**
This is an **ideal stable backport candidate** because: - Fixes real user-facing annoyance for kernel builders - Trivially small and safe change - No risk of regression or side effects - Follows ncurses best practices - Part of systematic fix across kconfig tools - Change is build-time only, doesn't affect kernel runtime
The lack of an explicit "Cc: stable@vger.kernel.org" tag is not a concern - stable maintainers correctly identified this as backport- worthy, as evidenced by its presence in the stable tree with the "[ Upstream commit ]" annotation.
**Verdict: Strong YES for backporting to all applicable stable kernel trees.**
scripts/kconfig/nconf.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index ae1fe5f603270..521700ed71524 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -7,6 +7,7 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif +#include <locale.h> #include <string.h> #include <strings.h> #include <stdlib.h> @@ -1478,6 +1479,8 @@ int main(int ac, char **av) int lines, columns; char *mode;
+ setlocale(LC_ALL, ""); + if (ac > 1 && strcmp(av[1], "-s") == 0) { /* Silence conf_read() until the real callback is set up */ conf_set_message_callback(NULL);