Bug 240768 - linux(4): 'openssl speed rsa' segfaults
Summary: linux(4): 'openssl speed rsa' segfaults
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Dmitry Chagin
URL:
Keywords:
Depends on:
Blocks: 247219
  Show dependency treegraph
 
Reported: 2019-09-23 12:42 UTC by Edward Tomasz Napierala
Modified: 2023-02-21 10:30 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Edward Tomasz Napierala freebsd_committer freebsd_triage 2019-09-23 12:42:57 UTC
Ubuntu's openssl (1.1.1b-1ubuntu2.1 amd64) crashes like this:

# openssl speed rsa
Doing 512 bits private rsa's for 10s: 236319 512 bits private RSA's in 10.06s
Doing 512 bits public rsa's for 10s: 4137009 512 bits public RSA's in 10.10s
Doing 1024 bits private rsa's for 10s: Segmentation fault (core dumped)
Comment 1 Conrad Meyer freebsd_committer freebsd_triage 2019-09-23 15:30:32 UTC
Which glibc?  Have you looked at the core / do you have a stack?
Comment 2 Edward Tomasz Napierala freebsd_committer freebsd_triage 2019-09-23 15:39:28 UTC
GNU C Library (Ubuntu GLIBC 2.29-0ubuntu2) stable release version 2.29.  I don't have a working core (linuxulator coredumps are not particularly useful), I'm afraid.  However, I've just noticed it's somewhat random: this time I got:

# openssl speed rsa
Doing 512 bits private rsa's for 10s: 197105 512 bits private RSA's in 10.02s
Doing 512 bits public rsa's for 10s: 3558737 512 bits public RSA's in 10.03s
Doing 1024 bits private rsa's for 10s: 96450 1024 bits private RSA's in 10.09s
Doing 1024 bits public rsa's for 10s: 1412783 1024 bits public RSA's in 10.07s
Doing 2048 bits private rsa's for 10s: Segmentation fault (core dumped)
Comment 3 Conrad Meyer freebsd_committer freebsd_triage 2019-09-23 17:16:01 UTC
Does Linux GDB work in linuxulator?  I'm pretty unfamiliar.  Getting cores working seems very useful.
Comment 4 Conrad Meyer freebsd_committer freebsd_triage 2019-09-23 17:16:23 UTC
(In reply to Conrad Meyer from comment #3)
(By which I meant, live debugging, as opposed to post-facto core inspection.)
Comment 5 Edward Tomasz Napierala freebsd_committer freebsd_triage 2019-09-23 17:23:47 UTC
It doesn't, I'm afraid.  I have some patches that improve the situation a bit, but they are not enough to make it work properly yet.

Regarding core files - the ones we generate have FreeBSD stuff in them, so Linux gdb can't use them; our native gdb, on the other hand, refuses to touch Linux executables.
Comment 6 Conrad Meyer freebsd_committer freebsd_triage 2019-09-23 18:20:02 UTC
Re: core files -- yeah, I have a vague recollection of something like that.  At the end of the day, it's one or more bugs.  It seems like something that can be fixed, from one end or the other (or both).
Comment 7 Edward Tomasz Napierala freebsd_committer freebsd_triage 2020-01-28 16:25:08 UTC
Hah; not sure how could I miss this:

time(NULL)                              = 1580227238 (2020-01-28T11:00:38-0500)
time(NULL)                              = 1580227238 (2020-01-28T11:00:38-0500)
time(NULL)                              = 1580227238 (2020-01-28T11:00:38-0500)
time(NULL)                              = 1580227238 (2020-01-28T11:00:38-0500)
time(NULL)                              = 1580227238 (2020-01-28T11:00:38-0500)
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
rt_sigaction(SIGALRM, {sa_handler=0x108da00, sa_mask=[ALRM], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x802c37a20}, {sa_handler=0x108da00, sa_mask=[ALRM], sa_flags=SA_RESTART}, 8) = 0
rt_sigreturn({mask=[]})                 = 15611098741728140169
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault

Funnily enough, previous SIGLARMs work... kind of:

time(NULL)                              = 1580227218 (2020-01-28T11:00:18-0500)
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---                          
rt_sigaction(SIGALRM, {sa_handler=0x108da00, sa_mask=[ALRM], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x802c37a20}, {sa_handler=0x108da00, sa_mask=[ALRM], sa_flags=SA_RESTART}, 8) = 0
rt_sigreturn({mask=[]})                 = 7816104742323179296     



times({tms_utime=947, tms_stime=45, tms_cutime=0, tms_cstime=0}) = 955958      
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL, si_errno=-512} ---           
rt_sigaction(SIGALRM, {sa_handler=0x108da00, sa_mask=[ALRM], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x802c37a20}, {sa_handler=0x108da00, sa_mask=[ALRM], sa_flags=SA_RESTART}, 8) = 0
rt_sigreturn({mask=[]})                 = -1 EPERM (Operation not permitted)   
write(2, "RSA verify failure\n", 19RSA verify failure
Comment 8 Edward Tomasz Napierala freebsd_committer freebsd_triage 2021-12-21 12:40:39 UTC
Fix for what seems to be the same problem: https://reviews.freebsd.org/D33599
Comment 9 commit-hook freebsd_committer freebsd_triage 2023-02-02 17:22:25 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a95cb95e12e537dbe70f9de18cc0fe98e4a5ebf5

commit a95cb95e12e537dbe70f9de18cc0fe98e4a5ebf5
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-02-02 17:21:37 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-02-02 17:21:37 +0000

    linux(4): Preserve fpu fxsave state across signal delivery on amd64.

    PR:                     240768
    Reviewed by:            kib
    Differential Revision:  https://reviews.freebsd.org/D38302
    MFC after:              1 week

 sys/amd64/linux/linux_sysvec.c     | 70 ++++++++++++++++++++++++++++++++++----
 sys/x86/linux/linux_x86_sigframe.h |  7 ++--
 2 files changed, 68 insertions(+), 9 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2023-02-09 07:57:11 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=20d601714206e0da7b82706ec9ac9ca74aafd749

commit 20d601714206e0da7b82706ec9ac9ca74aafd749
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-02-02 17:21:37 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-02-09 07:55:24 +0000

    linux(4): Preserve fpu fxsave state across signal delivery on amd64.

    PR:                     240768
    Reviewed by:            kib
    Differential Revision:  https://reviews.freebsd.org/D38302
    MFC after:              1 week

    (cherry picked from commit a95cb95e12e537dbe70f9de18cc0fe98e4a5ebf5)

 sys/amd64/linux/linux_sysvec.c     | 70 ++++++++++++++++++++++++++++++++++----
 sys/x86/linux/linux_x86_sigframe.h |  7 ++--
 2 files changed, 68 insertions(+), 9 deletions(-)
Comment 11 Dmitry Chagin freebsd_committer freebsd_triage 2023-02-21 10:30:44 UTC
Seems to be fixed, also linux jre/Mathlab works now.