]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
x86/delay: Fix the wrong asm constraint in delay_loop()
authorAmmar Faizi <ammarfaizi2@gnuweeb.org>
Tue, 29 Mar 2022 10:47:04 +0000 (17:47 +0700)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:24:02 +0000 (09:24 +0200)
commitbc394e65099c834ae6010624dc5c27dceaf214f4
treec074cb8493a8416097fc3894b425fb5a68ea3247
parent9f2bdd3401cd738a5186470700e8e04c8585652f
x86/delay: Fix the wrong asm constraint in delay_loop()

BugLink: https://bugs.launchpad.net/bugs/1981864
[ Upstream commit b86eb74098a92afd789da02699b4b0dd3f73b889 ]

The asm constraint does not reflect the fact that the asm statement can
modify the value of the local variable loops. Which it does.

Specifying the wrong constraint may lead to undefined behavior, it may
clobber random stuff (e.g. local variable, important temporary value in
regs, etc.). This is especially dangerous when the compiler decides to
inline the function and since it doesn't know that the value gets
modified, it might decide to use it from a register directly without
reloading it.

Change the constraint to "+a" to denote that the first argument is an
input and an output argument.

  [ bp: Fix typo, massage commit message. ]

Fixes: e01b70ef3eb3 ("x86: fix bug in arch/i386/lib/delay.c file, delay_loop function")
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20220329104705.65256-2-ammarfaizi2@gnuweeb.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/x86/lib/delay.c