[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZbpXieRZz3BQ6jBH@li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com>
Date: Wed, 31 Jan 2024 15:22:01 +0100
From: Alexander Gordeev <agordeev@...ux.ibm.com>
To: Kees Cook <keescook@...omium.org>, Sven Schnelle <svens@...ux.ibm.com>
Cc: linux-hardening@...r.kernel.org, Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Nico Boehr <nrb@...ux.ibm.com>, Philipp Rudo <prudo@...hat.com>,
Baoquan He <bhe@...hat.com>, Tao Liu <ltao@...hat.com>,
Alexander Egorenkov <egorenar@...ux.ibm.com>,
linux-s390@...r.kernel.org,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Bill Wendling <morbo@...gle.com>,
Justin Stitt <justinstitt@...gle.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 30/82] s390/kexec_file: Refactor intentional wrap-around
calculation
On Mon, Jan 22, 2024 at 04:27:05PM -0800, Kees Cook wrote:
Hi Kees,
..
> arch/s390/include/asm/stacktrace.h | 6 ++++--
> arch/s390/kernel/machine_kexec_file.c | 5 +++--
Subject does not match. These need to be two separate commits.
> 2 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/arch/s390/include/asm/stacktrace.h b/arch/s390/include/asm/stacktrace.h
> index 31ec4f545e03..3ce08d32a8ad 100644
> --- a/arch/s390/include/asm/stacktrace.h
> +++ b/arch/s390/include/asm/stacktrace.h
> @@ -34,11 +34,13 @@ int get_stack_info(unsigned long sp, struct task_struct *task,
> static inline bool on_stack(struct stack_info *info,
> unsigned long addr, size_t len)
> {
> + unsigned long sum;
> +
> if (info->type == STACK_TYPE_UNKNOWN)
> return false;
> - if (addr + len < addr)
> + if (check_add_overflow(addr, len, &sum))
Why not add_would_overflow()?
> return false;
> - return addr >= info->begin && addr + len <= info->end;
> + return addr >= info->begin && sum <= info->end;
> }
>
> /*
> diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c
> index 8d207b82d9fe..e5e925423061 100644
> --- a/arch/s390/kernel/machine_kexec_file.c
> +++ b/arch/s390/kernel/machine_kexec_file.c
> @@ -238,6 +238,7 @@ void *kexec_file_add_components(struct kimage *image,
> unsigned long max_command_line_size = LEGACY_COMMAND_LINE_SIZE;
> struct s390_load_data data = {0};
> unsigned long minsize;
> + unsigned long sum;
Please, use min_kernel_buf_len instead of sum.
@Sven, could you please correct me if (minsize + max_command_line_size)
means something else.
> int ret;
>
> data.report = ipl_report_init(&ipl_block);
> @@ -256,10 +257,10 @@ void *kexec_file_add_components(struct kimage *image,
> if (data.parm->max_command_line_size)
> max_command_line_size = data.parm->max_command_line_size;
>
> - if (minsize + max_command_line_size < minsize)
> + if (check_add_overflow(minsize, max_command_line_size, &sum))
> goto out;
>
> - if (image->kernel_buf_len < minsize + max_command_line_size)
> + if (image->kernel_buf_len < sum)
> goto out;
>
> if (image->cmdline_buf_len >= max_command_line_size)
Thanks!
Powered by blists - more mailing lists