mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net/nfc/nci: use memset avoid infoleaks
@ 2022-03-01  8:17 cgel.zte
  2022-03-01  8:20 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 5+ messages in thread
From: cgel.zte @ 2022-03-01  8:17 UTC (permalink / raw)
  To: krzysztof.kozlowski
  Cc: davem, kuba, netdev, linux-kernel, Minghao Chi, Zeal Robot

From: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>

Use memset to initialize structs to preventing infoleaks
in nci_set_config

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
---
 net/nfc/nci/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index d2537383a3e8..32be42be1152 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -641,6 +641,7 @@ int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, const __u8 *val)
 	if (!val || !len)
 		return 0;
 
+	memset(&param, 0x0, sizeof(param));
 	param.id = id;
 	param.len = len;
 	param.val = val;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/nfc/nci: use memset avoid infoleaks
  2022-03-01  8:17 [PATCH] net/nfc/nci: use memset avoid infoleaks cgel.zte
@ 2022-03-01  8:20 ` Krzysztof Kozlowski
  2022-03-01  8:33   ` Krzysztof Kozlowski
  2022-03-01  9:34   ` Lv Ruyi
  0 siblings, 2 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-01  8:20 UTC (permalink / raw)
  To: cgel.zte; +Cc: davem, kuba, netdev, linux-kernel, Minghao Chi, Zeal Robot

On 01/03/2022 09:17, cgel.zte@gmail.com wrote:
> From: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
> 
> Use memset to initialize structs to preventing infoleaks
> in nci_set_config
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
> ---
>  net/nfc/nci/core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
> index d2537383a3e8..32be42be1152 100644
> --- a/net/nfc/nci/core.c
> +++ b/net/nfc/nci/core.c
> @@ -641,6 +641,7 @@ int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, const __u8 *val)
>  	if (!val || !len)
>  		return 0;
>  
> +	memset(&param, 0x0, sizeof(param));
>  	param.id = id;
>  	param.len = len;
>  	param.val = val;

The entire 'param' is overwritten in later code, so what could leak here?

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/nfc/nci: use memset avoid infoleaks
  2022-03-01  8:20 ` Krzysztof Kozlowski
@ 2022-03-01  8:33   ` Krzysztof Kozlowski
  2022-03-01  9:34   ` Lv Ruyi
  1 sibling, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-01  8:33 UTC (permalink / raw)
  To: cgel.zte; +Cc: davem, kuba, netdev, linux-kernel, Minghao Chi, Zeal Robot

On 01/03/2022 09:20, Krzysztof Kozlowski wrote:
> On 01/03/2022 09:17, cgel.zte@gmail.com wrote:
>> From: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
>>
>> Use memset to initialize structs to preventing infoleaks
>> in nci_set_config
>>
>> Reported-by: Zeal Robot <zealci@zte.com.cn>

One more thing. This report seems to be hidden, not public. Reported-by
tag means someone reported something and you want to give credits for
that. Using internal tool in a hidden, secret, non-public way does not
fit open-source collaboration method.

What is more: the email is invalid. "User unknown id"

>> Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
>> ---
>>  net/nfc/nci/core.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
>> index d2537383a3e8..32be42be1152 100644
>> --- a/net/nfc/nci/core.c
>> +++ b/net/nfc/nci/core.c
>> @@ -641,6 +641,7 @@ int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, const __u8 *val)
>>  	if (!val || !len)
>>  		return 0;
>>  
>> +	memset(&param, 0x0, sizeof(param));
>>  	param.id = id;
>>  	param.len = len;
>>  	param.val = val;
> 
> The entire 'param' is overwritten in later code, so what could leak here?
> 
> Best regards,
> Krzysztof


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/nfc/nci: use memset avoid infoleaks
  2022-03-01  8:20 ` Krzysztof Kozlowski
  2022-03-01  8:33   ` Krzysztof Kozlowski
@ 2022-03-01  9:34   ` Lv Ruyi
  2022-03-01 10:24     ` Krzysztof Kozlowski
  1 sibling, 1 reply; 5+ messages in thread
From: Lv Ruyi @ 2022-03-01  9:34 UTC (permalink / raw)
  To: krzysztof.kozlowski
  Cc: cgel.zte, chi.minghao, davem, kuba, linux-kernel, netdev, zealci

hello sir

I think this way: On 64-bit systems, struct nci_set_config_param has 
an added padding of 7 bytes between struct members id and len. Even 
though all struct members are initialized, the 7-byte hole will 
contain data from the kernel stack. 

thanks
Minghao

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/nfc/nci: use memset avoid infoleaks
  2022-03-01  9:34   ` Lv Ruyi
@ 2022-03-01 10:24     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-01 10:24 UTC (permalink / raw)
  To: Lv Ruyi; +Cc: chi.minghao, davem, kuba, linux-kernel, netdev, zealci

On 01/03/2022 10:34, Lv Ruyi wrote:
> hello sir
> 
> I think this way: On 64-bit systems, struct nci_set_config_param has 
> an added padding of 7 bytes between struct members id and len. Even 
> though all struct members are initialized, the 7-byte hole will 
> contain data from the kernel stack. 
> 

That's reasonable. This explanation should be mentioned in the commit
msg. Also just initialize the array to 0, instead of separate memset call.


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-01 10:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01  8:17 [PATCH] net/nfc/nci: use memset avoid infoleaks cgel.zte
2022-03-01  8:20 ` Krzysztof Kozlowski
2022-03-01  8:33   ` Krzysztof Kozlowski
2022-03-01  9:34   ` Lv Ruyi
2022-03-01 10:24     ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®