Skip to content

Commit 4e942da

Browse files
peaktwilightgregkh
authored andcommitted
nfc: digital: clamp SENSF_RES length to the destination buffer
commit 344a56d upstream. digital_in_recv_sensf_res() memcpy()s resp->len bytes from a remote NFC-F device response into the NFC_SENSF_RES_MAXSIZE-byte target.sensf_res field without an upper-bound check. A nearby malicious NFC-F device can send an oversized SENSF_RES response to overflow the stack-local struct nfc_target. Clamp resp->len to NFC_SENSF_RES_MAXSIZE before the copy. Found by 0sec automated security-research tooling (https://0sec.ai). Fixes: 8c0695e ("NFC Digital: Add NFC-F technology support") Cc: stable@vger.kernel.org Signed-off-by: Doruk Tan Ozturk <doruk@0sec.ai> Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com> Link: https://patch.msgid.link/20260603141355.68156-1-doruk@0sec.ai Signed-off-by: David Heidelberg <david@ixit.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b8c9f25 commit 4e942da

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

net/nfc/digital_technology.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,8 @@ static void digital_in_recv_sensf_res(struct nfc_digital_dev *ddev, void *arg,
778778

779779
sensf_res = (struct digital_sensf_res *)resp->data;
780780

781+
resp->len = min_t(unsigned int, resp->len, NFC_SENSF_RES_MAXSIZE);
782+
781783
memcpy(target.sensf_res, sensf_res, resp->len);
782784
target.sensf_res_len = resp->len;
783785

0 commit comments

Comments
 (0)