Alternatively, we could have a full-blown --enable-msan option, but it’s more work, and I’m not convinced that it’s necessary or at least much better.
hebasto If you’re Concept ACK, are you willing to work on an equivalent PR for CMake?
real-or-random added the label
assurance
on Apr 15, 2024
real-or-random added the label
build
on Apr 15, 2024
real-or-random added the label
side-channel
on Apr 15, 2024
sipa
commented at 3:37 pm on April 15, 2024:
contributor
Concept ACK
hebasto
commented at 10:53 am on April 23, 2024:
member
Concept ACK.
@hebasto If you’re Concept ACK, are you willing to work on an equivalent PR for CMake?
Sure. I am :)
hebasto
commented at 11:45 am on April 23, 2024:
member
To have any effect, the ctime_tests_CFLAGS variable has to AC_SUBSTed.
However, to achieve the goal, the -fno-sanitize-memory-param-retval option has to be applied to the library code as well. So, I suggest:
0--- a/configure.ac
1+++ b/configure.ac
2@@ -142,7 +142,7 @@ if test "x$GCC" = "xyes"; then
3 # We need to wrap the argument in a --(start/end)-no-unused-arguments block to suppress a
4 # -Wunused-command-line-argument warning, which clang emits if MSan is not actually enabled, i.e.,
5 # if -fsanitize=memory does not appear on the command line.
6- SECP_TRY_APPEND_CFLAGS([--start-no-unused-arguments -fno-sanitize-memory-param-retval --end-no-unused-arguments], ctime_tests_CFLAGS)
7+ SECP_TRY_APPEND_CFLAGS([--start-no-unused-arguments -fno-sanitize-memory-param-retval --end-no-unused-arguments], SECP_CFLAGS)
8 fi
910 ###
real-or-random
commented at 12:13 pm on May 7, 2024:
contributor
To have any effect, the ctime_tests_CFLAGS variable has to AC_SUBSTed.
No, this seems to happen automatically. make V=1 shows me that it’s effective.
However, to achieve the goal, the -fno-sanitize-memory-param-retval option has to be applied to the library code as well.
Okay, true. Sorry, I thought I had tested this before opening a PR.
Then this is a bit annoying. Your suggestion will work for our “abuse” of MSan in the ctime_tests. But it will also disable the new eager checking behind the back of the user in the case of normal use, i.e., checking for actual memory issues.
So if we want to have both eager checking in “normal” MSan mode, and clean ctime_tests, I see no other way than having two builds (and adding a build to CI is not a problem). I think one of the following approaches will be sensible:
disable the ctime_tests if we find -fsanitize=memory or similar on the command line (but parsing this is complex in cases such as -fsanitize=unreachable,memory this may be fragile and overkill)
work with your suggestion to add this to SECP_CFLAGS, but only if constant-time tests are enabled. We could additionally print a warning that tells the users to disable the constant-time tests if they want to avoid that we add -fno-sanitize-memory-param-retval.
The second looks better to me. What do you think?
hebasto
commented at 5:00 pm on May 7, 2024:
member
To have any effect, the ctime_tests_CFLAGS variable has to AC_SUBSTed.
No, this seems to happen automatically. make V=1 shows me that it’s effective.
I mean, only ctime_tests.c is compiled with ctime_tests_CFLAGS. However, all code is needed to be compiled with -fno-sanitize-memory-param-retval.
hebasto
commented at 5:42 pm on May 7, 2024:
member
disable the ctime_tests if we find -fsanitize=memory or similar on the command line (but parsing this is complex in cases such as -fsanitize=unreachable,memory this may be fragile and overkill)
real-or-random
commented at 1:30 pm on May 22, 2024:
contributor
2. work with your suggestion to add this to SECP_CFLAGS, but only if constant-time tests are enabled. We could additionally print a warning that tells the users to disable the constant-time tests if they want to avoid that we add -fno-sanitize-memory-param-retval.
I did this, using your suggested check for msan. Also rebased. Ready for review from my side.
Note: CI is currently failing on macOS. This should be resolved once the GitHub Actions image is updated to have brew 4.3.1, which has the fix (https://github.com/Homebrew/brew/pull/17336). The images are updated every week, so the issue should just disappear in a few days.
real-or-random
commented at 2:55 pm on May 22, 2024:
contributor
Pushed another commit that adds a CI job with eager checks enabled explicitly (-fsanitize-memory-param-retval).
ci: Add job with -fsanitize-memory-param-retvalebfb82ee2f
real-or-random force-pushed
on May 26, 2024
real-or-random
commented at 12:02 pm on May 26, 2024:
contributor
Force pushed to fix a logic bug, should be really ready for review now. :)
hebasto approved
hebasto
commented at 2:07 pm on May 26, 2024:
member
ACKebfb82ee2f8c15ae6129932380b1dfb0942ea35a, tested on Ubuntu 24.04 with different clang versions (from 15 to 18) and different build configurations. CI changes look OK as well.
hebasto
commented at 2:57 pm on May 26, 2024:
member
This is a metadata mirror of the GitHub repository
bitcoin-core/secp256k1.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-11-21 11:15 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me