Bug 258211 - /usr/src/lib/libsecureboot/verify_file.c:59:22: error: use of undeclared identifier 'SOPEN_MAX'
Summary: /usr/src/lib/libsecureboot/verify_file.c:59:22: error: use of undeclared iden...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.0-STABLE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-02 13:20 UTC by O. Hartmann
Modified: 2021-09-03 20:48 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description O. Hartmann 2021-09-02 13:20:30 UTC
For a while now, 13-STABLE is not willing to build if WITH_BEARSSL is enabled in src.conf. Reporting this problem on the mailing list (CURRENT) did not have the impact I wished for, so I tried to investigate it myself.

Error:
[...]

===> libexec/rpc.sprayd (all)
--- all_subdir_stand ---
/usr/src/lib/libsecureboot/verify_file.c:59:22: error: use of undeclared identifier 'SOPEN_MAX'
static int ve_status[SOPEN_MAX+1];
                     ^
/usr/src/lib/libsecureboot/verify_file.c:74:22: error: use of undeclared identifier 'SOPEN_MAX'
        if (fd >= 0 && fd < SOPEN_MAX) {
                            ^
/usr/src/lib/libsecureboot/verify_file.c:78:12: error: use of undeclared identifier 'SOPEN_MAX'
        ve_status[SOPEN_MAX] = ves;
                  ^
/usr/src/lib/libsecureboot/verify_file.c:98:19: error: use of undeclared identifier 'SOPEN_MAX'
                fd >= 0 && fd < SOPEN_MAX)
                                ^
/usr/src/lib/libsecureboot/verify_file.c:100:20: error: use of undeclared identifier 'SOPEN_MAX'
        return (ve_status[SOPEN_MAX]);  /* most recent */
                          ^
--- all_subdir_cddl ---
--- all_subdir_cddl/lib/libzfs ---
===> cddl/lib/libzfs (all)
--- all_subdir_sbin ---
--- all_subdir_sbin/geom ---
===> sbin/geom (all)
--- all_subdir_lib ---
--- all_subdir_lib/libclang_rt/ubsan_standalone_cxx ---
===> lib/libclang_rt/ubsan_standalone_cxx (all)
--- all_subdir_stand ---
5 errors generated.
*** [verify_file.pieo] Error code 1




It seems obvious, as the comparison between recent CURRENT, where the sources build fine even with WITH_BEARSSL set and recent 13-STABLE, where world fails to build due to the error indicated above, see for yourself, the constant is undefinied in 13-STABLE:

On recent 13-STABLE:

:/usr/src # grep -r SOPEN_MAX *
lib/libsecureboot/tests/Makefile:XCFLAGS.verify_file += -DSOPEN_MAX=64
lib/libsecureboot/verify_file.c:static int ve_status[SOPEN_MAX+1];
lib/libsecureboot/verify_file.c:        if (fd >= 0 && fd < SOPEN_MAX) {
lib/libsecureboot/verify_file.c:        ve_status[SOPEN_MAX] = ves;
lib/libsecureboot/verify_file.c: *      @li ve_status[SOPEN_MAX] if ve_status_state is none
lib/libsecureboot/verify_file.c:                fd >= 0 && fd < SOPEN_MAX)
lib/libsecureboot/verify_file.c:        return (ve_status[SOPEN_MAX]);  /* most recent */


On recent CURRENT:

[...]
:/pool/sources/CURRENT/src # grep -r SOPEN_MAX *
lib/libsecureboot/verify_file.c:#ifndef SOPEN_MAX
lib/libsecureboot/verify_file.c:#define SOPEN_MAX       64
lib/libsecureboot/verify_file.c:static int ve_status[SOPEN_MAX+1];
lib/libsecureboot/verify_file.c:        if (fd >= 0 && fd < SOPEN_MAX) {
lib/libsecureboot/verify_file.c:        ve_status[SOPEN_MAX] = ves;
lib/libsecureboot/verify_file.c: *      @li ve_status[SOPEN_MAX] if ve_status_state is none
lib/libsecureboot/verify_file.c:                fd >= 0 && fd < SOPEN_MAX)
lib/libsecureboot/verify_file.c:        return (ve_status[SOPEN_MAX]);  /* most recent */
lib/libsecureboot/tests/Makefile:XCFLAGS.verify_file += -DSOPEN_MAX=64
Comment 1 commit-hook freebsd_committer 2021-09-03 20:48:02 UTC
A commit in branch stable/13 references this bug:

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

commit 343da8f5e98ffac6a7c02fc5f8dd74290e267be0
Author:     Toomas Soome <tsoome@FreeBSD.org>
AuthorDate: 2021-08-10 19:46:40 +0000
Commit:     Toomas Soome <tsoome@FreeBSD.org>
CommitDate: 2021-09-03 20:45:16 +0000

    libsecureboot: define SOPEN_MAX

    With commit 97cbd5e722389a575e820c4e03f38053308f08ea, the SOPEN_MAX
    was removed from stand.h.

    We would need better mechanism there.

    (cherry picked from commit ee6dc333e1a1af08afa3d14b83e963e4cf90b77b)

    PR:     258211

 lib/libsecureboot/verify_file.c | 3 +++
 1 file changed, 3 insertions(+)