What changed, and why it matters
This change adjusts how a specific warning/check (Undefined Behavior Sanitizer's 'shift-base' check) is handled for one cryptographic source file. It disables that sanitizer check when compiling crypto-ops.c, because that file intentionally left-shifts negative numbers as part of its math. It also removes a duplicate copy of the file from the test build. This is a build-system hygiene fix, not a patch for an exploitable vulnerability in the running code.
Treat as a build/maintenance change. If the underlying left-shift-of-negative behavior is a concern, audit crypto-ops.c for reliance on implementation-defined behavior and consider refactoring to well-defined signed/unsigned arithmetic. No urgent deployment action is indicated.
Security signals we found
Disables a sanitizer check for a source file rather than changing the source
Acknowledges left-shifting negative values in crypto-ops.c
Removes duplicated test wrapper of crypto-ops.c
No change to cryptographic constants, algorithms, or runtime behavior
Evidence from the diff
The commit adds a CMake probe for -fno-sanitize=shift-base and applies it to src/crypto/crypto-ops.c, which contains deliberate left shifts of negative signed values (e.g., carry0 << 26). That pattern is undefined behavior in C, but it is pre-existing code behavior. The commit also removes tests/crypto/crypto-ops.c, which was a thin wrapper including the same source, and drops crypto-ops.c from the test crypto_sources list. The change therefore suppresses a UBSan diagnostic rather than altering the cryptographic logic or fixing the underlying UB.
Changed components
src/crypto/CMakeLists.txttests/crypto/CMakeLists.txttests/crypto/crypto-ops.cInspect captured patch +6 / −32
### src/crypto/CMakeLists.txt
@@ -90,6 +90,12 @@ if (ARM)
endif()
endif()
+# crypto-ops.c left-shifts negative values (e.g. `carry0 << 26`)
+check_c_compiler_flag(-fno-sanitize=shift-base CC_SUPPORTS_NO_SANITIZE_SHIFT_BASE)
+if(CC_SUPPORTS_NO_SANITIZE_SHIFT_BASE)
+ set_property(SOURCE crypto-ops.c APPEND PROPERTY COMPILE_OPTIONS -fno-sanitize=shift-base)
+endif()
+
# Because of the way Qt works on android with JNI, the code does not live in the main android thread
# So this code runs with a 1 MB default stack size.
# This will force the use of the heap for the allocation of the scratchpad
### tests/crypto/CMakeLists.txt
@@ -28,7 +28,6 @@
set(crypto_sources
crypto-ops-data.c
- crypto-ops.c
crypto.cpp
hash.c
main.cpp
### tests/crypto/crypto-ops.c
@@ -1,31 +0,0 @@
-// Copyright (c) 2014-2024, The Monero Project
-//
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without modification, are
-// permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice, this list of
-// conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright notice, this list
-// of conditions and the following disclaimer in the documentation and/or other
-// materials provided with the distribution.
-//
-// 3. Neither the name of the copyright holder nor the names of its contributors may be
-// used to endorse or promote products derived from this software without specific
-// prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
-// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
-
-#include "crypto/crypto-ops.c"Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.