Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2785753rdh; Mon, 30 Oct 2023 07:41:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErJe8T3M5GUGeqASF8UKYyfbtR0ENjov8o2GkZGLuMAkQh98tymKOQM2Qa2XDkv4jiCyL/ X-Received: by 2002:a17:902:e743:b0:1cc:4336:8c7b with SMTP id p3-20020a170902e74300b001cc43368c7bmr5152375plf.39.1698676902573; Mon, 30 Oct 2023 07:41:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698676902; cv=none; d=google.com; s=arc-20160816; b=b1MbaEuTQHkHmfdb2jLI3+8rzfkegGKH3SP5DqyK5UKaq1rk5lqX8SCwRMTapRoOLu 79OdFs+eHTlZY1AhT8m89spLIzcz4MoiQUsYnvjR3hpMbqpp7obFzrnyU06ADE+E5R2w hxKIkXp30vz7QSnQ17rzVRHn8vqZOaoWznoR18qeWZ32/jMgGkErs1XwZHMqrcTtnd+I 7QUAL5BTdqmd2mai/aolvv5sRR6CaO1AyW/DHsuOyurMlv4IDWghwi/6wypq+0BnRA2g Xd2Vd6lUiBmqZoAx5Ty2FX7WzYcdJeYCv1XsGXUpzvJ0avvTSTUNZQERnw9INvksj6ti +fWg== 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=Vn7qZkofUDUN5kiSShZDRWi/rauBSGi2cdWrpGSJ9Lo=; fh=Zut9cVsAvS/MlqvRfujl0J73KmrUNv/wxGr64NsqY80=; b=kj2g/ZRbGpNiaI4o2BYdPZHS32Ha0XeSMZpAD6eYquyDoQ4ftpXCmxgTS+mFipgcYu /S1dsC/d3TrH0Q0Uytq+RafrQ7F0jZvV4gmEtSOLQzOb9lR5iJBpdbyOw+2uURstHaT2 WIk1DtWIa0WNoGI1u9tOpSZgupkRtPlpxA+LybgkI/yZ3CAa0LmVunKQW1KpjYD5yCGZ JP2pJgrmFolmJScJ/n8D6XnAICoJfWRTApzNPb7bO4T+DEdHwrNcwWBSaWNJ4YGGn7BM dCa6SwtLeEKXf8dPG1U/kF+VfdePyJi9fSm1jeuE8lWAtQu2P6+SDM1o96luqIZig7mw f6Zg== 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:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id kk3-20020a170903070300b001cc467a339esi1913857plb.389.2023.10.30.07.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 07:41:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 0F44A80A2385; Mon, 30 Oct 2023 07:41:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233302AbjJ3Old (ORCPT + 99 others); Mon, 30 Oct 2023 10:41:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232458AbjJ3Olc (ORCPT ); Mon, 30 Oct 2023 10:41:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2096BC9 for ; Mon, 30 Oct 2023 07:41:30 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1C11C433C7; Mon, 30 Oct 2023 14:41:28 +0000 (UTC) Date: Mon, 30 Oct 2023 10:41:27 -0400 From: Steven Rostedt To: Naresh Kamboju Cc: LKML , Linux trace kernel , Masami Hiramatsu , Mark Rutland , Arnd Bergmann , "Naresh Kamboju , Beau Belgrave , Ajay Kaher , Andrew Morton" , lkft-triage@lists.linaro.org Subject: Re: [PATCH v2] eventfs: Test for ei->is_freed when accessing ei->dentry Message-ID: <20231030104127.6f32c932@gandalf.local.home> In-Reply-To: References: <20231028164650.4f5ea18a@rorschach.local.home> <20231029091408.0179cee4@rorschach.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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Mon, 30 Oct 2023 07:41:40 -0700 (PDT) On Mon, 30 Oct 2023 12:37:08 +0530 Naresh Kamboju wrote: > > I have tested the linux-trace.git trace/core and run selftests ftrace > the reported kernel panic [1] & [2] has been fixed but found Good to know. Can I add "Tested-by" from you for that bug fix? > "general protection fault" at kernel/trace/trace_events.c:2439. Can you test with the below patch? Also, can I ask what are you testing this on that makes it trigger so easily? As I'm not able to trigger these in my tests, even though they are indeed bugs. -- Steve diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 7ad7496bd597..7a0b54ddda24 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -609,7 +609,13 @@ static struct dentry *eventfs_root_lookup(struct inode *dir, entry = &ei->entries[i]; if (strcmp(name, entry->name) == 0) { void *cdata = data; - r = entry->callback(name, &mode, &cdata, &fops); + mutex_lock(&eventfs_mutex); + /* If ei->is_freed, then the event itself may be too */ + if (!ei->is_freed) + r = entry->callback(name, &mode, &cdata, &fops); + else + r = -1; + mutex_unlock(&eventfs_mutex); if (r <= 0) continue; ret = simple_lookup(dir, dentry, flags); @@ -743,7 +749,13 @@ static int dcache_dir_open_wrapper(struct inode *inode, struct file *file) void *cdata = data; entry = &ei->entries[i]; name = entry->name; - r = entry->callback(name, &mode, &cdata, &fops); + mutex_lock(&eventfs_mutex); + /* If ei->is_freed, then the event itself may be too */ + if (!ei->is_freed) + r = entry->callback(name, &mode, &cdata, &fops); + else + r = -1; + mutex_unlock(&eventfs_mutex); if (r <= 0) continue; d = create_file_dentry(ei, i, parent, name, mode, cdata, fops, false);