2023-04-19 08:07:01

by Dan Carpenter

[permalink] [raw]
Subject: [PATCH] arm64: delete dead code in this_cpu_set_vectors()

The "slot" variable is an enum, and in this context it is an unsigned
int. So the type means it can never be negative and also we never pass
invalid data to this function. If something did pass invalid data then
this check would be insufficient protection.

Signed-off-by: Dan Carpenter <[email protected]>
---
arch/arm64/kernel/proton-pack.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c
index fca9cc6f5581..05f40c4e18fd 100644
--- a/arch/arm64/kernel/proton-pack.c
+++ b/arch/arm64/kernel/proton-pack.c
@@ -966,9 +966,6 @@ static void this_cpu_set_vectors(enum arm64_bp_harden_el1_vectors slot)
{
const char *v = arm64_get_bp_hardening_vector(slot);

- if (slot < 0)
- return;
-
__this_cpu_write(this_cpu_vector, v);

/*
--
2.39.2


2023-04-19 14:31:05

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [PATCH] arm64: delete dead code in this_cpu_set_vectors()

On Wed, 19 Apr 2023 at 09:58, Dan Carpenter <[email protected]> wrote:
>
> The "slot" variable is an enum, and in this context it is an unsigned
> int. So the type means it can never be negative and also we never pass
> invalid data to this function. If something did pass invalid data then
> this check would be insufficient protection.
>
> Signed-off-by: Dan Carpenter <[email protected]>

Acked-by: Ard Biesheuvel <[email protected]>

> ---
> arch/arm64/kernel/proton-pack.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c
> index fca9cc6f5581..05f40c4e18fd 100644
> --- a/arch/arm64/kernel/proton-pack.c
> +++ b/arch/arm64/kernel/proton-pack.c
> @@ -966,9 +966,6 @@ static void this_cpu_set_vectors(enum arm64_bp_harden_el1_vectors slot)
> {
> const char *v = arm64_get_bp_hardening_vector(slot);
>
> - if (slot < 0)
> - return;
> -
> __this_cpu_write(this_cpu_vector, v);
>
> /*
> --
> 2.39.2
>

2023-04-20 17:21:23

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH] arm64: delete dead code in this_cpu_set_vectors()

On Wed, 19 Apr 2023 10:58:43 +0300, Dan Carpenter wrote:
> The "slot" variable is an enum, and in this context it is an unsigned
> int. So the type means it can never be negative and also we never pass
> invalid data to this function. If something did pass invalid data then
> this check would be insufficient protection.
>
>

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64: delete dead code in this_cpu_set_vectors()
https://git.kernel.org/arm64/c/460e70e2dc9a

Cheers,
--
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev