Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: "Yann E. MORIN" <yann.morin.1998@free.fr>,
	Peter Korsgaard <peter@korsgaard.com>,
	Cherniaev Andrei <dungeonlords789@naver.com>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 6.16-5.4] kconfig: lxdialog: fix 'space' to (de)select options
Date: Sat,  9 Aug 2025 20:20:52 -0400	[thread overview]
Message-ID: <20250810002104.1545396-3-sashal@kernel.org> (raw)
In-Reply-To: <20250810002104.1545396-1-sashal@kernel.org>

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

[ Upstream commit 694174f94ebeeb5ec5cc0e9de9b40c82057e1d95 ]

In case a menu has comment without letters/numbers (eg. characters
matching the regexp '^[^[:alpha:][:digit:]]+$', for example - or *),
hitting space will cycle through those comments, rather than
selecting/deselecting the currently-highlighted option.

This is the behaviour of hitting any letter/digit: jump to the next
option which prompt starts with that letter. The only letters that
do not behave as such are 'y' 'm' and 'n'. Prompts that start with
one of those three letters are instead matched on the first letter
that is not 'y', 'm' or 'n'.

Fix that by treating 'space' as we treat y/m/n, ie. as an action key,
not as shortcut to jump to  prompt.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Cherniaev Andrei <dungeonlords789@naver.com>
[masahiro: took from Buildroot, adjusted the commit subject]
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

Now I have a complete understanding of the bug and fix. Let me provide
my analysis:

**Backport Status: YES**

## Extensive Analysis:

This commit fixes a **clear user interface bug** in the kernel's
menuconfig system (lxdialog) that affects the fundamental usability of
kernel configuration. Here's the detailed analysis:

### The Bug:
When a menu contains comment lines that start with non-alphanumeric
characters (like `-`, `*`, or other special characters matching
`^[^[:alpha:][:digit:]]+$`), pressing the space bar incorrectly cycles
through these comment items instead of selecting/deselecting the
currently highlighted option.

### Root Cause (from code analysis):

1. **Line 267 (original)**: The condition `if (strchr("ynmh", key))`
   checks if the pressed key is one of the special action keys (`y`,
   `n`, `m`, `h`). If it is, it sets `i = max_choice` to skip the jump-
   to-prompt logic.

2. **Lines 269-282**: For any other key (including space), the code
   searches for menu items starting with that character, treating it as
   a shortcut to jump to prompts beginning with that letter.

3. **The problem**: Space (ASCII 32) was not included in the special
   action keys list, so when pressed, it would trigger the jump-to-
   prompt logic. If menu items had comments starting with spaces or
   special characters, the space key would match these and jump to them
   instead of performing its intended action.

4. **Lines 362-398**: The switch statement shows that space (line 362)
   IS supposed to be an action key that returns value 8 (line 397-398),
   which indicates a selection/deselection action.

### The Fix:
The fix is minimal and surgical - changing line 267 from:
```c
if (strchr("ynmh", key))
```
to:
```c
if (strchr("ynmh ", key))  // Added space character
```

This ensures space is treated as an action key, not as a jump-to-prompt
shortcut.

### Why This Should Be Backported:

1. **Fixes a real user-facing bug**: This directly impacts anyone using
   menuconfig to configure the kernel, which is a fundamental tool for
   kernel configuration.

2. **Minimal and contained fix**: The change is a single character
   addition with no architectural changes or new features.

3. **Low regression risk**: The fix only affects the specific broken
   behavior and restores the intended functionality that's already
   defined in the switch statement.

4. **Long-standing issue**: The commit message indicates this came from
   Buildroot, suggesting it's been affecting users across multiple
   projects for some time.

5. **Clear behavioral inconsistency**: The code clearly shows space was
   meant to be an action key (returning value 8 in the switch
   statement), but was incorrectly handled in the shortcut logic.

6. **No side effects**: The change only affects space key handling in
   menuconfig and doesn't touch any kernel runtime code or critical
   subsystems.

This is an ideal stable backport candidate - it fixes a clear bug with
minimal change and risk.

 scripts/kconfig/lxdialog/menubox.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index 6e6244df0c56..d4c19b7beebb 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -264,7 +264,7 @@ int dialog_menu(const char *title, const char *prompt,
 		if (key < 256 && isalpha(key))
 			key = tolower(key);
 
-		if (strchr("ynmh", key))
+		if (strchr("ynmh ", key))
 			i = max_choice;
 		else {
 			for (i = choice + 1; i < max_choice; i++) {
-- 
2.39.5


  parent reply	other threads:[~2025-08-10  0:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-10  0:20 [PATCH AUTOSEL 6.16-5.4] kconfig: gconf: avoid hardcoding model2 in on_treeview2_cursor_changed() Sasha Levin
2025-08-10  0:20 ` [PATCH AUTOSEL 6.16-6.15] kheaders: rebuild kheaders_data.tar.xz when a file is modified within a minute Sasha Levin
2025-08-10  0:20 ` Sasha Levin [this message]
2025-08-10  0:20 ` [PATCH AUTOSEL 6.16-5.4] scsi: aacraid: Stop using PCI_IRQ_AFFINITY Sasha Levin
2025-08-10  0:20 ` [PATCH AUTOSEL 6.16-5.4] kconfig: gconf: fix potential memory leak in renderer_edited() Sasha Levin
2025-08-10  0:20 ` [PATCH AUTOSEL 6.16-5.15] scsi: target: core: Generate correct identifiers for PR OUT transport IDs Sasha Levin
2025-08-10  0:20 ` [PATCH AUTOSEL 6.16-5.4] ipmi: Fix strcpy source and destination the same Sasha Levin
2025-08-10  0:20 ` [PATCH AUTOSEL 6.16-5.4] scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans Sasha Levin
2025-08-10  0:20 ` [PATCH AUTOSEL 6.16-6.1] vfio/mlx5: fix possible overflow in tracking max message size Sasha Levin
2025-08-10  0:20 ` [PATCH AUTOSEL 6.16-5.4] kconfig: nconf: Ensure null termination where strncpy is used Sasha Levin
2025-08-10  0:21 ` [PATCH AUTOSEL 6.16-5.4] kconfig: lxdialog: replace strcpy() with strncpy() in inputbox.c Sasha Levin
2025-08-10  0:21 ` [PATCH AUTOSEL 6.16-5.15] vfio/type1: conditional rescheduling while pinning Sasha Levin
2025-08-10  0:21 ` [PATCH AUTOSEL 6.16-5.4] ipmi: Use dev_warn_ratelimited() for incorrect message warnings Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250810002104.1545396-3-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dungeonlords789@naver.com \
    --cc=masahiroy@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=peter@korsgaard.com \
    --cc=stable@vger.kernel.org \
    --cc=yann.morin.1998@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox