From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Carpenter Date: Tue, 02 Apr 2019 06:33:14 +0000 Subject: Re: [PATCH] Bluetooth: hci_event: potential out of bounds parsing ADV events Message-Id: <20190402063313.GA32613@kadam> List-Id: References: <20190330072511.GA5502@kadam> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Cong Wang Cc: Tomas Bortoli , Marcel Holtmann , Jaganath Kanakkassery , Johan Hedberg , linux-bluetooth , kernel-janitors@vger.kernel.org On Mon, Apr 01, 2019 at 11:03:53AM -0700, Cong Wang wrote: > Hi, > > On Sat, Mar 30, 2019 at 2:23 AM Tomas Bortoli wrote: > > > > Hi Dan, > > > > On 3/30/19 8:25 AM, Dan Carpenter wrote: > > > There is a potential out of bounds if "ev->length" is too high or if the > > > number of reports are too many. > > > > > > Fixes: c215e9397b00 ("Bluetooth: Process extended ADV report event") > > > Signed-off-by: Dan Carpenter > > Reviewed-By: Tomas Bortoli > > I sent a patchset to fix all of this kind of OOB: > https://marc.info/?l=linux-netdev&m5314874622831&w=2 > > Unfortunately I get no response... > > Does any of you mind to look at them? > I don't know the rules... When is it ok say: if (skb->len < sizeof(*ev)) return; and when must we say: if (!pskb_may_pull(skb, sizeof(*ev))) return; Btw, get rid of all the likely/unlikely() macros. Then the other style comment would be don't move the "ev = (void *)skb->data;" assignments around. It's ok to say: struct hci_ev_pin_code_req *ev = (void *)skb->data; struct hci_conn *conn; if (!pskb_may_pull(skb, sizeof(*ev))) return; regards, dan carpenter