Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2707385imb; Mon, 4 Mar 2019 11:59:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IYFhp7LYo6ho8INmrUd0XSq8kq9pTMyseUDTPXc2k1DHRQmBq8HhKa01cfQ8Li+7LrRmNpq X-Received: by 2002:a62:5c4:: with SMTP id 187mr21382071pff.153.1551729581203; Mon, 04 Mar 2019 11:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551729581; cv=none; d=google.com; s=arc-20160816; b=fjWN9LaO+6Kh3AYypZoB//53Ht+9wenaO+M6UyjrE5c8px4mH7KCWJusxmaGDqMWlX ZESvFd2yEWHLM71WHp4t5nNkwiR0zcewHJ7c3ODEuKWXtH3STSuyD2hbc9eiN2di2BGB I2I88qOpR4Owzkpqurpna4pKLhSajbAvFGnWeGnFkalUso9cJz2p2deHTEf8kEIb49YD zt9RgOBeog2jo7QIh+al70B0boAp6cIMFEUqrRsGeQgWafTPh7QyhirDxympAtp2/rpJ 7a+ZabqZmIwrxihR3/EkWFoO4wfdG9akcEuOc2qw5r1cQUYOOuVXIWjb3AIq95/x0Fes cj3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=elT29l8X5hVeGPNB6shy9LBKPe6vGAMd1PWsj3gyLFE=; b=w1Fjz+1Zrek9kf/faOaMITvqJ0RTzwhv7WSYgmH01RJazEsIR5EtxnvBYqbxvm4PyC 7gMoUr64XFema4cUUbNwkfHQiHa5qUloIj1GRZdM0mzYjd2yVK7krDxI7lX2KLa5IjRg j9t8F7Ro9zdTe09ps8dlMEnMJZXuuTeLhLFnkQmr3/EFDCSFdAOw9ny3Ir9xZhHCk4Au 9j/8fD/ehiwQQmK+KPkQUK+NYEHsu6uZ9S3gHjBXPgnIh4zaqhWHx871u9lwt+fIeUK1 Nl53TQeIXddfGhsK38kzTuy5mgmgEMdKUKydjlUQ5i35Cs9qwjPF2N4JIE60iPM8Ew2G qcrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XwV4bmBD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11si6197174plc.383.2019.03.04.11.59.26; Mon, 04 Mar 2019 11:59:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XwV4bmBD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbfCDT67 (ORCPT + 99 others); Mon, 4 Mar 2019 14:58:59 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:43988 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbfCDT65 (ORCPT ); Mon, 4 Mar 2019 14:58:57 -0500 Received: by mail-lf1-f67.google.com with SMTP id p73so3811361lfe.10; Mon, 04 Mar 2019 11:58:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=elT29l8X5hVeGPNB6shy9LBKPe6vGAMd1PWsj3gyLFE=; b=XwV4bmBDkKLNrNwZTpfW6J68aUu3ZZnajWKIlC12bXJIhi8gdniy038v0u+9uvk12G wsboS89UE6p/0ujeVJlhFmBDiPohwWgo99NP25m8ibh2m0Cdlp6xAiJu4v3wcjxVMZSJ Vv4/+28tVYjYECWpDeSP/XCVfMlVS+F2Kx5ImLzj7SU53Vv5bE7l642rPRJoyAuUwLrQ He2gSD95oOyUKXk65+T6YzlbluJXZNOnrrS/DBCCCceK0nN5BLMuAZG/9zXoK47CIyLC Y5X7Oo6EfB1dlrQ3GwskkabTiETXpZ3UJpExe+vHAifRraKvqf7lRTeJKxhGmnwXMHq9 Qr8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=elT29l8X5hVeGPNB6shy9LBKPe6vGAMd1PWsj3gyLFE=; b=skcQcO9PrEOS6ucdrfn+APNN+RvDcS00wMjAw03OIa1MOa/EPUgcoly+9ZW4DBUF8N LWy8uodM/hlx9ZCJ6B4SgBUZlFZuPDkkkvUJ65EsOOrJ9vmhPUdlmtV8lgKQMnI6M6ko S5N3LoWLqn9BhgDOvN9R6Agi7FsuUryN4IzK2z5UdV6HnBu4p880EATx5hqKezKetMzW gInrHLQzr9WTbezCmHgnWJw2CXOxgROsimfIU8grpJqqxiXbOPxoW1z4L87mb3kmWxhf wo9B/W6juVrt+BZgZTiH8bHraIFj8RIfAdSOAv5sXs3qa4kPT1+KAzaQyg8l+Bb8r98W HH1A== X-Gm-Message-State: APjAAAXlL71D+sliV6S8zgjkJJ879t+uDGNazUy2CXFyTzWDRlR2IqoB +zUA9Re7hIJS9Lug7DPttKo= X-Received: by 2002:ac2:55b2:: with SMTP id y18mr11053618lfg.72.1551729534291; Mon, 04 Mar 2019 11:58:54 -0800 (PST) Received: from ?IPv6:2a02:aa7:4000:561e:3eff:d48d:3612:5c09? ([2a02:aa7:4000:561e:3eff:d48d:3612:5c09]) by smtp.gmail.com with ESMTPSA id a201sm640497lfa.93.2019.03.04.11.58.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 11:58:53 -0800 (PST) Subject: Re: [PATCH] net/bluetooth: Fix bound check in event handling To: Dan Carpenter , kbuild@01.org Cc: kbuild-all@01.org, marcel@holtmann.org, johan.hedberg@gmail.com, davem@davemloft.net, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller@googlegroups.com References: <20190304150419.GC13452@kadam> From: Tomas Bortoli Openpgp: preference=signencrypt Autocrypt: addr=tomasbortoli@gmail.com; prefer-encrypt=mutual; keydata= mQINBFpCTZMBEADNZ1+Ibh0Z4pgGRcd1aOUMbe/YfHktmajjcoTnKmZZunjoUVAl8waeLITd BC2c8i1wHzHcnthrmb1izs5XlG6PZnl8n5tjysSNbwggzS1NcEK1qgn5VjNlHQ5aRMUwCC51 kicBiNmlQk2UuzzWwdheRGnaf+O1MNhC0GBeEDKQAL5obOU92pzflv6wWNACr+lHxdnpyies mOnRMjH16NjuTkrGbEmJe+MKp0qbjvR3R/dmFC1wczniRMQmV5w3MZ/N9wRappE+Atc1fOM+ wP7AWNuPvrKg4bN5uqKZLDFH7OFpxvjgVdWM40n0cQfqElWY9as+228Sltdd1XyHtUWRF2VW O1l5L0kX0+7+B5k/fpLhXqD3Z7DK7wRXpXmY59pofk7aFdcN97ZK+r6R7mqrwX4W9IpsPhkT kUyg3/Dx/khBZlJKFoUP325/hoH684bSiPEBroel9alB7gTq2ueoFwy6R3q5CMUw3D+CZWHA 3xllu46TRQ/Vt2g0cIHQNPoye2OWYFJ6kSEvaLpymjNDJ9ph2EuHegonDfOaYSq34ic2BcdB JkCgXRLP5K7KtRNJqqR+DM8xByeGmQv9yp6S97el+SiM9R53RhHawJZGz0EPl+2Q6+5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wGjfC2+PM5I0xebbxtnuTewRchVVfm7UWgLAy11pV3xM4wMSJOuqVMOz jYpWKYxDTpvsZ0ginUUY993Gb8k/CxjABEMUGVHhQPZ0OzjHIKS6cTzN6ue8bB+CGOLCaQp1 C0NRT5Tn9zpLxtf5nBExFd/zVENY5vAV2ZbKQdemO54O7j6B9DSgVRrm83GCZxbL4d+qTYBF 3tSCWw/6SG1F3q9gR9QrSC2YRjCmhijUVEh6FhZwB58TNZ1sEEttrps8TDa5tUd9 Message-ID: Date: Mon, 4 Mar 2019 20:58:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190304150419.GC13452@kadam> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dan, On 3/4/19 4:04 PM, Dan Carpenter wrote: > Hi Tomas, > > url: https://github.com/0day-ci/linux/commits/Tomas-Bortoli/net-bluetooth-Fix-bound-check-in-event-handling/20190301-213647 > base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master > > smatch warnings: > net/bluetooth/hci_event.c:3986 hci_inquiry_result_with_rssi_evt() warn: potential pointer math issue ('info' is a 120 bit pointer) > > # https://github.com/0day-ci/linux/commit/00305742c021794f147b348d45eb10ea26e5a514 > git remote add linux-review https://github.com/0day-ci/linux > git remote update linux-review > git checkout 00305742c021794f147b348d45eb10ea26e5a514 > vim +3986 net/bluetooth/hci_event.c > > a9de9248 Marcel Holtmann 2007-10-20 3979 if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) { > 138d22ef Szymon Janc 2011-02-17 3980 struct inquiry_info_with_rssi_and_pscan_mode *info; > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > 138d22ef Szymon Janc 2011-02-17 3981 info = (void *) (skb->data + 1); > a9de9248 Marcel Holtmann 2007-10-20 3982 > e17acd40 Johan Hedberg 2011-03-30 3983 for (; num_rsp; num_rsp--, info++) { > af58925c Marcel Holtmann 2014-07-01 3984 u32 flags; > af58925c Marcel Holtmann 2014-07-01 3985 > 00305742 Tomas Bortoli 2019-02-28 @3986 if ((void *)(info + sizeof(info)) > > ^^^^^^^^^^^^^^^^^^^ > This is a pointer math bug. The options to fix it are: > > if ((void *)info + sizeof(info) > Yes, also sizeof(info) should be sizeof(*info).. > > Or: > if ((void *)(info + 1) > > > > 00305742 Tomas Bortoli 2019-02-28 3987 (void *)(skb->data + skb->len)) > 00305742 Tomas Bortoli 2019-02-28 3988 break; > 00305742 Tomas Bortoli 2019-02-28 3989 > a9de9248 Marcel Holtmann 2007-10-20 3990 bacpy(&data.bdaddr, &info->bdaddr); > a9de9248 Marcel Holtmann 2007-10-20 3991 data.pscan_rep_mode = info->pscan_rep_mode; > a9de9248 Marcel Holtmann 2007-10-20 3992 data.pscan_period_mode = info->pscan_period_mode; > a9de9248 Marcel Holtmann 2007-10-20 3993 data.pscan_mode = info->pscan_mode; > a9de9248 Marcel Holtmann 2007-10-20 3994 memcpy(data.dev_class, info->dev_class, 3); > a9de9248 Marcel Holtmann 2007-10-20 3995 data.clock_offset = info->clock_offset; > a9de9248 Marcel Holtmann 2007-10-20 3996 data.rssi = info->rssi; > 41a96212 Marcel Holtmann 2008-07-14 3997 data.ssp_mode = 0x00; > 3175405b Johan Hedberg 2012-01-04 3998 > > regards, > dan carpenter > > --- > 0-DAY kernel test infrastructure Open Source Technology Center > https://lists.01.org/pipermail/kbuild-all Intel Corporation > regards, Tomas