Replace test_bit() + smp_rmb() with test_bit_acquire() for PIDFS_ATTR_BIT_EXIT and PIDFS_ATTR_BIT_COREDUMP tests in pidfd_info(). The acquire semantics ensure that if the flag is observed set, the associated attr fields written before smp_wmb() + set_bit() are also visible. Writers keep smp_wmb() + set_bit() since no release bitop exists. Cc: Alexander Viro Cc: Christian Brauner Cc: Jan Kara Assisted-by: DeepSeek:DeepSeek-V3 Signed-off-by: Jinjie Ruan --- fs/pidfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/pidfs.c b/fs/pidfs.c index a6a643f15d08..2cd0fab73180 100644 --- a/fs/pidfs.c +++ b/fs/pidfs.c @@ -393,8 +393,7 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg) attr = READ_ONCE(pid->attr); if (mask & PIDFD_INFO_EXIT) { - if (test_bit(PIDFS_ATTR_BIT_EXIT, &attr->attr_mask)) { - smp_rmb(); + if (test_bit_acquire(PIDFS_ATTR_BIT_EXIT, &attr->attr_mask)) { kinfo.mask |= PIDFD_INFO_EXIT; #ifdef CONFIG_CGROUPS kinfo.cgroupid = attr->cgroupid; @@ -405,8 +404,7 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg) } if (mask & PIDFD_INFO_COREDUMP) { - if (test_bit(PIDFS_ATTR_BIT_COREDUMP, &attr->attr_mask)) { - smp_rmb(); + if (test_bit_acquire(PIDFS_ATTR_BIT_COREDUMP, &attr->attr_mask)) { kinfo.mask |= PIDFD_INFO_COREDUMP | PIDFD_INFO_COREDUMP_SIGNAL | PIDFD_INFO_COREDUMP_CODE; kinfo.coredump_mask = attr->coredump_mask; kinfo.coredump_signal = attr->coredump_signal; -- 2.34.1