Rust for Linux List
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Miguel Ojeda <ojeda@kernel.org>, John Stultz <jstultz@google.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Alex Gaynor <alex.gaynor@gmail.com>,
	Wedson Almeida Filho <wedsonaf@gmail.com>,
	Gary Guo <gary@garyguo.net>,
	bjorn3_gh@protonmail.com, Benno Lossin <benno.lossin@proton.me>,
	Andreas Hindborg <a.hindborg@samsung.com>,
	Alice Ryhl <aliceryhl@google.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kees Cook <keescook@chromium.org>, Mara Bos <m-ou.se@m-ou.se>,
	Amanieu d'Antras <amanieu@gmail.com>
Subject: Re: [PATCH 2/2] rust: time: Use wrapping_sub() for Ktime::sub()
Date: Tue, 14 May 2024 06:12:53 -0700	[thread overview]
Message-ID: <ZkNjVbqR6gYqg4YZ@boqun-archlinux> (raw)
In-Reply-To: <CANiq72nGHhgRjfMOhz=ss51q2egHYexPMVvWTr0RES9WAmMF=A@mail.gmail.com>

On Mon, May 13, 2024 at 05:04:43PM +0200, Miguel Ojeda wrote:
> On Thu, May 9, 2024 at 2:14 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> >
> > In principle ktime_sub() should not overflow for regular use cases.
> >
> > If the binder example overflows the substraction, then something is
> > seriously wrong. Though in that case as it's only for debug purposes
> > panicing would be totally counter productive. A warning might be
> > appropriate though.
> 
> Thanks for the clarification Thomas.
> 
> Alice and I pinged about this in the RustNL Unconf, i.e. about having
> a way to customize what happens on integer overflow (and, in general,
> other panics too), which I had in:
> 
>     https://github.com/Rust-for-Linux/linux/issues/354
> 
> e.g. like UBSan that allows a "report and continue" option.
> 
> We chatted with Mara and Amanieu, who were receptive. In particular,
> Mara posted right away:
> 
>     https://github.com/rust-lang/rfcs/pull/3632
> 
> as a possible first step to eventually have that ability, mentioning
> Rust for Linux as a user.
> 
> If we get the ability to customize those, then this could simply be a
> normal arithmetic operation, i.e. like any other. That is, considered
> to be a bug if it overflows.
> 

That is nice to have, thank you guys!

> Meanwhile, one alternative is going with Boqun's approach, but I would
> just use the standard operator (i.e. what we do elsewhere) and try to
> get the customization happen as soon as possible since we will need it
> for everything else (plus we avoid to make the code uglier with
> changes that we will need to revert anyway; and it also allows us to
> easily test any new customization feature from the compiler/library).
> 

However, I must point out that it needs more than a customized panic
handler to work: we also need to change the code generation (or adding
a different flag similar to -Coverflow-checks), because the current code
generation is Rust panic when overflow happens, which means the
subsequent code is unreachable.

Regards,
Boqun

> Cheers,
> Miguel

  reply	other threads:[~2024-05-14 13:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 23:07 [PATCH 0/2] rust: time related cleanup Boqun Feng
2024-04-11 23:08 ` [PATCH 1/2] rust: time: doc: Add missing C header links Boqun Feng
2024-04-12  7:15   ` Miguel Ojeda
2024-04-12 11:04   ` Alice Ryhl
2024-04-11 23:08 ` [PATCH 2/2] rust: time: Use wrapping_sub() for Ktime::sub() Boqun Feng
2024-04-12  7:14   ` Miguel Ojeda
2024-04-12  7:43     ` Philipp Stanner
2024-04-12  7:58       ` Miguel Ojeda
2024-04-15 17:08         ` Kees Cook
2024-04-12 13:34     ` Boqun Feng
2024-04-12 14:41       ` Miguel Ojeda
2024-04-13  1:30         ` Boqun Feng
2024-04-13  2:16           ` Miguel Ojeda
2024-04-12  8:36   ` Alice Ryhl
2024-04-12 13:18     ` Boqun Feng
2024-04-12 13:51       ` Alice Ryhl
2024-04-25  9:00         ` Andreas Hindborg
2024-04-25 14:28           ` Boqun Feng
2024-04-23 21:11   ` Boqun Feng
2024-04-23 23:37     ` Kees Cook
2024-04-24 10:21       ` Miguel Ojeda
2024-05-09 12:14     ` Thomas Gleixner
2024-05-13 14:06       ` Boqun Feng
2024-05-13 15:04       ` Miguel Ojeda
2024-05-14 13:12         ` Boqun Feng [this message]
2024-05-14 14:21           ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZkNjVbqR6gYqg4YZ@boqun-archlinux \
    --to=boqun.feng@gmail.com \
    --cc=a.hindborg@samsung.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=amanieu@gmail.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=gary@garyguo.net \
    --cc=jstultz@google.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m-ou.se@m-ou.se \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wedsonaf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox