From patchwork Mon Oct 24 11:30:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9437 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp479267wru; Mon, 24 Oct 2022 07:18:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5X76bZWrd36UTrF4fEnRiSj5Hq3le2CvjxHkq72bB+zFEBHEKDW9gfIiokAxGp9ea/QnKY X-Received: by 2002:a05:6402:1f84:b0:455:27b8:27aa with SMTP id c4-20020a0564021f8400b0045527b827aamr30388354edc.243.1666621128367; Mon, 24 Oct 2022 07:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621128; cv=none; d=google.com; s=arc-20160816; b=aSDUoSi6v+dBs5NkWuEIn7hxIcjmNP3zXVhELTCqAPRzSSsdrxe7plv3Cwk8L7tXq9 3goby8bynxdL4ID6UtBJckMPBDyZ3+QK2/+KFH5FWkto1fI7RCkID8zihNjcreK1Q3/C iEJHlpHWZOxnBbVDWthSGCnrk++U34Fq/UG5PzsUK4bxEpQ4I3XqUoFK41P/GcVNK5LV PL3itIkiHSZb0r/AQy1ISr5YAa7S6vyUrioYRFBfRFxUFR42Lta43XNScsgrUJyFvUVC XJ6HbZNdvJRKFPDd1EeKnlBK2NhNZpYFW+mDOjQqRWatBrDyZLo/u7+EMZQqBfMVTO6y Dmqg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+l/vTwQ7AgEm8wvEijENBDCOS3WmNOc29YxtdEo6gD4=; b=apqLN09pdEmlnd612TWaUJYn69C+tk3xLhpe1ezWE8bMW9Jn4eeDuqlRG3hOstbl9C fmzqNfF+Mzx4hW92k20eNMg4R9zQur7g/jY91DcotN2+Hj+WwZJCO2lLZxkZBxJf+U39 DIwnlVigdHyzelptMSs9wVv/pZZluHkJGizcPEMGjTIf/B+wRxrzk0qkG/XRWHUhHfKZ NtRYebh9scEJnOFIfgYxU5oeg3gXn6MS+8O59Z+uvDA0rdf/3FBtv6/SmDXxcc6vPGq6 R0gnECpWLHMazmENuzh8U4Hen4oaa8q0rl+W/kvy+kFWUEUhZLsQWf4viCxC+28xqVod NLvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rVlLu6IJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a50eb0a000000b00458ab54baa5si23828330edp.503.2022.10.24.07.18.14; Mon, 24 Oct 2022 07:18:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rVlLu6IJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231173AbiJXOM3 (ORCPT + 99 others); Mon, 24 Oct 2022 10:12:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235824AbiJXOJS (ORCPT ); Mon, 24 Oct 2022 10:09:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC5E0C50A7; Mon, 24 Oct 2022 05:51:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 59BBAB81681; Mon, 24 Oct 2022 12:27:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA499C433D6; Mon, 24 Oct 2022 12:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614429; bh=B9QoODx8b47mSMAPwbmYToxEmBWDtndlvsP7641B40o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rVlLu6IJjAle0joVccipiZ/gUsWx83K6apbQsFaWo9QznHmlBd1dFNvKRnf5oHA+2 mQ7KPiOoh/zdKl1YRUzPznuWQi5CVs/Plt0578gFWvSP5owlhXuXAenYO1kpsdf4Ra YTa4I5ntkCXbI4+2yHRZNLOjHcrZFgbZsgKW4Ics= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, vincent.whitchurch@axis.com, Jason Baron , Daniel Vetter , Jim Cromie , Sasha Levin Subject: [PATCH 5.10 217/390] dyndbg: fix static_branch manipulation Date: Mon, 24 Oct 2022 13:30:14 +0200 Message-Id: <20221024113032.016723195@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747578916136411927?= X-GMAIL-MSGID: =?utf-8?q?1747578916136411927?= From: Jim Cromie [ Upstream commit ee879be38bc87f8cedc79ae2742958db6533ca59 ] In https://lore.kernel.org/lkml/20211209150910.GA23668@axis.com/ Vincent's patch commented on, and worked around, a bug toggling static_branch's, when a 2nd PRINTK-ish flag was added. The bug results in a premature static_branch_disable when the 1st of 2 flags was disabled. The cited commit computed newflags, but then in the JUMP_LABEL block, failed to use that result, instead using just one of the terms in it. Using newflags instead made the code work properly. This is Vincents test-case, reduced. It needs the 2nd flag to demonstrate the bug, but it's explanatory here. pt_test() { echo 5 > /sys/module/dynamic_debug/verbose site="module tcp" # just one callsite echo " $site =_ " > /proc/dynamic_debug/control # clear it # A B ~A ~B for flg in +T +p "-T #broke here" -p; do echo " $site $flg " > /proc/dynamic_debug/control done; # A B ~B ~A for flg in +T +p "-p #broke here" -T; do echo " $site $flg " > /proc/dynamic_debug/control done } pt_test Fixes: 84da83a6ffc0 dyndbg: combine flags & mask into a struct, simplify with it CC: vincent.whitchurch@axis.com Acked-by: Jason Baron Acked-by: Daniel Vetter Signed-off-by: Jim Cromie Link: https://lore.kernel.org/r/20220904214134.408619-2-jim.cromie@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- lib/dynamic_debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 921d0a654243..e67655d7b7cb 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -207,10 +207,11 @@ static int ddebug_change(const struct ddebug_query *query, continue; #ifdef CONFIG_JUMP_LABEL if (dp->flags & _DPRINTK_FLAGS_PRINT) { - if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT)) + if (!(newflags & _DPRINTK_FLAGS_PRINT)) static_branch_disable(&dp->key.dd_key_true); - } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT) + } else if (newflags & _DPRINTK_FLAGS_PRINT) { static_branch_enable(&dp->key.dd_key_true); + } #endif dp->flags = newflags; v2pr_info("changed %s:%d [%s]%s =%s\n",