From: Ding Tianhong <dingtianhong@huawei.com>
To: David Laight <David.Laight@ACULAB.COM>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"aryabinin@virtuozzo.co" <aryabinin@virtuozzo.co>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
LinuxArm <linuxarm@huawei.com>
Subject: Re: [PATCH] ubsan: don't handle misaligned address when support unaligned access
Date: Fri, 1 Dec 2017 20:37:09 +0800 [thread overview]
Message-ID: <957bb3ca-94a3-d083-7896-6bc8a5cac8a9@huawei.com> (raw)
In-Reply-To: <4b788fc92eee4c509c37fba83365dd72@AcuMS.aculab.com>
On 2017/12/1 19:47, David Laight wrote:
>> of noise in the log and cause confusion.
>>
>> This patch will close the detection of unaligned access when
>> the system support unaligned access.
>>
>> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
>> ---
>> lib/ubsan.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/ubsan.c b/lib/ubsan.c
>> index fb0409d..278b4c3 100644
>> --- a/lib/ubsan.c
>> +++ b/lib/ubsan.c
>> @@ -321,7 +321,8 @@ void __ubsan_handle_type_mismatch(struct type_mismatch_data *data,
>>
>> if (!ptr)
>> handle_null_ptr_deref(data);
>> - else if (data->alignment && !IS_ALIGNED(ptr, data->alignment))
>> + else if (data->alignment && !IS_ALIGNED(ptr, data->alignment) &&
>> + !IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
>> handle_missaligned_access(data, ptr);
>> else
>> handle_object_size_mismatch(data, ptr);
>
> Won't that report an object size error instead of actually
> doing the required access?
>
Yes,I miss it.
> Surely it shouldn't get into this function at all?
>
> I guess 'alignment' is set to 4 or 8.
> If it were set to 3 or 7 (or 0) then the tests on the pointer
> would be much simpler - maybe at a slight extra cost in setup.
>
Looks like we need to fix it in the handle_missaligned_access:
diff --git a/lib/ubsan.c b/lib/ubsan.c
index 278b4c3..040f8b2 100644
--- a/lib/ubsan.c
+++ b/lib/ubsan.c
@@ -289,6 +289,9 @@ static void handle_missaligned_access(struct type_mismatch_data *data,
if (suppress_report(&data->location))
return;
+ if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
+ return;
+
ubsan_prologue(&data->location, &flags);
pr_err("%s misaligned address %p for type %s\n",
Thanks
Ding
> David
>
prev parent reply other threads:[~2017-12-01 12:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 11:32 Ding Tianhong
2017-12-01 11:47 ` David Laight
2017-12-01 12:37 ` Ding Tianhong [this message]
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=957bb3ca-94a3-d083-7896-6bc8a5cac8a9@huawei.com \
--to=dingtianhong@huawei.com \
--cc=David.Laight@ACULAB.COM \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.co \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.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
all inboxes | Powered by JetHome®