From 2d977600de0229a9cd788616bc807dcd20b53700 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Mon, 9 Sep 2024 15:07:06 +0000 Subject: [PATCH 01/28] DAOS-16501 build: Add libsanitize TODO Required-githooks: true Signed-off-by: Cedric Koch-Hofer --- ci/unit/required_packages.sh | 1 + site_scons/components/__init__.py | 9 +++- site_scons/prereq_tools/base.py | 1 + site_scons/site_tools/compiler_setup.py | 42 ++++++++++++++++++- src/SConscript | 4 +- src/client/dfs/SConscript | 2 +- src/control/SConscript | 2 + utils/ansible/ftest/templates/daos-make.sh.j2 | 17 ++++---- utils/ansible/ftest/vars/Rocky8.yml | 3 ++ utils/build.config | 3 +- utils/rpms/daos.spec | 13 +++++- utils/scripts/install-el8.sh | 1 + utils/scripts/install-el9.sh | 1 + utils/scripts/install-leap15.sh | 1 + utils/scripts/install-ubuntu.sh | 1 + utils/sl/fake_scons/SCons/Script/__init__.py | 10 ++--- 16 files changed, 91 insertions(+), 20 deletions(-) diff --git a/ci/unit/required_packages.sh b/ci/unit/required_packages.sh index ff5e3f98d14..351e32bf6cd 100755 --- a/ci/unit/required_packages.sh +++ b/ci/unit/required_packages.sh @@ -16,6 +16,7 @@ pkgs="argobots \ fuse3-libs \ gotestsum \ hwloc-devel \ + libasn \ libipmctl-devel \ libisa-l-devel \ libfabric-devel \ diff --git a/site_scons/components/__init__.py b/site_scons/components/__init__.py index ed50b80461b..dd738bb6ad8 100644 --- a/site_scons/components/__init__.py +++ b/site_scons/components/__init__.py @@ -277,7 +277,14 @@ def define_components(reqs): abt_build = ['./configure', '--prefix=$ARGOBOTS_PREFIX', 'CC=gcc', - '--enable-stack-unwind'] + '--enable-stack-unwind=yes'] + try: + if reqs.get_env('SANITIZERS') != "": + # XXX Asan add some extra info on the stack and thus ULTs a bigger stack + print("Increase argobots default stack size from 16384 to 32768") + abt_build += ['--enable-default-stacksize=32768'] + except KeyError: + pass if reqs.target_type == 'debug': abt_build.append('--enable-debug=most') diff --git a/site_scons/prereq_tools/base.py b/site_scons/prereq_tools/base.py index 0f47bd68a9a..50c6c874bbd 100644 --- a/site_scons/prereq_tools/base.py +++ b/site_scons/prereq_tools/base.py @@ -456,6 +456,7 @@ def __init__(self, env, opts): ['gcc', 'covc', 'clang', 'icc'], ignorecase=2)) opts.Add(EnumVariable('WARNING_LEVEL', "Set default warning level", 'error', ['warning', 'warn', 'error'], ignorecase=2)) + opts.Add(('SANITIZERS', 'Instrument C code with google sanitizers', None)) opts.Update(self.__env) diff --git a/site_scons/site_tools/compiler_setup.py b/site_scons/site_tools/compiler_setup.py index 9f25ccace71..155639d944e 100644 --- a/site_scons/site_tools/compiler_setup.py +++ b/site_scons/site_tools/compiler_setup.py @@ -2,6 +2,7 @@ from SCons.Script import Configure, Exit, GetOption +FRAME_SIZE_MAX = 4096 DESIRED_FLAGS = ['-fstack-usage', '-Wno-sign-compare', '-Wno-unused-parameter', @@ -13,7 +14,7 @@ '-Wno-unused-command-line-argument', '-Wmismatched-dealloc', '-Wfree-nonheap-object', - '-Wframe-larger-than=4096'] + f"-Wframe-larger-than={FRAME_SIZE_MAX}"] # Compiler flags to prevent optimizing out security checks DESIRED_FLAGS.extend(['-fno-strict-overflow', '-fno-delete-null-pointer-checks', '-fwrapv']) @@ -54,6 +55,25 @@ def _base_setup(env): env.AppendIfSupported(CCFLAGS=DESIRED_FLAGS) + if 'SANITIZERS' in env and env['SANITIZERS'] != "": + for flag in [f"-Wframe-larger-than={FRAME_SIZE_MAX}", '-fomit-frame-pointer']: + if flag in env["CCFLAGS"]: + env["CCFLAGS"].remove(flag) + cc_flags = [f"-Wframe-larger-than={max(8192, FRAME_SIZE_MAX)}", + '-fno-omit-frame-pointer', + '-fno-common'] + + asan_flags = [] + for sanitizer in env['SANITIZERS'].split(','): + asan_flags.append(f"-fsanitize={sanitizer}") + + env.AppendIfSupported(CCFLAGS=cc_flags + asan_flags) + + for flag in asan_flags: + if flag in env["CCFLAGS"]: + env.AppendUnique(LINKFLAGS=flag) + print(f"Enabling {flag.split('=')[1]} sanitizer for C code") + if '-Wmismatched-dealloc' in env['CCFLAGS']: env.AppendUnique(CPPDEFINES={'HAVE_DEALLOC': '1'}) @@ -183,10 +203,30 @@ def _set_fortify_level(env): Exit(1) +def _check_func(env, func_name): + """Check if a function is usable""" + denv = env.Clone() + # NOTE Remove sanitizers to not scramble the test output + if 'SANITIZERS' in denv and denv['SANITIZERS'] != "": + for sanitizer in denv['SANITIZERS'].split(','): + flag = f"-fsanitize={sanitizer}" + if flag not in denv["CCFLAGS"]: + continue + denv["CCFLAGS"].remove(flag) + denv["LINKFLAGS"].remove(flag) + + config = Configure(denv) + res = config.CheckFunc(func_name) + config.Finish() + + return res + + def generate(env): """Add daos specific method to environment""" env.AddMethod(_base_setup, 'compiler_setup') env.AddMethod(_append_if_supported, "AppendIfSupported") + env.AddMethod(_check_func, "CheckFunc") def exists(_env): diff --git a/src/SConscript b/src/SConscript index 2741e6c93e1..65992cf500d 100644 --- a/src/SConscript +++ b/src/SConscript @@ -76,12 +76,10 @@ def scons(): base_env_mpi.AppendUnique(CPPPATH=[Dir('include')]) if not env.GetOption('clean') and not env.GetOption('help'): - conf = env.Clone().Configure() # Detect if we have explicit_bzero - if not conf.CheckFunc('explicit_bzero'): + if not env.CheckFunc('explicit_bzero'): env.Append(CCFLAGS=['-DNEED_EXPLICIT_BZERO']) base_env.Append(CCFLAGS=['-DNEED_EXPLICIT_BZERO']) - conf.Finish() for header in HEADERS: env.Install(os.path.join('$PREFIX', 'include'), os.path.join('include', header)) diff --git a/src/client/dfs/SConscript b/src/client/dfs/SConscript index 5b98d6d7e8a..faa84a79fbe 100644 --- a/src/client/dfs/SConscript +++ b/src/client/dfs/SConscript @@ -18,7 +18,7 @@ def configure_lustre(denv): _print("No installed Lustre version detected") else: _print("Installed Lustre version detected") - if not conf.CheckFunc('llapi_unlink_foreign'): + if not denv.CheckFunc('llapi_unlink_foreign'): _print("Lustre version is not compatible") else: _print("Lustre version is compatible") diff --git a/src/control/SConscript b/src/control/SConscript index 06410fee53a..efb586cfccb 100644 --- a/src/control/SConscript +++ b/src/control/SConscript @@ -36,6 +36,8 @@ def get_build_flags(benv): """Return string of build flags""" if is_release_build(benv): return '-buildmode=pie' + if 'SANITIZERS' in benv and benv['SANITIZERS'] != "": + return '-asan' # enable race detector for non-release builds return '-race' diff --git a/utils/ansible/ftest/templates/daos-make.sh.j2 b/utils/ansible/ftest/templates/daos-make.sh.j2 index e1bde6a59b5..838d5c38062 100644 --- a/utils/ansible/ftest/templates/daos-make.sh.j2 +++ b/utils/ansible/ftest/templates/daos-make.sh.j2 @@ -115,7 +115,7 @@ function check_cmds function usage { cat <<- EOF - usage: daos-make.sh [OPTIONS] + usage: daos-make.sh [OPTIONS] [-- ARGS] Build and install DAOS for running avocado functional tests @@ -221,17 +221,20 @@ run $PIP_EXE install --upgrade pip run $PIP_EXE install -r "$DAOS_SOURCE_DIR/requirements.txt" SCONS_OPTS="--directory="$DAOS_SOURCE_DIR" --jobs=$JOBS_NB" +if "$FORCE_INSTALL" ; then + SCONS_OPTS+=" --config=force" +fi if "$DAOS_BUILD_DEPS" ; then info "Building DAOS dependencies from source tree $DAOS_SOURCE_DIR" - if ! run "$SCONS_EXE" BUILD_TYPE="$DAOS_BUILD_TYPE" PREFIX="$DAOS_INSTALL_DIR" $SCONS_OPTS --build-deps=only ; then + if ! run "$SCONS_EXE" BUILD_TYPE="$DAOS_BUILD_TYPE" PREFIX="$DAOS_INSTALL_DIR" "${args[@]}" $SCONS_OPTS --build-deps=only ; then fatal "DAOS dependencies could not be properly build" fi fi info "Building DAOS from source tree $DAOS_SOURCE_DIR" # NOTE Dependencies will not be build as 'no' is default value of the --build-deps option -if ! run env MPI_PKG=any "$SCONS_EXE" BUILD_TYPE="$DAOS_BUILD_TYPE" PREFIX="$DAOS_INSTALL_DIR" $SCONS_OPTS ; then +if ! run env MPI_PKG=any "$SCONS_EXE" BUILD_TYPE="$DAOS_BUILD_TYPE" PREFIX="$DAOS_INSTALL_DIR" "${args[@]}" $SCONS_OPTS ; then fatal "DAOS could not be properly build" fi @@ -275,10 +278,10 @@ run $CLUSH_EXE $CLUSH_OPTS -l root -w $CLIENTS_LIST chmod 755 /usr/bin/dfuse info "Updating dynamic linker configuration" {% if "daos_clients" in groups and groups["daos_clients"] | length > 0 %} run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig +run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv {% else %} run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig +run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv {% endif %} if [[ ${MPICH_PATH:+x} ]] ; then @@ -627,8 +630,8 @@ fi info "Updating dynamic linker configuration" {% if "daos_clients" in groups and groups["daos_clients"] | length > 0 %} run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig +run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv {% else %} run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig +run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv {% endif %} diff --git a/utils/ansible/ftest/vars/Rocky8.yml b/utils/ansible/ftest/vars/Rocky8.yml index bc4d5dccd57..e5c01deae85 100644 --- a/utils/ansible/ftest/vars/Rocky8.yml +++ b/utils/ansible/ftest/vars/Rocky8.yml @@ -11,6 +11,7 @@ daos_base_deps: - glibc - jq - lbzip2 + - libasan - numactl - numactl-libs - numatop @@ -33,6 +34,7 @@ daos_dev_deps: - gcc-c++ - gcc-gfortran - golang + - hdf5-devel - libaec-devel - libattr-devel - libcmocka-devel @@ -40,6 +42,7 @@ daos_dev_deps: - libyaml-devel - openssl-devel - pciutils-devel + - protobuf-c-devel - python3.11 - python3.11-devel - python3-clustershell diff --git a/utils/build.config b/utils/build.config index c38d49a267a..38025a2db9c 100644 --- a/utils/build.config +++ b/utils/build.config @@ -2,7 +2,7 @@ component=daos [commit_versions] -argobots=v1.1 +argobots=v1.2 fuse=fuse-3.16.2 pmdk=2.0.0 isal=v2.30.0 @@ -30,3 +30,4 @@ spdk=https://github.com/spdk/spdk/commit/b0aba3fcd5aceceea530a702922153bc7566497 ofi=https://github.com/ofiwg/libfabric/commit/d827c6484cc5bf67dfbe395890e258860c3f0979.diff fuse=https://github.com/libfuse/libfuse/commit/c9905341ea34ff9acbc11b3c53ba8bcea35eeed8.diff mercury=https://raw.githubusercontent.com/daos-stack/mercury/481297621bafbbcac4cc6f8feab3f1b6f8b14b59/na_ucx_keyres_epchk.patch +argobots=https://github.com/pmodels/argobots/pull/397/commits/411e5b344642ebc82190fd8b125db512e5b449d1.diff,https://github.com/pmodels/argobots/commit/bb0c908abfac4bfe37852eee621930634183c6aa.diff diff --git a/utils/rpms/daos.spec b/utils/rpms/daos.spec index f90e6d7010f..b7dc1aadbc1 100644 --- a/utils/rpms/daos.spec +++ b/utils/rpms/daos.spec @@ -15,7 +15,7 @@ Name: daos Version: 2.7.100 -Release: 5%{?relval}%{?dist} +Release: 6%{?relval}%{?dist} Summary: DAOS Storage Engine License: BSD-2-Clause-Patent @@ -121,6 +121,14 @@ BuildRequires: libuct-devel BuildRequires: ucx-devel %endif +# Needed for debugging tasks +%if (0%{?rhel} >= 8) +BuildRequires: libasan +%endif +%if (0%{?suse_version} > 0) +BuildRequires: libasan8 +%endif +% Requires: openssl # This should only be temporary until we can get a stable upstream release # of mercury, at which time the autoprov shared library version should @@ -592,6 +600,9 @@ getent passwd daos_agent >/dev/null || useradd -s /sbin/nologin -r -g daos_agent # No files in a shim package %changelog +* Fri Sep 06 2024 Cedric Koch-Hofer 2.7.100-6 +- Add support of the libasan + * Thu Aug 15 2024 Michael MacDonald 2.7.100-5 - Add libdaos_self_test.so to client RPM diff --git a/utils/scripts/install-el8.sh b/utils/scripts/install-el8.sh index 81a044bfddb..180455b996b 100755 --- a/utils/scripts/install-el8.sh +++ b/utils/scripts/install-el8.sh @@ -36,6 +36,7 @@ dnf --nodocs install \ java-1.8.0-openjdk \ json-c-devel \ libaio-devel \ + libasan \ libcmocka-devel \ libevent-devel \ libiscsi-devel \ diff --git a/utils/scripts/install-el9.sh b/utils/scripts/install-el9.sh index 9ddd8c257d6..ab73ee71a6e 100755 --- a/utils/scripts/install-el9.sh +++ b/utils/scripts/install-el9.sh @@ -35,6 +35,7 @@ dnf --nodocs install \ java-1.8.0-openjdk \ json-c-devel \ libaio-devel \ + libasan \ libcmocka-devel \ libevent-devel \ libipmctl-devel \ diff --git a/utils/scripts/install-leap15.sh b/utils/scripts/install-leap15.sh index fc9826ce508..deebe1e50e2 100755 --- a/utils/scripts/install-leap15.sh +++ b/utils/scripts/install-leap15.sh @@ -31,6 +31,7 @@ dnf --nodocs install \ hwloc-devel \ java-1_8_0-openjdk-devel \ libaio-devel \ + libasan8 \ libcmocka-devel \ libcapstone-devel \ libevent-devel \ diff --git a/utils/scripts/install-ubuntu.sh b/utils/scripts/install-ubuntu.sh index ec21c92f474..4f40eee161e 100755 --- a/utils/scripts/install-ubuntu.sh +++ b/utils/scripts/install-ubuntu.sh @@ -25,6 +25,7 @@ apt-get install \ golang-go \ kmod \ libaio-dev \ + libasan8 \ libboost-dev \ libcapstone-dev \ libcmocka-dev \ diff --git a/utils/sl/fake_scons/SCons/Script/__init__.py b/utils/sl/fake_scons/SCons/Script/__init__.py index f490ba78cbe..19a8884620b 100644 --- a/utils/sl/fake_scons/SCons/Script/__init__.py +++ b/utils/sl/fake_scons/SCons/Script/__init__.py @@ -1,5 +1,5 @@ """Fake scons environment shutting up pylint on SCons files""" -# Copyright 2016-2023 Intel Corporation +# Copyright 2016-2024 Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -338,6 +338,10 @@ def require(self, env, *kw, headers_only=False): """Fake require""" return + def CheckFunc(self, *_args, **_kw): + """Fake CheckFunc""" + return True + class Variables(): """Fake variables""" @@ -396,10 +400,6 @@ def CheckProg(self, *_args, **_kw): """Fake CheckProg""" return True - def CheckFunc(self, *_args, **_kw): - """Fake CheckFunc""" - return True - def CheckFlag(self, *_args, **_kw): """Fake CheckFlag""" return True From ce48861afb63168da31c2fc59f094719b008e9f7 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Mon, 9 Sep 2024 15:07:06 +0000 Subject: [PATCH 02/28] DAOS-16501 build: Add libsanitize Miscelleneaous fixe\s. Required-githooks: true Signed-off-by: Cedric Koch-Hofer --- site_scons/components/__init__.py | 3 ++- utils/rpms/daos.spec | 2 +- utils/sl/fake_scons/SCons/Script/__init__.py | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/site_scons/components/__init__.py b/site_scons/components/__init__.py index dd738bb6ad8..a83a040ddba 100644 --- a/site_scons/components/__init__.py +++ b/site_scons/components/__init__.py @@ -280,7 +280,8 @@ def define_components(reqs): '--enable-stack-unwind=yes'] try: if reqs.get_env('SANITIZERS') != "": - # XXX Asan add some extra info on the stack and thus ULTs a bigger stack + # NOTE the address sanitizer library add some extra info on the stack and thus ULTs + # need a bigger stack print("Increase argobots default stack size from 16384 to 32768") abt_build += ['--enable-default-stacksize=32768'] except KeyError: diff --git a/utils/rpms/daos.spec b/utils/rpms/daos.spec index b7dc1aadbc1..56038fe57b9 100644 --- a/utils/rpms/daos.spec +++ b/utils/rpms/daos.spec @@ -128,7 +128,7 @@ BuildRequires: libasan %if (0%{?suse_version} > 0) BuildRequires: libasan8 %endif -% + Requires: openssl # This should only be temporary until we can get a stable upstream release # of mercury, at which time the autoprov shared library version should diff --git a/utils/sl/fake_scons/SCons/Script/__init__.py b/utils/sl/fake_scons/SCons/Script/__init__.py index 19a8884620b..22a184be38d 100644 --- a/utils/sl/fake_scons/SCons/Script/__init__.py +++ b/utils/sl/fake_scons/SCons/Script/__init__.py @@ -400,6 +400,10 @@ def CheckProg(self, *_args, **_kw): """Fake CheckProg""" return True + def CheckFunc(self, *_args, **_kw): + """Fake CheckFunc""" + return True + def CheckFlag(self, *_args, **_kw): """Fake CheckFlag""" return True From b39845905010d4475f21f56b88868d9ac22d17f5 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Mon, 9 Sep 2024 15:07:06 +0000 Subject: [PATCH 03/28] DAOS-16501 build: Add libsanitize Update to argobots 1.2 PR-repos: argobots@PR-20 Required-githooks: true Signed-off-by: Cedric Koch-Hofer --- utils/rpms/daos.spec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/rpms/daos.spec b/utils/rpms/daos.spec index 56038fe57b9..678c45d6055 100644 --- a/utils/rpms/daos.spec +++ b/utils/rpms/daos.spec @@ -15,7 +15,7 @@ Name: daos Version: 2.7.100 -Release: 6%{?relval}%{?dist} +Release: 7%{?relval}%{?dist} Summary: DAOS Storage Engine License: BSD-2-Clause-Patent @@ -41,7 +41,7 @@ BuildRequires: hwloc-devel BuildRequires: bullseye %endif %if (0%{?rhel} >= 8) -BuildRequires: argobots-devel >= 1.1 +BuildRequires: argobots-devel >= 1.2 BuildRequires: json-c-devel BuildRequires: boost-python3-devel %else @@ -600,7 +600,8 @@ getent passwd daos_agent >/dev/null || useradd -s /sbin/nologin -r -g daos_agent # No files in a shim package %changelog -* Fri Sep 06 2024 Cedric Koch-Hofer 2.7.100-6 +* Tue Sep 10 2024 Cedric Koch-Hofer 2.7.100-6 +- Update argobots to 1.2 - Add support of the libasan * Thu Aug 15 2024 Michael MacDonald 2.7.100-5 From 7e9f33984b98cc1331eb56829f75f4c819b62708 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Mon, 9 Sep 2024 15:07:06 +0000 Subject: [PATCH 04/28] DAOS-16501 build: Add libsanitize Fix reviewers comments: - Invalid pacakge nam PR-repos: argobots@PR-26:12 Required-githooks: true Signed-off-by: Cedric Koch-Hofer --- ci/unit/required_packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/unit/required_packages.sh b/ci/unit/required_packages.sh index 351e32bf6cd..efbd48be545 100755 --- a/ci/unit/required_packages.sh +++ b/ci/unit/required_packages.sh @@ -16,7 +16,7 @@ pkgs="argobots \ fuse3-libs \ gotestsum \ hwloc-devel \ - libasn \ + libasan \ libipmctl-devel \ libisa-l-devel \ libfabric-devel \ From 430daf607a43bc8ce6a0e54ec248f3a419fed39a Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Mon, 9 Sep 2024 15:07:06 +0000 Subject: [PATCH 05/28] DAOS-16501 build: Add libsanitize Miscellaneous fixes. Required-githooks: true Signed-off-by: Cedric Koch-Hofer --- .../ansible/ftest/templates/daos-launch.sh.j2 | 2 +- utils/ansible/ftest/templates/daos-make.sh.j2 | 30 +++++-------------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/utils/ansible/ftest/templates/daos-launch.sh.j2 b/utils/ansible/ftest/templates/daos-launch.sh.j2 index cdf7fe6704b..d9e6bf2f9c3 100644 --- a/utils/ansible/ftest/templates/daos-launch.sh.j2 +++ b/utils/ansible/ftest/templates/daos-launch.sh.j2 @@ -175,7 +175,7 @@ function cleanup mountpoint="/mnt/daos$index" if run ssh $host sudo mountpoint -q "$mountpoint" ; then info "Cleaning mount points $mountpoint of host $host" - run ssh $host sudo m -fr $mountpoint/* + run ssh $host sudo rm -fr $mountpoint/* run ssh $host sudo umount $mountpoint fi done diff --git a/utils/ansible/ftest/templates/daos-make.sh.j2 b/utils/ansible/ftest/templates/daos-make.sh.j2 index eb314316e67..fd036ca3bb7 100644 --- a/utils/ansible/ftest/templates/daos-make.sh.j2 +++ b/utils/ansible/ftest/templates/daos-make.sh.j2 @@ -169,7 +169,7 @@ do -v|--verbose) TRACE_LEVEL=$TRACE_LEVEL_VERBOSE ; shift 1 ;; -D|--debug) TRACE_LEVEL=$TRACE_LEVEL_DEBUG ; set -x ; shift 1 ;; -q|--quiet) TRACE_LEVEL=$TRACE_LEVEL_QUIET ; shift 1 ;; - --) shift ; break ;; + --) shift 1 ; args=("$@") ; break ;; *) fatal "unrecognized command line option: $1" ;; esac done @@ -218,14 +218,14 @@ fi if "$DAOS_BUILD_DEPS" ; then info "Building DAOS dependencies from source tree $DAOS_SOURCE_DIR" - if ! run "$SCONS_EXE" BUILD_TYPE="$DAOS_BUILD_TYPE" BUILD_ROOT="$DAOS_BUILD_DIR" PREFIX="$DAOS_INSTALL_DIR" $SCONS_OPTS --build-deps=only ; then + if ! run "$SCONS_EXE" BUILD_TYPE="$DAOS_BUILD_TYPE" BUILD_ROOT="$DAOS_BUILD_DIR" PREFIX="$DAOS_INSTALL_DIR" "${args[@]}" $SCONS_OPTS --build-deps=only ; then fatal "DAOS dependencies could not be properly build" fi fi info "Building DAOS from source tree $DAOS_SOURCE_DIR" # NOTE Dependencies will not be build as 'no' is default value of the --build-deps option -if ! run env MPI_PKG=any "$SCONS_EXE" BUILD_TYPE="$DAOS_BUILD_TYPE" BUILD_ROOT="$DAOS_BUILD_DIR" PREFIX="$DAOS_INSTALL_DIR" $SCONS_OPTS ; then +if ! run env MPI_PKG=any "$SCONS_EXE" BUILD_TYPE="$DAOS_BUILD_TYPE" BUILD_ROOT="$DAOS_BUILD_DIR" PREFIX="$DAOS_INSTALL_DIR" "${args[@]}" $SCONS_OPTS ; then fatal "DAOS could not be properly build" fi @@ -268,19 +268,11 @@ run $CLUSH_EXE $CLUSH_OPTS -w $CLIENTS_LIST sudo chmod 755 /usr/bin/dfuse info "Updating dynamic linker configuration" {% if "daos_clients" in groups and groups["daos_clients"] | length > 0 %} -<<<<<<< HEAD -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv -{% else %} -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv -======= run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST -w $CLIENTS_LIST sudo rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST -w $CLIENTS_LIST sudo ldconfig +run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST -w $CLIENTS_LIST sudo ldconfig "$DAOS_INSTALL_DIR/lib64" "$DAOS_INSTALL_DIR/lib64/daos_srv" {% else %} run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST sudo rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST sudo ldconfig ->>>>>>> origin/master +run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST sudo ldconfig "$DAOS_INSTALL_DIR/lib64" "$DAOS_INSTALL_DIR/lib64/daos_srv" {% endif %} if [[ ${MPICH_PATH:+x} ]] ; then @@ -628,17 +620,9 @@ fi info "Updating dynamic linker configuration" {% if "daos_clients" in groups and groups["daos_clients"] | length > 0 %} -<<<<<<< HEAD -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv -{% else %} -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv -======= run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST -w $CLIENTS_LIST sudo rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST -w $CLIENTS_LIST sudo ldconfig +run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST -w $CLIENTS_LIST sudo ldconfig "$DAOS_INSTALL_DIR/lib64" "$DAOS_INSTALL_DIR/lib64/daos_srv" {% else %} run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST sudo rm -f /etc/ld.so.cache -run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST sudo ldconfig ->>>>>>> origin/master +run $CLUSH_EXE $CLUSH_OPTS -w $SERVERS_LIST sudo ldconfig "$DAOS_INSTALL_DIR/lib64" "$DAOS_INSTALL_DIR/lib64/daos_srv" {% endif %} From 3e7f27252f2c3fdb0903c0d7f58270244bddf7f5 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 06/28] DAOS-16501 build: Add libsanitize Integrate reviewers comments: - Do not update the daos.spec file Signed-off-by: Cedric Koch-Hofer --- utils/rpms/daos.spec | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/utils/rpms/daos.spec b/utils/rpms/daos.spec index 51fd49c63ae..e9de33b41c7 100644 --- a/utils/rpms/daos.spec +++ b/utils/rpms/daos.spec @@ -16,7 +16,7 @@ Name: daos Version: 2.7.101 -Release: 3%{?relval}%{?dist} +Release: 2%{?relval}%{?dist} Summary: DAOS Storage Engine License: BSD-2-Clause-Patent @@ -598,9 +598,6 @@ getent passwd daos_agent >/dev/null || useradd -s /sbin/nologin -r -g daos_agent # No files in a shim package %changelog -* Fri Dec 06 2024 Cedric Koch-Hofer 2.7.101-3 -- Add support of the libasan - * Tue Nov 13 2024 Denis Barakhtanov 2.7.101-2 - Add pydaos.torch module to daos-client rpm. From 4f31826ba62be1a1e73838aa95f6960634c8dbf2 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 07/28] DAOS-16501 build: Add libsanitize Integrate reviewers comments: - Add clang support Signed-off-by: Cedric Koch-Hofer --- site_scons/site_tools/compiler_setup.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/site_scons/site_tools/compiler_setup.py b/site_scons/site_tools/compiler_setup.py index 825eb35e99e..1971bcc33dd 100644 --- a/site_scons/site_tools/compiler_setup.py +++ b/site_scons/site_tools/compiler_setup.py @@ -3,6 +3,8 @@ from SCons.Script import Configure, Exit, GetOption FRAME_SIZE_MAX = 4096 +ASAN_FRAME_SIZE_MAX = {'gcc': 8192, + 'clang': 9216} DESIRED_FLAGS = ['-fstack-usage', '-Wno-sign-compare', '-Wno-missing-attributes', @@ -60,7 +62,10 @@ def _base_setup(env): for flag in [f"-Wframe-larger-than={FRAME_SIZE_MAX}", '-fomit-frame-pointer']: if flag in env["CCFLAGS"]: env["CCFLAGS"].remove(flag) - cc_flags = [f"-Wframe-larger-than={max(8192, FRAME_SIZE_MAX)}", + cc = 'gcc' + if 'COMPILER' in env: + cc = env['COMPILER'] + cc_flags = [f"-Wframe-larger-than={ASAN_FRAME_SIZE_MAX[cc]}", '-fno-omit-frame-pointer', '-fno-common'] From 472d17864f6997968855eb5d7cd90f26ebe01b95 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 08/28] DAOS-16501 build: Add libsanitize Support of libasan wwith CI. Signed-off-by: Cedric Koch-Hofer --- Jenkinsfile | 15 +++++++++++++-- ci/provisioning/post_provision_config.sh | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3dfe5168368..4291cc026d1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -136,6 +136,14 @@ void rpm_test_post(String stage_name, String node) { job_status_update() } +String sconsArgs() { + if (params.CI_SCONS_ARGS) { + return sconsFaultsArgs() + } + + return sconsFaultsArgs() + ' ' + params.CI_SCONS_ARGS +} + /** * Update default commit pragmas based on files modified. */ @@ -160,7 +168,7 @@ pipeline { TEST_RPMS = cachedCommitPragma(pragma: 'RPM-test', def_val: 'true') COVFN_DISABLED = cachedCommitPragma(pragma: 'Skip-fnbullseye', def_val: 'true') REPO_FILE_URL = repoFileUrl(env.REPO_FILE_URL) - SCONS_FAULTS_ARGS = sconsFaultsArgs() + SCONS_FAULTS_ARGS = sconsArgs() } options { @@ -330,6 +338,9 @@ pipeline { string(name: 'CI_BUILD_DESCRIPTION', defaultValue: '', description: 'A description of the build') + string(name: 'CI_SCONS_ARGS', + defaultValue: '', + description: 'Arguments for scons when building DAOS') } stages { @@ -611,7 +622,7 @@ pipeline { stash_files: 'ci/test_files_to_stash.txt', build_deps: 'no', stash_opt: true, - scons_args: sconsFaultsArgs() + + scons_args: sconsArgs() + ' PREFIX=/opt/daos TARGET_TYPE=release')) } post { diff --git a/ci/provisioning/post_provision_config.sh b/ci/provisioning/post_provision_config.sh index 263da7c69ed..ef19d12a204 100755 --- a/ci/provisioning/post_provision_config.sh +++ b/ci/provisioning/post_provision_config.sh @@ -62,6 +62,7 @@ if ! retry_cmd 2400 clush -B -S -l root -w "$NODESTRING" \ REPO_PATH=\"${REPO_PATH:-}\" ARTIFACTS_URL=\"${ARTIFACTS_URL:-}\" COVFN_DISABLED=\"${COVFN_DISABLED:-true}\" + CI_SCONS_ARGS=\"${CI_SCONS_ARGS:-}\" $(cat ci/stacktrace.sh) $(cat ci/junit.sh) $(cat ci/provisioning/post_provision_config_common_functions.sh) From 35446b7c0d173e220d17bdb649cd4cb214da4546 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 09/28] DAOS-16501 build: Add libsanitize Fixing libasan support with the CI. Signed-off-by: Cedric Koch-Hofer --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4291cc026d1..5952f0f292d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -137,10 +137,11 @@ void rpm_test_post(String stage_name, String node) { } String sconsArgs() { - if (params.CI_SCONS_ARGS) { + if (!params.CI_SCONS_ARGS) { return sconsFaultsArgs() } + println("Compiling DAOS with libasan") return sconsFaultsArgs() + ' ' + params.CI_SCONS_ARGS } From 409fc8d7f556776ae124c90fa51f08b74a743b3e Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 10/28] DAOS-16501 build: Add libsanitize Fixing libasan support with the CI. Signed-off-by: Cedric Koch-Hofer --- debian/changelog | 6 ++++++ debian/control | 3 ++- utils/rpms/daos.spec | 13 ++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index bc6b0009359..35b3f40343b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +daos (2.7.101-3) unstable; urgency=medium + [ Cedric Koch-Hofer] + * Add support of the libasan + + -- Cedric Koch-Hofer Mon, 06 Jan 2025 14:12:00 -0700 + daos (2.7.101-2) unstable; urgency=medium [ Denis Barakhtanov ] * Add pydaos.torch module to daos-client package diff --git a/debian/control b/debian/control index 09876a93075..cc5ac5e2881 100644 --- a/debian/control +++ b/debian/control @@ -33,7 +33,8 @@ Build-Depends: debhelper (>= 10), liblz4-dev, libaio-dev, libcapstone-dev, - libpci-dev + libpci-dev, + libasan8 Standards-Version: 4.1.2 Homepage: https://docs.daos.io/ Vcs-Git: https://github.com/daos-stack/daos.git diff --git a/utils/rpms/daos.spec b/utils/rpms/daos.spec index 10139799e2d..639f9513b38 100644 --- a/utils/rpms/daos.spec +++ b/utils/rpms/daos.spec @@ -16,7 +16,7 @@ Name: daos Version: 2.7.101 -Release: 3%{?relval}%{?dist} +Release: 4%{?relval}%{?dist} Summary: DAOS Storage Engine License: BSD-2-Clause-Patent @@ -114,6 +114,14 @@ BuildRequires: systemd-rpm-macros %endif BuildRequires: libuuid-devel +# Needed for debugging tasks +%if (0%{?rhel} >= 8) +BuildRequires: libasan +%endif +%if (0%{?suse_version} > 0) +BuildRequires: libasan8 +%endif + Requires: openssl # This should only be temporary until we can get a stable upstream release # of mercury, at which time the autoprov shared library version should @@ -602,6 +610,9 @@ getent passwd daos_agent >/dev/null || useradd -s /sbin/nologin -r -g daos_agent # No files in a shim package %changelog +* Mon Jan 06 2025 Cedric Koch-Hofer 2.7.101-4 +- Add support of the libasan + * Thu Dec 19 2024 Phillip Henderson 2.7.101-3 - Fix protobuf-c requiremnent for daos-client-tests on Leap. From 9a4a358a626d2d7b74e35986d892495dd2af0dc0 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 11/28] DAOS-16501 build: Add libsanitize Fixing libasan version for Debian pacakaging. Signed-off-by: Cedric Koch-Hofer --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index cc5ac5e2881..945b966c460 100644 --- a/debian/control +++ b/debian/control @@ -34,7 +34,7 @@ Build-Depends: debhelper (>= 10), libaio-dev, libcapstone-dev, libpci-dev, - libasan8 + libasan5 Standards-Version: 4.1.2 Homepage: https://docs.daos.io/ Vcs-Git: https://github.com/daos-stack/daos.git From ec60363321c57d61bdaf3f6f58542e798defafc9 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 12/28] DAOS-16501 build: Add libsanitize Fixing compilation errors reported by gcc on el9. Signed-off-by: Cedric Koch-Hofer --- src/client/dfs/obj.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/client/dfs/obj.c b/src/client/dfs/obj.c index 21c09027bef..1fde5da8318 100644 --- a/src/client/dfs/obj.c +++ b/src/client/dfs/obj.c @@ -1,5 +1,6 @@ /** * (C) Copyright 2018-2024 Intel Corporation. + * (C) Copyright 2025 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -510,10 +511,11 @@ dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **_new_obj) D_GOTO(err, rc = EINVAL); } - strncpy(new_obj->name, obj->name, DFS_MAX_NAME + 1); - new_obj->dfs = dfs; - new_obj->mode = obj->mode; - new_obj->flags = flags; + strncpy(new_obj->name, obj->name, DFS_MAX_NAME); + new_obj->name[DFS_MAX_NAME] = '\0'; + new_obj->dfs = dfs; + new_obj->mode = obj->mode; + new_obj->flags = flags; oid_cp(&new_obj->parent_oid, obj->parent_oid); oid_cp(&new_obj->oid, obj->oid); @@ -616,8 +618,8 @@ dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob) oid_cp(&obj_glob->parent_oid, obj->parent_oid); uuid_copy(obj_glob->coh_uuid, coh_uuid); uuid_copy(obj_glob->cont_uuid, cont_uuid); - strncpy(obj_glob->name, obj->name, DFS_MAX_NAME + 1); - obj_glob->name[DFS_MAX_NAME] = 0; + strncpy(obj_glob->name, obj->name, DFS_MAX_NAME); + obj_glob->name[DFS_MAX_NAME] = '\0'; if (S_ISDIR(obj_glob->mode)) return 0; rc = dfs_get_chunk_size(obj, &obj_glob->chunk_size); @@ -674,7 +676,7 @@ dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **_obj) oid_cp(&obj->oid, obj_glob->oid); oid_cp(&obj->parent_oid, obj_glob->parent_oid); - strncpy(obj->name, obj_glob->name, DFS_MAX_NAME + 1); + strncpy(obj->name, obj_glob->name, DFS_MAX_NAME); obj->name[DFS_MAX_NAME] = '\0'; obj->mode = obj_glob->mode; obj->dfs = dfs; From 343449aaa38c8bbd299fcdbe70f61df1024431ca Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 13/28] DAOS-16501 build: Add libsanitize Fixing invalid compilation errors reported by gcc on el9. Signed-off-by: Cedric Koch-Hofer --- src/client/dfs/cont.c | 7 ++++++- src/client/dfs/obj.c | 15 ++++++++++++--- src/client/dfuse/ops/lookup.c | 7 ++++++- utils/scripts/install-ubuntu.sh | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/client/dfs/cont.c b/src/client/dfs/cont.c index 152f714ab88..1aa2580c076 100644 --- a/src/client/dfs/cont.c +++ b/src/client/dfs/cont.c @@ -1,5 +1,6 @@ /** * (C) Copyright 2018-2024 Intel Corporation. + * (C) Copyright 2025 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -83,7 +84,11 @@ dfs_cont_create(daos_handle_t poh, uuid_t *cuuid, dfs_attr_t *attr, daos_handle_ dattr.da_chunk_size = DFS_DEFAULT_CHUNK_SIZE; if (attr->da_hints[0] != 0) { - strncpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN); + /* GCC warns (-Wstringop-truncation) because the destination buffer size is + * identical to max-size, leading to a potential char[] with no null + * terminator. nanopb can handle it fine, and parentheses around strncpy + * silence that compiler warning. */ + (strncpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN - 1)); dattr.da_hints[DAOS_CONT_HINT_MAX_LEN - 1] = '\0'; } } else { diff --git a/src/client/dfs/obj.c b/src/client/dfs/obj.c index 1fde5da8318..a786761fda6 100644 --- a/src/client/dfs/obj.c +++ b/src/client/dfs/obj.c @@ -511,7 +511,10 @@ dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **_new_obj) D_GOTO(err, rc = EINVAL); } - strncpy(new_obj->name, obj->name, DFS_MAX_NAME); + /* GCC warns (-Wstringop-truncation) because the destination buffer size is identical to + * max-size, leading to a potential char[] with no null terminator. nanopb can handle it + * fine, and parentheses around strncpy silence that compiler warning. */ + (strncpy(new_obj->name, obj->name, DFS_MAX_NAME - 1)); new_obj->name[DFS_MAX_NAME] = '\0'; new_obj->dfs = dfs; new_obj->mode = obj->mode; @@ -618,7 +621,10 @@ dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob) oid_cp(&obj_glob->parent_oid, obj->parent_oid); uuid_copy(obj_glob->coh_uuid, coh_uuid); uuid_copy(obj_glob->cont_uuid, cont_uuid); - strncpy(obj_glob->name, obj->name, DFS_MAX_NAME); + /* GCC warns (-Wstringop-truncation) because the destination buffer size is identical to + * max-size, leading to a potential char[] with no null terminator. nanopb can handle it + * fine, and parentheses around strncpy silence that compiler warning. */ + (strncpy(obj_glob->name, obj->name, DFS_MAX_NAME)); obj_glob->name[DFS_MAX_NAME] = '\0'; if (S_ISDIR(obj_glob->mode)) return 0; @@ -676,7 +682,10 @@ dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **_obj) oid_cp(&obj->oid, obj_glob->oid); oid_cp(&obj->parent_oid, obj_glob->parent_oid); - strncpy(obj->name, obj_glob->name, DFS_MAX_NAME); + /* GCC warns (-Wstringop-truncation) because the destination buffer size is identical to + * max-size, leading to a potential char[] with no null terminator. nanopb can handle it + * fine, and parentheses around strncpy silence that compiler warning. */ + (strncpy(obj->name, obj_glob->name, DFS_MAX_NAME)); obj->name[DFS_MAX_NAME] = '\0'; obj->mode = obj_glob->mode; obj->dfs = dfs; diff --git a/src/client/dfuse/ops/lookup.c b/src/client/dfuse/ops/lookup.c index 77bcc9bb0da..cb172573ff9 100644 --- a/src/client/dfuse/ops/lookup.c +++ b/src/client/dfuse/ops/lookup.c @@ -1,5 +1,6 @@ /** * (C) Copyright 2016-2024 Intel Corporation. + * (C) Copyright 2025 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -118,7 +119,11 @@ dfuse_reply_entry(struct dfuse_info *dfuse_info, struct dfuse_inode_entry *ie, /* Save the old name so that we can invalidate it in later */ wipe_parent = inode->ie_parent; - strncpy(wipe_name, inode->ie_name, NAME_MAX); + /* GCC warns (-Wstringop-truncation) because the destination buffer size is + * identical to max-size, leading to a potential char[] with no null + * terminator. nanopb can handle it fine, and parentheses around strncpy + * silence that compiler warning. */ + (strncpy(wipe_name, inode->ie_name, NAME_MAX - 1)); wipe_name[NAME_MAX] = '\0'; inode->ie_parent = ie->ie_parent; diff --git a/utils/scripts/install-ubuntu.sh b/utils/scripts/install-ubuntu.sh index d0599e6d2a9..bf8b7adcf0c 100755 --- a/utils/scripts/install-ubuntu.sh +++ b/utils/scripts/install-ubuntu.sh @@ -25,7 +25,7 @@ apt-get install \ golang-go \ kmod \ libaio-dev \ - libasan8 \ + libasan5 \ libboost-dev \ libcapstone-dev \ libcmocka-dev \ From e2a272b16a4973fd9050822a4b4f5ae4aad668df Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 14/28] DAOS-16501 build: Add libsanitize Fixing invalid compilation errors reported by gcc on el9. Signed-off-by: Cedric Koch-Hofer --- src/client/dfs/cont.c | 7 +------ src/client/dfs/obj.c | 15 +++------------ src/client/dfuse/ops/lookup.c | 6 +----- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/client/dfs/cont.c b/src/client/dfs/cont.c index 1aa2580c076..152f714ab88 100644 --- a/src/client/dfs/cont.c +++ b/src/client/dfs/cont.c @@ -1,6 +1,5 @@ /** * (C) Copyright 2018-2024 Intel Corporation. - * (C) Copyright 2025 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -84,11 +83,7 @@ dfs_cont_create(daos_handle_t poh, uuid_t *cuuid, dfs_attr_t *attr, daos_handle_ dattr.da_chunk_size = DFS_DEFAULT_CHUNK_SIZE; if (attr->da_hints[0] != 0) { - /* GCC warns (-Wstringop-truncation) because the destination buffer size is - * identical to max-size, leading to a potential char[] with no null - * terminator. nanopb can handle it fine, and parentheses around strncpy - * silence that compiler warning. */ - (strncpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN - 1)); + strncpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN); dattr.da_hints[DAOS_CONT_HINT_MAX_LEN - 1] = '\0'; } } else { diff --git a/src/client/dfs/obj.c b/src/client/dfs/obj.c index a786761fda6..20679e84e95 100644 --- a/src/client/dfs/obj.c +++ b/src/client/dfs/obj.c @@ -511,10 +511,7 @@ dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **_new_obj) D_GOTO(err, rc = EINVAL); } - /* GCC warns (-Wstringop-truncation) because the destination buffer size is identical to - * max-size, leading to a potential char[] with no null terminator. nanopb can handle it - * fine, and parentheses around strncpy silence that compiler warning. */ - (strncpy(new_obj->name, obj->name, DFS_MAX_NAME - 1)); + strncpy(new_obj->name, obj->name, DFS_MAX_NAME + 1); new_obj->name[DFS_MAX_NAME] = '\0'; new_obj->dfs = dfs; new_obj->mode = obj->mode; @@ -621,10 +618,7 @@ dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob) oid_cp(&obj_glob->parent_oid, obj->parent_oid); uuid_copy(obj_glob->coh_uuid, coh_uuid); uuid_copy(obj_glob->cont_uuid, cont_uuid); - /* GCC warns (-Wstringop-truncation) because the destination buffer size is identical to - * max-size, leading to a potential char[] with no null terminator. nanopb can handle it - * fine, and parentheses around strncpy silence that compiler warning. */ - (strncpy(obj_glob->name, obj->name, DFS_MAX_NAME)); + strncpy(obj_glob->name, obj->name, DFS_MAX_NAME + 1); obj_glob->name[DFS_MAX_NAME] = '\0'; if (S_ISDIR(obj_glob->mode)) return 0; @@ -682,10 +676,7 @@ dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **_obj) oid_cp(&obj->oid, obj_glob->oid); oid_cp(&obj->parent_oid, obj_glob->parent_oid); - /* GCC warns (-Wstringop-truncation) because the destination buffer size is identical to - * max-size, leading to a potential char[] with no null terminator. nanopb can handle it - * fine, and parentheses around strncpy silence that compiler warning. */ - (strncpy(obj->name, obj_glob->name, DFS_MAX_NAME)); + strncpy(obj->name, obj_glob->name, DFS_MAX_NAME + 1); obj->name[DFS_MAX_NAME] = '\0'; obj->mode = obj_glob->mode; obj->dfs = dfs; diff --git a/src/client/dfuse/ops/lookup.c b/src/client/dfuse/ops/lookup.c index cb172573ff9..b681eccc756 100644 --- a/src/client/dfuse/ops/lookup.c +++ b/src/client/dfuse/ops/lookup.c @@ -119,11 +119,7 @@ dfuse_reply_entry(struct dfuse_info *dfuse_info, struct dfuse_inode_entry *ie, /* Save the old name so that we can invalidate it in later */ wipe_parent = inode->ie_parent; - /* GCC warns (-Wstringop-truncation) because the destination buffer size is - * identical to max-size, leading to a potential char[] with no null - * terminator. nanopb can handle it fine, and parentheses around strncpy - * silence that compiler warning. */ - (strncpy(wipe_name, inode->ie_name, NAME_MAX - 1)); + strncpy(wipe_name, inode->ie_name, NAME_MAX + 1); wipe_name[NAME_MAX] = '\0'; inode->ie_parent = ie->ie_parent; From 1bbf2b1b6349d2fe327a99e32327269e1221263b Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 15/28] DAOS-16501 build: Add libsanitize Fixing invalid compilation errors reported by gcc on el9. Signed-off-by: Cedric Koch-Hofer --- src/client/dfs/cont.c | 3 ++- src/client/dfs/obj.c | 6 +++--- src/client/dfuse/ops/lookup.c | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/client/dfs/cont.c b/src/client/dfs/cont.c index 152f714ab88..3aa96af0f58 100644 --- a/src/client/dfs/cont.c +++ b/src/client/dfs/cont.c @@ -1,5 +1,6 @@ /** * (C) Copyright 2018-2024 Intel Corporation. + * (C) Copyright 2025 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -83,7 +84,7 @@ dfs_cont_create(daos_handle_t poh, uuid_t *cuuid, dfs_attr_t *attr, daos_handle_ dattr.da_chunk_size = DFS_DEFAULT_CHUNK_SIZE; if (attr->da_hints[0] != 0) { - strncpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN); + strncpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN - 1); dattr.da_hints[DAOS_CONT_HINT_MAX_LEN - 1] = '\0'; } } else { diff --git a/src/client/dfs/obj.c b/src/client/dfs/obj.c index 20679e84e95..1fde5da8318 100644 --- a/src/client/dfs/obj.c +++ b/src/client/dfs/obj.c @@ -511,7 +511,7 @@ dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **_new_obj) D_GOTO(err, rc = EINVAL); } - strncpy(new_obj->name, obj->name, DFS_MAX_NAME + 1); + strncpy(new_obj->name, obj->name, DFS_MAX_NAME); new_obj->name[DFS_MAX_NAME] = '\0'; new_obj->dfs = dfs; new_obj->mode = obj->mode; @@ -618,7 +618,7 @@ dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob) oid_cp(&obj_glob->parent_oid, obj->parent_oid); uuid_copy(obj_glob->coh_uuid, coh_uuid); uuid_copy(obj_glob->cont_uuid, cont_uuid); - strncpy(obj_glob->name, obj->name, DFS_MAX_NAME + 1); + strncpy(obj_glob->name, obj->name, DFS_MAX_NAME); obj_glob->name[DFS_MAX_NAME] = '\0'; if (S_ISDIR(obj_glob->mode)) return 0; @@ -676,7 +676,7 @@ dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **_obj) oid_cp(&obj->oid, obj_glob->oid); oid_cp(&obj->parent_oid, obj_glob->parent_oid); - strncpy(obj->name, obj_glob->name, DFS_MAX_NAME + 1); + strncpy(obj->name, obj_glob->name, DFS_MAX_NAME); obj->name[DFS_MAX_NAME] = '\0'; obj->mode = obj_glob->mode; obj->dfs = dfs; diff --git a/src/client/dfuse/ops/lookup.c b/src/client/dfuse/ops/lookup.c index b681eccc756..d78c61ce953 100644 --- a/src/client/dfuse/ops/lookup.c +++ b/src/client/dfuse/ops/lookup.c @@ -119,11 +119,12 @@ dfuse_reply_entry(struct dfuse_info *dfuse_info, struct dfuse_inode_entry *ie, /* Save the old name so that we can invalidate it in later */ wipe_parent = inode->ie_parent; - strncpy(wipe_name, inode->ie_name, NAME_MAX + 1); + strncpy(wipe_name, inode->ie_name, NAME_MAX); wipe_name[NAME_MAX] = '\0'; inode->ie_parent = ie->ie_parent; - strncpy(inode->ie_name, ie->ie_name, NAME_MAX + 1); + strncpy(inode->ie_name, ie->ie_name, NAME_MAX); + inode->ie_name[NAME_MAX] = '\0'; } atomic_fetch_sub_relaxed(&ie->ie_ref, 1); dfuse_ie_close(dfuse_info, ie); From 9535e1cd397c51b819407b7189d49f243e9e5c6b Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 16/28] DAOS-16501 build: Add libsanitize Fixing invalid compilation errors reported by gcc on el9. Signed-off-by: Cedric Koch-Hofer --- src/client/dfuse/ops/lookup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/dfuse/ops/lookup.c b/src/client/dfuse/ops/lookup.c index d78c61ce953..2bb752426fb 100644 --- a/src/client/dfuse/ops/lookup.c +++ b/src/client/dfuse/ops/lookup.c @@ -119,11 +119,13 @@ dfuse_reply_entry(struct dfuse_info *dfuse_info, struct dfuse_inode_entry *ie, /* Save the old name so that we can invalidate it in later */ wipe_parent = inode->ie_parent; - strncpy(wipe_name, inode->ie_name, NAME_MAX); + /* strncpy(wipe_name, inode->ie_name, NAME_MAX); */ + strncpy(wipe_name, inode->ie_name, sizeof(wipe_name) - 1); wipe_name[NAME_MAX] = '\0'; inode->ie_parent = ie->ie_parent; - strncpy(inode->ie_name, ie->ie_name, NAME_MAX); + /* strncpy(inode->ie_name, ie->ie_name, NAME_MAX); */ + strncpy(inode->ie_name, ie->ie_name, sizeof(inode->ie_name) - 1); inode->ie_name[NAME_MAX] = '\0'; } atomic_fetch_sub_relaxed(&ie->ie_ref, 1); @@ -297,6 +299,7 @@ dfuse_cb_lookup(fuse_req_t req, struct dfuse_inode_entry *parent, DFUSE_TRA_DEBUG(ie, "Attr len is %zi", attr_len); strncpy(ie->ie_name, name, NAME_MAX); + ie->ie_name[NAME_MAX] = '\0' dfs_obj2id(ie->ie_obj, &ie->ie_oid); From df2675b325e7151c1cfd068b64eb604810392252 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 17/28] DAOS-16501 build: Add libsanitize Fixing invalid compilation errors reported by gcc on el9. Signed-off-by: Cedric Koch-Hofer --- src/client/dfuse/ops/lookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/dfuse/ops/lookup.c b/src/client/dfuse/ops/lookup.c index 2bb752426fb..d34d03cb39c 100644 --- a/src/client/dfuse/ops/lookup.c +++ b/src/client/dfuse/ops/lookup.c @@ -299,7 +299,7 @@ dfuse_cb_lookup(fuse_req_t req, struct dfuse_inode_entry *parent, DFUSE_TRA_DEBUG(ie, "Attr len is %zi", attr_len); strncpy(ie->ie_name, name, NAME_MAX); - ie->ie_name[NAME_MAX] = '\0' + ie->ie_name[NAME_MAX] = '\0'; dfs_obj2id(ie->ie_obj, &ie->ie_oid); From 6b25da9c575982bd03d863ab23bd7d7ada07547b Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 18/28] DAOS-16501 build: Add libsanitize Fixing invalid compilation errors reported by gcc on el9. Signed-off-by: Cedric Koch-Hofer --- src/client/dfuse/ops/lookup.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/client/dfuse/ops/lookup.c b/src/client/dfuse/ops/lookup.c index d34d03cb39c..0094c5b5131 100644 --- a/src/client/dfuse/ops/lookup.c +++ b/src/client/dfuse/ops/lookup.c @@ -119,13 +119,11 @@ dfuse_reply_entry(struct dfuse_info *dfuse_info, struct dfuse_inode_entry *ie, /* Save the old name so that we can invalidate it in later */ wipe_parent = inode->ie_parent; - /* strncpy(wipe_name, inode->ie_name, NAME_MAX); */ - strncpy(wipe_name, inode->ie_name, sizeof(wipe_name) - 1); + memcpy(wipe_name, inode->ie_name, NAME_MAX); wipe_name[NAME_MAX] = '\0'; inode->ie_parent = ie->ie_parent; - /* strncpy(inode->ie_name, ie->ie_name, NAME_MAX); */ - strncpy(inode->ie_name, ie->ie_name, sizeof(inode->ie_name) - 1); + memcpy(inode->ie_name, ie->ie_name, NAME_MAX); inode->ie_name[NAME_MAX] = '\0'; } atomic_fetch_sub_relaxed(&ie->ie_ref, 1); From 192f66d22847210dbcec044407d471dff00209e8 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 19/28] DAOS-16501 build: Add libsanitize Fixing invalid compilation errors reported by gcc on el9. Signed-off-by: Cedric Koch-Hofer --- src/client/dfs/cont.c | 2 +- src/client/dfs/obj.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/dfs/cont.c b/src/client/dfs/cont.c index 3aa96af0f58..f5a0ddc713b 100644 --- a/src/client/dfs/cont.c +++ b/src/client/dfs/cont.c @@ -84,7 +84,7 @@ dfs_cont_create(daos_handle_t poh, uuid_t *cuuid, dfs_attr_t *attr, daos_handle_ dattr.da_chunk_size = DFS_DEFAULT_CHUNK_SIZE; if (attr->da_hints[0] != 0) { - strncpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN - 1); + memcpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN - 1); dattr.da_hints[DAOS_CONT_HINT_MAX_LEN - 1] = '\0'; } } else { diff --git a/src/client/dfs/obj.c b/src/client/dfs/obj.c index 1fde5da8318..965847f35b4 100644 --- a/src/client/dfs/obj.c +++ b/src/client/dfs/obj.c @@ -511,7 +511,7 @@ dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **_new_obj) D_GOTO(err, rc = EINVAL); } - strncpy(new_obj->name, obj->name, DFS_MAX_NAME); + memcpy(new_obj->name, obj->name, DFS_MAX_NAME); new_obj->name[DFS_MAX_NAME] = '\0'; new_obj->dfs = dfs; new_obj->mode = obj->mode; @@ -618,7 +618,7 @@ dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob) oid_cp(&obj_glob->parent_oid, obj->parent_oid); uuid_copy(obj_glob->coh_uuid, coh_uuid); uuid_copy(obj_glob->cont_uuid, cont_uuid); - strncpy(obj_glob->name, obj->name, DFS_MAX_NAME); + memcpy(obj_glob->name, obj->name, DFS_MAX_NAME); obj_glob->name[DFS_MAX_NAME] = '\0'; if (S_ISDIR(obj_glob->mode)) return 0; @@ -676,7 +676,7 @@ dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **_obj) oid_cp(&obj->oid, obj_glob->oid); oid_cp(&obj->parent_oid, obj_glob->parent_oid); - strncpy(obj->name, obj_glob->name, DFS_MAX_NAME); + memcpy(obj->name, obj_glob->name, DFS_MAX_NAME); obj->name[DFS_MAX_NAME] = '\0'; obj->mode = obj_glob->mode; obj->dfs = dfs; From 9ef5a08705ccc55edc1022c0f42e609a17b5c97b Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 20/28] DAOS-16501 build: Add libsanitize Fixing invalid compilation errors reported by gcc on el9. Signed-off-by: Cedric Koch-Hofer --- src/tests/obj_ctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/obj_ctl.c b/src/tests/obj_ctl.c index a789ce2ecd5..26f2e1d2cf1 100644 --- a/src/tests/obj_ctl.c +++ b/src/tests/obj_ctl.c @@ -1,5 +1,6 @@ /** * (C) Copyright 2017-2022 Intel Corporation. + * (C) Copyright 2025 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -198,7 +199,7 @@ ctl_cmd_run(char opc, char *args) int rc; if (args) { - strncpy(buf, args, CTL_BUF_LEN); + strncpy(buf, args, CTL_BUF_LEN - 1); buf[CTL_BUF_LEN - 1] = '\0'; str = daos_str_trimwhite(buf); } else { From 25665722f76ee1f7a7da1810379cec543a7a10e8 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 21/28] DAOS-16501 build: Add libsanitize Fixing invalid compilation errors reported by gcc on el9. Signed-off-by: Cedric Koch-Hofer --- utils/rpms/daos.rpmlintrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/rpms/daos.rpmlintrc b/utils/rpms/daos.rpmlintrc index 67285ef5b50..81301ebb048 100644 --- a/utils/rpms/daos.rpmlintrc +++ b/utils/rpms/daos.rpmlintrc @@ -54,3 +54,13 @@ addFilter("daos-client-tests\.x86_64: E: devel-dependency capstone-devel") addFilter("daos-client-tests\.x86_64: E: explicit-lib-dependency lib(capstone|ndctl|protobuf-c)-devel") addFilter("daos-client-tests\.x86_64: E: devel-dependency libcapstone-devel") addFilter("daos-client-tests\.x86_64: E: devel-dependency fuse3-devel") + +# Golang executable are not position independent executable +addFilter("daos-admin\.x86_64: W: position-independent-executable-suggested /usr/bin/dmg") +addFilter("daos-client\.x86_64: W: position-independent-executable-suggested /usr/bin/daos") +addFilter("daos-client\.x86_64: W: position-independent-executable-suggested /usr/bin/daos_agent") +addFilter("daos-client-tests\.x86_64: W: position-independent-executable-suggested /usr/bin/hello_drpc") +addFilter("daos-firmware\.x86_64: W: position-independent-executable-suggested /usr/bin/daos_firmware_helper") +addFilter("daos-server\.x86_64: W: position-independent-executable-suggested /usr/bin/daos_server") +addFilter("daos-server\.x86_64: W: position-independent-executable-suggested /usr/bin/daos_server_helper") +addFilter("daos-server\.x86_64: W: position-independent-executable-suggested /usr/bin/ddb") From d81556cebbbe79ba0fa813e590f9dc37780d16ec Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 22/28] DAOS-16501 build: Add libsanitize Fix libasan version for ubuntu image used with GHA Fix invalid copyright Signed-off-by: Cedric Koch-Hofer --- site_scons/components/__init__.py | 1 + site_scons/prereq_tools/base.py | 1 + utils/scripts/install-ubuntu.sh | 2 +- utils/sl/fake_scons/SCons/Script/__init__.py | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/site_scons/components/__init__.py b/site_scons/components/__init__.py index a5604295b4f..b67008dcd57 100644 --- a/site_scons/components/__init__.py +++ b/site_scons/components/__init__.py @@ -1,4 +1,5 @@ # Copyright 2016-2024 Intel Corporation +# Copyright 2025 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/site_scons/prereq_tools/base.py b/site_scons/prereq_tools/base.py index 96422f3a1e3..389571ba0cd 100644 --- a/site_scons/prereq_tools/base.py +++ b/site_scons/prereq_tools/base.py @@ -1,4 +1,5 @@ # Copyright 2016-2024 Intel Corporation +# Copyright 2025 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/utils/scripts/install-ubuntu.sh b/utils/scripts/install-ubuntu.sh index bf8b7adcf0c..53ae7781471 100755 --- a/utils/scripts/install-ubuntu.sh +++ b/utils/scripts/install-ubuntu.sh @@ -25,7 +25,7 @@ apt-get install \ golang-go \ kmod \ libaio-dev \ - libasan5 \ + libasan6 \ libboost-dev \ libcapstone-dev \ libcmocka-dev \ diff --git a/utils/sl/fake_scons/SCons/Script/__init__.py b/utils/sl/fake_scons/SCons/Script/__init__.py index 22a184be38d..299abd2db06 100644 --- a/utils/sl/fake_scons/SCons/Script/__init__.py +++ b/utils/sl/fake_scons/SCons/Script/__init__.py @@ -1,5 +1,6 @@ """Fake scons environment shutting up pylint on SCons files""" -# Copyright 2016-2024 Intel Corporation +# Copyright 2016-2023 Intel Corporation +# Copyright 2025 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal From e5e647f6b294b9dd5b97c3dac0bcb3f906c3f73e Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 23/28] DAOS-16501 build: Add libsanitize Update modification de Signed-off-by: Cedric Koch-Hofer --- debian/changelog | 2 +- utils/rpms/daos.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 737739f5f7a..d21293f8b20 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,7 @@ daos (2.7.101-4) unstable; urgency=medium [ Cedric Koch-Hofer] * Add support of the libasan - -- Cedric Koch-Hofer Mon, 06 Jan 2025 14:12:00 -0700 + -- Cedric Koch-Hofer Mon, 20 Jan 2025 14:12:00 -0700 daos (2.7.101-3) unstable; urgency=medium [ Jeff Olivier ] diff --git a/utils/rpms/daos.spec b/utils/rpms/daos.spec index 299e33331b2..658d07ca939 100644 --- a/utils/rpms/daos.spec +++ b/utils/rpms/daos.spec @@ -600,7 +600,7 @@ getent passwd daos_agent >/dev/null || useradd -s /sbin/nologin -r -g daos_agent # No files in a shim package %changelog -* Mon Jan 17 2025 Cedric Koch-Hofer 2.7.101-5 +* Mon Jan 20 2025 Cedric Koch-Hofer 2.7.101-5 - Add support of the libasan * Fri Dec 20 2024 Jeff Olivier 2.7.101-4 From 84535079b42ca01a6f583d24ed715c7c5c03f911 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 24/28] DAOS-16501 build: Add libsanitize Add documentation on ASan lib usaged and limitations. Signed-off-by: Cedric Koch-Hofer --- docs/dev/development.md | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/docs/dev/development.md b/docs/dev/development.md index 25fff2bcfa8..65373c93a4a 100644 --- a/docs/dev/development.md +++ b/docs/dev/development.md @@ -122,6 +122,57 @@ scons reduces the clutter from compiler setup. Additionally, the tool supports options to filter by directory and file names and specify a lower bound value to report. +### Address Sanitizer + +To debug memory corruptions, leaks, and other issues, DAOS can be compiled with the +[AddressSanitizer (ASan)](https://github.com/google/sanitizers/wiki/AddressSanitizer) library. + +#### Building with ASan + +To build instrumented libraries, executables, RPMs, etc., use the `SANITIZERS=address` flag with the +`scons` command. This option is also managed by the CI system through a Jenkins configuration +variable. + +ASan is supported with both Clang and GCC compilers. However, some compiler-specific configurations, +such as maximum function stack size, may lead to unexpected behavior in the instrumented +binaries. + +#### Customizing ASan Behavior +ASan behavior can be configured using the `ASAN_OPTIONS` environment variable. For example, you can +add the following entry to the `env_vars` section of the `daos_server.yml` configuration file: +```yaml +engines: +- .. + env_vars: + ... + - ASAN_OPTIONS=atexit=1:print_stats=1:log_path=/tmp/daos_engine0.asan:disable_coredump=1:handle_segv=2:handle_abort=2:handle_sigfpe=2:handle_sigill=2:handle_sigbus=2:use_sigaltstack=1 +``` +For detailed information, see the +[Sanitizer Common Flags](https://github.com/google/sanitizers/wiki/SanitizerCommonFlags) and +[AddressSanitizer Flags](https://github.com/google/sanitizers/wiki/AddressSanitizerFlags) +documentation pages. + +#### Known Issues + +ASan support in DAOS is still experimental and has the following known issues: +1. **Library Path Issues** + ASan's instrumentation of `dlopen()` removes `RPATH` and `RUNPATH` entries passed to the + compiler. As a result, libraries like `librdb` may not be found if DAOS is built with SCons and + installed in a non-standard location. + **Workaround**: Use the `LD_LIBRARY_PATH` environment variable or the `ldconfig` command. + More details are available in [Bug 27790](https://bugs.llvm.org/show_bug.cgi?id=27790). + +2. **Missing Statistics on SIGKILL** + Stopping an application with `kill -s SIGKILL` prevents ASan from printing statistics, such as + detected memory leaks. For instance, this occurs when stopping DAOS engines using: + ```bash + dmg system stop --force + ``` + +3. **Integration with Test Framework** + ASan is not fully integrated with the DAOS regression testing framework. Some tests, such as + those using Valgrind, may fail due to false positives. + ## Go dependencies Developers contributing Go code may need to change the external dependencies From f38fd44a0f7443d79b861e44fdea096f9445602b Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 25/28] DAOS-16501 build: Add libsanitize Integrate reviewers comments: - Restore, add comments and pragma on strncpy() usage - Increase DSS_DEEP_STACK_SZ when libasan is used - Add info about compiler custom setting and consequences in the compiler_setup.py script - Fix Jenkinsfile argument help Signed-off-by: Cedric Koch-Hofer --- Jenkinsfile | 2 +- site_scons/site_tools/compiler_setup.py | 12 +++++++++--- src/client/dfs/cont.c | 6 +++++- src/client/dfs/obj.c | 18 +++++++++++++++--- src/client/dfuse/ops/lookup.c | 16 ++++++++++++++-- src/include/daos_srv/daos_engine.h | 13 ++++++++++++- 6 files changed, 56 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6b80856debf..46470cad1cc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -142,7 +142,7 @@ String sconsArgs() { return sconsFaultsArgs() } - println("Compiling DAOS with libasan") + println("Compiling DAOS with custom arguments") return sconsFaultsArgs() + ' ' + params.CI_SCONS_ARGS } diff --git a/site_scons/site_tools/compiler_setup.py b/site_scons/site_tools/compiler_setup.py index 1971bcc33dd..6abb52a0115 100644 --- a/site_scons/site_tools/compiler_setup.py +++ b/site_scons/site_tools/compiler_setup.py @@ -59,12 +59,18 @@ def _base_setup(env): env.AppendIfSupported(CCFLAGS=DESIRED_FLAGS) if 'SANITIZERS' in env and env['SANITIZERS'] != "": - for flag in [f"-Wframe-larger-than={FRAME_SIZE_MAX}", '-fomit-frame-pointer']: - if flag in env["CCFLAGS"]: - env["CCFLAGS"].remove(flag) cc = 'gcc' if 'COMPILER' in env: cc = env['COMPILER'] + if cc not in ASAN_FRAME_SIZE_MAX: + print(f"C compiler {cc} is not supported with the ASan lib") + Exit(3) + + print("Using ASasn lib is updating the compilation configuration " + "and may lead to unexpected behavior") + for flag in [f"-Wframe-larger-than={FRAME_SIZE_MAX}", '-fomit-frame-pointer']: + if flag in env["CCFLAGS"]: + env["CCFLAGS"].remove(flag) cc_flags = [f"-Wframe-larger-than={ASAN_FRAME_SIZE_MAX[cc]}", '-fno-omit-frame-pointer', '-fno-common'] diff --git a/src/client/dfs/cont.c b/src/client/dfs/cont.c index f5a0ddc713b..57733de9229 100644 --- a/src/client/dfs/cont.c +++ b/src/client/dfs/cont.c @@ -84,8 +84,12 @@ dfs_cont_create(daos_handle_t poh, uuid_t *cuuid, dfs_attr_t *attr, daos_handle_ dattr.da_chunk_size = DFS_DEFAULT_CHUNK_SIZE; if (attr->da_hints[0] != 0) { - memcpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN - 1); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" + /* DAOS-17042 Replace strncpy with strncat or strlcpy */ + strncpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN - 1); dattr.da_hints[DAOS_CONT_HINT_MAX_LEN - 1] = '\0'; +#pragma GCC diagnostic pop } } else { dattr.da_oclass_id = 0; diff --git a/src/client/dfs/obj.c b/src/client/dfs/obj.c index 965847f35b4..dd07ba11097 100644 --- a/src/client/dfs/obj.c +++ b/src/client/dfs/obj.c @@ -511,8 +511,12 @@ dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **_new_obj) D_GOTO(err, rc = EINVAL); } - memcpy(new_obj->name, obj->name, DFS_MAX_NAME); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" + /* DAOS-17042 Replace strncpy with strncat or strlcpy */ + strncpy(new_obj->name, obj->name, DFS_MAX_NAME); new_obj->name[DFS_MAX_NAME] = '\0'; +#pragma GCC diagnostic pop new_obj->dfs = dfs; new_obj->mode = obj->mode; new_obj->flags = flags; @@ -618,8 +622,12 @@ dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob) oid_cp(&obj_glob->parent_oid, obj->parent_oid); uuid_copy(obj_glob->coh_uuid, coh_uuid); uuid_copy(obj_glob->cont_uuid, cont_uuid); - memcpy(obj_glob->name, obj->name, DFS_MAX_NAME); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" + /* DAOS-17042 Replace strncpy with strncat or strlcpy */ + strncpy(obj_glob->name, obj->name, DFS_MAX_NAME); obj_glob->name[DFS_MAX_NAME] = '\0'; +#pragma GCC diagnostic pop if (S_ISDIR(obj_glob->mode)) return 0; rc = dfs_get_chunk_size(obj, &obj_glob->chunk_size); @@ -676,8 +684,12 @@ dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **_obj) oid_cp(&obj->oid, obj_glob->oid); oid_cp(&obj->parent_oid, obj_glob->parent_oid); - memcpy(obj->name, obj_glob->name, DFS_MAX_NAME); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" + /* DAOS-17042 Replace strncpy with strncat or strlcpy */ + strncpy(obj->name, obj_glob->name, DFS_MAX_NAME); obj->name[DFS_MAX_NAME] = '\0'; +#pragma GCC diagnostic pop obj->mode = obj_glob->mode; obj->dfs = dfs; obj->flags = flags ? flags : obj_glob->flags; diff --git a/src/client/dfuse/ops/lookup.c b/src/client/dfuse/ops/lookup.c index 0094c5b5131..d9af8bb8ddb 100644 --- a/src/client/dfuse/ops/lookup.c +++ b/src/client/dfuse/ops/lookup.c @@ -119,12 +119,20 @@ dfuse_reply_entry(struct dfuse_info *dfuse_info, struct dfuse_inode_entry *ie, /* Save the old name so that we can invalidate it in later */ wipe_parent = inode->ie_parent; - memcpy(wipe_name, inode->ie_name, NAME_MAX); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" + /* DAOS-17042 Replace strncpy with strncat or strlcpy */ + strncpy(wipe_name, inode->ie_name, NAME_MAX); wipe_name[NAME_MAX] = '\0'; +#pragma GCC diagnostic pop inode->ie_parent = ie->ie_parent; - memcpy(inode->ie_name, ie->ie_name, NAME_MAX); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" + /* DAOS-17042 Replace strncpy with strncat or strlcpy */ + strncpy(inode->ie_name, ie->ie_name, NAME_MAX); inode->ie_name[NAME_MAX] = '\0'; +#pragma GCC diagnostic pop } atomic_fetch_sub_relaxed(&ie->ie_ref, 1); dfuse_ie_close(dfuse_info, ie); @@ -296,8 +304,12 @@ dfuse_cb_lookup(fuse_req_t req, struct dfuse_inode_entry *parent, if (attr_len) DFUSE_TRA_DEBUG(ie, "Attr len is %zi", attr_len); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" + /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(ie->ie_name, name, NAME_MAX); ie->ie_name[NAME_MAX] = '\0'; +#pragma GCC diagnostic pop dfs_obj2id(ie->ie_obj, &ie->ie_oid); diff --git a/src/include/daos_srv/daos_engine.h b/src/include/daos_srv/daos_engine.h index 6f6eb714fdc..dba0bf67376 100644 --- a/src/include/daos_srv/daos_engine.h +++ b/src/include/daos_srv/daos_engine.h @@ -408,7 +408,18 @@ struct dss_module { /** * Stack size used for ULTs with deep stack */ -#define DSS_DEEP_STACK_SZ 65536 +#if defined(__clang__) +# if defined(__has_feature) && __has_feature(address_sanitizer) +# define DSS_DEEP_STACK_SZ 98304 +# endif +#elif defined(__GNUC__) +# ifdef __SANITIZE_ADDRESS__ +# define DSS_DEEP_STACK_SZ 98304 +# endif +#endif +#ifndef DSS_DEEP_STACK_SZ +# define DSS_DEEP_STACK_SZ 65536 +#endif enum dss_xs_type { /** current xstream */ From d7d3bf698d55567ac3667b0cea01325191b751fe Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 26/28] DAOS-16501 build: Add libsanitize Fix clang formating Signed-off-by: Cedric Koch-Hofer --- src/client/dfs/obj.c | 6 +++--- src/include/daos_srv/daos_engine.h | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/client/dfs/obj.c b/src/client/dfs/obj.c index dd07ba11097..e922b9e11d0 100644 --- a/src/client/dfs/obj.c +++ b/src/client/dfs/obj.c @@ -517,9 +517,9 @@ dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **_new_obj) strncpy(new_obj->name, obj->name, DFS_MAX_NAME); new_obj->name[DFS_MAX_NAME] = '\0'; #pragma GCC diagnostic pop - new_obj->dfs = dfs; - new_obj->mode = obj->mode; - new_obj->flags = flags; + new_obj->dfs = dfs; + new_obj->mode = obj->mode; + new_obj->flags = flags; oid_cp(&new_obj->parent_oid, obj->parent_oid); oid_cp(&new_obj->oid, obj->oid); diff --git a/src/include/daos_srv/daos_engine.h b/src/include/daos_srv/daos_engine.h index dba0bf67376..cbb646e31b7 100644 --- a/src/include/daos_srv/daos_engine.h +++ b/src/include/daos_srv/daos_engine.h @@ -409,16 +409,16 @@ struct dss_module { * Stack size used for ULTs with deep stack */ #if defined(__clang__) -# if defined(__has_feature) && __has_feature(address_sanitizer) -# define DSS_DEEP_STACK_SZ 98304 -# endif +#if defined(__has_feature) && __has_feature(address_sanitizer) +#define DSS_DEEP_STACK_SZ 98304 +#endif #elif defined(__GNUC__) -# ifdef __SANITIZE_ADDRESS__ -# define DSS_DEEP_STACK_SZ 98304 -# endif +#ifdef __SANITIZE_ADDRESS__ +#define DSS_DEEP_STACK_SZ 98304 +#endif #endif #ifndef DSS_DEEP_STACK_SZ -# define DSS_DEEP_STACK_SZ 65536 +#define DSS_DEEP_STACK_SZ 65536 #endif enum dss_xs_type { From 8e5d47d1f43cbc6c420bb1e847d644ce643847dc Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 27/28] DAOS-16501 build: Add libsanitize Revert gcc strigop-truncation warning. Signed-off-by: Cedric Koch-Hofer --- src/client/dfs/cont.c | 5 +---- src/client/dfs/obj.c | 15 +++------------ src/client/dfuse/ops/lookup.c | 15 +++------------ 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/client/dfs/cont.c b/src/client/dfs/cont.c index 57733de9229..10f3036201e 100644 --- a/src/client/dfs/cont.c +++ b/src/client/dfs/cont.c @@ -84,12 +84,9 @@ dfs_cont_create(daos_handle_t poh, uuid_t *cuuid, dfs_attr_t *attr, daos_handle_ dattr.da_chunk_size = DFS_DEFAULT_CHUNK_SIZE; if (attr->da_hints[0] != 0) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN - 1); - dattr.da_hints[DAOS_CONT_HINT_MAX_LEN - 1] = '\0'; -#pragma GCC diagnostic pop + dattr.da_hints[DAOS_CONT_HINT_MAX_LEN - 1] = NULL; } } else { dattr.da_oclass_id = 0; diff --git a/src/client/dfs/obj.c b/src/client/dfs/obj.c index e922b9e11d0..ffcd3e63ba2 100644 --- a/src/client/dfs/obj.c +++ b/src/client/dfs/obj.c @@ -511,12 +511,9 @@ dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **_new_obj) D_GOTO(err, rc = EINVAL); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(new_obj->name, obj->name, DFS_MAX_NAME); - new_obj->name[DFS_MAX_NAME] = '\0'; -#pragma GCC diagnostic pop + new_obj->name[DFS_MAX_NAME] = NULL; new_obj->dfs = dfs; new_obj->mode = obj->mode; new_obj->flags = flags; @@ -622,12 +619,9 @@ dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob) oid_cp(&obj_glob->parent_oid, obj->parent_oid); uuid_copy(obj_glob->coh_uuid, coh_uuid); uuid_copy(obj_glob->cont_uuid, cont_uuid); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(obj_glob->name, obj->name, DFS_MAX_NAME); - obj_glob->name[DFS_MAX_NAME] = '\0'; -#pragma GCC diagnostic pop + obj_glob->name[DFS_MAX_NAME] = NULL; if (S_ISDIR(obj_glob->mode)) return 0; rc = dfs_get_chunk_size(obj, &obj_glob->chunk_size); @@ -684,12 +678,9 @@ dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **_obj) oid_cp(&obj->oid, obj_glob->oid); oid_cp(&obj->parent_oid, obj_glob->parent_oid); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(obj->name, obj_glob->name, DFS_MAX_NAME); - obj->name[DFS_MAX_NAME] = '\0'; -#pragma GCC diagnostic pop + obj->name[DFS_MAX_NAME] = NULL; obj->mode = obj_glob->mode; obj->dfs = dfs; obj->flags = flags ? flags : obj_glob->flags; diff --git a/src/client/dfuse/ops/lookup.c b/src/client/dfuse/ops/lookup.c index d9af8bb8ddb..7d7ce80a09c 100644 --- a/src/client/dfuse/ops/lookup.c +++ b/src/client/dfuse/ops/lookup.c @@ -119,20 +119,14 @@ dfuse_reply_entry(struct dfuse_info *dfuse_info, struct dfuse_inode_entry *ie, /* Save the old name so that we can invalidate it in later */ wipe_parent = inode->ie_parent; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(wipe_name, inode->ie_name, NAME_MAX); - wipe_name[NAME_MAX] = '\0'; -#pragma GCC diagnostic pop + wipe_name[NAME_MAX] = NULL; inode->ie_parent = ie->ie_parent; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(inode->ie_name, ie->ie_name, NAME_MAX); - inode->ie_name[NAME_MAX] = '\0'; -#pragma GCC diagnostic pop + inode->ie_name[NAME_MAX] = NULL; } atomic_fetch_sub_relaxed(&ie->ie_ref, 1); dfuse_ie_close(dfuse_info, ie); @@ -304,12 +298,9 @@ dfuse_cb_lookup(fuse_req_t req, struct dfuse_inode_entry *parent, if (attr_len) DFUSE_TRA_DEBUG(ie, "Attr len is %zi", attr_len); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(ie->ie_name, name, NAME_MAX); - ie->ie_name[NAME_MAX] = '\0'; -#pragma GCC diagnostic pop + ie->ie_name[NAME_MAX] = NULL; dfs_obj2id(ie->ie_obj, &ie->ie_oid); From 79d730f95f445be86c472496ed278cb32da5f520 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 10 Dec 2024 14:41:05 +0000 Subject: [PATCH 28/28] DAOS-16501 build: Add libsanitize Revert gcc strigop-truncation warning. Signed-off-by: Cedric Koch-Hofer --- src/client/dfs/cont.c | 2 +- src/client/dfs/obj.c | 6 +++--- src/client/dfuse/ops/lookup.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client/dfs/cont.c b/src/client/dfs/cont.c index 10f3036201e..f1da6b17a09 100644 --- a/src/client/dfs/cont.c +++ b/src/client/dfs/cont.c @@ -86,7 +86,7 @@ dfs_cont_create(daos_handle_t poh, uuid_t *cuuid, dfs_attr_t *attr, daos_handle_ if (attr->da_hints[0] != 0) { /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN - 1); - dattr.da_hints[DAOS_CONT_HINT_MAX_LEN - 1] = NULL; + dattr.da_hints[DAOS_CONT_HINT_MAX_LEN - 1] = '\0'; } } else { dattr.da_oclass_id = 0; diff --git a/src/client/dfs/obj.c b/src/client/dfs/obj.c index ffcd3e63ba2..215a4dbe218 100644 --- a/src/client/dfs/obj.c +++ b/src/client/dfs/obj.c @@ -513,7 +513,7 @@ dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **_new_obj) /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(new_obj->name, obj->name, DFS_MAX_NAME); - new_obj->name[DFS_MAX_NAME] = NULL; + new_obj->name[DFS_MAX_NAME] = '\0'; new_obj->dfs = dfs; new_obj->mode = obj->mode; new_obj->flags = flags; @@ -621,7 +621,7 @@ dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob) uuid_copy(obj_glob->cont_uuid, cont_uuid); /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(obj_glob->name, obj->name, DFS_MAX_NAME); - obj_glob->name[DFS_MAX_NAME] = NULL; + obj_glob->name[DFS_MAX_NAME] = '\0'; if (S_ISDIR(obj_glob->mode)) return 0; rc = dfs_get_chunk_size(obj, &obj_glob->chunk_size); @@ -680,7 +680,7 @@ dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **_obj) oid_cp(&obj->parent_oid, obj_glob->parent_oid); /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(obj->name, obj_glob->name, DFS_MAX_NAME); - obj->name[DFS_MAX_NAME] = NULL; + obj->name[DFS_MAX_NAME] = '\0'; obj->mode = obj_glob->mode; obj->dfs = dfs; obj->flags = flags ? flags : obj_glob->flags; diff --git a/src/client/dfuse/ops/lookup.c b/src/client/dfuse/ops/lookup.c index 7d7ce80a09c..84c2ceafb3c 100644 --- a/src/client/dfuse/ops/lookup.c +++ b/src/client/dfuse/ops/lookup.c @@ -121,12 +121,12 @@ dfuse_reply_entry(struct dfuse_info *dfuse_info, struct dfuse_inode_entry *ie, wipe_parent = inode->ie_parent; /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(wipe_name, inode->ie_name, NAME_MAX); - wipe_name[NAME_MAX] = NULL; + wipe_name[NAME_MAX] = '\0'; inode->ie_parent = ie->ie_parent; /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(inode->ie_name, ie->ie_name, NAME_MAX); - inode->ie_name[NAME_MAX] = NULL; + inode->ie_name[NAME_MAX] = '\0'; } atomic_fetch_sub_relaxed(&ie->ie_ref, 1); dfuse_ie_close(dfuse_info, ie); @@ -300,7 +300,7 @@ dfuse_cb_lookup(fuse_req_t req, struct dfuse_inode_entry *parent, /* DAOS-17042 Replace strncpy with strncat or strlcpy */ strncpy(ie->ie_name, name, NAME_MAX); - ie->ie_name[NAME_MAX] = NULL; + ie->ie_name[NAME_MAX] = '\0'; dfs_obj2id(ie->ie_obj, &ie->ie_oid);