Cryptographically verifiable, distributed dependency reviews
reviewer: phgsng
$ cargo crev repo fetch url https://gitlab.com/phgsng/crev-proofs
$ cargo crev id trust pt_he2sLPg2w2u4YN7lj-6Gvu25R8aN6ZCcuQFzxC1g
repo: https://gitlab.com/phgsng/crev-proofs
Please, use mobile in landscape.
unsafe
limited to interaction with the Netlink socket.
unsafe
All uses of unsafe
are warranted and blocks span the
minimum necessary amount of code.
unsafe
blocks wrap syscalls on the socket descriptor
(fcntl
, socket
, setsockopt
, getsockopt
,send
, recv
, close
). Arguments in general don’t
depend on dynamically sized objects, and where they do, it is
safe buffer types whose lengths are handled correctly.
line 65: socket()
, args: only integer values, return
ok.
line 82: fcntl()
(two calls), args: integer values,
return ok.
line 96: fcntl()
(two calls), args: integer values,
return ok.
line 110: fcntl()
, args: integer values, return ok.
line 121: mem::zeroed()
, ok because a sockaddr_nl
can be safely zero initialized.
line 125: bind()
, args: integer and pointer values,
correct size supplied for struct sockaddr
pointer arg,
return ok.
line 144: setsockopt()
, args: integer values, arg size
ok, return ok.
line 163: setsockopt()
, args: integer values, arg size
ok, return ok.
line 183, 197: getsockopt()
, args: integer and pointer
values, out-pointer arg is zero initialized Vec
, arg
size ok, return ok.
line 220: send()
, args: integer and pointer values, arg
size ok, return ok.
line 238: recv()
, args: integer and pointer values, arg
size ok, return ok.
line 282: close()
, arg: integer value, return discarded
but is harmless in Drop
impl.
line 851: NlSocket::from_raw_fd()
, arg: dummy value,
ok for unit test.
unsafe fn
in trait impls for FromRawFd
. → Nothing
actually unsafe going on in there; wrapped assigment is plainCopy
data only except for heap allocation via safe
interface.
Comprehensive wrapper for talking Netlink and various dialects
thereof (rtnetlink, generic netlink, …) to the Kernel.
Active development.
Typed APIs allow for intuitive use of Netlink APIs that is
superior to the everything-is-an-int C analogues (libnl*
,libmnl
),
Provides macros for defining idiomatic wrappers of other
Netlink based interfaces.
v0.x versioned, frequent API breakage.
Depends itself on various zerover crates.
Disclaimer: as far evaluating syscall usage is concerned, this
review considers only the behavior on Linux.
FromRawFD
).dir.rs
Dir::_open()
calling libc::open()
: return check ok;Dir::_sub_dir()
calling libc::openat()
: return checkDir::_read_link()
calling libc::readlinkat()
: returnVec
; size passedDir::new_unnamed_file()
callingCStr::from_bytes_with_nul_unchecked()
: argument is staticDir::_open_file()
calling libc::openat()
: returnDir::_open_file()
calling File::from_raw_fd()
: argDir::_symlink()
calling libc::symlinkat()
: returnDir::_create_dir()
calling libc::mkdirat()
: returnDir::_unlink()
calling libc::unlinkat()
: return checkDir::_stat()
calling mem::zeroed()
: used on stackDir::_stat()
calling libc::fstatat()
: return checkpath
obtained from safe Rust type; struct stat
obtained from zeroed buffer._rename()
calling libc::renameat()
: return check ok;_hardlink()
calling libc::linkat()
: return check ok;_rename_flags()
calling libc::syscall()
forrenameat(2)
: return check ok; pointer args from safe Rustimpl FromRawFd for Dir {}
: unsafe API.impl Drop for Dir {}
calling libc::close()
: no checkslibc::AT_FDCWD
which is used occasionally in arguments toO_NOFOLLOW
in calls to openat(2)
, fstatat(2)
.O_TMPFILE
in Dir::new_unnamed_file()
: ok-ishlast_os_error()
.libc::mode_t
to libc::c_uint
for calls toopenat()
; apparently necessary on Freebsd; the rationaleDir::symlink()
reverses order of argument of the syscall.list.rs
DirIter::next_entry()
: unsafe due to writes to errnoreaddir(3)
;DirIter
is neither Send nor Sync), droppedimpl Iterator for DirIter {}
: calls unsafenext_entry()
(see above); calls unsafe
CStr::from_ptr()on
const charpointer obtained earlier by call to
readdir(3)`` which guarantees null termination.impl Drop for DirIter {}
calling libc::closedir()
:name.rs
AsPath
for converting various typesCStr
,filetype.rs
metadata.rs
is.metadata.rs
struct stat
, so no issue here with lifetimes.No build.rs. No use of unsafe code or calls into C libraries. String accesses using bounds checked APIs. No IO.
errors.rs
error_chain
crate; no unsafe.facility.rs
format.rs
lib.rs
Disclaimer: as far as syscall usage is concerned, this review
considers only the behavior on Linux.
shutdown()
twice on one socket. The result istry!()
and thus may not build with a futureunsafe
is never gratuitous.lib.rs
io::Result
.unsafe
use safe lower level constructs.There is only one source file, lib.rs
, so all uses of
“unsafe” are found there.
fn sun_path_offset()
: calculates the offset of a structoffsetof()
is still an unsolved problem in Rust.impl Drop for Inner
: obligatory dtor.fn Inner::new()
: wraps socket(2)
; return valuefn Inner::new_pair()
: wraps socketpair(2)
; returnfn Inter::try_clone()
: wraps dup(2)
; return valuefn Inner::shutdown()
: wraps shutdown(2)
; return valueint how
argument.fn Inner::timeout()
: wraps getsockopt(2)
; returnstruct timeval
) handledfn Inner::set_timeout()
: wraps setsockopt(2)
; returntime_t
argument using saturating± fn Inner::set_nonblocking()
: wraps ioctl(2)
withFIONBIO
; return value handled ok. Why not use fcntl(2)
with O_NONBLOCK
instead? Probably to save one syscall? This
warrants an explantory comment.
fn Inner::take_error()
: wraps getsockopt(2)
; returnunsafe fn sockaddr_un()
: initializes a struct sockaddr_un
; inputs validated appropriately; raw pointerfn SocketAddr::new()
: obtains a socket address; for usegetpeername()
/ getsockname()
etc.; return valuefn SocketAddr::address()
: casts memory of a wrapped type[char]
to [u8]
; array bounds are preserved thusfn UnixStream::connect()`: public API wrapping socket creation and
connect(2)``; arguments obtained from internalfn UnixStream::local_addr()`: wraps
getsockname(2); return value and arguments handled by
SocketAddr::new()``.fn UnixStream::peer_addr()`: wraps
getpeername(2); return value and arguments handled by
SocketAddr::new()``.impl Read for UnixStream, fn read()
: wraps recv(2)
;impl Write for UnixStream, fn write()
: wraps send(2)
;impl FromRawFd for UnixStream, fn from_raw_fd()
: unsafeUnixStream
without validating the± fn UnixListener::bind()
: wraps socket creation,bind(2)
and listen(2
; return values handled ok; backlog
of socket queue hard-coded to the default Linux maximum of 128
which is reasonable but deserves mention in the docs.
fn UnixListener::accept()
: wrapper for accept(2)
;SocketAddr::new()
.fn UnixListener::local_addr()
: wrapper forgetsockname(2)
; return value and arguments handled bySocketAddr::new()
.impl FromRawFd for UnixListener, fn from_raw_fd()
: unsafeUnixListener
without validating anything.fn UnixDatagram::bind()
: wraps bind(2)
forSOCK_DGRAM
type sockets; return value handled ok; argsfn UnixDatagram::connect()
: wraps connect(2)
; returnfn UnixDatagram::local_addr()`: wraps
getsockname(2); return value and arguments handled by
SocketAddr::new()``.fn UnixDatagram::peer_addr()`: wraps
getpeername(2); return value and arguments handled by
SocketAddr::new()``.fn UnixDatagram::recv_from()`: wraps
recvfrom(2)``;fn UnixDatagram::recv()`: wraps
recv(2)``; args obtainedfn UnixDatagram::send_to()`: wraps
send_to(2)``; argsfn UnixDatagram::send()`: wraps
send_to(2)``; argsimpl FromRawFd for UnixDatagram, fn from_raw_fd()
: unsafeUnixDatagram
without validating anything.Zero uses of unsafe
by virtue of the safe APIs provided byneli
.
Safe APIs for the Wireguard Netlink interface, does eliminate
the need for unsafe primitives talking to the kernel.
Exposes a foolproof API wrapping more low-level components like
Netlink sockets.
Under active development.
Currently (v2.0.5) dependent on an ancient version of theneli
library.
Depends on numerous v0.x versioned crates (neli
, libc
).
Zero uses of unsafe
by virtue of the safe APIs provided byneli
.
Safe APIs for the Wireguard Netlink interface, does eliminate
the need for unsafe primitives talking to the kernel.
Exposes a foolproof API wrapping more low-level components like
Netlink sockets.
Under active development.
Currently (v2.0.5) dependent on an ancient version of theneli
library.
Depends on numerous v0.x versioned crates (neli
, libc
).
© bestia.dev 2023, MIT License, Version: 2023.608.1636
Open source repository for this web app: https://github.com/bestia-dev/cargo_crev_web/
No “unsafe” code. Trivial functionality. Basic functionality tests.