Received: by 2002:a05:7412:85a1:b0:e2:908c:2ebd with SMTP id n33csp65420rdh; Mon, 30 Oct 2023 14:04:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcmD+lFPBh0kAtROSjVy/eJKfduszSyEnV6Em7Z5ov5bG1qOBGkFDpR/FYjkwzcsWRBUck X-Received: by 2002:a05:6a00:3a08:b0:6bd:2c0a:e82 with SMTP id fj8-20020a056a003a0800b006bd2c0a0e82mr10289866pfb.7.1698699840308; Mon, 30 Oct 2023 14:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698699840; cv=none; d=google.com; s=arc-20160816; b=cGXQlTzJqjg0K5cDzL8sDysw6Soi1gS/lqKsnHWkI8/NnlvHy7ZD16104emDOruBUl 0VAQY/iGSQQIkkfnbP8g53qKccUJfA+ldW0oBSor8jfuO0B9Fz5mAZuTIWHrjfrTnzrV 0/x8a7246xdkNQX9qLw5+pagaENZ5NyBhqHR6J9eGZi4VtZFpRXfGsh/j1N7GJ9+sm01 +S4ICI+W0yhTsMjtSSCyJdqLiXtHFQFwlo3lOrLXUlcxb3vgkolPFq0SCAh2etNMDuLu df8BOGgR+6cTnSz7+3lQW8b0f8vJSSDemfWcpNWfrjwEm7rdOnQQuW21H4Jmq+zRWcD3 CWOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=crwNbqxR7nPOodoWp7WUIXqNMkXcMnjDYt1yU/ik8o4=; fh=lftvAKUR5ldmousKutC5mBcgJsWJVX6Cwux6t7kGSfI=; b=jd9EIk6+epYuo0Im9il+8cnfOZPEtZCwyifGLDqLTkZF3IpUvE4PjQh4h0GtsVnq1I q/5d1g+4B0uNCQ62Z7tjudgnnQvTJ57rKlWU8qq1T+g3CJ5dBMEmeSLx7k77hN3aQhRl vsTdofzmja5ujq/qAuMoWBcz5XGTWKU/iwF8TtbE6jQiIAThNJrQh43RB6aK3NC8pZLs oJhp1FJNqF2Pst8NIlF4f/r1coO67QtYt3PVUkTF112k0wvUNeAGOr28qXLeWBYEMYmc qXaEudELQmZQGTNSsJRLG6cqN33PydvTPMTOgruTu26NN1nIKToP7b0fUb2e8jhDXRC2 x6GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lKZE3AaI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id s123-20020a637781000000b0056952b496efsi5381739pgc.366.2023.10.30.14.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 14:04:00 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=lKZE3AaI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id F1AAE80473AD; Mon, 30 Oct 2023 14:03:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231789AbjJ3VDr (ORCPT + 99 others); Mon, 30 Oct 2023 17:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbjJ3VDq (ORCPT ); Mon, 30 Oct 2023 17:03:46 -0400 Received: from mail-vs1-xe35.google.com (mail-vs1-xe35.google.com [IPv6:2607:f8b0:4864:20::e35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25753FE for ; Mon, 30 Oct 2023 14:03:43 -0700 (PDT) Received: by mail-vs1-xe35.google.com with SMTP id ada2fe7eead31-457c82cd837so2055292137.2 for ; Mon, 30 Oct 2023 14:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698699822; x=1699304622; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=crwNbqxR7nPOodoWp7WUIXqNMkXcMnjDYt1yU/ik8o4=; b=lKZE3AaITXAyrxY3lwszx2239avcI3TT1dr+PD6c4bQ3H0mQnLwrbIQ8QnYCoRdB2z yCVQ6Z5AgsmFmiBoDWrX4p8FuWcmefM+h5Y0s9DNUzm/GfxGry/3jOEsTPoj8XRWgaqX xMb8SSqqiUX6BNjmJSQqa+1q30IMPHxziX1Tv6l0k9Yz79a5u/2QPwEiZ2Tt2NQrpNHl LqJkdPWwI4uFP7f7f50sfiugrT2DJqhZJkKmcD1nGHcLm2MMkv8XJcoh/lXpkeW3FcbD 1isgpp0G++iS0l3KnMdBjsZr8GGmUSnDhu9J1Ed0TKCNlOWCSgU+c6qe+KBM2aiTt09f 4BYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698699822; x=1699304622; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=crwNbqxR7nPOodoWp7WUIXqNMkXcMnjDYt1yU/ik8o4=; b=PQE1aP6fbeL883gRU3sDlGSWsNIgV2HpPw/Ve8V5FspUSQ4wI2FBZgODJBw8954DSe EP895cxCYtq6HrKPH1X5F16x5IGIZl7eqw5V2/7Tl5WeKCwDZHgozhQA3TxPgZMpuXDa WHv7+3pP3Vtabl54072LS2pBvimpZUtLgOuSmzwq5HwfMWl+NOqGIkqVTPyVG1snGIYm NuS/T+aAV5lhzHa5rOmjsJrI4tziAk8tptyMVnR1PpJ/ihm5VUUS5z9BmTesMzFtAsvw KRZUMXaxpNQj/4ng2e3pXtaOp0wlQoI8VGRog9IJ1NvkvjHknlg4M+VCyeow68ENE6XG yERQ== X-Gm-Message-State: AOJu0YxLqAPZhcNDznkpaLaYAL9p374AWlgCQSckSqusaDCZ6kMLP2Ko 1WYzYF6f3Ptxw+KzCcrHO8XSPhgBA6Mp9I5vOjgs8A== X-Received: by 2002:a67:c295:0:b0:458:11dd:87aa with SMTP id k21-20020a67c295000000b0045811dd87aamr10199144vsj.22.1698699822074; Mon, 30 Oct 2023 14:03:42 -0700 (PDT) MIME-Version: 1.0 References: <20231028164650.4f5ea18a@rorschach.local.home> <20231029091408.0179cee4@rorschach.local.home> <20231030104127.6f32c932@gandalf.local.home> In-Reply-To: <20231030104127.6f32c932@gandalf.local.home> From: Naresh Kamboju Date: Tue, 31 Oct 2023 02:33:29 +0530 Message-ID: Subject: Re: [PATCH v2] eventfs: Test for ei->is_freed when accessing ei->dentry To: Steven Rostedt Cc: LKML , Linux trace kernel , Masami Hiramatsu , Mark Rutland , Arnd Bergmann , "Naresh Kamboju , Beau Belgrave , Ajay Kaher , Andrew Morton" , lkft-triage@lists.linaro.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 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]); Mon, 30 Oct 2023 14:03:57 -0700 (PDT) On Mon, 30 Oct 2023 at 20:11, Steven Rostedt wrote: > > 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? Please add, Tested-by: Linux Kernel Functional Testing Tested-by: Naresh Kamboju > > > "general protection fault" at kernel/trace/trace_events.c:2439. > > Can you test with the below patch? Applied this patch on top of linux-trace.git trace/core and test passed. All the reported issues have been resolved. > > 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. I use following build artifacts and running selftests: ftrace: ftracetest-ktap kernel: url: https://storage.tuxsuite.com/public/linaro/naresh/builds/2XT84xYJIMmKApmqOOtKhnLdCyz/bzImage modules: url: https://storage.tuxsuite.com/public/linaro/naresh/builds/2XT84xYJIMmKApmqOOtKhnLdCyz/modules.tar.xz compression: xz nfsrootfs: url: https://storage.tuxboot.com/debian/bookworm/amd64/rootfs.tar.xz kselftest: url: https://storage.tuxsuite.com/public/linaro/naresh/builds/2XT84xYJIMmKApmqOOtKhnLdCyz/kselftest.tar.xz Steps to test: ========== 1) Boot x86 machine with above bzImage, modules, rootfs and copy kselftest.tar.xz from above url and unzip. 2) cd /opt/kselftests/default-in-kernel/ftrace 3) ./run_kselftest.sh -c ftrace # selftests: ftrace: ftracetest-ktap # unlink: cannot unlink '/opt/kselftests/default-in-kernel/ftrace/logs/latest': No such file or directory # TAP version 13 # 1..129 # ok 1 Basic trace file check ... # # Totals: pass:126 faii:0 xfail:1 xpass:0 skip:1 error:1 Test logs: https://lkft.validation.linaro.org/scheduler/job/6985018#L4742 > > -- 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);