Bug 230762 - getentropy(3) should not use ENOSYS to test existence of getrandom(2)
Summary: getentropy(3) should not use ENOSYS to test existence of getrandom(2)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Xin LI
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-20 00:32 UTC by Xin LI
Modified: 2018-08-20 02:18 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xin LI freebsd_committer freebsd_triage 2018-08-20 00:32:13 UTC
Reported by Mark Millard:

-r338057 built fine for both then:

https://ci.freebsd.org/job/FreeBSD-head-amd64-testvm/9265/console

of -r338065 shows:
(so after "deprecation of arc4random_stir and arc4random_addrandom")

19:38:13 + sudo chroot ufs env 'ASSUME_ALWAYS_YES=yes' pkg update
19:38:13 Bad system call
19:38:13 Build step 'Execute shell' marked build as failure
19:38:13 FTP: Current build result is [FAILURE], not going to run.
19:38:13 [PostBuildScript] - Executing post build scripts.
19:38:13 [FreeBSD-head-amd64-testvm] $ /bin/sh -xe /tmp/jenkins7995907498943424274.sh
19:38:13 + sh freebsd-ci/scripts/jail/clean.sh
19:38:13 clean jail FreeBSD-head-amd64-testvm
19:38:41 Finished: FAILURE

instead of (from the prior successful one):

18:37:15 + sudo chroot ufs env 'ASSUME_ALWAYS_YES=yes' pkg update
18:37:15 [FreeBSD-head-amd64-testvm.jail.ci.FreeBSD.org] Installing pkg-1.10.5_1...
18:37:15 [FreeBSD-head-amd64-testvm.jail.ci.FreeBSD.org] Extracting pkg-1.10.5_1: .......... done
18:37:15 Updating FreeBSD repository catalogue...
18:37:15 pkg: Repository FreeBSD load error: access repo file(/var/db/pkg/repo-FreeBSD.sqlite) failed: No such file or directory
18:37:15 [FreeBSD-head-amd64-testvm.jail.ci.FreeBSD.org] Fetching meta.txz: . done
18:37:15 [FreeBSD-head-amd64-testvm.jail.ci.FreeBSD.org] Fetching packagesite.txz: .......... done
18:37:16 Processing entries: .......... done
18:37:25 FreeBSD repository update completed. 32107 packages processed.
18:37:25 All repositories are up to date.
. . .

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
Comment 1 Xin LI freebsd_committer freebsd_triage 2018-08-20 00:35:43 UTC
Analysis: In https://reviews.freebsd.org/D14500 I have suggested using ENOSYS to test the existence of the new entropy system call.  This will not work unless application already handles SIGSYS.

The solution is to check osreldate instead, I'll create a review soon.
Comment 2 Xin LI freebsd_committer freebsd_triage 2018-08-20 00:44:57 UTC
https://reviews.freebsd.org/D16807
Comment 3 commit-hook freebsd_committer freebsd_triage 2018-08-20 02:18:36 UTC
A commit references this bug:

Author: delphij
Date: Mon Aug 20 02:17:56 UTC 2018
New revision: 338084
URL: https://svnweb.freebsd.org/changeset/base/338084

Log:
  In r331279 the code used ENOSYS to check the existence of getrandom(2).
  This will only work if the caller already handles SIGSYS, which is not
  always the case.

  Address this by checking osreldate instead. Note that because there
  was not __FreeBSD_version bump when the system call was added, use
  1200061 (r332100) which is the first bump after the introduction of
  the system call.

  PR:		230762
  Reported by:	Jenkins via Mark Millard
  Reviewed by:	cem
  Differential Revision:	https://reviews.freebsd.org/D16807

Changes:
  head/lib/libc/gen/getentropy.c