Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1194435pxb; Fri, 1 Apr 2022 07:06:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzUAoHA2Ub6nLPnTSyZ7b3hAgg1nOFA2MiJDqr5het0CgoYKfVtF4f0jThmmIlARCrH9/t X-Received: by 2002:a17:906:2408:b0:6e0:dc2a:3394 with SMTP id z8-20020a170906240800b006e0dc2a3394mr9688075eja.181.1648822014512; Fri, 01 Apr 2022 07:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648822014; cv=none; d=google.com; s=arc-20160816; b=DXABRy6HZuEFkFT1o/I7DnP0OEd3GydC8bumKuMHohBmpb9keXBTw6zQJ8cgvru2zE doE2Lc88U/4vmJHeaslgbUtch6/OSevlS4LwJxSYM7lL45Uo50M6cPjfth6GRIYGYBVz dPwWCc1CSrNvlt32ZeFLxgsIGQkwRCw855tJTA9Ltl1Q4ugUtsgXrH0YKH2vyToWIzuK 998VTZS+BQAEX+i9dOLlp57nh3+Y5ubr4ABvc/8GMv1TeDurecsuvY+oq8mrwC5OrtL7 JUmyYe6dWvymE+V2LOAyCooFVUNMy3m9DZGewQ2sMxV/pE/IMS05fW0CrxPsfmp9HwCM lmgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-filter; bh=SWBH1x/bG2/stAsbPXhvmCa2033yzR+vse1oK9BHR6U=; b=ajibUmSZ8csNaweFneyVQ9DlrALffNf5Y3lKL5snY/hGrgOX04iocOdJrK2zIzKLF1 167GBFmltRLgI8OmgjsO+Y2a2shdQCnwKkS0XeVa2LB/C34KxtC+FvZjOJBnwafPMyqV iucJtn7XYKcWev9pv3HewQhHTJOq1HU4obOx4t2hD1GsYx1sZdLWWk/5eYkFPWAwD0Xv OvwothJ+U5LQ9nIBim0/Vk7zYIfLquHmiKRzHf2HVc1kdX8ap6EjFeJys1om/MgtwRkS JruDsB8JjlkdzzlPIdmPnAjkQOpxBsWxdxcrm9x8yCR4gKLdZxhzzxYobLFJg71BQIME 2S2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ey18-20020a1709070b9200b006df76385bd0si1515434ejc.112.2022.04.01.07.06.27; Fri, 01 Apr 2022 07:06:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244056AbiDAHyl (ORCPT + 99 others); Fri, 1 Apr 2022 03:54:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245562AbiDAHyj (ORCPT ); Fri, 1 Apr 2022 03:54:39 -0400 Received: from mxout02.lancloud.ru (mxout02.lancloud.ru [45.84.86.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF2CF26240E for ; Fri, 1 Apr 2022 00:52:50 -0700 (PDT) Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout02.lancloud.ru B479622C62A9 Received: from LanCloud Received: from LanCloud Received: from LanCloud From: Ildar Kamaletdinov To: CC: Ildar Kamaletdinov Subject: [PATCH BlueZ 1/7] monitor: Fix out-of-bound read in print_le_states Date: Fri, 1 Apr 2022 10:46:34 +0300 Message-ID: <20220401074640.3956695-2-i.kamaletdinov@omp.ru> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220401074640.3956695-1-i.kamaletdinov@omp.ru> References: <20220401074640.3956695-1-i.kamaletdinov@omp.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT02.lancloud.ru (fd00:f066::142) To LFEX1910.lancloud.ru (fd00:f066::80) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Accessing le_states_desc_table array with value 15 can cause out-of-bound read because current size of array is 14. Currently this cannot lead to any problems becase we do no have such state in le_states_comb_table but this could be changed in future and raise described problem. Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. --- monitor/packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor/packet.c b/monitor/packet.c index b7431b57d..c61d6bd4b 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -2833,7 +2833,7 @@ static void print_le_states(const uint8_t *states_array) if (!(states & val)) continue; - for (n = 0; n < 16; n++) { + for (n = 0; n < ARRAY_SIZE(le_states_desc_table); n++) { if (le_states_comb_table[i].states & (1 << n)) str[num++] = le_states_desc_table[n].str; } -- 2.34.0