Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadkeys triggers all mounts in the cwd #101

Closed
poettering opened this issue Aug 8, 2023 · 6 comments
Closed

loadkeys triggers all mounts in the cwd #101

poettering opened this issue Aug 8, 2023 · 6 comments
Labels

Comments

@poettering
Copy link

It appears that loadskeys triggers all inodes in the current cwd. It really shouldn#t do that, as this might lead to deadlocks during boot, because the system might not be ready to trigger an autofs this early.

it's also a security hole of sorts (i.e. compare with the fact that on linux execvp() does not bother with the cwd either by default, and people generally frown upon it).

I think loadkeys should never look in the cwd for keymaps. If you want to keep it, at least don#t trigger the inodes anymore. i.e. use AT_NO_AUTOMOUNT

@poettering
Copy link
Author

poettering commented Aug 8, 2023

See systemd/systemd#28677 for details where people ran into this.

@legionus
Copy link
Owner

legionus commented Aug 8, 2023

This is a very old behavior that appeared before I joined this project:

char *dirpath[] = { "", DATADIR "/" KEYMAPDIR "/**", KERNDIR "/", 0 };

I totally agree that this is extremely counter-intuitive behavior. I'm going to remove the current directory and search list.

@legionus legionus added the bug label Aug 8, 2023
@poettering
Copy link
Author

excellent! thanks!

legionus added a commit that referenced this issue Aug 9, 2023
Now loadkeys first tries to look for a keymap in the current directory.
This behavior is not intuitive and leads to problems. It appears that
loadskeys triggers all inodes in the current cwd. This might lead to
deadlocks during boot, because the system might not be ready to trigger
an autofs this early.

To solve this I exclude the current directory from the keymaps search
paths.

We still have ways to specify a different directory to search for
keymaps than the one specified on build time. The user can set the
LOADKEYS_KEYMAP_PATH environment variable to specify a different search
path.

Link: #101
Signed-off-by: Alexey Gladkov <[email protected]>
@legionus
Copy link
Owner

Should be fixed in kbd-2.6.2.

@poettering
Copy link
Author

Excellent! thanks!

@DaanDeMeyer
Copy link
Contributor

@legionus It seems like loadkeys still probes all directories in the cwd for some reason. This is from loadkeys 2.6.3 on Arch Linux:

[pid   382] newfstatat(AT_FDCWD, "./abc", {st_mode=S_IFREG|0644, st_size=119468, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./bin", {st_mode=S_IFDIR|0755, st_size=28672, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./boot", {st_mode=S_IFDIR|0755, st_size=0, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./dev", {st_mode=S_IFDIR|0755, st_size=3360, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./efi", {st_mode=S_IFDIR|0500, st_size=4096, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./etc", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./failed-services", {st_mode=S_IFREG|0644, st_size=0, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./home", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./init", {st_mode=S_IFREG|0755, st_size=100464, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./lib", {st_mode=S_IFDIR|0755, st_size=24576, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./lib64", {st_mode=S_IFDIR|0755, st_size=24576, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./lost+found", {st_mode=S_IFDIR|0700, st_size=16384, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./mnt", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./opt", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./proc", {st_mode=S_IFDIR|0555, st_size=0, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./root", {st_mode=S_IFDIR|0750, st_size=4096, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./run", {st_mode=S_IFDIR|0755, st_size=380, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./sbin", {st_mode=S_IFDIR|0755, st_size=28672, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./srv", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./sys", {st_mode=S_IFDIR|0555, st_size=0, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=160, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
[pid   382] newfstatat(AT_FDCWD, "./var", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0

DaanDeMeyer added a commit to DaanDeMeyer/kbd that referenced this issue Dec 9, 2023
Fixes the same issue as a770f39
but for include files.

Link: legionus#101
DaanDeMeyer added a commit to DaanDeMeyer/kbd that referenced this issue Dec 9, 2023
Fixes the same issue as a770f39
but for include files.

Link: legionus#101
Signed-off-by: Daan De Meyer <[email protected]>
legionus added a commit that referenced this issue Dec 10, 2023
Another fix that corrects the search for keymaps in the current
directory.

Link: #101
Link: #105
Signed-off-by: Alexey Gladkov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants