Skip to content

Commit 25b052d

Browse files
committed
Deny libc select syscalls in vm and stdlib clippy
Block libc poll/select/kqueue/epoll entry points and non-reexported ABI types. host_env keeps empty lists. Assisted-by: Grok:grok-4.6
1 parent 00c2db7 commit 25b052d

5 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎crates/host_env/clippy.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
disallowed-methods = []
2+
disallowed-types = []

‎crates/stdlib/clippy.toml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,22 @@ disallowed-methods = [
2929
{ path = "std::net::TcpStream::connect", reason = "use rustpython_host_env for host network access" },
3030
{ path = "std::net::TcpListener::bind", reason = "use rustpython_host_env for host network access" },
3131
{ path = "std::net::UdpSocket::bind", reason = "use rustpython_host_env for host network access" },
32+
{ path = "libc::select", reason = "use rustpython_host_env::select", allow-invalid = true },
33+
{ path = "libc::pselect", reason = "use rustpython_host_env::select", allow-invalid = true },
34+
{ path = "libc::poll", reason = "use rustpython_host_env::select", allow-invalid = true },
35+
{ path = "libc::ppoll", reason = "use rustpython_host_env::select", allow-invalid = true },
36+
{ path = "libc::kqueue", reason = "use rustpython_host_env::select", allow-invalid = true },
37+
{ path = "libc::kevent", reason = "use rustpython_host_env::select", allow-invalid = true },
38+
{ path = "libc::kevent64", reason = "use rustpython_host_env::select", allow-invalid = true },
39+
{ path = "libc::epoll_create", reason = "use rustpython_host_env::select", allow-invalid = true },
40+
{ path = "libc::epoll_create1", reason = "use rustpython_host_env::select", allow-invalid = true },
41+
{ path = "libc::epoll_ctl", reason = "use rustpython_host_env::select", allow-invalid = true },
42+
{ path = "libc::epoll_wait", reason = "use rustpython_host_env::select", allow-invalid = true },
43+
{ path = "libc::epoll_pwait", reason = "use rustpython_host_env::select", allow-invalid = true },
44+
]
45+
46+
disallowed-types = [
47+
{ path = "libc::fd_set", reason = "use rustpython_host_env::select::FdSet", allow-invalid = true },
48+
{ path = "libc::kevent", reason = "use rustpython_host_env::select::kqueue::Event", allow-invalid = true },
49+
{ path = "libc::epoll_event", reason = "use rustpython_host_env::select::epoll", allow-invalid = true },
3250
]

‎crates/stdlib/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// to allow `mod foo {}` in foo.rs; clippy thinks this is a mistake/misunderstanding of
22
// how `mod` works, but we want this sometimes for pymodule declarations
3-
#![deny(clippy::disallowed_methods)]
3+
#![deny(clippy::disallowed_methods, clippy::disallowed_types)]
44
#![allow(clippy::module_inception)]
55

66
#[macro_use]

‎crates/vm/clippy.toml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,22 @@ disallowed-methods = [
2929
{ path = "std::net::TcpStream::connect", reason = "use rustpython_host_env for host network access" },
3030
{ path = "std::net::TcpListener::bind", reason = "use rustpython_host_env for host network access" },
3131
{ path = "std::net::UdpSocket::bind", reason = "use rustpython_host_env for host network access" },
32+
{ path = "libc::select", reason = "use rustpython_host_env::select", allow-invalid = true },
33+
{ path = "libc::pselect", reason = "use rustpython_host_env::select", allow-invalid = true },
34+
{ path = "libc::poll", reason = "use rustpython_host_env::select", allow-invalid = true },
35+
{ path = "libc::ppoll", reason = "use rustpython_host_env::select", allow-invalid = true },
36+
{ path = "libc::kqueue", reason = "use rustpython_host_env::select", allow-invalid = true },
37+
{ path = "libc::kevent", reason = "use rustpython_host_env::select", allow-invalid = true },
38+
{ path = "libc::kevent64", reason = "use rustpython_host_env::select", allow-invalid = true },
39+
{ path = "libc::epoll_create", reason = "use rustpython_host_env::select", allow-invalid = true },
40+
{ path = "libc::epoll_create1", reason = "use rustpython_host_env::select", allow-invalid = true },
41+
{ path = "libc::epoll_ctl", reason = "use rustpython_host_env::select", allow-invalid = true },
42+
{ path = "libc::epoll_wait", reason = "use rustpython_host_env::select", allow-invalid = true },
43+
{ path = "libc::epoll_pwait", reason = "use rustpython_host_env::select", allow-invalid = true },
44+
]
45+
46+
disallowed-types = [
47+
{ path = "libc::fd_set", reason = "use rustpython_host_env::select::FdSet", allow-invalid = true },
48+
{ path = "libc::kevent", reason = "use rustpython_host_env::select::kqueue::Event", allow-invalid = true },
49+
{ path = "libc::epoll_event", reason = "use rustpython_host_env::select::epoll", allow-invalid = true },
3250
]

‎crates/vm/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//!
77
//! Some stdlib modules are implemented here, but most of them are in the `rustpython-stdlib` module. The
88
9-
#![deny(clippy::disallowed_methods)]
9+
#![deny(clippy::disallowed_methods, clippy::disallowed_types)]
1010
#![allow(
1111
clippy::module_inception,
1212
reason = "

0 commit comments

Comments
 (0)