Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E54BAC5ACCC for ; Tue, 16 Oct 2018 20:20:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96A8620869 for ; Tue, 16 Oct 2018 20:20:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u9mP7oqK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96A8620869 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727020AbeJQEM1 (ORCPT ); Wed, 17 Oct 2018 00:12:27 -0400 Received: from mail-lj1-f182.google.com ([209.85.208.182]:38816 "EHLO mail-lj1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725960AbeJQEM1 (ORCPT ); Wed, 17 Oct 2018 00:12:27 -0400 Received: by mail-lj1-f182.google.com with SMTP id v7-v6so22178053ljg.5 for ; Tue, 16 Oct 2018 13:20:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=J80eSmA4ZEhPM8rl0v8PFmbZW6xrPRuvkzJIvtNYE2g=; b=u9mP7oqKdgWzFpcvcqjyg2ko4i8+nTVq22HCgivtf92/pI8ey7NuGImv+XvofnPL++ vX1gv7Xj1HDI5A7oDGflYwFYIBvyLm05lbcHOm5kwcmdwdZpBifEFfCxBGhj05i1vqdQ UKO+Pjx/1AfjY4Rczh+z16H23Lo2bpFdVrZs8CK7ln/d5wpueydx+nU4ZUulZoABL+u3 w3sPtppnYzIH3zdQWWzfE4F4LVJsKeVdpNWyn9ypozXb616G6t5eMG+n8CugrRiRPZC7 AN3m6RtHMK4yppa4bjQ51Gmi+HIjq++7xrlMJ2Bn4vYsjh5jqDsWgmR5bIRD6guktC4N ZYEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=J80eSmA4ZEhPM8rl0v8PFmbZW6xrPRuvkzJIvtNYE2g=; b=K6TJUuluUnbWPKMhnP1xCmihYQHzsh4Dsync9Hd3jSzJ1hEDLcOKTGh1x/SgvhejIp 9dbPhsc3rv6ZxrOjLWNB5npgYJ3WRYwB6wLvHQg1+IPC0/72bL4qLGnwL92cCFScPz7O Q+SbK3zt3Ql6epGjd7IkTw2Dud86TfHhvKH7Vt5oHLI26ZcIry8bb2sngiJn7jkkxBlt 5TWyLFRl6i4rJcqeOmBmQ950UzOPQzTDppGNijl331tiGa+YTZbK8ISNpEgnd0e6YJRl 2q1QMgKb+Z8anwQocN6MqHZy0EWJUE9ydHGU4mLr4t86p6idkDSI2J7nLTkFpp0WQDCu Mk7Q== X-Gm-Message-State: ABuFfois51mQzKI0EHLLaEnRujNP9HsBXiLhLqC2xhCHm5wenc/wfVkX QbE57MFxV9DVQQWVhQ8A0I7wQ9tvUEA= X-Google-Smtp-Source: ACcGV61H1Ilg7kjjbOMMWH/zc4pJSRRw615VZULFWOwEp6ufS6Zpt99jhXZoHgn1fYly8TNYOnpTDQ== X-Received: by 2002:a2e:5109:: with SMTP id f9-v6mr14778229ljb.155.1539721219626; Tue, 16 Oct 2018 13:20:19 -0700 (PDT) Received: from Matias-MacBook-Air.local (85-23-86-144.bb.dnainternet.fi. [85.23.86.144]) by smtp.gmail.com with ESMTPSA id q124-v6sm3394535ljb.89.2018.10.16.13.20.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 13:20:18 -0700 (PDT) Date: Tue, 16 Oct 2018 23:23:47 +0300 From: Matias Karhumaa To: linux-bluetooth@vger.kernel.org Subject: [PATCH 09/12] btmon: fix segfault caused by buffer over-read Message-ID: <20181016202347.GA85019@Matias-MacBook-Air.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Fix segfault caused by buffer over-read in btmon. Fix is to check in packet_monitor() that index is not bigger than MAX_INDEX before accessing index_list. Crash was found by fuzzing btmon with AFL. --- monitor/packet.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 1e9f9d9e4..2d8e15597 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -3864,6 +3864,11 @@ void packet_monitor(struct timeval *tv, struct ucred *cred, index_current = index; } + if (index != HCI_DEV_NONE && index > MAX_INDEX) { + print_field("Invalid index (%d)", index); + return; + } + if (tv && time_offset == ((time_t) -1)) time_offset = tv->tv_sec; -- 2.17.1