Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5580795rwb; Mon, 14 Nov 2022 06:44:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ralTmqsMf/IfLrL7ZdUshF0rptPdCBdRn4PfLrlgP0HAbs/pVPn4336LNB4VhENhz1iED X-Received: by 2002:a17:907:cc83:b0:7a9:8d8e:c3df with SMTP id up3-20020a170907cc8300b007a98d8ec3dfmr10413498ejc.519.1668437086606; Mon, 14 Nov 2022 06:44:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668437086; cv=none; d=google.com; s=arc-20160816; b=yVgJeZ4JgQjyaT5ZUI9eh0xgUApsKuzYmjxsqrSh8TUKpC6thnA2Ke8su9hJnhOOXA xFp2znPQ9sFM8FTZVzZe1FfBlDnWZ/MECP8FATUkIrz5Crn0blt1l27/y2gFIrlaxCq/ DJ3w5irGgG9OlUIlu7PUpePIxg/9aEFcdKJbyTfhwVnxbw5J7qB3Agmx5QeBwGbN7LRB lbgwI7bbYL0ZEK25OfZt25iCpSyEyJR6yyCsXtwAErYT86ZSuNeBmPj3MsinqQfOTenn MVuZoPUX7enGMSU72Oym9EUMc0yrtGdm3Me/uhsitx3YnoFgtLC12JH6R+FQ+64MdXvK JroQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tiAlNaz5lTJwnYCelBGX08b8+sUElNWbgFxFjc6KPlw=; b=oNtIRA1YqyfddeJqq3KFQkxErl6repAWg6q37PMvnUUdzmmhOM3DmlO7tiZ6R4VII4 4TSz2jgguVMea+wN8aiSZ1QeDNs5P/3UIHMgH+OJa52uxnc1vnbaxQtCASi9+6cjbOQw ENlrXwsjKq7esMNXmP+ggnr98FdsIyEQ/wdUcqVxe5lBLwIxTSwP9dtUUsdiYvp/f6Ym gTCZsYdvetNKA9gFhZ8ZCfSPhK6Y50OKuf8XuYDaufYTySbRiyC2+lyYBo1e9KeG+mpf RxmZZt86o12XyzE6CbbYGsmxOVTnAV6ZxRa4oFOwCqE17/N2VDaNMgKZ4TdlwF3GQWdM JwHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x8KFv1A5; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l18-20020a056402029200b004614db9083csi7823815edv.313.2022.11.14.06.44.25; Mon, 14 Nov 2022 06:44:46 -0800 (PST) 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=@linaro.org header.s=google header.b=x8KFv1A5; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236957AbiKNOik (ORCPT + 87 others); Mon, 14 Nov 2022 09:38:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236608AbiKNOi3 (ORCPT ); Mon, 14 Nov 2022 09:38:29 -0500 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D24F95F4E for ; Mon, 14 Nov 2022 06:38:27 -0800 (PST) Received: by mail-ot1-x32b.google.com with SMTP id 94-20020a9d0067000000b0066c8d13a33dso6722116ota.12 for ; Mon, 14 Nov 2022 06:38:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=tiAlNaz5lTJwnYCelBGX08b8+sUElNWbgFxFjc6KPlw=; b=x8KFv1A5lU7NRkxneKmqgLZcmC4tP4chHibNMKrrnlaINMGlFlP/5dK/1GsN9zT010 +RKef96BhSFt30UprdR+ytvPxv1ACCGP5mOFANPLRtpJQNq8W1QANv/65bJd9PQqfqOi 3yjODOq8gB7np91YFIga17VbO299DdJ0Yyl5+Ij3ALoSNhrANJvaZ4isLw7VHy8JgYeA sc890Ejp0Krg6+mNMddUV+BBoQZUXojDSvJBEeNry+sE/L68nIpxsXcMnUiaHu9DQc3R IxSn3VDjToVI/ep2OeBOIKrHX4b7veXiOczxA3pK9cZukTrRJN3gY2sIByHtHn715nOp ydxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tiAlNaz5lTJwnYCelBGX08b8+sUElNWbgFxFjc6KPlw=; b=Jgi2IJMAj/L4BD+eatdZP70/8XMdalU6V+5agOPxoo4+wpTnxrJ3JzHFuo+JJdf8Es HjptyPsK0GKRIkFQEJ+gX79bH6E3sVZKs7vv/WDzwf+nH1sV9kAIm0Rch4BleYM4HxEr IVItgFqKPzfPwXKdOEM4v2ssFHczdzRWht19AOjwiNHVZckunzLQhHqJurC4ff23JnEx xwdZhgUFqNOyLjsP/lY1Xn+snZQpUYOYfFh3+QMmzuhoNRevLeA+UFIzIc+KCLs2wUv4 fQVhUoWcdKKyshGHRxJxWdJ8L7Kp81x3L00qDcN3Fm7O37V4tdh/W3dYULoX+di+MvUE ISiQ== X-Gm-Message-State: ANoB5pm7EOLMHViX1ZbToAIbuy1Fi0F8Wev7Ry9uCJld1248zCxwQiqk 8s/WFg93wG0E23gZuXkqYCLz17lrmoTapx/XZRzycg== X-Received: by 2002:a05:6830:6486:b0:66d:65a5:b0b3 with SMTP id ck6-20020a056830648600b0066d65a5b0b3mr5854433otb.170.1668436707187; Mon, 14 Nov 2022 06:38:27 -0800 (PST) MIME-Version: 1.0 References: <20221103170210.464155-1-peter.griffin@linaro.org> In-Reply-To: From: Peter Griffin Date: Mon, 14 Nov 2022 14:38:15 +0000 Message-ID: Subject: Re: [PATCH] vfs: vfs_tmpfile: ensure O_EXCL flag is enforced To: Alexander Viro Cc: Miklos Szeredi , stable@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Will McVicker , Peter Griffin Content-Type: text/plain; charset="UTF-8" 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_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Hi Alexander, On Thu, 3 Nov 2022 at 19:12, Miklos Szeredi wrote: > > On Thu, 3 Nov 2022 at 18:04, Peter Griffin wrote: > > > > If O_EXCL is *not* specified, then linkat() can be > > used to link the temporary file into the filesystem. > > If O_EXCL is specified then linkat() should fail (-1). > > > > After commit 863f144f12ad ("vfs: open inside ->tmpfile()") > > the O_EXCL flag is no longer honored by the vfs layer for > > tmpfile, which means the file can be linked even if O_EXCL > > flag is specified, which is a change in behaviour for > > userspace! > > > > The open flags was previously passed as a parameter, so it > > was uneffected by the changes to file->f_flags caused by > > finish_open(). This patch fixes the issue by storing > > file->f_flags in a local variable so the O_EXCL test > > logic is restored. > > > > This regression was detected by Android CTS Bionic fcntl() > > tests running on android-mainline [1]. > > > > [1] https://android.googlesource.com/platform/bionic/+/ > > refs/heads/master/tests/fcntl_test.cpp#352 > > Looks good. > > Acked-by: Miklos Szeredi As this patch now has an Acked-by the original author of the commit that reworked the tmpfile vfs logic and introduced the regression. Can you pick up this commit and send it onto Linus for inclusion into the next v6.1-rc release? Note, it fixes a regression for userspace introduced in this merge window so I was hoping to get the fix into the next -rc so that the v6.1 release does not contain this bug. Many thanks, Peter