mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 1/4] NFC: st21nfca: Fix out of bounds kernel access when handling ATR_REQ
@ 2018-05-03 18:38 Amit Pundir
  2018-05-03 18:38 ` [PATCH v3 2/4] NFC: Fix possible memory corruption when handling SHDLC I-Frame commands Amit Pundir
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Amit Pundir @ 2018-05-03 18:38 UTC (permalink / raw)
  To: lkml, linux-wireless
  Cc: Suren Baghdasaryan, Samuel Ortiz, Christophe Ricard,
	Andy Shevchenko, Greg KH, John Stultz, Dmitry Shmidt, Todd Kjos,
	Android Kernel Team, Stable

From: Suren Baghdasaryan <surenb@google.com>

Out of bounds kernel accesses in st21nfca's NFC HCI layer
might happen when handling ATR_REQ events if user-specified
atr_req->length is bigger than the buffer size. In
that case memcpy() inside st21nfca_tm_send_atr_res() will
read extra bytes resulting in OOB read from the kernel heap.

cc: Stable <stable@vger.kernel.org>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v3..v1:
Resend. No changes.

 drivers/nfc/st21nfca/dep.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nfc/st21nfca/dep.c b/drivers/nfc/st21nfca/dep.c
index fd08be2917e6..3420c5104c94 100644
--- a/drivers/nfc/st21nfca/dep.c
+++ b/drivers/nfc/st21nfca/dep.c
@@ -217,7 +217,8 @@ static int st21nfca_tm_recv_atr_req(struct nfc_hci_dev *hdev,
 
 	atr_req = (struct st21nfca_atr_req *)skb->data;
 
-	if (atr_req->length < sizeof(struct st21nfca_atr_req)) {
+	if (atr_req->length < sizeof(struct st21nfca_atr_req) ||
+	    atr_req->length > skb->len) {
 		r = -EPROTO;
 		goto exit;
 	}
-- 
2.7.4

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

end of thread, other threads:[~2018-06-09  9:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 18:38 [PATCH v3 1/4] NFC: st21nfca: Fix out of bounds kernel access when handling ATR_REQ Amit Pundir
2018-05-03 18:38 ` [PATCH v3 2/4] NFC: Fix possible memory corruption when handling SHDLC I-Frame commands Amit Pundir
2018-05-03 18:38 ` [PATCH v3 3/4] NFC: fdp: Fix possible buffer overflow in WCS4000 NFC driver Amit Pundir
2018-05-03 18:38 ` [PATCH v3 4/4] NFC: fdp: Remove __func__ from dev_dbg() Amit Pundir
2018-06-09  9:51 ` [PATCH v3 1/4] NFC: st21nfca: Fix out of bounds kernel access when handling ATR_REQ Samuel Ortiz

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

Powered by JetHome