lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230508124701.443ba331.gary@garyguo.net>
Date:   Mon, 8 May 2023 12:47:01 +0100
From:   Gary Guo <gary@...yguo.net>
To:     Alice Ryhl <aliceryhl@...gle.com>
Cc:     Miguel Ojeda <ojeda@...nel.org>,
        Wedson Almeida Filho <wedsonaf@...il.com>,
        Alex Gaynor <alex.gaynor@...il.com>,
        Boqun Feng <boqun.feng@...il.com>,
        "Björn Roy Baron" <bjorn3_gh@...tonmail.com>,
        Benno Lossin <benno.lossin@...ton.me>,
        rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
        patches@...ts.linux.dev
Subject: Re: [PATCH v2] rust: error: add missing error codes

On Thu,  4 May 2023 06:48:54 +0000
Alice Ryhl <aliceryhl@...gle.com> wrote:

> This adds the error codes from `include/linux/errno.h` to the list of
> Rust error constants. These errors were not included originally, because
> they are not supposed to be visible from userspace. However, they are
> still a perfectly valid error to use when writing a kernel driver. For
> example, you might want to return ERESTARTSYS if you receive a signal
> during a call to `schedule`.

`include/linux/errno.h` also includes all of `asm/errno.h`,
which defines EDEADLK - EHWPOISON, which is not included in this patch.
I feel like these error codes should be added first?

> 
> This patch inserts an annotation to skip rustfmt on the list of error
> codes. Without it, three of the error codes are split over several
> lines, which looks terribly inconsistent.
> 
> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
> ---
>  rust/kernel/error.rs | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
> index 5f4114b30b94..de4fa8640f29 100644
> --- a/rust/kernel/error.rs
> +++ b/rust/kernel/error.rs
> @@ -14,6 +14,7 @@ use core::num::TryFromIntError;
>  use core::str::Utf8Error;
>  
>  /// Contains the C-compatible error codes.
> +#[rustfmt::skip]
>  pub mod code {
>      macro_rules! declare_err {
>          ($err:tt $(,)? $($doc:expr),+) => {
> @@ -58,6 +59,25 @@ pub mod code {
>      declare_err!(EPIPE, "Broken pipe.");
>      declare_err!(EDOM, "Math argument out of domain of func.");
>      declare_err!(ERANGE, "Math result not representable.");
> +    declare_err!(ERESTARTSYS, "Restart the system call.");
> +    declare_err!(ERESTARTNOINTR, "System call was interrupted by a signal and will be restarted.");
> +    declare_err!(ERESTARTNOHAND, "Restart if no handler.");
> +    declare_err!(ENOIOCTLCMD, "No ioctl command.");
> +    declare_err!(ERESTART_RESTARTBLOCK, "Restart by calling sys_restart_syscall.");
> +    declare_err!(EPROBE_DEFER, "Driver requests probe retry.");
> +    declare_err!(EOPENSTALE, "Open found a stale dentry.");
> +    declare_err!(ENOPARAM, "Parameter not supported.");
> +    declare_err!(EBADHANDLE, "Illegal NFS file handle.");
> +    declare_err!(ENOTSYNC, "Update synchronization mismatch.");
> +    declare_err!(EBADCOOKIE, "Cookie is stale.");
> +    declare_err!(ENOTSUPP, "Operation is not supported.");
> +    declare_err!(ETOOSMALL, "Buffer or request is too small.");
> +    declare_err!(ESERVERFAULT, "An untranslatable error occurred.");
> +    declare_err!(EBADTYPE, "Type not supported by server.");
> +    declare_err!(EJUKEBOX, "Request initiated, but will not complete before timeout.");
> +    declare_err!(EIOCBQUEUED, "iocb queued, will get completion event.");
> +    declare_err!(ERECALLCONFLICT, "Conflict with recalled state.");
> +    declare_err!(ENOGRACE, "NFS file lock reclaim refused.");
>  }
>  
>  /// Generic integer kernel error.
> 
> base-commit: ea76e08f4d901a450619831a255e9e0a4c0ed162

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ