Bug 240769 - linux(4): 'openssl speed rsa' calls time(2)
Summary: linux(4): 'openssl speed rsa' calls time(2)
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:
 
Reported: 2019-09-23 12:46 UTC by Edward Tomasz Napierala
Modified: 2022-07-12 15:50 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:46:12 UTC
For some reason Linux 'openssl speed rsa' ends up calling time(2) over and over again:

write(2, "Doing 512 bit private rsa's for "..., 37Doing 512 bit private rsa's for 10s: ) = 37
alarm(10)                               = 0
times({tms_utime=0, tms_stime=1, tms_cutime=0, tms_cstime=0}) = 2574131
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996
time([1568856996])                      = 1568856996

[..]

This obviously doesn't happen under real Linux.
Comment 1 Conrad Meyer freebsd_committer freebsd_triage 2019-09-23 15:24:17 UTC
Which version of openssl?  Under real linux (4.20.4 kernel, glibc 2.27), with openssl 1.1.0i, I instead see a bajillion getpid() calls (something like 300/second).  (suggestive of fork-detection.)

But I suspect that has nothing to do with your time() calls.  Probably instead of time() syscall, openssl is hitting some linux-vdso.so.1 call that we don't implement in linuxulator.
Comment 2 Conrad Meyer freebsd_committer freebsd_triage 2019-09-23 15:29:36 UTC
Yeah, time is one of the functions provided by vdso on Linux x86_64:

       __vdso_clock_gettime   LINUX_2.6
       __vdso_getcpu          LINUX_2.6
       __vdso_gettimeofday    LINUX_2.6
       __vdso_time            LINUX_2.6

http://man7.org/linux/man-pages/man7/vdso.7.html
Comment 3 Edward Tomasz Napierala freebsd_committer freebsd_triage 2019-09-23 15:43:24 UTC
I see this with both CentOS (openssl-1.0.2k-16.el7_6.1) and Ubuntu (openssl-1.1.1b-1ubuntu2.1).

It does seem related to vdso... but doesn't our vdso already provide this symbol (sys/amd64/linux/linux_vdso.lds.s)?
Comment 4 Conrad Meyer freebsd_committer freebsd_triage 2019-09-23 16:32:33 UTC
Yeah, you're right, it does seem to provide it.  Hmm.  I don't know what is going wrong here, but for some reason the linux dynamic linker isn't connecting openssl to our emulated linux vdso.
Comment 5 Dmitry Chagin freebsd_committer freebsd_triage 2022-06-21 16:10:45 UTC
(In reply to Conrad Meyer from comment #4)
no, even current vdso time() always calls syscall.
on Linux strace does not show time() call as it in the vdso (not a syscall)
Comment 6 Dmitry Chagin freebsd_committer freebsd_triage 2022-06-21 16:11:39 UTC
grab, I think it not a bug, but I'll close it when implement time() in the vdso
Comment 7 commit-hook freebsd_committer freebsd_triage 2022-07-04 20:44:05 UTC
A commit in branch main references this bug:

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

commit 42317e642645b36e711b5dd560d06a303a492e0f
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-07-04 20:41:32 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-07-04 20:41:32 +0000

    linux(4): Implement __vdso_time

    PR:             240769
    MFC after:      3 days

 sys/compat/linux/linux_vdso_gtod.inc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2022-07-11 21:31:10 UTC
A commit in branch stable/13 references this bug:

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

commit f8da86347070ce4b6c39a8d6ba2df53e49ec4f84
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-07-04 20:41:32 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-07-11 21:28:28 +0000

    linux(4): Implement __vdso_time

    PR:             240769
    MFC after:      3 days

    (cherry picked from commit 42317e642645b36e711b5dd560d06a303a492e0f)

 sys/compat/linux/linux_vdso_gtod.inc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Comment 9 Dmitry Chagin freebsd_committer freebsd_triage 2022-07-12 15:50:43 UTC
in stable/13