Return-path: Received: from mail-we0-f180.google.com ([74.125.82.180]:43169 "EHLO mail-we0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751226AbaIBI5u (ORCPT ); Tue, 2 Sep 2014 04:57:50 -0400 MIME-Version: 1.0 In-Reply-To: <20140902085436.GE6549@mwanda> References: <20140901172729.GA6549@mwanda> <20140902085436.GE6549@mwanda> Date: Tue, 2 Sep 2014 10:57:49 +0200 Message-ID: (sfid-20140902_105755_417766_109FBC79) Subject: Re: [patch -RESEND] NFC: potential overflows in microread_target_discovered() From: Frans Klaver To: Dan Carpenter Cc: Lauro Ramos Venancio , Eric Lapuyade , Aloisio Almeida Jr , Samuel Ortiz , "John W. Linville" , Jeff Kirsher , linux-wireless@vger.kernel.org, linux-nfc@ml01.01.org, kernel-janitors@vger.kernel.org, Kees Cook Content-Type: text/plain; charset=UTF-8 Sender: linux-wireless-owner@vger.kernel.org List-ID: On Tue, Sep 2, 2014 at 10:54 AM, Dan Carpenter wrote: > On Tue, Sep 02, 2014 at 09:02:36AM +0200, Frans Klaver wrote: >> > diff --git a/drivers/nfc/microread/microread.c b/drivers/nfc/microread/microread.c >> > index f868333271aa..963a4a5dc88e 100644 >> > --- a/drivers/nfc/microread/microread.c >> > +++ b/drivers/nfc/microread/microread.c >> > @@ -501,9 +501,13 @@ static void microread_target_discovered(struct nfc_hci_dev *hdev, u8 gate, >> > targets->sens_res = >> > be16_to_cpu(*(u16 *)&skb->data[MICROREAD_EMCF_A_ATQA]); >> > targets->sel_res = skb->data[MICROREAD_EMCF_A_SAK]; >> > - memcpy(targets->nfcid1, &skb->data[MICROREAD_EMCF_A_UID], >> > - skb->data[MICROREAD_EMCF_A_LEN]); >> > targets->nfcid1_len = skb->data[MICROREAD_EMCF_A_LEN]; >> > + if (targets->nfcid1_len > sizeof(targets->nfcid1)) { >> >> You should probably compare against sizeof(*targets->nfcid1). >> > > No. It's an array not a pointer. Ai, I overlooked that one. My bad.