Go to file
Mihai Moldovan cc1956f8b2 kconfig: nconf: stop endless search loops
[ Upstream commit 8c94b430b9f6213dec84e309bb480a71778c4213 ]

If the user selects the very first entry in a page and performs a
search-up operation, or selects the very last entry in a page and
performs a search-down operation that will not succeed (e.g., via
[/]asdfzzz[Up Arrow]), nconf will never terminate searching the page.

The reason is that in this case, the starting point will be set to -1
or n, which is then translated into (n - 1) (i.e., the last entry of
the page) or 0 (i.e., the first entry of the page) and finally the
search begins. This continues to work fine until the index reaches 0 or
(n - 1), at which point it will be decremented to -1 or incremented to
n, but not checked against the starting point right away. Instead, it's
wrapped around to the bottom or top again, after which the starting
point check occurs... and naturally fails.

My original implementation added another check for -1 before wrapping
the running index variable around, but Masahiro Yamada pointed out that
the actual issue is that the comparison point (starting point) exceeds
bounds (i.e., the [0,n-1] interval) in the first place and that,
instead, the starting point should be fixed.

This has the welcome side-effect of also fixing the case where the
starting point was n while searching down, which also lead to an
infinite loop.

OTOH, this code is now essentially all his work.

Amazingly, nobody seems to have been hit by this for 11 years - or at
the very least nobody bothered to debug and fix this.

Signed-off-by: Mihai Moldovan <ionic@ionic.de>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-05-19 10:12:56 +02:00
arch powerpc/mm: Add cond_resched() while removing hpte mappings 2021-05-19 10:12:56 +02:00
block
certs
crypto
Documentation
drivers drm/amd/display: Force vsync flip when reconfiguring MPCC 2021-05-19 10:12:56 +02:00
fs cuse: prevent clone 2021-05-19 10:12:56 +02:00
include i2c: Add I2C_AQ_NO_REP_START adapter quirk 2021-05-19 10:12:54 +02:00
init
ipc
kernel
lib
LICENSES
mm
net mac80211: clear the beacon's CRC after channel switch 2021-05-19 10:12:55 +02:00
samples
scripts kconfig: nconf: stop endless search loops 2021-05-19 10:12:56 +02:00
security
sound ASoC: rsnd: call rsnd_ssi_master_clk_start() from rsnd_ssi_init() 2021-05-19 10:12:56 +02:00
tools selftests: Set CC to clang in lib.mk if LLVM is set 2021-05-19 10:12:56 +02:00
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.