[Bug 1188327] New: kernel 5.13.1 is crashing on boot on armv7 due to 'Unhandled fault: alignment exception' in ecdsa_set_pub_key
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327 Bug ID: 1188327 Summary: kernel 5.13.1 is crashing on boot on armv7 due to 'Unhandled fault: alignment exception' in ecdsa_set_pub_key Classification: openSUSE Product: openSUSE Tumbleweed Version: Current Hardware: armv7 URL: https://openqa.opensuse.org/tests/1841539/modules/welc ome/steps/6 OS: Other Status: NEW Severity: Normal Priority: P5 - None Component: Kernel Assignee: kernel-bugs@opensuse.org Reporter: guillaume.gardet@arm.com QA Contact: qa-bugs@suse.de CC: afaerber@suse.com, dmueller@suse.com, mbrugger@suse.com Found By: openQA Blocker: Yes Created attachment 851007 --> http://bugzilla.opensuse.org/attachment.cgi?id=851007&action=edit kernel traces ## Observation openQA test in scenario opensuse-Tumbleweed-NET-arm-create_hdd_minimalx@aarch32 fails in [welcome](https://openqa.opensuse.org/tests/1841539/modules/welcome/steps/6) Since update to kernel 5.13.1 [0], kernel is crashing on boot on armv7 due to 'Unhandled fault: alignment exception' See attachment for the full log. [0]: https://build.opensuse.org/request/show/905770 ## Test suite description ## Reproducible Fails since (at least) Build [20210714](https://openqa.opensuse.org/tests/1841078) ## Expected result Last good: [20210712](https://openqa.opensuse.org/tests/1838553) (or more recent) ## Further details Always latest result in this scenario: [latest](https://openqa.opensuse.org/tests/latest?arch=arm&distri=opensuse&flavor=NET&machine=aarch32&test=create_hdd_minimalx&version=Tumbleweed) -- You are receiving this mail because: You are the assignee for the bug.
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
Guillaume GARDET
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c1
Mian Yousaf Kaukab
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c2
--- Comment #2 from Mian Yousaf Kaukab
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c3
Mian Yousaf Kaukab
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c4
Richard Biener
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c5
Richard Biener
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c6
Takashi Iwai
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c7
--- Comment #7 from Richard Biener
FWIW, ecc_swap_digits() handles the u64 array, so copying would be needed there instead of the caller. (And there are two calls of ecc_swap_digits() in ecdsa_set_pub_key()).
If performance matters, we'd need two versions of ecc_swap_digits() for aligned and unaligned. But all calls of ecc_swap_digits() in ecdsa.c look suspicious wrt alignment.
Instead of a memcpy you can also use typedef u64 unaligned_u64 __attribute__((aligned(1))); *(unaligned_u64 *)digits that avoids the memcpy (which should be similarly optimized in most cases, but you'd need to check). It might of course be slow when the target cannot do unaligned accesses as it will to shifting/masking/etc. to produce the u64 value which might not actually be needed as 'u64' (without knowing the code in question) -- You are receiving this mail because: You are the assignee for the bug.
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c8
Mian Yousaf Kaukab
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c9
--- Comment #9 from Mian Yousaf Kaukab
(In reply to Takashi Iwai from comment #6)
FWIW, ecc_swap_digits() handles the u64 array, so copying would be needed there instead of the caller. (And there are two calls of ecc_swap_digits() in ecdsa_set_pub_key()).
If performance matters, we'd need two versions of ecc_swap_digits() for aligned and unaligned. But all calls of ecc_swap_digits() in ecdsa.c look suspicious wrt alignment.
Instead of a memcpy you can also use
typedef u64 unaligned_u64 __attribute__((aligned(1)));
*(unaligned_u64 *)digits
that avoids the memcpy (which should be similarly optimized in most cases, but you'd need to check). It might of course be slow when the target cannot do unaligned accesses as it will to shifting/masking/etc. to produce the u64 value which might not actually be needed as 'u64' (without knowing the code in question)
Or may be use get_unaligned(). -- You are receiving this mail because: You are the assignee for the bug.
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c10
--- Comment #10 from Takashi Iwai
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c11
--- Comment #11 from Mian Yousaf Kaukab
There is get_unaligned_be64() and this will do both jobs done there :) Yes, I wasn't explicit :)
-- You are receiving this mail because: You are the assignee for the bug.
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c12
Richard Biener
Please confirm that compiler inferring LDM instruction instead of LDR is correct for ecc_swap_digits().
In armv7, LDR instruction can handle unaligned address whereas LDM instruction can't handle them [1].
[1]: https://developer.arm.com/documentation/ddi0406/c/Application-Level- Architecture/Application-Level-Memory-Model/Alignment-support/Unaligned-data- access
I can find static inline void ecc_swap_digits(const u64 *in, u64 *out, unsigned int ndigits) { int i; for (i = 0; i < ndigits; i++) out[i] = __swab64(in[ndigits - 1 - i]); } where yes, the compiler is correctly infering 64bit alignment for the load in[ndigits - 1 - 1] because in is of type u64 *. The instance where it doesn't likely knows better from where it is inlined to (we don't try to actively break things when we're faced with a 100% sure unaligned access). -- You are receiving this mail because: You are the assignee for the bug.
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c14
--- Comment #14 from Mian Yousaf Kaukab
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c15
--- Comment #15 from Mian Yousaf Kaukab
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c16
--- Comment #16 from Guillaume GARDET
Thanks! Did you send it to stable as well? I think this would need to be backported to stable releases. -- You are receiving this mail because: You are the assignee for the bug.
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c17
--- Comment #17 from Mian Yousaf Kaukab
(In reply to Mian Yousaf Kaukab from comment #15)
Thanks!
Did you send it to stable as well? I think this would need to be backported to stable releases. No, but I can send it once it is accepted.
-- You are receiving this mail because: You are the assignee for the bug.
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c22
Guillaume GARDET
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c23
--- Comment #23 from Guillaume GARDET
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327#c24
--- Comment #24 from Takashi Iwai
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1188327
Matthias Brugger
participants (1)
-
bugzilla_noreply@suse.com