Bug 3276 - Missing SC_ALLOW(__NR_fstatat64) for ix86 + glibc 2.33 when OpenSSL not using getrandom()
Summary: Missing SC_ALLOW(__NR_fstatat64) for ix86 + glibc 2.33 when OpenSSL not using...
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 8.5p1
Hardware: ix86 Linux
: P5 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_8_6
  Show dependency treegraph
 
Reported: 2021-03-11 08:50 AEDT by Kris Karas
Modified: 2021-04-23 15:09 AEST (History)
1 user (show)

See Also:


Attachments
Patch to fix this issue. (388 bytes, patch)
2021-03-11 08:50 AEDT, Kris Karas
no flags Details | Diff
Updated patch, seems to work fine (338 bytes, patch)
2021-03-12 15:56 AEDT, Kris Karas
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kris Karas 2021-03-11 08:50:58 AEDT
Created attachment 3478 [details]
Patch to fix this issue.

This is a follow on to #3260, opened as a new issue at Darren Tucker's suggestion.  (I had emailed him, so will copy a rework of that email here.)

I have a i686 Linux VM that I use for building 32-bit.  Upgraded to glibc 2.33, and encountered SIGSYS as others reported.  The newest 8.5p1 with the fixes from #3260 works fine, if one uses a standard configuration of OpenSSL as likely shipped by the OS distro.  But when fixing a "feature" of OpenSSL that causes non-blocking reads to block, one additional syscall is required in addition to those addressed by #3260.  I'll upload a trivial 3-liner fix.

OpenSSL has a feature that allows user code to specify the source of entropy used, usually /dev/random or /dev/urandom on *nix.  Recent OpenSSL checks whether glibc supports the getrandom(2) call, and if so, uses it; but in doing so, it ignores and bypasses the user's specified source of entropy.  In particular, when reading random bytes in non-blocking mode, getrandom() will block until the kernel's entropy pool has "initialized."  On a VM in a quiet isolated network, that can take up to several minutes in my experience, causing SSH connections to a newly booted machine to hang for the duration.  (Other services, e.g. www, smtp, are of course similarly affected.)

I "fixed" this locally by fooling OpenSSL's configure script to ignore the getrandom() call entirely, using only the entropy sources specified by user code.  Works wonderfully!  But, it evidently uses one syscall not used when getrandom() is called, and that is __NR_fstatat64.  When OpenSSH is patched to allow that syscall, sshd will once again permit incoming connections.
Comment 1 Darren Tucker 2021-03-12 13:37:05 AEDT
Does the call need to succeed, or would allowing the call to fail with EACCES be sufficient?  ie

SC_DENY(__NR_fstatat64), EACCES),

similar to the other *stat* calls in that file?
Comment 2 Kris Karas 2021-03-12 15:56:44 AEDT
Created attachment 3480 [details]
Updated patch, seems to work fine

Interesting theory, to label a required syscall as a "deny".  Counterintuitive, so I didn't try that before.

However, just tested the update, attached as a patch, and it works fine as a deny.  Seems safer, though I'd be happier if I knew the odd mechanics there.
Comment 3 Darren Tucker 2021-03-12 16:06:16 AEDT
Thanks for the report and patch.  It's been applied and will be in the next release.
Comment 4 Kris Karas 2021-03-12 16:20:29 AEDT
Terrific.  Thanks.
Comment 5 Damien Miller 2021-04-23 15:09:41 AEST
closing resolved bugs as of 8.6p1 release