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, 9 Jun 2022 16:20:03 +0100
From:   Will Deacon <will@...nel.org>
To:     Chen Jun <chenjun102@...wei.com>
Cc:     linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        catalin.marinas@....com, xuqiang36@...wei.com
Subject: Re: [PATCH] arm64/smp: check !ipi_desc[i] in arch_show_interrupts

On Fri, May 27, 2022 at 08:22:36AM +0000, Chen Jun wrote:
> There is a potential dereferencing null pointer issue in
> arch_show_interrupts.
> 
> Problem 1:
> int arch_show_interrupts(struct seq_file *p, int prec)
>         for (i = 0; i < NR_IPI; i++) {
>                 seq_printf(p, "%10u ", irq_desc_kstat_cpu(ipi_desc[i],
> 			cpu));
> 
> Only ipi_desc[0..nr_ipi - 1] are initialized in set_smp_ipi_range.
> and ipi_desc[nr_ipi..NR_IPI] are NULL.
> irq_desc_kstat_cpu will dereference NULL pointer.
> For now, the problem can not be triggered, because NR_IPI is always
> equal to nr_ipi.
> 
> Problem 2:
> If request_percpu_irq failed in set_smp_ipi_range, ipi_desc[i]
> would be NULL.
> irq_desc_kstat_cpu will dereference NULL pointer.
> 
> check !ipi_desc[i] (as arm does) to avoid the problem.
> 
> Signed-off-by: Chen Jun <chenjun102@...wei.com>
> ---
>  arch/arm64/kernel/smp.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index 62ed361a4376..3d54f464428b 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -781,6 +781,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
>  	unsigned int cpu, i;
>  
>  	for (i = 0; i < NR_IPI; i++) {
> +		if (!ipi_desc[i])
> +			continue;

Why not just use nr_ipi instead of NR_IPI?

Will

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ