Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4630282pxj; Wed, 12 May 2021 09:36:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+ncibbMw1vkCBCKWiVhAg2SIIerFWM3HGttebJdBZVKEuh5sgCmNfyA+qrdF1LyD6/07s X-Received: by 2002:a05:6512:1113:: with SMTP id l19mr24722984lfg.213.1620837395859; Wed, 12 May 2021 09:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837395; cv=none; d=google.com; s=arc-20160816; b=UuSvz4Ir9GLZCL6Kz5egEr6cK47WytWtDPsisiXJRgdByfHCV5sA6ytzkbugGHfza5 L5vUuEVbVXN9AU6CGNpkugKFxcympMU9t+bz6OZjjopuraeCWWrIzT5i24FFHIhwm0s1 6EzDzrlqI1BqF2zSzuTqJbL9gjHuVO6HSdH7ysx6Tq22BJPoVUARPsuoncppPTybdIQQ 2mVWbO+BTo6dGGkS24VNL7e4+riN0Ko+RAH4szLqktqvmdLkT1Y4M6bUwqX+hm1oLt1U Ls+P+b7DsIXWfmn2A2C8jYnvKv2/XCScEJhIWCb9W+P9o7bLb9Kd1SpLyvuRrzkaHRiO Qfxg== 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:cc:to:from :subject; bh=cQTxwsxT/wlV85nYsejeoh1tqcycProOX+bFXo55+AI=; b=ccy36xOv4SdJlUYhPL3/66N+FGFrc8TfWOkdGvUJf6WgECy/aY3Aa3J2VEDYes8xLl 9lvoYwqVCKy4BR8Ga8utm6uYgBEOWiAMUNr8BvU63Q9lZ2qOPXQWBPafV+SGY5yyrcYb iRlDiXeMaVdACbvZZNHM9n5NIuRAI2Hpicubgk/niWb1+6e0LZcDMW3MCrvHDxg/PjVz u7Sm7Nkb+22tYSOo/Qaeom1xmoGQu6/3c/i3uDzxqJmfvdqT/dHdDlFQAvj7uFMTlORJ yO8OmShcAw2ozVJ4FmRR6g9Xzu8EzKKU+vJVeu7yEP2/kkLMxXh+9opwGm/jmL6qgQQa 23Wg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si344230ljq.46.2021.05.12.09.36.05; Wed, 12 May 2021 09:36:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236853AbhELQcV (ORCPT + 99 others); Wed, 12 May 2021 12:32:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:34570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238719AbhELQGI (ORCPT ); Wed, 12 May 2021 12:06:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 78CF261CEA; Wed, 12 May 2021 15:35:03 +0000 (UTC) Subject: [PATCH v2 01/25] NFSD: Fix TP_printk() format specifier in trace_nfsd_dirent() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: dwysocha@redhat.com, bfields@fieldses.org, rostedt@goodmis.org Date: Wed, 12 May 2021 11:35:02 -0400 Message-ID: <162083370248.3108.7424008399973918267.stgit@klimt.1015granger.net> In-Reply-To: <162083366966.3108.12581818416105328952.stgit@klimt.1015granger.net> References: <162083366966.3108.12581818416105328952.stgit@klimt.1015granger.net> User-Agent: StGit/1.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Since commit 9a6944fee68e ("tracing: Add a verifier to check string pointers for trace events"), which was merged in v5.13-rc1, TP_printk() no longer tacitly supports the "%.*s" format specifier. Note that __string() and __assign_str() cannot be used for non-NUL-terminated C strings because they perform a strlen() on the string that is to be copied. Instead, memcpy the whole file name into the record, but display just the part up to the first NUL. In almost every case that will show the whole file name. Reported-by: David Wysochanski Fixes: 6019ce0742ca ("NFSD: Add a tracepoint to record directory entry encoding") Signed-off-by: Chuck Lever Cc: Steven Rostedt --- fs/nfsd/trace.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index 27a93ebd1d80..781af519b40c 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -400,19 +400,17 @@ TRACE_EVENT(nfsd_dirent, TP_STRUCT__entry( __field(u32, fh_hash) __field(u64, ino) - __field(int, len) - __dynamic_array(unsigned char, name, namlen) + __dynamic_array(char, name, namlen + 1) ), TP_fast_assign( __entry->fh_hash = fhp ? knfsd_fh_hash(&fhp->fh_handle) : 0; __entry->ino = ino; - __entry->len = namlen; memcpy(__get_str(name), name, namlen); - __assign_str(name, name); + __get_str(name)[namlen] = '\0'; ), - TP_printk("fh_hash=0x%08x ino=%llu name=%.*s", - __entry->fh_hash, __entry->ino, - __entry->len, __get_str(name)) + TP_printk("fh_hash=0x%08x ino=%llu name=%s", + __entry->fh_hash, __entry->ino, __get_str(name) + ) ) #include "state.h"