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] [day] [month] [year] [list]
Date:   Wed, 17 Apr 2019 09:03:54 +0530
From:   Sai Prakash Ranjan <saiprakash.ranjan@...eaurora.org>
To:     Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Mulu He <muluhe@...eaurora.org>,
        David Laight <David.Laight@...lab.com>,
        Tingwei Zhang <tingwei@...eaurora.org>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexandre Torgue <alexandre.torgue@...com>,
        linux-stm32@...md-mailman.stormreply.com,
        Mathieu Poirier <mathieu.poirier@...aro.org>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Mike Leach <mike.leach@...aro.org>,
        Leo Yan <leo.yan@...aro.org>
Cc:     Rajendra Nayak <rnayak@...eaurora.org>,
        Vivek Gautam <vivek.gautam@...eaurora.org>,
        Sibi Sankar <sibis@...eaurora.org>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        linux-arm-msm@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH] stm class: Fix out of bound access from bitmap allocation

On 4/16/2019 8:30 PM, Alexander Shishkin wrote:
> Sai Prakash Ranjan <saiprakash.ranjan@...eaurora.org> writes:
> 
>> From: Mulu He <muluhe@...eaurora.org>
>>
>> Bitmap allocation works on array of unsigned longs and
>> for stm master allocation when the number of software
>> channels is 32, 4 bytes are allocated and there is a out of
>> bound access at the first 8 bytes access of bitmap region.
> 
> Does the below fix the problem for you?
> 
>  From fb22b9ab109b332e58d72df13563e270befbd0e3 Mon Sep 17 00:00:00 2001
> From: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
> Date: Tue, 16 Apr 2019 17:47:02 +0300
> Subject: [PATCH] stm class: Fix channel bitmap on 32-bit systems
> 
> Commit 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace
> Module devices") naively calculates the channel bitmap size in 64-bit
> chunks regardless of the size of underlying unsigned long, making the
> bitmap half as big on a 32-bit system. This leads to an out of bounds
> access with the upper half of the bitmap.
> 
> Fix this by using BITS_TO_LONGS. While at it, convert to using
> struct_size() for the total size calculation of the master struct.
> 
> Signed-off-by: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
> Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace Module devices")
> Reported-by: Mulu He <muluhe@...eaurora.org>
> Cc: stable@...r.kernel.org # v4.4+
> ---
>   drivers/hwtracing/stm/core.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
> index 5b5807cbcf7c..8c45e79e47db 100644
> --- a/drivers/hwtracing/stm/core.c
> +++ b/drivers/hwtracing/stm/core.c
> @@ -166,11 +166,9 @@ stm_master(struct stm_device *stm, unsigned int idx)
>   static int stp_master_alloc(struct stm_device *stm, unsigned int idx)
>   {
>   	struct stp_master *master;
> -	size_t size;
>   
> -	size = ALIGN(stm->data->sw_nchannels, 8) / 8;
> -	size += sizeof(struct stp_master);
> -	master = kzalloc(size, GFP_ATOMIC);
> +	master = kzalloc(struct_size(master, chan_map, BITS_TO_LONGS(stm->data->sw_nchannels)),
> +			 GFP_ATOMIC);
>   	if (!master)
>   		return -ENOMEM;
>   
> 

++ David

Yes it does fix the issue. Actually initial fix internally was using
BITS_TO_LONGS, don't no why they deferred from it.

Anyways thanks for the patch.

- Sai

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ