Skip to content

sockfs: the owner and the mode of the inode of a socket (LTP af_alg07) - #714

Merged
tamnd merged 1 commit into
mainfrom
alg-4
Nov 13, 2026
Merged

tamnd merged 1 commit into
mainfrom
alg-4

Conversation

@tamnd

@tamnd tamnd commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Part of #541 (the AF_ALG item). This is the fourth PR of the item, after #699, #703 and #709. LTP af_alg07 failed after #703, and this PR fixes it.

What this does

  • The file of a socket has the owner and the mode of its inode, as the inode of sockfs in Linux.
    • new_file in net/rk-net/src/lib.rs takes the owner. socket, socketpair, accept and the other callers give the file system user and group IDs of the caller, as sock_alloc of Linux. The mode is 0777.
    • fstat gives the owner, the group and the mode of the inode.
  • rk_net::SockInode is the inode of a socket file for a change of its attributes. It holds a weak reference, so it does not keep the socket open.
    • set_attr changes the mode, the owner and the group, as sockfs_setattr of Linux.
    • After the socket closes, a change of the owner gives ENOENT, as Linux after CVE-2019-8912. A change of the mode has no effect.
  • fchmod, fchown and fchownat or utimensat with AT_EMPTY_PATH on a socket go to set_attr_sock in core/rk-syscall/src/fs.rs. It does the checks of notify_change (setattr_prepare and the kill of the set-ID bits on a change of the owner) and then calls set_attr.
    • With AT_EMPTY_PATH, the path lookup of Linux holds the inode and not the file. So the file reference goes before the checks. If another thread closes the last descriptor in the meantime, the socket closes and the change of the owner gives ENOENT. LTP af_alg07 makes this race with dup2 and wants ENOENT or success, never a use after free.

Tests

  • cargo fmt --all --check, and cargo clippy --all-targets for rk-net, rk-syscall and xtask: no errors. The warnings are in files that this PR does not change.
  • cargo test for rk-net (130 tests), rk-syscall and xtask: ok, with a time limit of 900 s.
  • The new test socket_inode_attributes of net/rk-net/src/tests.rs: the owner and the mode of a new socket file, a change of the owner and the mode, and ENOENT for a change of the owner after the file goes.
  • LTP crypto on x86_64 (server1, load 0.2) and arm64 (server2, load 15 to 18), with a kernel that had the change of this PR on AF_ALG: the skcipher sockets #709:
    • af_alg01 and af_alg07 pass.
    • af_alg02 to af_alg06 and af_alg08 give TCONF, as on Linux 7.3 with the allow list of crypto.af_alg_restrict.
    • pcrypt_aead01, crypto_user01 and crypto_user02 give TCONF on arm64, because NETLINK_CRYPTO is not there. The x86_64 LTP build does not have them.

Load averages on server2 during the build and the tests: 14 to 22.

The full gate did not run.

@tamnd tamnd added kind/bug A crash, a hang or a wrong result. area/net Networking: sockets, TCP, netlink and netfilter. labels Nov 13, 2026
@tamnd
tamnd merged commit 6f2c40e into main Nov 13, 2026
6 of 7 checks passed
@tamnd
tamnd deleted the alg-4 branch November 13, 2026 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/net Networking: sockets, TCP, netlink and netfilter. kind/bug A crash, a hang or a wrong result.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant