diff mbox series

net/nfc/nci: use memset avoid infoleaks

Message ID 20220301081750.2053246-1-chi.minghao@zte.com.cn (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net/nfc/nci: use memset avoid infoleaks | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

CGEL March 1, 2022, 8:17 a.m. UTC
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(+)

Comments

Krzysztof Kozlowski March 1, 2022, 8:20 a.m. UTC | #1
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
Krzysztof Kozlowski March 1, 2022, 8:33 a.m. UTC | #2
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
CGEL March 1, 2022, 9:34 a.m. UTC | #3
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
Krzysztof Kozlowski March 1, 2022, 10:24 a.m. UTC | #4
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
diff mbox series

Patch

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;