Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1836032lqo; Sun, 12 May 2024 22:34:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDAuQEbt+mBysYbx+2yzXeFL8ZrE6cFM6YbOiVClarF44HPHhX2dtVGqvnkLXIutJ76n0PYhc9AksAWYI5igUMnm0oaXnlrONIBcbbXA== X-Google-Smtp-Source: AGHT+IHtlkDwRlf0G5Z0eqif91QE8HZj2rMtjkzOdMnjLy3L4BviOWFaK+BpOFa3hU4q6//EOqhK X-Received: by 2002:a9d:7d81:0:b0:6f0:e2ba:a91d with SMTP id 46e09a7af769-6f0e911e962mr10101515a34.12.1715578460402; Sun, 12 May 2024 22:34:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715578460; cv=pass; d=google.com; s=arc-20160816; b=P0pF/PVTXAYa8LEbdo3qPlmZ++1eku+EP0iduxgi5MlTj7TMOYlUzziECecC2PgeAc 2krvkdJ6crLuFPvfXewXs86wxdjDc0CPNhxIoYAGPyRJHKQtyNkjy2uRUWHLcEJVY7mg xMBO81hbJyjpIY1mACb/YeFbRtyipj+eFAhxsxW4GPnrOafmVJZr5/U6hDgE3/dLHBIC w0R34+QesOlA89DwNsp/N7T09MSFsJvF2IU/80E7GwUciglw144EO0LzZRH4mJNLgAWI P4z6xSpO8xKHt3aqKAlzJAmRsEcXONTEXOlwA+7L3k1/NpdSNvDvJ1jrQDZp8+KmVcIo iG6Q== ARC-Message-Signature: i=2; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NtkBKlqRVPiYt0KU2gHHEP+MV+jp5EvYQ4ZKCZH6xvs=; fh=rrZR1X91I38oFBHHBRfFhCLke/DSGxnW734Quv8keeU=; b=KHo8SAxqb/zg2axNZrzOOUPVHwoJBeBGDiBBhT6wj2ds9BMILGpd9igcbmwrGV/WFf YGxbyQpByXXKZRN0x9qggHx3B5jA579hBHe+tyysks/i9DMvLWZEoPB4HQ71cWCIeXV1 B3aeS0NASbGRFzS39GCrHpxjnli46xMTv8gRegbPBGQXNszKlVSWIEDuYohYyQVTLHL/ O/RajtU8IUhhyX3UvXbroqI2q4ZlAL0qkMhOA4Nmwemm8RA7QbfHUWvvmKZAtPQkqtsc w0VY6RsAwgPCihqsIpAJd/aghU5ATWbv9px6FaeLYSZnUMnpy1nQGGeNpsfsYb9dDvvL kcjg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="bPNF6x/3"; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-177167-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177167-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6341180eac7si8146751a12.552.2024.05.12.22.34.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 22:34:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177167-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="bPNF6x/3"; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-177167-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177167-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 055EF2814F8 for ; Mon, 13 May 2024 05:34:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABC5514658E; Mon, 13 May 2024 05:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="bPNF6x/3" Received: from out-176.mta0.migadu.com (out-176.mta0.migadu.com [91.218.175.176]) (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 3E1EE146585 for ; Mon, 13 May 2024 05:34:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715578454; cv=none; b=uYXGdZBtxib8nymVaqZKXcg8wwMjtZu3LPaa6vQZM6r5HCanAnSI3baj7EjclPA+GN/qBSluixwNNyhN72HasN3YMh3B5TaM+NH1WeAUBiouXKGGQkMB+yvkvWxhzFggmrDVXtQvflBqDseQGElLbZy8VnnR4n0SpX7PZ7ii+hg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715578454; c=relaxed/simple; bh=3novfxKmuOHtv2/2Uxne6GNAqtrqJ5MvuaL4zalChp4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JyGdmSY8UKeBVbVwgI5rvhe09pUJGaFmc0fZhJwHTMeOEkGbR72d3kMJwzKcjcMLKp7f71k+IDOF6wnk17zvJZ9Tv7ynCyk+x7Bg72/ysqo7xjw6CEEG2uGBhIbSDmDoc8HjhNuA6vhdeQv5I7jnbBal7z2OGwS/KGT3TD1VAlk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=bPNF6x/3; arc=none smtp.client-ip=91.218.175.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715578448; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NtkBKlqRVPiYt0KU2gHHEP+MV+jp5EvYQ4ZKCZH6xvs=; b=bPNF6x/3D3j3GV79OW8FEMCFENYlL3367JFVNkpvFwAj+4hJh6PsD8ntCa1+sBBnBnlI2V EkHkfGP0Osy0bczztTYbcbNGT0iT9/eGfPZwa4BG/I/oYuBP4CQovPJNR1g38DxH7qORLJ +TfxTSq2+/maLlJOVvUJwVtuqTzcUj4= From: hao.ge@linux.dev To: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, hao.ge@linux.dev, Hao Ge Subject: [PATCH v2] eventfs: Fix a possible null pointer dereference in eventfs_find_events Date: Mon, 13 May 2024 13:33:38 +0800 Message-Id: <20240513053338.63017-1-hao.ge@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Hao Ge In function eventfs_find_events,there is a potential null pointer that may be caused by calling update_events_attr which will perform some operations on the members of the ei struct when ei is NULL. Hence,When ei->is_freed is set,return NULL directly. Fixes: 8186fff7ab64 ("tracefs/eventfs: Use root and instance inodes as default ownership") Signed-off-by: Hao Ge --- v2: - adjust title and commit message - omit curly brackets --- fs/tracefs/event_inode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index a878cea70f4c..0256afdd4acf 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -345,10 +345,9 @@ static struct eventfs_inode *eventfs_find_events(struct dentry *dentry) * If the ei is being freed, the ownership of the children * doesn't matter. */ - if (ei->is_freed) { - ei = NULL; - break; - } + if (ei->is_freed) + return NULL; + // Walk upwards until you find the events inode } while (!ei->is_events); -- 2.25.1