Closed Bug 1396301 Opened 7 years ago Closed 7 years ago

verified/kremlib.h:204:23: error: implicit declaration of function 'le64toh' [-Werror=implicit -function-declaration]

Categories

(NSS :: Libraries, defect, P3)

3.33
Unspecified
FreeBSD
defect

Tracking

(firefox-esr52 unaffected, firefox56 unaffected, firefox57 wontfix, firefox58 wontfix, firefox59 fixed)

RESOLVED FIXED
Tracking Status
firefox-esr52 --- unaffected
firefox56 --- unaffected
firefox57 --- wontfix
firefox58 --- wontfix
firefox59 --- fixed

People

(Reporter: jbeich, Unassigned)

References

Details

(Keywords: regression)

Attachments

(3 obsolete files)

In file included from ecl/curve25519_64.c:6:
In file included from ecl/../verified/hacl_curve25519_64.h:17:
verified/kremlib.h:307:30: error: implicit declaration of function 'le64toh' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    uint128_t l = (uint128_t)load64_le(b);
                             ^
verified/kremlib.h:204:23: note: expanded from macro 'load64_le'
#define load64_le(b) (le64toh(load64(b)))
                      ^
verified/kremlib.h:315:5: error: implicit declaration of function 'htole64' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    store64_le(b, (uint64_t)n);
    ^
verified/kremlib.h:205:38: note: expanded from macro 'store64_le'
#define store64_le(b, i) (store64(b, htole64(i)))
                                     ^
verified/kremlib.h:315:5: note: did you mean 'store64'?
verified/kremlib.h:205:38: note: expanded from macro 'store64_le'
#define store64_le(b, i) (store64(b, htole64(i)))
                                     ^
verified/kremlib.h:189:1: note: 'store64' declared here
store64(uint8_t *b, uint64_t i)
^
verified/kremlib.h:322:30: error: implicit declaration of function 'be64toh' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    uint128_t h = (uint128_t)load64_be(b);
                             ^
verified/kremlib.h:206:23: note: expanded from macro 'load64_be'
#define load64_be(b) (be64toh(load64(b)))
                      ^
verified/kremlib.h:322:30: note: did you mean 'le64toh'?
verified/kremlib.h:206:23: note: expanded from macro 'load64_be'
#define load64_be(b) (be64toh(load64(b)))
                      ^
verified/kremlib.h:307:30: note: 'le64toh' declared here
    uint128_t l = (uint128_t)load64_le(b);
                             ^
verified/kremlib.h:204:23: note: expanded from macro 'load64_le'
#define load64_le(b) (le64toh(load64(b)))
                      ^
verified/kremlib.h:330:5: error: implicit declaration of function 'htobe64' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    store64_be(b, (uint64_t)(n >> 64));
    ^
verified/kremlib.h:207:38: note: expanded from macro 'store64_be'
#define store64_be(b, i) (store64(b, htobe64(i)))
                                     ^
verified/kremlib.h:330:5: note: did you mean 'htole64'?
verified/kremlib.h:207:38: note: expanded from macro 'store64_be'
#define store64_be(b, i) (store64(b, htobe64(i)))
                                     ^
verified/kremlib.h:315:5: note: 'htole64' declared here
    store64_le(b, (uint64_t)n);
    ^
verified/kremlib.h:205:38: note: expanded from macro 'store64_le'
#define store64_le(b, i) (store64(b, htole64(i)))
                                     ^
4 errors generated.
BSDs provide byteswap functions via sys/endian.h. However, NSS is probably better off using compiler builtins on all platforms.
Should we add those
Jan,

What's probably easiest here is if you provide us a patch that works on BSD and also on the Tier 1 platforms we CI on, and then we can review that.
Flags: needinfo?(jbeich)
These are in the BSD headers, which are guarded via <features.h> on GNU/Linux. Last I dived into these man pages, the following two options make these functions visible on both Ubuntu 14.04 and 16.04 (and KreMLin, when used as a driver for the C compiler, enables them):

-D_BSD_SOURCE -D_DEFAULT_SOURCE

If this is to silence the warnings, then these two options might be helpful in Makefiles.
Priority: -- → P3
Unfortunately this bug breaks all https connections (at least on my FreeBSD 11-stable box). Attaching a band-aid patch in case some desperate soul's looking for a workaround. Oh, and I hope I got the OpenBSD part right...
Ooops!
v2 needed to wipe out a typo affecting DragonflyBSD.
Sorry for the bugspam.
Attachment #8915751 - Attachment is obsolete: true
The original version of this file is located at https://github.com/FStarLang/kremlin/blob/master/kremlib/kremlib.h ... would you mind submitting a pull request there? We added support for Solaris this week, so I'd be happy to take in proper support for the BSDs as well.

Thanks!
Comment on attachment 8915757 [details] [diff] [review]
band-aid patch to fix ssl/tls on the BSDs for now

Sorry for accidentally mixing up the BSD patch with the Windows block.
Attachment #8915757 - Attachment is obsolete: true
Upstream fix looks fine given it's similar to downstream one:
https://svnweb.freebsd.org/ports/head/security/nss/files/patch-bug1396301?revision=450203&view=markup

What we're waiting for to backport it into NSS?
Flags: needinfo?(jbeich) → needinfo?(franziskuskiefer)
Great, first splinter, then mozreview, then github, then phabricator :)

(In reply to Benjamin Beurdouche from comment #11)
> Does this look good ?
> https://phabricator.services.mozilla.com/D141

Not 100% for OpenBSD, as i already said in https://github.com/FStarLang/kremlin/pull/62#discussion_r143208459 (and quoting the header itself)

 * This file should be included as <endian.h> in userspace and as
 * <sys/endian.h> in the kernel.
Fixed by using the fix from upstream Kremlin, can you check again please ?
Even if i havent built-tested any of this (nor experienced the build failure reported in this bug) this looks good to me for OpenBSD.
(In reply to Benjamin Beurdouche from comment #11)
> Does this look good ?
> https://phabricator.services.mozilla.com/D141

Yes. Replacing downstream patch with this one doesn't break build on FreeBSD.
Example build log: http://sprunge.us/PcjE
This isn't a simple import (yet). We might land a hotfix and get the upstream changes later (depending on which one's done first).
Flags: needinfo?(franziskuskiefer)
For Firefox this doesn't break build but https:// no longer works. Nightly (and even Beta now) cannot use --with-system-nss due to Gecko chasing NSS trunk and depending on unstable API (e.g., SSL_UseAltHandshakeType).
needinfo myself to request tracking for Firefox ESR59 as Tor Browser (only tracks ESR) users may want to avoid --with-system-nss per

https://gitweb.torproject.org/tor-browser.git/commit/?id=76cee7a86e72
https://gitweb.torproject.org/tor-browser.git/commit/?id=e57fa6f6f8fd
Flags: needinfo?(jbeich)
(In reply to Jan Beich from comment #17)
> For Firefox this doesn't break build but https:// no longer works. Nightly
> (and even Beta now) cannot use --with-system-nss due to Gecko chasing NSS
> trunk and depending on unstable API (e.g., SSL_UseAltHandshakeType).

I am not exactly sure to understand the discussion about API here nor how the breakage is done.
Can you please expand ? Is it just that additional compilation flags are passed to NSS ?

The current plan is to push the fix with the new iteration of HACL* by early
December for integration in NSS 3.35/Firefox 59.
The API discussion is unrelated to this bug.
This should be fixed by https://bugzilla.mozilla.org/show_bug.cgi?id=1419173
Can you please confirm ? Thanks
I confirm, Nightly 59 builds/works fine with bundled NSS.
Flags: needinfo?(jbeich)
https://hg.mozilla.org/projects/nss/diff/6a27e4b4c92c/lib/freebl/verified/kremlib.h#l1.300
Status: NEW → RESOLVED
Closed: 7 years ago
Depends on: 1419173
Resolution: --- → FIXED
Err, that change didn't land in Nightly 59 yet. https:// works but always says "connection is not secure", even for sites using EV.
Comment on attachment 8940788 [details]
Backporting KreMLin support for BSDs

Martin Thomson [:mt:] has approved the revision.

https://phabricator.services.mozilla.com/D141
Attachment #8940788 - Attachment is obsolete: true
Attachment #8940788 - Flags: review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: