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, 4 Nov 2021 12:55:16 -0400
From:   Johannes Weiner <hannes@...xchg.org>
To:     Ravi Singh <ravi.singh1@...sung.com>
Cc:     mingo@...hat.com, peterz@...radead.org,
        linux-kernel@...r.kernel.org, a.sahrawat@...sung.com,
        v.narang@...sung.com, vishal.goel@...sung.com,
        Suren Baghdasaryan <surenb@...gle.com>
Subject: Re: [PATCH] psi: fix integer overflow on unsigned int multiply on 32
 bit systems

CC Suren

Sorry, this fell through the cracks.

On Mon, Sep 13, 2021 at 02:21:35PM +0530, Ravi Singh wrote:
> psi accepts window sizes upto WINDOW_MAX_US(10000000). In the case
> where window_us is larger than 4294967, the result of an
> multiplication overflows an unsigned int/long(4 bytes on 32 bit
> system).
> 
> For example, this can happen when the window_us is 5000000 so 5000000
> * 1000 (NSEC_PER_USEC) will result in 5000000000 which is greater than
> UINT_MAX(4294967295). Due to this overflow, 705032704 is stored in
> t->win.size instead of 5000000000. Now psi will be monitoring the
> window size of 705 msecs instead of 5 secs as expected by user.
> 
> Fix this by type casting the first term of the mutiply to a u64.
> 
> Issue doesnot occur on 64 bit systems because NSEC_PER_USEC is of type
> long which is 8 bytes on 64 bit systems.
> 
> Signed-off-by: Ravi Singh <ravi.singh1@...sung.com>

Fixes: 0e94682b73bf psi: introduce psi monitor
Acked-by: Johannes Weiner <hannes@...xchg.org>

Peter would you mind taking this through -tip?

> ---
>  kernel/sched/psi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
> index 1652f2bb5..a2cc33dc2 100644
> --- a/kernel/sched/psi.c
> +++ b/kernel/sched/psi.c
> @@ -1145,7 +1145,7 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group,
>  	t->group = group;
>  	t->state = state;
>  	t->threshold = threshold_us * NSEC_PER_USEC;
> -	t->win.size = window_us * NSEC_PER_USEC;
> +	t->win.size = (u64)window_us * NSEC_PER_USEC;
>  	window_reset(&t->win, 0, 0, 0);
>  
>  	t->event = 0;
> -- 
> 2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ