diff options
| author | Breno Leitao <leitao@debian.org> | 2026-05-07 03:57:54 -0700 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-05-10 10:11:08 -0700 |
| commit | c8c2bd2bcf67c43f0b2ec8250c258cd8c486b1a2 (patch) | |
| tree | 180ba1d935d489c772424e2a485ed5753f437169 /rust/kernel/alloc/kvec/errors.rs | |
| parent | 8aaaa32a7965d4aac1ec0408f1d2426619759edb (diff) | |
selftests: net: getsockopt_iter: cleanup
Apply two cleanups suggested by Stanislav and bobby on the original
selftest series:
- Reorder local variable declarations into reverse christmas-tree
order (longest line first). Because that ordering puts socklen_t
optlen before the variable whose size it stores, the
"optlen = sizeof(...)" initializer is moved out of the declaration
to a plain assignment in the test body, as Stanislav suggested.
- Add ASSERT_EQ(optlen, ...) on every error path so the value the
kernel writes back to the userspace optlen is pinned down even
when the syscall returns -1. With do_sock_getsockopt() now writing
opt->optlen back to userspace unconditionally, asserting that the
netlink/vsock error paths leave the original input length untouched
guards against future regressions.
Bobby Eshleman pointed out that
SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW/OLD return a sock_timeval-shaped
payload (16 bytes on 64-bit), which is wider than the u64 case
already covered. Add four tests that exercise this path:
- connect_timeout_new_exact exact-size buffer
- connect_timeout_new_oversize_clamped oversize buffer, clamped
- connect_timeout_new_undersize undersize -> -EINVAL, optlen
untouched
- connect_timeout_old_exact exact-size buffer for OLD optname
Suggested-by: Stanislav Fomichev <sdf@fomichev.me>
Suggested-by: Bobby Eshleman <bobbyeshleman@meta.com>
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260507-getsock_two-v2-5-5873111d9c12@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'rust/kernel/alloc/kvec/errors.rs')
0 files changed, 0 insertions, 0 deletions
