Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1256972rdg; Fri, 13 Oct 2023 15:49:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbK+Qmct1Wxn+M8UgId81K3hjgH1WZPYrjaZ2mY8jXcCMpSTBG+AizitRUPkLU87QdTclD X-Received: by 2002:a05:6a00:3a1e:b0:690:ce36:8b00 with SMTP id fj30-20020a056a003a1e00b00690ce368b00mr32179386pfb.2.1697237373218; Fri, 13 Oct 2023 15:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697237373; cv=none; d=google.com; s=arc-20160816; b=dB7dW2GCdz2bMK+LDHIFiwDa3PjpHmmllyYSS4dWRuKJdwxMUwizg5g+JIk3pqYagt QdU2pAcRwBW6P7Bs6EKC98ew2iHd9tOtXjX673xXg3Y0AbMIW6C0vVDunM/YyG0y4uUU fdfyb0TX9UEb8rUmS8d7xiWUlGEgjL9Qtc0BYuSo3/X/GwmFjXgCuWOi3f849naagfvU 4rEOwfxMCb9fn2Mo4Q1ER4gJBYAXwO0sBPQcpViyH0JabbQ97w8RX3gm4nc0TMF4AgYm lDHeyqpZZcp049+z6WbzSBy0/X+iqhrII3cD1UnTfUyG20yi73N+XxljEX72jOObgY+X 3zFg== 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-signature; bh=jF8ZuY1M1o6SHHQ3gYRaaYnGIssRMD3RHl4cqnyzMiQ=; fh=z8A2UgI9Ozi/zM+meU3S7fSTeKB52ixSkA1q1cGr6xs=; b=gnExXkoim8j5QESEk+MYj7vo94fHt2XFtVoR17Bu08slib5/qL6amHbXaKWB9ZHMw2 3rCBhTLkbwuXpKwHvpNJG7uQvD88hqxqM0HYNqEMYJ8LbaWZxq6P9PSow7qJOohMN1Kq e/JqR4UQyCMM8vyOGLpgXMLV5jrNCEJkH58fj+/pjHsGCpu8a6lg41cRUMU6T/WgzJPk YwrqZ42QcxrE+40/mGKAI4iKSmZ6qOTz4ozTx+Kp1j9VDwN1crq2z4DCmsZusHRt0Pfy XfHMopOTttt3QwLqXkPG6ZBzOnIpl3ZWEMfQBavdLo4dtTdUUC3T7eanFVZkCmzJ1EAB Vy8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="W6qV/M1b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id fj14-20020a056a003a0e00b00690fec2f3b6si17614644pfb.193.2023.10.13.15.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 15:49:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="W6qV/M1b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 812B2834D764; Fri, 13 Oct 2023 15:49:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231814AbjJMWtO (ORCPT + 99 others); Fri, 13 Oct 2023 18:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232576AbjJMWs4 (ORCPT ); Fri, 13 Oct 2023 18:48:56 -0400 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAB11102; Fri, 13 Oct 2023 15:48:43 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-3574f99d260so9970775ab.3; Fri, 13 Oct 2023 15:48:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697237323; x=1697842123; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jF8ZuY1M1o6SHHQ3gYRaaYnGIssRMD3RHl4cqnyzMiQ=; b=W6qV/M1bT6By5u8nn/3iem4FIdY9AbQyqSNOoICzeEk484fh9d4Ts1HRyI7sBU85GX gvT29QHzWmRKoXmOHq83MYNrHPh6wZHQr6kB6LxmxGT/TmBzAG4ZVEBiAl8d4/97iCBX 94rPq6cvEG1ItNTEHmSpx8nxZZWF3v2F15s6SwCKxnejqsOWKsTgljo356OBTPvxmcQJ 2SV6cHdCHO3sf6Z0HOQjV3UdWGG66FLgpTdMKMjkEoK45j9F5EkmqnDNyAWZNoHkM2Ev bDAyAFtjZNVOvOlZuTakR4Nrg34lQiG10KkuBjh4Xz6INiwlVt2GSe3LISmGuDd6rD+D qetA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697237323; x=1697842123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jF8ZuY1M1o6SHHQ3gYRaaYnGIssRMD3RHl4cqnyzMiQ=; b=O77t9+6ClWnhQcHDQb3uspJkSK7gscpEiHM5pQ3pdnT/02qrciewWipcgtl0f1svRn wk5fWNqWSPWer6GjY5HCU1SQcrNKCM2/FEw9gh/qgr80+xng31qN36AOuZ2zQ3pAlOAp 1SF+LCf3gYDOpB/THuhWEZnR3ldBcKVujn+Zh1kJvr6GYidyNjOTySAWFg5/LeN+41CF S9tb+1O2ZengXoGGLsgIK6xXj5BbCGNf1wg/Lzs3XodQW1Ck00nl3k5yXiStUbiV2JHT qNh09bilIwQyK9SRyCdOXa0vk1RhV26mBuOnioR4MBd3myA2lk4qKUSryzNXKc2N+OSX vKXA== X-Gm-Message-State: AOJu0YzjA8PwhZb7nBrYyGN1PwXRgB7jxugllcdi/z9h0C91OUR7e5ZS 5Kq3ERf62rwY4y/ijYaf2Z7GC3JpsP1D3w== X-Received: by 2002:a05:6e02:1a0e:b0:352:6f88:9818 with SMTP id s14-20020a056e021a0e00b003526f889818mr32961051ild.11.1697237322782; Fri, 13 Oct 2023 15:48:42 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id t10-20020a92dc0a000000b003512c3e8809sm1683071iln.71.2023.10.13.15.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 15:48:42 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, daniel.vetter@ffwll.ch, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, groeck@google.com, yanivt@google.com, bleung@google.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v7b 11/25] dyndbg: tighten fn-sig of ddebug_apply_class_bitmap Date: Fri, 13 Oct 2023 16:48:03 -0600 Message-ID: <20231013224818.3456409-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231013224818.3456409-1-jim.cromie@gmail.com> References: <20231013224818.3456409-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 13 Oct 2023 15:49:27 -0700 (PDT) old_bits arg is currently a pointer to the input bits, but this could allow inadvertent changes to the input by the fn. Disallow this. And constify new_bits while here. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8158943b350d..8beb98a831f5 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -593,7 +593,8 @@ static int ddebug_exec_queries(char *query, const char *modname) /* apply a new class-param setting */ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, - unsigned long *new_bits, unsigned long *old_bits, + const unsigned long *new_bits, + const unsigned long old_bits, const char *query_modname) { #define QUERY_SIZE 128 @@ -602,12 +603,12 @@ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, int matches = 0; int bi, ct; - if (*new_bits != *old_bits) + if (*new_bits != old_bits) v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, - *old_bits, query_modname ?: "'*'"); + old_bits, query_modname ?: "'*'"); for (bi = 0; bi < map->length; bi++) { - if (test_bit(bi, new_bits) == test_bit(bi, old_bits)) + if (test_bit(bi, new_bits) == test_bit(bi, &old_bits)) continue; snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], @@ -619,9 +620,9 @@ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, ct, map->class_names[bi], *new_bits); } - if (*new_bits != *old_bits) + if (*new_bits != old_bits) v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, - *old_bits, query_modname ?: "'*'"); + old_bits, query_modname ?: "'*'"); return matches; } @@ -678,7 +679,7 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa continue; } curr_bits ^= BIT(cls_id); - totct += ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL); + totct += ddebug_apply_class_bitmap(dcp, &curr_bits, *dcp->bits, NULL); *dcp->bits = curr_bits; v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, map->class_names[cls_id]); @@ -688,7 +689,7 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa old_bits = CLASSMAP_BITMASK(*dcp->lvl); curr_bits = CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); - totct += ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL); + totct += ddebug_apply_class_bitmap(dcp, &curr_bits, old_bits, NULL); *dcp->lvl = (cls_id + (wanted ? 1 : 0)); v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, map->class_names[cls_id], old_bits, curr_bits); @@ -742,7 +743,7 @@ static int param_set_dyndbg_module_classes(const char *instr, inrep &= CLASSMAP_BITMASK(map->length); } v2pr_info("bits:0x%lx > %s.%s\n", inrep, modnm ?: "*", KP_NAME(kp)); - totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, modnm); + totct += ddebug_apply_class_bitmap(dcp, &inrep, *dcp->bits, modnm); *dcp->bits = inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: @@ -755,7 +756,7 @@ static int param_set_dyndbg_module_classes(const char *instr, old_bits = CLASSMAP_BITMASK(*dcp->lvl); new_bits = CLASSMAP_BITMASK(inrep); v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); - totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, modnm); + totct += ddebug_apply_class_bitmap(dcp, &new_bits, old_bits, modnm); *dcp->lvl = inrep; break; default: -- 2.41.0