Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-16501 build: Add libsanitize #15105

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2d97760
DAOS-16501 build: Add libsanitize
kanard38 Sep 9, 2024
8d233f5
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Sep 9, 2024
ce48861
DAOS-16501 build: Add libsanitize
kanard38 Sep 9, 2024
b398459
DAOS-16501 build: Add libsanitize
kanard38 Sep 9, 2024
fbc4faa
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Sep 24, 2024
7e9f339
DAOS-16501 build: Add libsanitize
kanard38 Sep 9, 2024
e7e8139
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Dec 6, 2024
430daf6
DAOS-16501 build: Add libsanitize
kanard38 Sep 9, 2024
bf62474
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Dec 10, 2024
3e7f272
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
f66748c
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Dec 31, 2024
4f31826
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
472d178
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
35446b7
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
409fc8d
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
afc358a
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Jan 6, 2025
9a4a358
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
ec60363
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
343449a
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
e2a272b
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
1bbf2b1
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
9535e1c
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
df2675b
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
6b25da9
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
192f66d
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
9ef5a08
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
2566572
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
0011ba7
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Jan 8, 2025
d81556c
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
4fb5e2e
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Jan 17, 2025
5daf2d6
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Jan 20, 2025
e5e647f
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
8453507
DAOS-16501 build: Add libsanitize
kanard38 Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* groovylint-disable-next-line LineLength */
/* groovylint-disable DuplicateMapLiteral, DuplicateNumberLiteral */
/* groovylint-disable DuplicateStringLiteral, NestedBlockDepth, VariableName */
/* Copyright 2019-2024 Intel Corporation

Check failure on line 5 in Jenkinsfile

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
* Copyright 2025 Hewlett Packard Enterprise Development LP
* All rights reserved.
*
Expand Down Expand Up @@ -137,6 +137,15 @@
job_status_update()
}

String sconsArgs() {
if (!params.CI_SCONS_ARGS) {
return sconsFaultsArgs()
}

println("Compiling DAOS with libasan")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not libasan specific argument.

Suggested change
println("Compiling DAOS with libasan")
println("Compiling DAOS with custom arguments")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix Jenkinsfile argument help

return sconsFaultsArgs() + ' ' + params.CI_SCONS_ARGS
}

/**
* Update default commit pragmas based on files modified.
*/
Expand All @@ -161,7 +170,7 @@
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 {
Expand Down Expand Up @@ -331,6 +340,9 @@
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 {
Expand Down Expand Up @@ -612,7 +624,7 @@
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 {
Expand Down
1 change: 1 addition & 0 deletions ci/provisioning/post_provision_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions ci/unit/required_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pkgs="argobots \
fuse3-libs \
gotestsum \
hwloc-devel \
libasan \
libipmctl-devel \
libisa-l-devel \
libfabric-devel \
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
daos (2.7.101-4) unstable; urgency=medium
[ Cedric Koch-Hofer]
* Add support of the libasan

-- Cedric Koch-Hofer <[email protected]> Mon, 20 Jan 2025 14:12:00 -0700

daos (2.7.101-3) unstable; urgency=medium
[ Jeff Olivier ]
* Switch from libfuse3 to libfused
Expand Down
3 changes: 2 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Build-Depends: debhelper (>= 10),
liblz4-dev,
libaio-dev,
libcapstone-dev,
libpci-dev
libpci-dev,
libasan5
Standards-Version: 4.1.2
Homepage: https://docs.daos.io/
Vcs-Git: https://github.com/daos-stack/daos.git
Expand Down
51 changes: 51 additions & 0 deletions docs/dev/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, ...
Shall we move this info to the compiler_setuo.py script where actual values are proposed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do both. I will add this info int the compiler_setup.py script.

  • Add info about compiler custom setting and consequences in the compiler_setup.py script.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests, such as those using Valgrind, may fail due to false positives.
Is it a problem with the ASan integration or is it just a known issue that ASan may not work properly with Valgrind?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I have not dive too much into this but it seems reasonable to think that they will not be well interact. At this time, I am sure that the unit test are miss interpreting the Asan report output. I have planned to do this in the follow-up PR.
My goal with this PR was to allow the two actions:

  1. Allow developers to build instrumented versions of DAOS with updating the scons build system
  2. Allow the support team to build RPMs with instrumented binaries with the CI.


## Go dependencies

Developers contributing Go code may need to change the external dependencies
Expand Down
10 changes: 9 additions & 1 deletion site_scons/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2016-2024 Intel Corporation

Check failure on line 1 in site_scons/components/__init__.py

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -277,7 +277,15 @@
abt_build = ['./configure',
'--prefix=$ARGOBOTS_PREFIX',
'CC=gcc',
'--enable-stack-unwind']
'--enable-stack-unwind=yes']
try:
if reqs.get_env('SANITIZERS') != "":
# 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']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abt_build += ['--enable-default-stacksize=32768']
This may not work for these area where custom (bigger than default) stack size is used - see DSS_DEEP_STACK_SZ.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I will try to find a way to increase It when we are using the libasan.

  • Increase DSS_DEEP_STACK_SZ when libasan is used

except KeyError:
pass

if reqs.target_type == 'debug':
abt_build.append('--enable-debug=most')
Expand Down
2 changes: 2 additions & 0 deletions site_scons/prereq_tools/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2016-2024 Intel Corporation

Check failure on line 1 in site_scons/prereq_tools/base.py

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
# 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
Expand Down Expand Up @@ -469,6 +470,7 @@
['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)

Expand Down
47 changes: 46 additions & 1 deletion site_scons/site_tools/compiler_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

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',
Expand All @@ -14,7 +17,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'])
Expand Down Expand Up @@ -55,6 +58,28 @@ 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']
cc_flags = [f"-Wframe-larger-than={ASAN_FRAME_SIZE_MAX[cc]}",
'-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'})

Expand Down Expand Up @@ -184,10 +209,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):
Expand Down
4 changes: 1 addition & 3 deletions src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,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))
Expand Down
2 changes: 1 addition & 1 deletion src/client/dfs/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion src/client/dfs/cont.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* (C) Copyright 2018-2024 Intel Corporation.

Check failure on line 2 in src/client/dfs/cont.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -83,7 +84,7 @@
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);
memcpy(dattr.da_hints, attr->da_hints, DAOS_CONT_HINT_MAX_LEN - 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Restore, add comments and pragma on strncpy() usage

dattr.da_hints[DAOS_CONT_HINT_MAX_LEN - 1] = '\0';
}
} else {
Expand Down
16 changes: 9 additions & 7 deletions src/client/dfs/obj.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* (C) Copyright 2018-2024 Intel Corporation.

Check failure on line 2 in src/client/dfs/obj.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -510,10 +511,11 @@
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;
memcpy(new_obj->name, obj->name, DFS_MAX_NAME);
new_obj->name[DFS_MAX_NAME] = '\0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was there a compiler warning for this?
this should not be necessary because obj->name should have been verified before that it does not exceed DFS_MAX_LEN.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not fully understand, but I have this kind of new compiler warning that I struggle to solve:

[2025-01-06T16:28:18.441Z] sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF8)
[2025-01-06T16:28:18.441Z] In file included from /usr/include/string.h:519,
[2025-01-06T16:28:18.441Z]                  from src/include/daos/common.h:17,
[2025-01-06T16:28:18.441Z]                  from src/client/dfs/obj.c:12:
[2025-01-06T16:28:18.441Z] In function 'strncpy',
[2025-01-06T16:28:18.441Z]     inlined from 'dfs_dup' at src/client/dfs/obj.c:514:2:
[2025-01-06T16:28:18.441Z] /usr/include/bits/string_fortified.h:95:10: error: '__builtin_strncpy' output may be truncated copying 255 bytes from a string of length 255 [-Werror=stringop-truncation]
[2025-01-06T16:28:18.441Z]    95 |   return __builtin___strncpy_chk (__dest, __src, __len,
[2025-01-06T16:28:18.441Z]       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[2025-01-06T16:28:18.441Z]    96 |                                   __glibc_objsize (__dest));
[2025-01-06T16:28:18.441Z]       |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The better solution will be to replace all strncpy() with strncat()

strncat(new_obj->name, obj->name, DFS_MAX_NAME);

strncpy() adds some overhead as it always fills the destination up with \0 up to given maximum size.

strncat(), when used properly (with BUF_MAX_SIZE -1), ensures both: no overwriting and \0 at the end of the string.

Alternatively, we can ignore this warning here and in all similar places with pragmas:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(new_obj->name, obj->name, DFS_MAX_NAME + 1);
#pragma GCC diagnostic pop

I see many places in DAOS where strncpy() is used. It might be better to fix all output may be truncated copying' warnings with #pragma' in this PR, and fix the misuse of strncpy() in a separate PR.
This PR should only address the introduction of the sanitizer. It should not fix any problems.

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);

Expand Down Expand Up @@ -616,8 +618,8 @@
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;
memcpy(obj_glob->name, obj->name, DFS_MAX_NAME);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Restore, add comments and pragma on strncpy() usage

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);
Expand Down Expand Up @@ -674,7 +676,7 @@

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);
memcpy(obj->name, obj_glob->name, DFS_MAX_NAME);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Restore, add comments and pragma on strncpy() usage

obj->name[DFS_MAX_NAME] = '\0';
obj->mode = obj_glob->mode;
obj->dfs = dfs;
Expand Down
7 changes: 5 additions & 2 deletions src/client/dfuse/ops/lookup.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* (C) Copyright 2016-2024 Intel Corporation.

Check failure on line 2 in src/client/dfuse/ops/lookup.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -118,11 +119,12 @@

/* 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);
memcpy(wipe_name, inode->ie_name, NAME_MAX);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Restore, add comments and pragma on strncpy() usage

wipe_name[NAME_MAX] = '\0';

inode->ie_parent = ie->ie_parent;
strncpy(inode->ie_name, ie->ie_name, NAME_MAX + 1);
memcpy(inode->ie_name, ie->ie_name, NAME_MAX);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Restore, add comments and pragma on strncpy() usage

inode->ie_name[NAME_MAX] = '\0';
}
atomic_fetch_sub_relaxed(&ie->ie_ref, 1);
dfuse_ie_close(dfuse_info, ie);
Expand Down Expand Up @@ -295,6 +297,7 @@
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);

Expand Down
2 changes: 2 additions & 0 deletions src/control/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
3 changes: 2 additions & 1 deletion src/tests/obj_ctl.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* (C) Copyright 2017-2022 Intel Corporation.

Check failure on line 2 in src/tests/obj_ctl.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -198,7 +199,7 @@
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 {
Expand Down
Loading
Loading