diff mbox series

[V2] net/nfc/nci: fix infoleak in struct nci_set_config_param

Message ID 20220302033307.2054766-1-chi.minghao@zte.com.cn (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [V2] net/nfc/nci: fix infoleak in struct nci_set_config_param | 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 2, 2022, 3:33 a.m. UTC
From: "Minghao Chi (CGEL ZTE)" <chi.minghao@zte.com.cn>

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.
This patch zeroes out struct nci_set_config_param before
usage, preventing infoleaks to userspace.

v1->v2:
  -Modify the title.
  -Add explanatory information.

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

Wei Yongjun March 2, 2022, 4:13 a.m. UTC | #1
> From: "Minghao Chi (CGEL ZTE)" <chi.minghao@zte.com.cn>
>
> 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.
> This patch zeroes out struct nci_set_config_param before
> usage, preventing infoleaks to userspace.


How this info leaks to userspace?


nci_set_config_req() convert to use packed 'struct nci_core_set_config_cmd'

to send data, which does not contain hole.
Krzysztof Kozlowski March 2, 2022, 9:02 a.m. UTC | #2
On 02/03/2022 04:33, cgel.zte@gmail.com wrote:
> From: "Minghao Chi (CGEL ZTE)" <chi.minghao@zte.com.cn>
> 
> 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.
> This patch zeroes out struct nci_set_config_param before
> usage, preventing infoleaks to userspace.
> 
> v1->v2:
>   -Modify the title.
>   -Add explanatory information.

Changelog goes below ---.

> Reported-by: Zeal Robot <zealci@zte.com.cn>

Why do you ignore the comment about missing report?

> 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));

You ignored the comment here as well. That's not how a v2 should be
sent...  if you don't agree with comments, we need to keep discussing.

>  	param.id = id;
>  	param.len = len;
>  	param.val = val;


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;