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 E30AE14A8D for ; Wed, 9 Aug 2023 10:51:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62111C433C8; Wed, 9 Aug 2023 10:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1691578270; bh=KWNLgesY/Rb7cY0OLiQ4Uptk/7pRFBOKDOI5cWp7gxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HKfI614luaLHh0yMOU7rOilxY0eziem04js6ue9l1J2pQTqfGgxWnc93YdD5H5i6H k1s+sgfYzOXMc5d0YlWxo7a8yT6hsE+aVYwBOxCXA3uWDCxpE++OGIpnnJQLNok8tT y5sz7ZzygYgoK4P5QbTl8W8UC8uNOeGTCPJ5bJ/M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Aleksa Sarai , Christian Brauner Subject: [PATCH 6.4 127/165] open: make RESOLVE_CACHED correctly test for O_TMPFILE Date: Wed, 9 Aug 2023 12:40:58 +0200 Message-ID: <20230809103646.956840756@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230809103642.720851262@linuxfoundation.org> References: <20230809103642.720851262@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aleksa Sarai commit a0fc452a5d7fed986205539259df1d60546f536c upstream. O_TMPFILE is actually __O_TMPFILE|O_DIRECTORY. This means that the old fast-path check for RESOLVE_CACHED would reject all users passing O_DIRECTORY with -EAGAIN, when in fact the intended test was to check for __O_TMPFILE. Cc: stable@vger.kernel.org # v5.12+ Fixes: 99668f618062 ("fs: expose LOOKUP_CACHED through openat2() RESOLVE_CACHED") Signed-off-by: Aleksa Sarai Message-Id: <20230806-resolve_cached-o_tmpfile-v1-1-7ba16308465e@cyphar.com> Signed-off-by: Christian Brauner Signed-off-by: Greg Kroah-Hartman --- fs/open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/open.c +++ b/fs/open.c @@ -1271,7 +1271,7 @@ inline int build_open_flags(const struct lookup_flags |= LOOKUP_IN_ROOT; if (how->resolve & RESOLVE_CACHED) { /* Don't bother even trying for create/truncate/tmpfile open */ - if (flags & (O_TRUNC | O_CREAT | O_TMPFILE)) + if (flags & (O_TRUNC | O_CREAT | __O_TMPFILE)) return -EAGAIN; lookup_flags |= LOOKUP_CACHED; }