Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5066387rdb; Tue, 12 Dec 2023 19:09:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGP2eXUDZbSMEJkakDVMzJety+YTq3AS/ZAYlZ+QaWh5aC7GSRPKJcmoBC+WaoJ3u4QyV7Q X-Received: by 2002:a17:90b:3c2:b0:28a:c1bc:e166 with SMTP id go2-20020a17090b03c200b0028ac1bce166mr2355045pjb.34.1702436979616; Tue, 12 Dec 2023 19:09:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702436979; cv=none; d=google.com; s=arc-20160816; b=PjmaM+uNjNnUAb3ZyCpRwJqCOSeHAVLAbhqWI8tOXwhjIe4Sr80/J1PSY8fjxNeSGi 7fcwIGCB8jeqUC+1yiHFCb6jtjVpt/1vxkCA3cs+qDGcT5oZgOUfRiMFElnrJIOtix2i /i938XcQ4TdEpQL8m9Zu/zVGUtOF1Kk7Omn1+VW/pvOpmzttHinRxBSYU5dFaQFifT+i kaIM/spv/udzit3IApAAcOTShsMO0/Mp/7qhu4BtcO6QVz014cQYMLKn6cnYauRhTXxl O62EIqbHjX4aI+hhUuBM24ZtNYPyygsTAwqA2rOCUL2xkihSThiNqMpe6Iw/SvlexP2f Zlcg== 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:subject:cc:to:from:date; bh=7N+0RlcuZSbanb4n9xOLbZsrZ6CFFfP0gwGnWfqjwmU=; fh=R8JZsVKDlS7lXIAvTNV55bsjlDBI0i4sqiOYXO4tZQA=; b=TSKpiVxbs8imKWeX32vYAB1CKqR9cENRb1vjKhC4aimJgeiejuCCmkDQADRDsrmqTY k8V9LPUGWgZtzZUTe/Hcp55zckBeNq73nt0vXpD6OWn1vRojWr7UPUBBsINP0n6duik9 74gLzR3cgWvc+kn2R9VHxpbiCENM2P2fhRQUGN1+dOfrpCZoLrQTElZTHRdEesHfgV09 d/gd37QH8aF/x6YddXCPP5Yi07QXqRVrpWC5YvSVLMYF1SLDK94reezqnCXjUTq12xJK 8GXr8rpI/5zwFog1d9HJiKqFg1I6i5a4B8ZETZ6fJmKNGpvFyXVAUkVgMKknu64HHDTx VI2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h5-20020a17090a130500b00286b22b913fsi8944174pja.37.2023.12.12.19.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 19:09:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4048C80ACC6B; Tue, 12 Dec 2023 19:09:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378393AbjLMDJW (ORCPT + 99 others); Tue, 12 Dec 2023 22:09:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378288AbjLMDJW (ORCPT ); Tue, 12 Dec 2023 22:09:22 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BA4AAB for ; Tue, 12 Dec 2023 19:09:28 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B41CC433C8; Wed, 13 Dec 2023 03:09:27 +0000 (UTC) Date: Tue, 12 Dec 2023 22:10:10 -0500 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers Subject: Re: [PATCH] tracing: Add size check when printing trace_marker output Message-ID: <20231212221010.70c84d2d@gandalf.local.home> In-Reply-To: <20231212084444.4619b8ce@gandalf.local.home> References: <20231212084444.4619b8ce@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 12 Dec 2023 19:09:37 -0800 (PST) On Tue, 12 Dec 2023 08:44:44 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > If for some reason the trace_marker write does not have a nul byte for the > string, it will overflow the print: > > trace_seq_printf(s, ": %s", field->buf); > > The field->buf could be missing the nul byte. To prevent overflow, add the > max size that the buf can be by using the event size and the field > location. > > int max = iter->ent_size - offsetof(struct print_entry, buf); > > trace_seq_printf(s, ": %*s", max, field->buf); Bah, this needs to be: trace_seq_printf(s, ": %.*s", max, field->buf); Note the '.' between % and *. Otherwise it right aligns the output. This did fail the selftest for trace_printk(), but I modified the new one to add " *" to accommodate it :-p Sending out v2. -- Steve