From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 471B42E62D9 for ; Wed, 1 Apr 2026 14:09:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775052568; cv=none; b=FFUUydWW7TfAxHC9LrJkzmjk7YSTrWzq2G9uwNm5Y2vzxQOJWGF07EJWb0dQmhiOIBPdLn38Bzey7QgqpljFY2eYUX7II6s/Pf+DI6yzOlQTJKVmrdTrxHTeSKfKpvaW9rtk6R42UVf4CjJAVJU5ZBijX2CjhOO5m0pq7g/X2YY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775052568; c=relaxed/simple; bh=FkHhl5SAKIEruahir/S4Yn91EO6ZVJU7/+9TaXQ8gB0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r9okPoW5NBGNkrHK4ehfmouVA92FVrxOj56YFwS4vkCM2K2eM1qWouXaShHruhfZgm0HP0RIrmNY8XIdDF2mACKVJ14XOpdrd/WgprTxpwIuknKn4gf2bxhT6Seaf7W/3ZqbOo9E7J/0AioI+plI1W1ULoBFkPcd/uieDEvXDiE= 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.41 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-f41.google.com with SMTP id 5b1f17b1804b1-4852c9b4158so57016335e9.0 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=LpkCyIBFMrl4yZdXXRYwWt2UVc8CTCsxiSq7IZpfvKE//2d8y/msJb3THxTgwq5O/W hQBhQ36G3NxF+UCawCqiHMwQrt2pO1vZcja8oiGrVA4Pp4EKIrkJfd4UMs/Kjt+DyMGZ xCus29y3ENk+LumRJIWmjeoS1I0wz/9QJZziTBmFYga4nmyUuBUAPwqNIGUQJUCFt/bh audFYYvdwoOnV0FpJR/zfRltVnuC2uqU67wpTFT80JSCOONRna4hJ9idWwG7JSBfQagG NzGYbkIxVtUEwkeDAEBhpv0y/7/NAsp+8NodbcAEVW3ylx8aFQKqaucMwqi6u4XaepPR jgHQ== X-Forwarded-Encrypted: i=1; AJvYcCUBK6W0ikwMARmqCYsULLDx0GQPg2whVyCjmjxHyoMfPP++nmgt5XcrPq42seGZiH+/vCsNTq+kH37zuRc=@vger.kernel.org X-Gm-Message-State: AOJu0YxWTF6l02dWm8Umzo91/FTeS29aSQCjhzb0eLsbx26ZdXQkf+2G CgmEFWwh0sT/y+mUG/kSIM0oF7f4wQ864mWSfVVAd9fwZ5caQCniLmdA X-Gm-Gg: ATEYQzwUuyV634f3QEwiQY5ufz3MFyJaRDTX/Vw7C2XF+mv5koVeQLaiaNNgyoZvZH2 EE7yXZXjQtJmEdZFyGJxqJfp02OHpefbsSCYxdZGS8aRkMk1zl7J+r9KrPDwxcIJZnw8RMS192s hOvcCk+DDYknPwPFCqWWKA68/1B94Tdmm2lYO3KbnbJlkINovyAmkQuKxT7g93TWQDUjRCP/u4o M1gIWGFPHWgyY3o7HvsehlYD0G0s6X3RNq4EJPEHJOfLZBzQiwax/wj3+WzCuIGPvqCKNKlbfu4 lQM61DPc0aP2tRx0jxbJsLThaBPntdtuMgFEantX1oiSCrwUoI6FSgyPJHyraW3YPlxyATShxRl Zr4s0XxHb0p1VIjPsZVBsRCKXsF4tAxv9uVeDCtYeiSnZpY0uxt0d/0W00i/P9ISXQkzklj/CIA uYJKxNs7TS4LZATZzYcCgtsSNQWYt6prHjgBje6It7015oskyvAe8Ebfa6cJnB 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-kernel@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/ >