On 2025-08-21, Askar Safin <safinaskar@xxxxxxxxxxxx> wrote: > There is a convention: you can pass invalid fd (such as -1) as dfd to *at-syscalls to enforce that the path is absolute. > This is documented. "man openat" says: "Specifying an invalid file descriptor number in dirfd can be used as a means to ensure that pathname is absolute". > But fsconfig with FSCONFIG_SET_PATH breaks this convention due to this line: https://elixir.bootlin.com/linux/v6.16/source/fs/fsopen.c#L377 . > I think this is a bug, and it should be fixed in kernel. Also, it is possible there are a lot of similarly buggy syscalls. All of them should be fixed, > and moreover a warning should be added to https://docs.kernel.org/process/adding-syscalls.html . And then new fsconfig behavior should be documented. > (Of course, I'm not saying that *you* should do all these. I'm just saying that this bug exists.) (I tested this.) Indeed, good catch! I think we discussed this before -- FSCONFIG_SET_PATH actually doesn't work with any parameters today so it's not very surprising nobody has noticed this until now. I'll include it in the set of fixes I have for fscontext. (FWIW, the convention I see more commonly is -EBADF but that's just a stylistic I suppose.) -- Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH https://www.cyphar.com/
Attachment:
signature.asc
Description: PGP signature