From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 4020B2DC32C for ; Wed, 1 Apr 2026 14:09:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775052569; cv=none; b=sXFrq7R7Ohhj0QLGiBMwaxdGAOoYGFQG1wL2hnL8h/z5DV4CnqOAaRYvHr9JNxvdLj5nsuJ06UuRKtfzww7gyET4U/AAda1aadl5bwVNvZ/iyIdCf7OybCwmpwCVfOYUfCmbbche5OEJbF2gNgxkbL1yH8ewwFnGs0BoQfsUfco= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775052569; c=relaxed/simple; bh=FkHhl5SAKIEruahir/S4Yn91EO6ZVJU7/+9TaXQ8gB0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L81XpDNrANYaC/2WSadkZPsN97gfIQK4YChZnGJnb8fvFn9P4S+LWn1zjoNrrOzD96JQQKwgIckm1X3itL562z3cnOsedEBYVDaLRRppCADXEz9HQ518ht4tE2HukD3ZN8aZpE26b7yretDwSOxfdxslaCumAmOnWehdhzqihkA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YH9UZTjy; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YH9UZTjy" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-48374014a77so83652275e9.3 for ; Wed, 01 Apr 2026 07:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775052566; x=1775657366; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=O7S8G0jPQziP2icNG+Xq9AlGcKIFYSGaYnHCga7XZDY=; b=YH9UZTjy3/pdQ79lXxzABHUThvXHPlEoBkr2uM26hOMLonb0pB4TOTJFXYkqTdqUL1 uAmYbJwr/TTHkIl4EGRqqZAFR86rl5d5WB8ao+h9PbLUHExLUo7WsR46VV//tkeQP04m De+Vaaz54awqHQj/7hixZSVaZACSjjJgwmLvTA45KKDMZmulYc+fN+5tiyTDQn8PNx3E KJoOk9Oeai6SM71kEMALniwZJUd5nZ7VUhv/m03Y1YYOJgOrvsic1hAN+Jaz7ipNlw3x O8J7QFCxHEBvhLzdGqOqtvmmwhJ3d3IRLanmIwT1v09/tTvzatB+tB6yAKELkUQm4l3f NbEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775052566; x=1775657366; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=O7S8G0jPQziP2icNG+Xq9AlGcKIFYSGaYnHCga7XZDY=; b=QtLpYsLxiFLaRSJ7J0G/p73n5qB4kBz2mSARDXEW7mkmUglytu4mhXiaLAXmipkxSm IxNr0bW3JdA3de8QqLOWfBkmb62yrXhpOIRtPCX1WivKAvUSpTrM6fNFDUkNK3QWUA7n gifeAB/e7Lqx1t6L1Kx7wAcrrB8tE3ksmZAOEPQ2U6/vphl2mzMefkjqli6Kh6XYsQ4y r51vG53kz5yIsM1riZu2nvKmMMCkejNa0buwgNvq/fVlMknAeeWt68BUIM5PtofOQ5Zk lF5WL0LnvKy3TX5NAc5ba8UKxzk5untvF6SgUFrBB5lrOYwiPTU8I+EEk3PGPVkJ4oMl +KoQ== X-Forwarded-Encrypted: i=1; AJvYcCU/Txn+kMBYxRCvipRfJwhhnPW3QxO73eB1KW+MuEE8QGjJHsr4u7vN8FSNfQ/jt5IHQE7th2sSvo8=@vger.kernel.org X-Gm-Message-State: AOJu0YxgB6GqlM81HTBl0z/K0U/q8A6MluWUwxk//t6lxJJmYnUM1yxu S83meEq9bouemwAC56Gy7oeb9ePJQ9VSCkokNfqOowY4zbMN3DrHxER7 X-Gm-Gg: ATEYQzw3hEqekaz//r58a68lgcZrvc/8ikefg3XhGvSrYy1Wqd3rYtNCZEtNd+6jfYh zSqdHOao2d5fYeMVenF7xAJqSSx4d2yP9ta3tXnov4l5ROjRd6bxjlPFGk3sHgSJJt2OCy3cxku oNpjQ/HQpCGHuKhi/n5hIGvczC/3rZDx38UTaQaEdgoC2DYxsJmoTXjbQqFM/LjbKrUtcb0SyII RM84TXQbGdUPZWkh7NJA14xikuwXrH+WoALrOBY0LfgVG0UYL7WVeXu0ZLe/Ok+9syjQO1Bdqzd rvG2qtsvqImA8olJzUn9sSxlXEcWWRIYUNwQTg588lyMCXPwMoudGCsDjQfih/i1dBecASSO39z VE+O1zUr4o7w1DohIrwFz8aMW8IQFgEDrXLRkoYIj1aBosIaNz7wCoXkc1gqovnofxcdxKfE9N0 OsKfZlVSk/QVKv/rtBC8U0E1OtQlSyspf3OjmQmUKht7pocLEWDeZaXCEd7ysf X-Received: by 2002:a05:600c:3e1b:b0:485:ae14:8173 with SMTP id 5b1f17b1804b1-4888355e47fmr62749425e9.1.1775052565221; Wed, 01 Apr 2026 07:09:25 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887c8b12aesm40093505e9.22.2026.04.01.07.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2026 07:09:24 -0700 (PDT) Date: Wed, 1 Apr 2026 15:09:22 +0100 From: David Laight To: "Arnd Bergmann" Cc: "Jori Koolstra" , "Andy Lutomirski" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , x86@kernel.org, "Alexander Viro" , "Christian Brauner" , "Jeff Layton" , "Chuck Lever" , shuah , "Greg Kroah-Hartman" , "H. Peter Anvin" , "Jan Kara" , "Alexander Aring" , "Peter Zijlstra" , "Oleg Nesterov" , "Andrey Albershteyn" , "Jiri Olsa" , "Mathieu Desnoyers" , Thomas =?UTF-8?B?V2Vpw59zY2h1aA==?= , "Namhyung Kim" , "Arnaldo Carvalho de Melo" , "Aleksa Sarai" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Linux-Arch , linux-kselftest@vger.kernel.org, cmirabil@redhat.com, "Masami Hiramatsu" Subject: Re: [RFC PATCH 1/2] vfs: syscalls: add mkdirat_fd() Message-ID: <20260401150922.0990d935@pumpkin> In-Reply-To: References: <20260331172011.3512876-1-jkoolstra@xs4all.nl> <20260331172011.3512876-2-jkoolstra@xs4all.nl> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 31 Mar 2026 21:13:34 +0200 "Arnd Bergmann" wrote: > On Tue, Mar 31, 2026, at 19:19, Jori Koolstra wrote: > > Currently there is no way to race-freely create and open a directory. > > For regular files we have open(O_CREAT) for creating a new file inode, > > and returning a pinning fd to it. The lack of such functionality for > > directories means that when populating a directory tree there's always > > a race involved: the inodes first need to be created, and then opened > > to adjust their permissions/ownership/labels/timestamps/acls/xattrs/..., > > but in the time window between the creation and the opening they might > > be replaced by something else. > > > > Addressing this race without proper APIs is possible (by immediately > > fstat()ing what was opened, to verify that it has the right inode type), > > but difficult to get right. Hence, mkdirat_fd() that creates a directory > > and returns an O_DIRECTORY fd is useful. > > > > This feature idea (and description) is taken from the UAPI group: > > https://github.com/uapi-group/kernel-features?tab=readme-ov-file#race-free-creation-and-opening-of-non-file-inodes > > > > Signed-off-by: Jori Koolstra > > I checked that the calling conventions are fine, i.e. this will work > as expected across all architectures. I assume you are also aware > that the non-RFC patch will need to add the syscall number to all > .tbl files. > > The hardest problem here does seem to be the naming of the > new syscall, and I'm sorry to not be able to offer any solution > either, just two observations: > > - mkdirat/mkdirat_fd sounds similar to the existing > quotactl/quotactl_fd pair, but quotactl_fd() takes a file > descriptor argument rather than returning it, which makes > this addition quite confusing. > > - the nicest interface IMO would have been a variation of > openat(dfd, filename, O_CREAT | O_DIRECTORY, mode) > but that is a minefield of incompatible implementations[1], > so we can't do that without changing the behavior for > existing callers that currently run into an error. Just require O_TMPFILE to be set as well :-) You know you'll never regret it one Apr-1 is over. Can something be done with the flags to openat2(). That might save allocating an extra system call. David > > Arnd > > [1] https://lwn.net/Articles/926782/ >