[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YhSs5ZTL9ixdCCU9@alley>
Date: Tue, 22 Feb 2022 10:29:09 +0100
From: Petr Mladek <pmladek@...e.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: Rasmus Villemoes <linux@...musvillemoes.dk>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Miguel Ojeda <ojeda@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
rust-for-linux <rust-for-linux@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
Gary Guo <gary@...yguo.net>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...gle.com>,
Steven Rostedt <rostedt@...dmis.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>
Subject: Re: [PATCH v4 12/20] vsprintf: add new `%pA` format specifier
On Mon 2022-02-14 13:12:24, Miguel Ojeda wrote:
> On Mon, Feb 14, 2022 at 11:52 AM Rasmus Villemoes
> <linux@...musvillemoes.dk> wrote:
> >
> > I think the point is for vsnprintf() to call (back) into Rust code.
>
> Indeed, this is the case.
>
> > That said, I don't like the !CONFIG_RUST version to return NULL, that
> > will surely crash moments later.
> >
> > So I prefer something like
> >
> > [rust.h]
> > // no CONFIG_RUST conditional
> > +char *rust_fmt_argument(char* buf, char* end, void *ptr);
> >
> > [vsprintf.c]
> > + case 'A':
> > + if (IS_ENABLED(CONFIG_RUST))
> > + return rust_fmt_argument(buf, end, ptr);
> > + else
> > + return string_nocheck(buf, end, "[%pA in non-Rust
> > code?!]", default_str_spec);
Any long message might cause buffer overflow when the caller expects
fixed short string.
> Sounds good. Or perhaps simply `break` and let it print the pointer
> (to be consistent with `g` case and non-error `e` case).
Also this might cause buffer overflow.
The most safe solution would be to use WARN_ONCE(). The only drawback
is that it might cause panic() when using "panic_on_warn" kernel
parameter. But it will not open security hole.
Best Regards,
Petr
Powered by blists - more mailing lists