Bug 2083876

Summary: -Wimplicit-function-declaration when compiling FIPS_mode() function with clang
Product: [Fedora] Fedora Reporter: Tom Stellard <tstellar>
Component: opensslAssignee: Dmitry Belyavskiy <dbelyavs>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 36CC: crypto-team, dbelyavs, fweimer, mspacek, mturk, sahana, sam, tm
Target Milestone: ---Keywords: Reopened, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openssl-3.0.7-2.fc38 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2083879 (view as bug list) Environment:
Last Closed: 2023-01-05 11:05:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2137512, 2083879    

Description Tom Stellard 2022-05-10 21:29:43 UTC
Description of problem:
The new FIPS_mode() macros expands to EVP_default_properties_is_fips_enabled() which has a declaration in a different header file.  This causes clang to emit the -Wimplicit-function-declaration warning when compiling applications that use the macro.

Version-Release number of selected component (if applicable):
openssl-3.0.2-5.fc36

How reproducible:
Always

Steps to Reproduce:

$ dnf install clang openssl-devel
$ cat fips-clang.c
#include <stdio.h>
#include <openssl/fips.h>

int main(int argc, char **argv) {
  if (FIPS_mode())
    printf("FIPS mode enabled\n");
  return 0;
}

$ clang -Werror clang-fips.c 
clang-fips.c:5:7: error: implicit declaration of function 'EVP_default_properties_is_fips_enabled' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  if (FIPS_mode())
      ^
/usr/include/openssl/fips.h:20:22: note: expanded from macro 'FIPS_mode'
# define FIPS_mode() EVP_default_properties_is_fips_enabled(NULL)
                     ^
1 error generated.


Expected results:
Program compiles successfully.

Comment 1 Dmitry Belyavskiy 2022-10-11 12:32:10 UTC
-Werror is not default compilation option, clang is not default compiler, and workaround exists. So closing.

Comment 2 Florian Weimer 2022-12-12 10:15:48 UTC
Sorry, this hasn't been valid C for over 20 years and needs to be fixed.

Comment 3 Dmitry Belyavskiy 2022-12-12 10:25:37 UTC
NP as I fixed a similar bug for RHEL

Comment 4 Fedora Update System 2023-01-05 11:04:46 UTC
FEDORA-2023-68886f4451 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-68886f4451

Comment 5 Fedora Update System 2023-01-05 11:05:21 UTC
FEDORA-2023-68886f4451 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.