From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Petr Mladek <pmladek@suse.com>,
linux-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Nick Desaulniers <ndesaulniers@google.com>
Subject: Re: [PATCH v1 1/1] vsprintf: Fix potential unaligned access
Date: Tue, 11 Jan 2022 16:18:36 +0200 [thread overview]
Message-ID: <Yd2RvIeP3LRc/+gl@smile.fi.intel.com> (raw)
In-Reply-To: <Yd2QkVMnmZ57qXTH@paasikivi.fi.intel.com>
On Tue, Jan 11, 2022 at 04:13:37PM +0200, Sakari Ailus wrote:
> On Tue, Jan 11, 2022 at 01:22:29PM +0200, Andy Shevchenko wrote:
> > On Tue, Jan 11, 2022 at 12:54:41PM +0200, Sakari Ailus wrote:
> > > On Tue, Jan 11, 2022 at 12:10:28PM +0200, Andy Shevchenko wrote:
> > > > On Tue, Jan 11, 2022 at 12:12:46AM +0200, Sakari Ailus wrote:
> > > > > On Mon, Jan 10, 2022 at 10:50:49PM +0200, Andy Shevchenko wrote:
> > > > > > The %p4cc specifier in some cases might get an unaligned pointer.
> > > > > > Due to this we need to make copy to local variable once to avoid
> > > > > > potential crashes on some architectures due to improper access.
> > > > >
> > > > > I guess this problem exists virtually everywhere where pointers are being
> > > > > handled: the pointer could be unaligned.
> > > >
> > > > True. And my patch improves the situation.
> > > > See, for example, 0f70fe605fad ("hexdump: fix for non-aligned buffers").
> > >
> > > This is different since there's no guarantee of a void pointer's alignment.
> > >
> > > The pixelformat used for %p4cc is a pointer to u32.
> >
> > Oh, look at the %p, compiler doesn't know about the %p extensions and caller
> > may supply whatever they want, i.e. %p may take any address that can be kept
> > in void *. Actual argument _is_ void *. What you put there as u32 is just
> > personal expectation, and not the reality.
>
> If you assume this, you should add get_unaligned() calls in all places
> where you're casting a type to another with higher alignment requirements.
Those places so far were not subject of any reports, but ideally yes, you are
right (in a scope of %p extensions, otherwise it's silly).
I will leave this to the VSPRINTF / PRINTK maintainers to proceed. Personally
I found this patch useful since we don't know what other user will do unaligned
call to it.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-01-11 14:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-10 20:50 [PATCH v1 1/1] vsprintf: Fix potential unaligned access Andy Shevchenko
2022-01-10 22:12 ` Sakari Ailus
2022-01-11 10:10 ` Andy Shevchenko
2022-01-11 10:54 ` Sakari Ailus
2022-01-11 11:22 ` Andy Shevchenko
2022-01-11 14:13 ` Sakari Ailus
2022-01-11 14:18 ` Andy Shevchenko [this message]
2022-01-11 14:57 ` Petr Mladek
2022-01-11 15:09 ` Andy Shevchenko
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=Yd2RvIeP3LRc/+gl@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=ndesaulniers@google.com \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sakari.ailus@linux.intel.com \
--cc=senozhatsky@chromium.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.