From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 798AF3630B0 for ; Sat, 10 Oct 2026 07:38:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791617907; cv=none; b=ZalrEfTNS/ECmWrKUaWKb19IxyXm6WwfB9Z4Q7iBCxefg5odLvl0gWc59jv/kfRPEKCvKUa4L0ZNs7PYE4N+W1E7DuwrcV/0TcW/ihn/cB+xv3ue+kdhjHXd+U2rbYBjEJbT2elRx0LIK9RQNo+pjR+3XY0iyZFpcKc0oWCSvXc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791617907; c=relaxed/simple; bh=HrNtqZGMJwHAHK27VJ1CwFKK7rixvgcxmfh56RdnLq0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=H06WqjaPIj683WsybfAAC1Us5BUMAsG4TeK7J7nbdiPe+Lj1HkcE0ohksGjBQjzTqMOOnZemZU0jhEkdmmR8Xh14gtw9iFTkT4nANNRtPrEzt1dIpuqjbm2rWl1gBZKBNHauR+0EwEpSRXkYJyLKHWDuuI3MlOft3KydRc18H8c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=bHD5hBIm; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="bHD5hBIm" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-49ff639372eso494405e9.3 for ; Sat, 10 Oct 2026 00:38:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1791617904; x=1792222704; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=icy62ZS1ngYq12CKSGVk1ttF9vUahbM+7mKp/fS2KJ4=; b=bHD5hBImVVhZEhqtmBKcPA1tKv+cNoxpOcd0wUig2U/TE/YJKAXrkX3U9PmWLqKE5N S2yxRra48zEfkzLhRhDnG8fZhxjKca18cAyvFVOMfGhKnpsS1adsI3g+NxFSaK4ZeAz5 sGOhzfOfov7nfxlrk9MMT9gai9iIE/ylXLBzumL9EOsP5NuJMnSEzzw4K33o2QODjWwo sAu1hazhhWP1wDMoXmjQJu8C8GGNN6YNZiwFpcyJ6lTnhMUNlsLmIgpfCJxVUvVG0vEx Da3Y6Wo7OXNyMYL7aE5O9dr3ouckfNeOmkRzqXTxXReUJntg0ax7s3noasYlnxH5aQfV iDdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791617904; x=1792222704; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=icy62ZS1ngYq12CKSGVk1ttF9vUahbM+7mKp/fS2KJ4=; b=lkGR9X4vKMvjfTwKcON2CrPuxIb4CuDzbvDEL7Hd0c3adv8mG9sDu0gJ6pAW+RFF0I sbZBmi1TePz31mTYpCmdbCLvTFgd/BAPiXnvJH9s0KTSy0A8UsWOC2Npl8VnYX1cZdLO 3d/Bc966SwTxcJfQeWorj4CCq0+mJ6Nt/q9yK59SrgJaWjcpn45EOEsAPwPWHC5rUIbZ l+fLOPRm7te8tXzMvwG1xbDpHyIcLVv0AwOcWCp5T1HYa6eEYQ4CRGA/VYugZeWW3dFi +QnI5ujneofSONmYlAhoHIV0dQK9SVP30mPIyv79cWY3RgZNjLcrQLY9GCB0VLt9aOat Qu2Q== X-Forwarded-Encrypted: i=1; AKwUvBxEhMzfiQdwkbTQAYFBGJ/HSKCUrIna7X/u9YqeZglkw/xxXJ/yjM+xm2O0XxxYKMvsZWOoZfMIoHCza0Y=@vger.kernel.org X-Gm-Message-State: AFq9FYL7za5REoT+92nvP/8yDfks8kmCADfd3iAvvXMu8YqEAb/nimJD jtHjjAJg2OIJS5kwjm/uHYJrKVQCquDGRPcrH5FKDhRPwloeCxuRpMm2csjrhNphuKk= X-Gm-Gg: AYBFou2/52v/di7c1qt7bU1AJNTRhuWMWiToxfqWIu8ZScZhZY42to6gOKQ2Gi68VTk kH0OJqSRjmZYe36oG4o4PC9/rh1Fwk0ZcMP1F7++K03xxzuRqPCCI0kTK/ztn111+QqkdQm9okX mveL5sjOWYDJX7qNLKG3fTeT5LJJkg+UISjtpeDX12sWZuNvJoxcGh86ibErFBysPFYHs8h01kt QWMZf4mpPLvF1onu4s3UzNHqhEuCeRphRZM/YlHeB5ahVU9J/hNVQTrpG4d0naDpYLygWN5vJjT jePPJijFE0AK7nP8iekumBLMBPkBhiadtWF0pKK1qa6YE5L7kQ7OGwM7WRfgv8ymaUVEezbfG2f RIqT5H7bayvAaNtxUw7KjMX4T4kJGdQgkABidgHpVBnLWkfqXV9fHGLVCD7kwKCAlizIDkg0HQR Nenl91gqvnFH3whqRitsnAAHabJLjHMdWJk+P158IsBrKhxNVdHfgROD/17GLh8Uip1w/6ISal6 BVVRYQ= X-Received: by 2002:a05:600c:1e0f:b0:4a1:8469:e6c8 with SMTP id 5b1f17b1804b1-4a18e46f48fmr76946365e9.1.1791617904172; Sat, 10 Oct 2026 00:38:24 -0700 (PDT) Received: from localhost ([202.127.77.110]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ab50ce9d98sm5322288a91.9.2026.10.10.00.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2026 00:38:22 -0700 (PDT) Date: Sat, 10 Oct 2026 15:38:18 +0800 From: Heming Zhao To: Cen Zhang Cc: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, akpm@linux-foundation.org, ghe@suse.com, ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com, jjzuming@gmail.com Subject: Re: [PATCH] ocfs2: Publish the filecheck owner before adding sysfs attributes Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Oct 09, 2026 at 06:04:49PM +0800, Cen Zhang wrote: > ocfs2_filecheck_create_sysfs() initializes the filecheck allocation > before calling kobject_init_and_add(), but assigns entry->fs_fcheck > only after that call returns. The default attribute group can already > be visible while registration is in progress. A concurrent read can > therefore enter ocfs2_filecheck_attr_show() with a NULL fs_fcheck and > try to lock its fc_lock. > > Assign the initialized owner before adding the kobject, so every > activated attribute has valid state. Clear the pointer when addition > fails, preserving the existing teardown guard and error cleanup. > > A controlled probe-instrumented test kernel with the original OCFS2 > registration ordering produced this Oops during a concurrent sysfs read: > > KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f] > RIP: 0010:kasan_byte_accessible+0x15/0x30 > Call Trace: > > __kasan_check_byte+0x13/0x50 > lock_acquire+0x113/0x300 > _raw_spin_lock+0x31/0x40 > ocfs2_filecheck_attr_show+0x138/0x5f0 > ocfs2_filecheck_show+0x5d/0x90 > sysfs_kf_seq_show+0x1d3/0x360 > seq_read_iter+0x480/0x1110 > kernfs_fop_read_iter+0x419/0x5a0 > vfs_read+0x7d2/0xc20 > ksys_read+0x111/0x200 > do_syscall_64+0x114/0x620 > entry_SYSCALL_64_after_hwframe+0x77/0x7f > > Modules linked in: > > Fixes: a860f6eb4c6a ("ocfs2: sysfile interfaces for online file check") > Assisted-by: LLM > Signed-off-by: Cen Zhang > --- > fs/ocfs2/filecheck.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c > index be713d7d24a76b9aa8fcded3d83b3d91d124eb6e..862c1ee7099c943b2e3e57e31f887380c6dc8a88 100644 > --- a/fs/ocfs2/filecheck.c > +++ b/fs/ocfs2/filecheck.c > @@ -181,2 +181,4 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb) > > + /* Publish the initialized owner before activating its sysfs callbacks. */ > + entry->fs_fcheck = fcheck; > entry->fs_kobj.kset = osb->osb_dev_kset; > @@ -186,2 +188,3 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb) > if (ret) { > + entry->fs_fcheck = NULL; setting to NULL is unnecessary, it becomes a harmless dangling pointer here. Other code looks good to me. Thanks, Heming > kobject_put(&entry->fs_kobj); > @@ -191,3 +194,2 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb) > > - entry->fs_fcheck = fcheck; > return 0; >