[PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer

Stuart Hayes posted 3 patches 6 months, 3 weeks ago
There is a newer version of this series
[PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer
Posted by Stuart Hayes 6 months, 3 weeks ago
The dell_rbu driver will use memset to clear the data held by each packet
when it is no longer needed (when the driver is unloaded, the packet size
is changed, etc).

The amount of memory that is cleared is (currently) the normal packet
size.  However, the last packet in the list may be smaller.  Fix this to
only clear the memory actually used by each packet, to prevent it from
writing past the end of data buffer.

Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>
---
 drivers/platform/x86/dell/dell_rbu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/dell/dell_rbu.c b/drivers/platform/x86/dell/dell_rbu.c
index c03d4d55fcc1..7d5b26735a20 100644
--- a/drivers/platform/x86/dell/dell_rbu.c
+++ b/drivers/platform/x86/dell/dell_rbu.c
@@ -322,7 +322,7 @@ static void packet_empty_list(void)
 		 * zero out the RBU packet memory before freeing
 		 * to make sure there are no stale RBU packets left in memory
 		 */
-		memset(newpacket->data, 0, rbu_data.packetsize);
+		memset(newpacket->data, 0, newpacket->length);
 		set_memory_wb((unsigned long)newpacket->data,
 			1 << newpacket->ordernum);
 		free_pages((unsigned long) newpacket->data,
-- 
2.47.1
Re: [PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer
Posted by Ilpo Järvinen 6 months, 3 weeks ago
On Thu, 22 May 2025, Stuart Hayes wrote:

> The dell_rbu driver will use memset to clear the data held by each packet

Please add () after function names.

> when it is no longer needed (when the driver is unloaded, the packet size
> is changed, etc).
> 
> The amount of memory that is cleared is (currently) the normal packet
> size.  However, the last packet in the list may be smaller.  Fix this to

One space is enough after .

> only clear the memory actually used by each packet, to prevent it from
> writing past the end of data buffer.
> 
> Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>

Fixes tag?

> ---
>  drivers/platform/x86/dell/dell_rbu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/dell/dell_rbu.c b/drivers/platform/x86/dell/dell_rbu.c
> index c03d4d55fcc1..7d5b26735a20 100644
> --- a/drivers/platform/x86/dell/dell_rbu.c
> +++ b/drivers/platform/x86/dell/dell_rbu.c
> @@ -322,7 +322,7 @@ static void packet_empty_list(void)
>  		 * zero out the RBU packet memory before freeing
>  		 * to make sure there are no stale RBU packets left in memory
>  		 */
> -		memset(newpacket->data, 0, rbu_data.packetsize);
> +		memset(newpacket->data, 0, newpacket->length);
>  		set_memory_wb((unsigned long)newpacket->data,
>  			1 << newpacket->ordernum);
>  		free_pages((unsigned long) newpacket->data,
> 

-- 
 i.
Re: [PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer
Posted by stuart hayes 6 months, 2 weeks ago
On 5/25/2025 5:14 PM, Ilpo Järvinen wrote:
> On Thu, 22 May 2025, Stuart Hayes wrote:
> 
>> The dell_rbu driver will use memset to clear the data held by each packet
> 
> Please add () after function names.
> 
>> when it is no longer needed (when the driver is unloaded, the packet size
>> is changed, etc).
>>
>> The amount of memory that is cleared is (currently) the normal packet
>> size.  However, the last packet in the list may be smaller.  Fix this to
> 
> One space is enough after .
> 
>> only clear the memory actually used by each packet, to prevent it from
>> writing past the end of data buffer.
>>
>> Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>
> 
> Fixes tag?
> 
>> ---

Thank you for reviewing this! I sent a new version (V3) with these fixes 
(and a module version bump).