From patchwork Sun Nov 12 17:18:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 164264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp788884vqg; Sun, 12 Nov 2023 09:18:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCnZuVerZi+JeJMLZ+1sihSQRxM8gML0GiYVZQ7NctoqTMd0gj8mEBJXSrra6+Q6lbdl8H X-Received: by 2002:aa7:8548:0:b0:68f:b5a3:5ec6 with SMTP id y8-20020aa78548000000b0068fb5a35ec6mr6154923pfn.0.1699809526214; Sun, 12 Nov 2023 09:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699809526; cv=none; d=google.com; s=arc-20160816; b=l+MMqNd6gm/bkOJHT4ybISUt63ZiNDIrMb4aZnnfvXQV6K486LkTdn/r5nPLdjFYgj z5iIAjdOddDoIj9vw0mzbUFO7NgYWrPtRjq/RQW+Q+GGQky48Y3ONxFuQMTjPL0p7O+H r21+6RCYw0r6pN4QumihPeZmEwnPktXEBELvTQPIPMkbcKehNaBpdXbqda+QI9IZ+wLj kglG0WLv4U8yhYq/Qs3LKgBwQX24dCCeL8pCSTkkmHJITtJgYlp6U9ytKXxlgVVhknvd GNuA10ZW8gPC4WIunBbq8jUum0lDp/Do3Hwq6wtBWaDupfVtF/jXsHcnsiYXsR7PuSH6 uj1Q== 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 :message-id:subject:cc:to:from:date; bh=Tc28xQnBJCBwlo4r/0B7j8pjOvCkKl+3PnJnC3f5yeY=; fh=rjPHL/0ptRYaK1NXj6Re1pCG0atUQ//mAuLSHhuEqb0=; b=BMNZCEl9Y13wU0224RmZuaetpdHSO7UxA6ZKruWQZj6z55xCJ5Z58jzBudWqRmttQs INcslYaaFCPLt87vrYnMZRiB4QuDKUTmz0cYS8N0R2xyKYK+lBD/KIVfgvugByFS/RpW Jd6zmnLELuBm1GNY+fu/cTSbUhX9r8qGD5/oZVuTIq4a8AhhLcnMOhvmNgmi0emty0/4 cW+qkjsK7I3b4nveZFnmjd6ej9j/hQam+SiXNOFIa2rquqezoDFlIIJc2iMe+o625yFd yJmIF1/MdcWOIVM3l+EW6vQEIVnOV+cYfw291QIhrPexo76OWe0Clj+qBUUajdgWAatb ZJtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bo15-20020a056a000e8f00b006bf53365ac4si4029545pfb.139.2023.11.12.09.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 09:18:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id B447E806B33A; Sun, 12 Nov 2023 09:18:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231556AbjKLRSY (ORCPT + 30 others); Sun, 12 Nov 2023 12:18:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjKLRSX (ORCPT ); Sun, 12 Nov 2023 12:18:23 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C6BD1FF6; Sun, 12 Nov 2023 09:18:20 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47788C433C7; Sun, 12 Nov 2023 17:18:19 +0000 (UTC) Date: Sun, 12 Nov 2023 12:18:17 -0500 From: Steven Rostedt To: LKML , stable Cc: Greg Kroah-Hartman , Masami Hiramatsu , Mark Rutland , Milian Wolff , akaher@vmware.com, Andrew Morton Subject: [v6.6][PATCH] eventfs: Check for NULL ef in eventfs_set_attr() Message-ID: <20231112121817.2713c150@rorschach.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sun, 12 Nov 2023 09:18:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782379473299278130 X-GMAIL-MSGID: 1782379473299278130 From: "Steven Rostedt (Google)" The top level events directory dentry does not have a d_fsdata set to a eventfs_file pointer. This dentry is still passed to eventfs_set_attr(). It can not assume that the d_fsdata is set. Check for that. Link: https://lore.kernel.org/all/20231112104158.6638-1-milian.wolff@kdab.com/ Fixes: 9aaee3eebc91 ("eventfs: Save ownership and mode") Reported-by: Milian Wolff Signed-off-by: Steven Rostedt (Google) Tested-by: Milian Wolff --- Note: This only affects 6.6 as the code in 6.7 here was rewritten. I tested 6.7 and it does not have this bug. fs/tracefs/event_inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 5fcfb634fec2..efbdc47c74dc 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -113,14 +113,14 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry, mutex_lock(&eventfs_mutex); ef = dentry->d_fsdata; - if (ef->is_freed) { + if (ef && ef->is_freed) { /* Do not allow changes if the event is about to be removed. */ mutex_unlock(&eventfs_mutex); return -ENODEV; } ret = simple_setattr(idmap, dentry, iattr); - if (!ret) + if (!ret && ef) update_attr(ef, iattr); mutex_unlock(&eventfs_mutex); return ret;