Skip to content

drivers/contactless: fix uninitialized uid leak in mfrc522_read#19419

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/mfrc522-uid-uninit
Jul 13, 2026
Merged

drivers/contactless: fix uninitialized uid leak in mfrc522_read#19419
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/mfrc522-uid-uninit

Conversation

@Zepp-Hanzj

Copy link
Copy Markdown
Contributor

Summary

Fix security issue where uninitialized kernel stack contents could be leaked to userspace when mfrc522_picc_select() fails.

In mfrc522_read(), the local variable uid was not initialized before being passed to mfrc522_picc_select(). If the function fails (e.g., due to bad data on the SPI bus), the uninitialized uid.sak value could pass the PICC_TYPE_NOT_COMPLETE check, causing snprintf() to copy uninitialized kernel stack data to the userspace buffer.

Fixes #19417

Impact

  • Security fix: prevents kernel stack information leak to userspace
  • No functional changes for normal operation
  • Properly propagates error codes from mfrc522_picc_select()

Testing

  • Verified by code inspection against master
  • checkpatch passes
  • Builds successfully with sim:nsh + CONFIG_CL_MFRC522=y

Signed-off-by: hanzhijian hanzhijian@zepp.com

Fix security issue where uninitialized kernel stack contents could be
leaked to userspace when mfrc522_picc_select() fails.

In mfrc522_read(), the local variable 'uid' was not initialized before
being passed to mfrc522_picc_select(). If the function fails (e.g., due
to bad data on the SPI bus), the uninitialized uid.sak value could pass
the PICC_TYPE_NOT_COMPLETE check, causing snprintf() to copy
uninitialized kernel stack data to the userspace buffer.

Fixes apache#19417

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
Author: hanzhijian <hanzhijian@zepp.com>
@github-actions github-actions Bot added the Size: XS The size of the change in this PR is very small label Jul 13, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@xiaoxiang781216 xiaoxiang781216 merged commit 20579ab into apache:master Jul 13, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Lack of Error Code Verification Causes Memory Info Leak

3 participants