Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2287214iof; Wed, 8 Jun 2022 01:29:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjQsSJnERXWzLqFnh6DRoGD41yvgArzh3bTsd4hpBV/8dKnYN7aT6MYk80+47XgBnknUeC X-Received: by 2002:a63:d34f:0:b0:3fa:8a90:f395 with SMTP id u15-20020a63d34f000000b003fa8a90f395mr29673490pgi.107.1654676943067; Wed, 08 Jun 2022 01:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654676943; cv=none; d=google.com; s=arc-20160816; b=NwE00LtWKOX6XTjcyxKJDjCe/K6PlvJ0dSe040T9SrJ5kGys9XVRMKG6T/lAlJNMVI VFLpjLRzdcadKZscb5uoPjZKhT/br9L/xsfH3JKIB+hbn+4P6bLUVkSXLZ9ZvOCE8Cot LqPCdeonLaWb0ZfrPWpLCyT2V8NxHjQjPyenxJwOHSRKhc0RAaHxk3bqLI/yGIRhsSDt 2XzEQak6oMkeeOqy7iIifbiHFRnYdP6zx+6IOTuNuxO87x6BA9xibljl7XaNjVafZWgk eq/Rxe4FiCpBJAWuEuWb2QTQuHqAdvswyUsrBuZxU3DQZGVhqo0gCBOWxDCpiJrnmryx J0JA== 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=irxR1mNoZhzZAGad9jf/P5S3GvT/NKJmf3TpKdBnVQo=; b=gZANOdz3YQzRa9jrESvZ/QENaAKBWZymfIyYHCtKaQyg4sQ7aNerh2qq95Ltp81nip gOno0bF16xINZj2fzN9iYaHpt0giXonw2H/BIoKp8dJ8CQOWtmVQa7VOCGVmgbWGcRrw 6lhuyJQ99RXNGVf5zRgs5hDXLdXj54HFfOiB8lfr3Y8TumBOUE9MSWbvHkofTy6X/5vz gAK7JCg6ljdvodQr1ZUKKhikm4XOqyUCU5EfrdeJeLPzeu+4vmNhBBiMEwWgbdvgCVFc ZQ8bZOBvVvp2VlBfQAyR1GquhnPefg9U47HDCsIGnjkoPX7D6DLl2ifM0RXxQeXB8mBt L4wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cl1pK9eS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o10-20020a17090aeb8a00b001e2c1e7fe25si30134492pjy.113.2022.06.08.01.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:29:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cl1pK9eS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C5EE41DA096; Wed, 8 Jun 2022 00:58:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235042AbiFHCR4 (ORCPT + 99 others); Tue, 7 Jun 2022 22:17:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1390383AbiFHBuW (ORCPT ); Tue, 7 Jun 2022 21:50:22 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB4F11973DA; Tue, 7 Jun 2022 12:20:06 -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 sin.source.kernel.org (Postfix) with ESMTPS id E0389CE24B7; Tue, 7 Jun 2022 19:20:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7331C385A5; Tue, 7 Jun 2022 19:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629602; bh=OZOS/pHplCASWNPmT8U8e9P9qYz6jNCQYk6G30jMRTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cl1pK9eSMuqrJ9/hHtniglVrs+VhLlYKsMZcy0QJVHiWDy1OBbVRNMEdYjse0CWoa gmFdN1e8V9V47y5PKgIra01+YYfKmCkYRaU7PGq4jtDHj8NFr/yUX69ffQ7uslch79 mroeGuyIXioPgk+/7Srm5lSOA1tsooMfUBhVXBz4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Rothwell , "Steven Rostedt (Google)" Subject: [PATCH 5.18 749/879] tracing: Have event format check not flag %p* on __get_dynamic_array() Date: Tue, 7 Jun 2022 19:04:27 +0200 Message-Id: <20220607165024.602410761@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Steven Rostedt (Google) commit 499f12168aebd6da8fa32c9b7d6203ca9b5eb88d upstream. The print fmt check against trace events to make sure that the format does not use pointers that may be freed from the time of the trace to the time the event is read, gives a false positive on %pISpc when reading data that was saved in __get_dynamic_array() when it is perfectly fine to do so, as the data being read is on the ring buffer. Link: https://lore.kernel.org/all/20220407144524.2a592ed6@canb.auug.org.au/ Cc: stable@vger.kernel.org Fixes: 5013f454a352c ("tracing: Add check of trace event print fmts for dereferencing pointers") Reported-by: Stephen Rothwell Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -392,12 +392,6 @@ static void test_event_printk(struct tra if (!(dereference_flags & (1ULL << arg))) goto next_arg; - /* Check for __get_sockaddr */; - if (str_has_prefix(fmt + i, "__get_sockaddr(")) { - dereference_flags &= ~(1ULL << arg); - goto next_arg; - } - /* Find the REC-> in the argument */ c = strchr(fmt + i, ','); r = strstr(fmt + i, "REC->"); @@ -413,7 +407,14 @@ static void test_event_printk(struct tra a = strchr(fmt + i, '&'); if ((a && (a < r)) || test_field(r, call)) dereference_flags &= ~(1ULL << arg); + } else if ((r = strstr(fmt + i, "__get_dynamic_array(")) && + (!c || r < c)) { + dereference_flags &= ~(1ULL << arg); + } else if ((r = strstr(fmt + i, "__get_sockaddr(")) && + (!c || r < c)) { + dereference_flags &= ~(1ULL << arg); } + next_arg: i--; arg++;