From patchwork Sat Aug 5 22:48:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksa Sarai X-Patchwork-Id: 131558 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp737759vqr; Sat, 5 Aug 2023 20:24:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7mlIYWftQrN3j7fAMYd/fuMybCB9uqkJMcocEcNhrJv2I83LNpnqCkag3jwbOFCEqroYK X-Received: by 2002:a17:903:22d1:b0:1b6:797d:33fb with SMTP id y17-20020a17090322d100b001b6797d33fbmr6716398plg.64.1691292262230; Sat, 05 Aug 2023 20:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691292262; cv=none; d=google.com; s=arc-20160816; b=T/3dxgvM76EJFjXi3eJnyhjEjEFYtlhioCEfpG/kFpTF8dSI6WaGE/saG5pU+Sdppe njv2jcE/xsJioW1reqwO8IaFi+toupiXLXmxfwTNTIyCp0qOxb3eCN3W4jHhp+R6kbqm Sq7DnsgJMip8BcWcrl6Wv8zhYQ0z85xXbVoW+j8K2vPoqCDvpRIl6wHVEoHyVSRn6OJq 9dnt4RdIkcod5z78TXikw/0ZydMDE8NbPvE5Jhl2wVze6bb8gGRcQbv7BP9WkoYu3DpQ Qfd/gId+aTDp/wticcndTV0Mr93qTu+vo+CvGna4T3w3IDT1+eqE6W31Up9g2MeATRSJ QgwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=IH0KsC6OjiP5vq0A6Tdbg/v/G6fKP45ZcMl0AmDcmOA=; fh=tyuo81uf8EBo4PqTEAeD2fxcZ4owKgaqFeuM7cWaFg4=; b=gUDm2Gv5OigmDI8Qtbdk4IlXh8zGUNuNDj/eBCTAkv+2EUQLr5vm8DXwL2HOiF+8up nhGtwlrqrNOt12SJ+zrsUcD8pX/Mnx9YjQvFG1Q8c5YgiMhK2GiM1dfunDDBvqkAazUN rEtRzLceSpUr0nndjtAnzZbRn374If+mS2yoCIQp+lx1Z963xT7JdVpswc+yOY7oLQd4 wtjdLsEKzLgcR11HXXe+nmsgMQpb6jlAZsiQEKKBmBGvi5d4aZGb5HrZOFs2qzHcOTuD QFwiYnXNX2SQisXMGxOlU9cQocbhsYggmkNMTb1z2DhWl7KTS+46Qz+Mgor6P3x15IUN Gh2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cyphar.com header.s=MBO0001 header.b=OCzkM9IU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cyphar.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 35-20020a631363000000b00563e6d70f7esi3731375pgt.443.2023.08.05.20.24.08; Sat, 05 Aug 2023 20:24:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cyphar.com header.s=MBO0001 header.b=OCzkM9IU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cyphar.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230052AbjHEWs6 (ORCPT + 99 others); Sat, 5 Aug 2023 18:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230012AbjHEWsz (ORCPT ); Sat, 5 Aug 2023 18:48:55 -0400 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C09EC19B5; Sat, 5 Aug 2023 15:48:54 -0700 (PDT) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4RJHnH2g5Vz9scK; Sun, 6 Aug 2023 00:48:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cyphar.com; s=MBO0001; t=1691275731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IH0KsC6OjiP5vq0A6Tdbg/v/G6fKP45ZcMl0AmDcmOA=; b=OCzkM9IUSZsSp6kO/WcZlLSUvAUOX3yTN30CSP6tAsr24VByzDMWKJUa3vvGeTo/Qlg8h1 LcJpsf7EuGYPDVIDdHiEJFaaFVAe43P/sw/oUiQuEU+iGUeHfyYbpnGkgGfWeda8PPeV9B 3D7D450vtUNt713nJI0zSW0vsZJwTUtlCXKOJKnWBFjRIqy/wLJqioHO3CIlHVFhuua73a LciCHOkNg6AE+fGFqtGhqkec5fjfJx/JeBS5T3pdN0gV8I6PrcBTAXFuEh/VuK/2i9ETcB Q1hTsGr1udZeiE/NLAew1Hw3V29+EcIAId20Hsz85CColTmfdNQ1gAd7MUbUSw== From: Aleksa Sarai Date: Sun, 06 Aug 2023 08:48:08 +1000 Subject: [PATCH v2 1/2] open: make RESOLVE_CACHED correctly test for O_TMPFILE MIME-Version: 1.0 Message-Id: <20230806-resolve_cached-o_tmpfile-v2-1-058bff24fb16@cyphar.com> References: <20230806-resolve_cached-o_tmpfile-v2-0-058bff24fb16@cyphar.com> In-Reply-To: <20230806-resolve_cached-o_tmpfile-v2-0-058bff24fb16@cyphar.com> To: Alexander Viro , Christian Brauner , Jens Axboe , Pavel Begunkov Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Aleksa Sarai , stable@vger.kernel.org X-Developer-Signature: v=1; a=openpgp-sha256; l=1006; i=cyphar@cyphar.com; h=from:subject:message-id; bh=OiJ0X41F7OTqXAqgldma319Yo5G2MNu2En+iv/Foe7M=; b=owGbwMvMwCWmMf3Xpe0vXfIZT6slMaScu3jiTIpvTXiAgVgoU8rPSOv3ZvyVqebmq5xCdxzY6 6R58fP8jlIWBjEuBlkxRZZtfp6hm+YvvpL8aSUbzBxWJpAhDFycAjCRNU0Mf6XN2Thcf/bw/zds yXj1a/+KVZZfHvjZ7tHZenTK1rWlZ2IY/leeV+p6aXDv7xuzwr9HV0xbv4bnjMa0nXUlfCZvr0t eDmYGAA== X-Developer-Key: i=cyphar@cyphar.com; a=openpgp; fpr=C9C370B246B09F6DBCFC744C34401015D1D2D386 X-Rspamd-Queue-Id: 4RJHnH2g5Vz9scK X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773443577223278033 X-GMAIL-MSGID: 1773448475235209142 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 --- fs/open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/open.c b/fs/open.c index b8883ec286f5..2634047c9e9f 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1337,7 +1337,7 @@ inline int build_open_flags(const struct open_how *how, struct open_flags *op) 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; }