From patchwork Wed Jan 3 02:07:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 184559 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4791857dyb; Tue, 2 Jan 2024 18:16:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHo2Sgulj1mbRldB4t2W8h2FKAurvuhOloMHjxT3SM5mtpjQQKW6JvXGU8GWDDlr6CM/RtN X-Received: by 2002:a19:2d08:0:b0:50e:76e7:b1fc with SMTP id k8-20020a192d08000000b0050e76e7b1fcmr4929255lfj.0.1704248167557; Tue, 02 Jan 2024 18:16:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704248167; cv=none; d=google.com; s=arc-20160816; b=RYhqEaEHNxxQavqFpOc+3tcnZFNQmeWCfetSPZ8aILF+nVfbybVocO/8l1N3SAbQvu 9/laULiW4dPxfZcAF/J2P61thbJrZHWY2514/P6CBtdCBi9h9XXFR99odwhZDnkFnJDc kL5B8P7y2o2F7W1xgukK2ichplRPT10l5UzVuoDdQUzriPptbWgXy5ZETC5qwd6IKtoj QBNGTYOZiFfc952ErEPra/JnDqq5XFvPfS1gneooz9iV3PV5HSk1pI0RXV7SNWUstacu ZKOKgm2SVXdvCNEJyOPpa7rZCVj7rbTNF350gOSC8MnCLgg7/Dgb03o6WKeBc8NqPgRQ 2TGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date; bh=YD1rEwPVyAZ8lsXn+2KmcHAf71vCp2DAUkG2TWhuQKQ=; fh=BJjscmstiuwSmMpx+EuWwz/EH9XNPUTFyivEKBLydzI=; b=hYe3djvoFL6iwtbmpqfRvcgOF11+GhEg30QjbTM4Z+EeiphFuLlyddWrZ5m8Om7Vkx TrVQYav2oSnAkQq3lvHsoq2iZ/vGXPzs1KaYVIS96ukiRqKS3YiHx5UJMJcPyWX6BVQF SVU8KwIzRywwpKz0SMDSaFYL50aYypnUP652g5kpka7VftOM9BYuBcgrQx0V7rOSCtIc w6S+xOtJUfsjwEgOftcD4A474upOyk01/NqzZ6QCy/takaDTmC8aeUpkklGWD7jubJqu erHw02D5fPg31R8qEdir1d2WlZVn0Ja9W45TgRyz+CAW3CKGgm3M7pDe2ABmKXbg4etJ Bv8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15059-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15059-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dk5-20020a0564021d8500b00556aa3cd766si649672edb.204.2024.01.02.18.16.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 18:16:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15059-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15059-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15059-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CF6051F23924 for ; Wed, 3 Jan 2024 02:06:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A50A1C2E; Wed, 3 Jan 2024 02:06:33 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99DB8136B for ; Wed, 3 Jan 2024 02:06:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 891A0C433C9; Wed, 3 Jan 2024 02:06:30 +0000 (UTC) Date: Tue, 2 Jan 2024 21:07:31 -0500 From: Steven Rostedt To: Linus Torvalds Cc: LKML , Masami Hiramatsu , Mathieu Desnoyers Subject: [GIT PULL] tracing: Final fixes for v6.7 Message-ID: <20240102210731.1f1c5bf5@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787033726598192662 X-GMAIL-MSGID: 1787033726598192662 Linus, tracing fixes for v6.7-rc8: - Fix a NULL kernel dereference in set_gid() on tracefs mounting. When tracefs is mounted with "gid=1000", it will update the existing dentries to have the new gid. The tracefs_inode which is retrieved by a container_of(dentry->d_inode) has flags to see if the inode belongs to the eventfs system. The issue that was fixed was if getdents() was called on tracefs that was previously mounted, and was not closed. It will leave a "cursor dentry" in the subdirs list of the current dentries that set_gid() walks. On a remount of tracefs, the container_of(dentry->d_inode) will dereference a NULL pointer and cause a crash when referenced. Simply have a check for dentry->d_inode to see if it is NULL and if so, skip that entry. - Fix the bits of the eventfs_inode structure. The "is_events" bit was taken from the nr_entries field, but the nr_entries field wasn't updated to be 30 bits and was still 31. Including the "is_freed" bit this would use 33 bits which would make the structure use another integer for just one bit. Please pull the latest trace-v6.7-rc8 tree, which can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git trace-v6.7-rc8 Tag SHA1: 268dc78680a450c2207c0af35e0e367ff07b25eb Head SHA1: fd56cd5f6d76e93356d9520cf9dabffe1e3d1aa0 Steven Rostedt (Google) (2): tracefs: Check for dentry->d_inode exists in set_gid() eventfs: Fix bitwise fields for "is_events" ---- fs/tracefs/inode.c | 4 ++++ fs/tracefs/internal.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) --------------------------- diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 62524b20964e..bc86ffdb103b 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -215,6 +215,10 @@ static void set_gid(struct dentry *parent, kgid_t gid) struct dentry *dentry = list_entry(tmp, struct dentry, d_child); next = tmp->next; + /* Note, getdents() can add a cursor dentry with no inode */ + if (!dentry->d_inode) + continue; + spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); change_gid(dentry, gid); diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h index 899e447778ac..42bdeb471a07 100644 --- a/fs/tracefs/internal.h +++ b/fs/tracefs/internal.h @@ -63,7 +63,7 @@ struct eventfs_inode { }; unsigned int is_freed:1; unsigned int is_events:1; - unsigned int nr_entries:31; + unsigned int nr_entries:30; }; static inline struct tracefs_inode *get_tracefs(const struct inode *inode)