From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7CCD42C236D for ; Mon, 15 Sep 2025 22:38:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757975894; cv=none; b=CghH7SSCP66iuJ9GzYtSYLfpeCizpUpzUCIgfn0cp6DbN/Ol0CpniIgIerO0mcKjvPQC27Hr2o1bgu7D/qU7hZrSgKuswWLO5UmTsFBLHGuJIUVLXZIwm0Bt66rHWiXMV2k/1zYFo+nFkVeXu7bCs3tg8C2ztzgzbiat1ZWX628= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757975894; c=relaxed/simple; bh=MDc9E4MVP6maeBz5e3kcImL0EaRxzQHs4Ru3zcjIvJM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oc0WlJmnb/15eJT63Y7p6tNJ7Gp3+q/jaUK1oTZajt7yP/MqIeS391hXQbbibBErYXzK/T8XQs3F6wVzHRxJGsVP9hkVVmX0NNSpix8AWl8emdmKgnosQdBHkWY9u7NMn1aZa+GwofkJYfUnViEIWHlSj4W7D6f7tlwFazbJecs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S90ZPbR0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S90ZPbR0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50085C4CEF1; Mon, 15 Sep 2025 22:38:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757975894; bh=MDc9E4MVP6maeBz5e3kcImL0EaRxzQHs4Ru3zcjIvJM=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=S90ZPbR0RlogzH1DQo4yxkOxk5v0OUnvQb0KyXDBln2zlXCuvA1cR15gkgpTkfyA/ TBPJ1JBbHxeH4Rix6Enc7tpgnMkmV3q0je60LU/XENTbfTWIigpXy5v+WTuU+AGcVh lzdJCdksTDYSKpIWQbLQsz9iq3+gNZjYWP9Ls3KsniU2mXofDDeUUzCExVQ96f4oDH A3AaHZImVywApktFJKCPTX7qmYhzjNoNPlzLZ9iRVhhaZ0prXw2+DpehlOAFVIRgfX swIoRxhy3FK30fkgZ27+eeMmu5V/Gt1CmpXuDHWzc6Kz3Bu+dFuER7Z+YWaw/OUPCL OruvnmJ8oXnaQ== Date: Mon, 15 Sep 2025 15:38:13 -0700 Subject: [PATCH 02/12] libext2fs: don't look for O_EXCL in the F_GETFL output From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org, linux-ext4@vger.kernel.org Message-ID: <175797569655.245695.8543695297980818018.stgit@frogsfrogsfrogs> In-Reply-To: <175797569564.245695.4628729304068635201.stgit@frogsfrogsfrogs> References: <175797569564.245695.4628729304068635201.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit From: Darrick J. Wong For decades, Linux has never propagated O_EXCL into the user-visible file flags in do_dentry_open: f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); Therefore, one cannot use F_GETFL to determine if the file was opened with O_EXCL. The unixfd IO manager will have to trust that the caller opened the file in O_EXCL mode. Without this patch, the upcoming flock patch will not work correctly in determining the lock mode to keep other copies of fuse4fs and/or systemd from touching a fuse4fs mounted filesystem. Cc: # v1.43.2 Fixes: 4ccf9e4fe165cf ("libext2fs: add unixfd_io_manager") Signed-off-by: "Darrick J. Wong" --- lib/ext2fs/unix_io.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index adbdd5f6603d74..723a5c2474cdd5 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -1090,11 +1090,10 @@ static errcode_t unixfd_open(const char *str_fd, int flags, if (fd_flags == -1) return EBADF; - flags = 0; + /* O_EXCL is cleared by Linux at open and not returned by F_GETFL */ + flags &= IO_FLAG_EXCLUSIVE; if (fd_flags & O_RDWR) flags |= IO_FLAG_RW; - if (fd_flags & O_EXCL) - flags |= IO_FLAG_EXCLUSIVE; #if defined(O_DIRECT) if (fd_flags & O_DIRECT) flags |= IO_FLAG_DIRECT_IO;