Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp53697lqn; Thu, 11 Apr 2024 13:37:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQl49u1W/WzjGubXkDTasY/ses8iKD2gHNUDV5WcGY2PJ7aix+G+JSv+1+X00haSqR91H+i09nxD1IBrDvPfCPHxoIVSk16736nQWtUw== X-Google-Smtp-Source: AGHT+IFwxW4Li6oIT8zQArzaPe40kBgYVO3uRDD9BJosq3iWM+GN7tbEIctMf/57m1Xyz5jD9izy X-Received: by 2002:a17:90a:fb51:b0:2a4:acac:e4ac with SMTP id iq17-20020a17090afb5100b002a4acace4acmr4553252pjb.1.1712867831675; Thu, 11 Apr 2024 13:37:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712867831; cv=pass; d=google.com; s=arc-20160816; b=m46aNQj53SZGvnPKk0VF+qjJJNBMsJbFO3q0bPWtlKS/KaGpnOoTM6QZfBAe6kazhM lIfp+5XP4EvHwR910AIwEnOUYEnBLMYt66rKXkfNxWODpjjLwXQ84NDYsCj8Zh/4xF/M iPLmHACHz2BFq7Y8PMcHCpgOmOMSwFVFd/VWId8tSxB+/TN7tn3XUuoc2GxAWhLwtSnf rojWCPVYLtyeo8JSMyYVdo8ysl9NCy2ZVRbnTh7wGjkbzTlv+TVJwol940rPbQ0bDuKW XqMD6uzth/MBbtHrO+dCeyZIm7RLdzr6RgJUkmBdOIzFCPQmRFt3afyWd83KzfGuQdNl 5KzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=u06VN/tWbKJg/XvyqgCGuqCQEW3Uw0o35DW++ROLCwY=; fh=RNUSKdylbYJzADGU5BfgW+fIlrLE404lTNHjJH+AEQ8=; b=kdi8IPZySpxzc/Gzd7O6DHDerY8olX+gvf0FnjZjBUnBvuQxfdXsnWcmIO7RF+V+hP qX9oaR+vuTyOF+vWNG98ceLcEPa+xc/iRJTmy5lALHVFPYpJ4auxrzPf0SIIMGqZumYP jbVV5gj5eepUyDDDFqDsjV8Kuv8JGgHZTNtxQMsUf+deBL8CsAZ6qWuzpb+mPsC9pHcA LlY0tMw11AvhH8RbSRaVSc1Td1d6Ng6fHuw6jQoelv6IpdZz71Crbyq8HwVc3PvXbEXF u2/PIsN3zLigkjRrqfUBtz8/Cti+07GreZOJUL9atHnFTotCirelDma5tCeHSHT3WdYA g0/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=hHRm1QLg; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-141566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141566-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id gz21-20020a17090b0ed500b002a279d17e99si1973494pjb.161.2024.04.11.13.37.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 13:37:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=hHRm1QLg; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-141566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141566-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 743FEB21858 for ; Thu, 11 Apr 2024 20:22:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2947018037; Thu, 11 Apr 2024 20:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="hHRm1QLg" Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C5CC14F65 for ; Thu, 11 Apr 2024 20:22:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712866968; cv=none; b=M9C8McIwUZ23CwG2ag++IrXWecNPeG/EC2eHwwYfeiSUm2y2Lcv2wPjeGcmAR6N3gNL/mzUrw5cgkO4r81Zq2P1tpqicOdNcM3YxqDJ+O0swYoCRXgppIuC1gWe9eS26mEVcOQzNJk0+U9OcEO8xQp8e3QcaVK74/NH8XdPhDl4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712866968; c=relaxed/simple; bh=dkOu2O8WzCBJ47ChmxIx9bdrhdZhytLJzKX9YJkD1KU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=AvCNPbPFAtnQE4J9uwzRZ0Ww8E6v22M20D7a6yVQ5ju5LuWHo1krc227vFjVklUIyyTQtazkngvC4MKxy9G/VFQOQLyeEWXxuIgSTHyBv89kPhh7s/BLOwreO7g51Nv/7PsZ+tEF0FaRWbNkyDs5I/2uk2RT97UCbd85DGTAjqY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=hHRm1QLg; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2d717603aa5so2075091fa.0 for ; Thu, 11 Apr 2024 13:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1712866964; x=1713471764; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=u06VN/tWbKJg/XvyqgCGuqCQEW3Uw0o35DW++ROLCwY=; b=hHRm1QLgJYhN5hqPoU6wcr3zOPSMzRUcl2BFMYTFUku4q0HMJUICywNWZ5n4/FWvft MuoMG25eRpRHlYgFelYMvCkqYsg2aeU0eKhGtY0bwFzOEK+grEL5IZEjSDBALoYqviEC wyHCqwJTBlT93zw3/edJubsNxde6amd9r/B4A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712866964; x=1713471764; 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=u06VN/tWbKJg/XvyqgCGuqCQEW3Uw0o35DW++ROLCwY=; b=hW0+GpmqruqLw564nIC8BoIpr1bZQOlGkwycusGP6LkELsj6vd1gl9/zzXUEZv+Vpa otgVBRoaSGFX44DsZzhEx72iGpffqEZhKUE0k6OWHwlZc8YUN0QJx7z7Y+nrmjXixYGO NtOJelJ6fomP+DjUszhiaSE/18zj2CZNFdN1xcir7HYfQD/pVNONWjUrHCrSs/UvrYVS J+79RilPMS9h2UOkY6jkxfizTvCqon2E9aJ+xXTwYGe0wfztvrLC88cI2pOadytb4qtE 5wVjpoJzTUWkfDZ0cUhJPH7JydEipC7Rv41avyLJP2J1dGLrHyOt6UxdMEfpmZCTqD4E hVIw== X-Forwarded-Encrypted: i=1; AJvYcCV5DVfiZQGuB1hiKn8Uf81RAMMHIXr66fAw4bg2dfVbawg/PfR9cDRg3hYp/BhhLCFqUigXIcAOuNHdssOISlxx5c0CcE6lP3HIjXln X-Gm-Message-State: AOJu0YwVsTwYYvs89JlvXuhPpL4lXe62ddpxUALqHlJ4iPx0N/ReVcwB VdxRj8mvalEiCvoPBaxuKDBj6zDuc0c4uB5BZsG4yvOJr/cM3ls6G3Wieuqsyy35zarPTuL2sWC n3dlXoQ== X-Received: by 2002:a05:6512:158b:b0:516:c763:b4f5 with SMTP id bp11-20020a056512158b00b00516c763b4f5mr468430lfb.3.1712866964537; Thu, 11 Apr 2024 13:22:44 -0700 (PDT) Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com. [209.85.218.42]) by smtp.gmail.com with ESMTPSA id g19-20020a1709063b1300b00a519e8c27d2sm1048688ejf.208.2024.04.11.13.22.43 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Apr 2024 13:22:43 -0700 (PDT) Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a51b008b3aeso21394366b.3 for ; Thu, 11 Apr 2024 13:22:43 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWsxfyN0ZDc3NVIEKk2daOn8Eo7kmjh4G5DdwwP2es+t+87KbghXoilB9BcfepjNgjaCofkRkoXNWluSpLzLHobI6IY17FgeUv/M5LB X-Received: by 2002:a17:907:9725:b0:a51:d1f6:3943 with SMTP id jg37-20020a170907972500b00a51d1f63943mr537096ejc.56.1712866963123; Thu, 11 Apr 2024 13:22:43 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240411001012.12513-1-torvalds@linux-foundation.org> <20240411-alben-kocht-219170e9dc99@brauner> In-Reply-To: From: Linus Torvalds Date: Thu, 11 Apr 2024 13:22:26 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] vfs: relax linkat() AT_EMPTY_PATH - aka flink() - requirements To: Charles Mirabile Cc: Christian Brauner , Alexander Viro , Jan Kara , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Lutomirski , Peter Anvin Content-Type: text/plain; charset="UTF-8" On Thu, 11 Apr 2024 at 13:08, Charles Mirabile wrote: > > The problem with this is that another process might be able to access > the file during via that name during the brief period before it is > unlinked. If I am not using NFS, I am always going to prefer using > O_TMPFILE. I would rather be able to do that without restriction even > if it isn't the most robust solution by your definition. Oh, absolutely. I think the right pattern is basically some variation of fd = open(filename, O_TMPFILE | O_WRONLY, 0600); if (fd < 0) { char template{...] = ".tmpfileXXXXXX"; fd = mkstmp(template); unlink(template); } .. now act on fd to initialize it .. linkat(fd, "", AT_FDCWD, "finalname", AT_EMPTY_PATH); which should work reasonably well in various environments. Clearly O_TMPFILE is the superior option when it exists. I'm just saying that anything that *relies* on it existing is dubious. Linus