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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 16 Jan 2020 17:52:13 -0600
From:   Michael Bringmann <mwb@...ux.ibm.com>
To:     Michael Ellerman <mpe@...erman.id.au>,
        linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
        Gustavo Walbon <gwalbon@...ux.ibm.com>,
        Paul Mackerras <paulus@...ba.org>
Subject: Re: [PATCH v2] Fix display of Maximum Memory

On 1/15/20 11:53 PM, Michael Ellerman wrote:
> Michael Bringmann <mwb@...ux.ibm.com> writes:
>> Correct overflow problem in calculation+display of Maximum Memory
>> value to syscfg where 32bits is insufficient.
>>
>> Signed-off-by: Michael Bringmann <mwb@...ux.ibm.com>
>> ---
>>  arch/powerpc/platforms/pseries/lparcfg.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/powerpc/platforms/pseries/lparcfg.c b/arch/powerpc/platforms/pseries/lparcfg.c
>> index e33e8bc..f00411c 100644
>> --- a/arch/powerpc/platforms/pseries/lparcfg.c
>> +++ b/arch/powerpc/platforms/pseries/lparcfg.c
>> @@ -433,12 +433,12 @@ static void parse_em_data(struct seq_file *m)
>>  
>>  static void maxmem_data(struct seq_file *m)
>>  {
>> -	unsigned long maxmem = 0;
>> +	u64 maxmem = 0;
> 
> This is 64-bit only code, so u64 == unsigned long.
> 
>> -	maxmem += drmem_info->n_lmbs * drmem_info->lmb_size;
>> -	maxmem += hugetlb_total_pages() * PAGE_SIZE;
>> +	maxmem += (u64)drmem_info->n_lmbs * drmem_info->lmb_size;
> 
> The only problem AFAICS is n_lmbs is int and lmb_size is u32, so this
> multiplication will overflow.
> 
>> +	maxmem += (u64)hugetlb_total_pages() * PAGE_SIZE;
> 
> hugetlb_total_pages() already returns unsigned long.
> 
>> -	seq_printf(m, "MaxMem=%ld\n", maxmem);
>> +	seq_printf(m, "MaxMem=%llu\n", maxmem);
>>  }
> 
> This should be sufficient?
> 
> diff --git a/arch/powerpc/platforms/pseries/lparcfg.c b/arch/powerpc/platforms/pseries/lparcfg.c
> index e33e8bc4b69b..38c306551f76 100644
> --- a/arch/powerpc/platforms/pseries/lparcfg.c
> +++ b/arch/powerpc/platforms/pseries/lparcfg.c
> @@ -435,10 +435,10 @@ static void maxmem_data(struct seq_file *m)
>  {
>         unsigned long maxmem = 0;
>  
> -       maxmem += drmem_info->n_lmbs * drmem_info->lmb_size;
> +       maxmem += (unsigned long)drmem_info->n_lmbs * drmem_info->lmb_size;
>         maxmem += hugetlb_total_pages() * PAGE_SIZE;
>  
> -       seq_printf(m, "MaxMem=%ld\n", maxmem);
> +       seq_printf(m, "MaxMem=%lu\n", maxmem);
>  }
>  
>  static int pseries_lparcfg_data(struct seq_file *m, void *v)
> 
> 
> cheers
> 

Trying it out.

-- 
Michael W. Bringmann
Linux Technology Center
IBM Corporation
Tie-Line  363-5196
External: (512) 286-5196
Cell:       (512) 466-0650
mwb@...ux.ibm.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ