From: Joe Perches <joe@perches.com>
To: Andrey Ryabinin <a.ryabinin@samsung.com>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Sasha Levin <sasha.levin@oracle.com>,
Randy Dunlap <rdunlap@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Jonathan Corbet <corbet@lwn.net>, Michal Marek <mmarek@suse.cz>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Yury Gribov <y.gribov@samsung.com>,
Dmitry Vyukov <dvyukov@google.com>,
Konstantin Khlebnikov <koct9i@gmail.com>,
x86@kernel.org, linux-doc@vger.kernel.org,
linux-kbuild@vger.kernel.org
Subject: Re: [PATCH v2 1/2] kernel: printk: specify alignment for struct printk_log
Date: Fri, 14 Nov 2014 09:22:08 -0800 [thread overview]
Message-ID: <1415985728.5912.17.camel@perches.com> (raw)
In-Reply-To: <1415969446-26356-2-git-send-email-a.ryabinin@samsung.com>
On Fri, 2014-11-14 at 15:50 +0300, Andrey Ryabinin wrote:
> On architectures that have support for efficient unaligned access
> struct printk_log has 4-byte alignment.
> Specify alignment attribute in type declaration.
>
> The whole point of this patch is to fix deadlock which happening
> when UBSan detects unaligned access in printk() thus UBSan recursively
> calls printk() with logbuf_lock held by top printk() call.
[]
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
[]
> @@ -223,7 +223,11 @@ struct printk_log {
> u8 facility; /* syslog facility */
> u8 flags:5; /* internal record flags */
> u8 level:3; /* syslog level */
> -};
> +}
> +#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
> +__packed __aligned(4)
> +#endif
Why is adding __packed useful or __aligned(4) useful?
The struct is naturally aligned on u64 and should be
the size of 2 u64s.
struct printk_log {
u64 ts_nsec; /* timestamp in nanoseconds */
u16 len; /* length of entire record */
u16 text_len; /* length of text buffer */
u16 dict_len; /* length of dictionary buffer */
u8 facility; /* syslog facility */
u8 flags:5; /* internal record flags */
u8 level:3; /* syslog level */
};
Is there any case when it's not sizeof(u64) * 2?
next prev parent reply other threads:[~2014-11-14 17:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-14 12:50 [PATCH v2 0/2] UBSan: run-time undefined behavior sanity checker Andrey Ryabinin
2014-11-14 12:50 ` [PATCH v2 1/2] kernel: printk: specify alignment for struct printk_log Andrey Ryabinin
2014-11-14 17:22 ` Joe Perches [this message]
2014-11-14 20:54 ` Andrey Ryabinin
2014-11-14 12:50 ` [PATCH v2 2/2] UBSan: run-time undefined behavior sanity checker Andrey Ryabinin
2015-11-03 17:20 ` [PATCH v2 0/2] " Sasha Levin
2015-11-03 17:35 ` Dmitry Vyukov
2015-11-03 17:45 ` Dmitry Vyukov
2015-11-03 17:50 ` Sasha Levin
2015-11-03 18:15 ` Andrey Ryabinin
2015-11-03 18:46 ` Sasha Levin
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=1415985728.5912.17.camel@perches.com \
--to=joe@perches.com \
--cc=a.ryabinin@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=dvyukov@google.com \
--cc=hpa@zytor.com \
--cc=koct9i@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mingo@redhat.com \
--cc=mmarek@suse.cz \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=sasha.levin@oracle.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=y.gribov@samsung.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;
as well as URLs for NNTP newsgroup(s).