lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 23 Jun 2022 09:13:08 +0100
From:   Marc Zyngier <maz@...nel.org>
To:     Chen Zhongjin <chenzhongjin@...wei.com>
Cc:     linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
        linuxppc-dev@...ts.ozlabs.org,
        linux-arm-kernel@...ts.infradead.org, linux-kbuild@...r.kernel.org,
        live-patching@...r.kernel.org, jpoimboe@...nel.org,
        peterz@...radead.org, catalin.marinas@....com, will@...nel.org,
        masahiroy@...nel.org, michal.lkml@...kovi.net,
        ndesaulniers@...gle.com, mark.rutland@....com,
        pasha.tatashin@...een.com, broonie@...nel.org,
        rmk+kernel@...linux.org.uk, madvenka@...ux.microsoft.com,
        christophe.leroy@...roup.eu, daniel.thompson@...aro.org
Subject: Re: [PATCH v6 32/33] arm64: irq-gic: Replace unreachable() with
 -EINVAL

On 2022-06-23 02:49, Chen Zhongjin wrote:
> Using unreachable() at default of switch generates an extra branch at
> end of the function, and compiler won't generate a ret to close this
> branch because it knows it's unreachable.
> 
> If there's no instruction in this branch, compiler will generate a NOP,
> And it will confuse objtool to warn this NOP as a fall through branch.
> 
> In fact these branches are actually unreachable, so we can replace
> unreachable() with returning a -EINVAL value.
> 
> Signed-off-by: Chen Zhongjin <chenzhongjin@...wei.com>
> ---
>  arch/arm64/kvm/hyp/vgic-v3-sr.c | 7 +++----
>  drivers/irqchip/irq-gic-v3.c    | 2 +-
>  2 files changed, 4 insertions(+), 5 deletions(-)

Basic courtesy would have been to Cc the maintainers of this code.

> 
> diff --git a/arch/arm64/kvm/hyp/vgic-v3-sr.c 
> b/arch/arm64/kvm/hyp/vgic-v3-sr.c
> index 4fb419f7b8b6..f3cee92c3038 100644
> --- a/arch/arm64/kvm/hyp/vgic-v3-sr.c
> +++ b/arch/arm64/kvm/hyp/vgic-v3-sr.c
> @@ -6,7 +6,6 @@
> 
>  #include <hyp/adjust_pc.h>
> 
> -#include <linux/compiler.h>
>  #include <linux/irqchip/arm-gic-v3.h>
>  #include <linux/kvm_host.h>
> 
> @@ -55,7 +54,7 @@ static u64 __gic_v3_get_lr(unsigned int lr)
>  		return read_gicreg(ICH_LR15_EL2);
>  	}
> 
> -	unreachable();
> +	return -EINVAL;

NAK. That's absolutely *wrong*, and will hide future bugs.
Nothing checks for -EINVAL, and we *never* expect to
reach this, hence the perfectly valid annotation.

If something needs fixing, it probably is your tooling.

         M.
-- 
Jazz is not dead. It just smells funny...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ