Compare commits

..

No commits in common. "9554b8d1d1203c6f2d3ad5315ffa95cfd7494f45" and "7b11770bae0653eb7c9c81f90ebc7324c25bf697" have entirely different histories.

3 changed files with 12 additions and 23 deletions

View File

@ -50,7 +50,6 @@ int efi_get_variable(
_cleanup_free_ char *p = NULL; _cleanup_free_ char *p = NULL;
_cleanup_free_ void *buf = NULL; _cleanup_free_ void *buf = NULL;
struct stat st; struct stat st;
usec_t begin;
uint32_t a; uint32_t a;
ssize_t n; ssize_t n;
@ -69,9 +68,6 @@ int efi_get_variable(
return 0; return 0;
} }
if (DEBUG_LOGGING)
begin = now(CLOCK_MONOTONIC);
fd = open(p, O_RDONLY|O_NOCTTY|O_CLOEXEC); fd = open(p, O_RDONLY|O_NOCTTY|O_CLOEXEC);
if (fd < 0) if (fd < 0)
return log_debug_errno(errno, "open(\"%s\") failed: %m", p); return log_debug_errno(errno, "open(\"%s\") failed: %m", p);
@ -125,16 +121,6 @@ int efi_get_variable(
/* Assume that the reported size is accurate */ /* Assume that the reported size is accurate */
n = st.st_size - 4; n = st.st_size - 4;
if (DEBUG_LOGGING) {
char ts[FORMAT_TIMESPAN_MAX];
usec_t end;
end = now(CLOCK_MONOTONIC);
if (end > begin + EFI_RETRY_DELAY)
log_debug("Detected slow EFI variable read access on " SD_ID128_FORMAT_STR "-%s: %s",
SD_ID128_FORMAT_VAL(vendor), name, format_timespan(ts, sizeof(ts), end - begin, 1));
}
/* Note that efivarfs interestingly doesn't require ftruncate() to update an existing EFI variable /* Note that efivarfs interestingly doesn't require ftruncate() to update an existing EFI variable
* with a smaller value. */ * with a smaller value. */

View File

@ -10,10 +10,10 @@ runas() {
su "$userid" -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID exec "$@"' -- sh "$@" su "$userid" -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID exec "$@"' -- sh "$@"
} }
runas testuser systemd-run --wait --user --unit=test-private-users \ runas testuser systemd-run --user --unit=test-private-users \
-p PrivateUsers=yes -P echo hello -p PrivateUsers=yes -P echo hello
runas testuser systemd-run --wait --user --unit=test-private-tmp-innerfile \ runas testuser systemd-run --user --unit=test-private-tmp-innerfile \
-p PrivateUsers=yes -p PrivateTmp=yes \ -p PrivateUsers=yes -p PrivateTmp=yes \
-P touch /tmp/innerfile.txt -P touch /tmp/innerfile.txt
# File should not exist outside the job's tmp directory. # File should not exist outside the job's tmp directory.
@ -21,17 +21,17 @@ test ! -e /tmp/innerfile.txt
touch /tmp/outerfile.txt touch /tmp/outerfile.txt
# File should not appear in unit's private tmp. # File should not appear in unit's private tmp.
runas testuser systemd-run --wait --user --unit=test-private-tmp-outerfile \ runas testuser systemd-run --user --unit=test-private-tmp-outerfile \
-p PrivateUsers=yes -p PrivateTmp=yes \ -p PrivateUsers=yes -p PrivateTmp=yes \
-P test ! -e /tmp/outerfile.txt -P test ! -e /tmp/outerfile.txt
# Confirm that creating a file in home works # Confirm that creating a file in home works
runas testuser systemd-run --wait --user --unit=test-unprotected-home \ runas testuser systemd-run --user --unit=test-unprotected-home \
-P touch /home/testuser/works.txt -P touch /home/testuser/works.txt
test -e /home/testuser/works.txt test -e /home/testuser/works.txt
# Confirm that creating a file in home is blocked under read-only # Confirm that creating a file in home is blocked under read-only
runas testuser systemd-run --wait --user --unit=test-protect-home-read-only \ runas testuser systemd-run --user --unit=test-protect-home-read-only \
-p PrivateUsers=yes -p ProtectHome=read-only \ -p PrivateUsers=yes -p ProtectHome=read-only \
-P bash -c ' -P bash -c '
test -e /home/testuser/works.txt test -e /home/testuser/works.txt
@ -40,12 +40,12 @@ runas testuser systemd-run --wait --user --unit=test-protect-home-read-only \
test ! -e /home/testuser/blocked.txt test ! -e /home/testuser/blocked.txt
# Check that tmpfs hides the whole directory # Check that tmpfs hides the whole directory
runas testuser systemd-run --wait --user --unit=test-protect-home-tmpfs \ runas testuser systemd-run --user --unit=test-protect-home-tmpfs \
-p PrivateUsers=yes -p ProtectHome=tmpfs \ -p PrivateUsers=yes -p ProtectHome=tmpfs \
-P test ! -e /home/testuser -P test ! -e /home/testuser
# Confirm that home, /root, and /run/user are inaccessible under "yes" # Confirm that home, /root, and /run/user are inaccessible under "yes"
runas testuser systemd-run --wait --user --unit=test-protect-home-yes \ runas testuser systemd-run --user --unit=test-protect-home-yes \
-p PrivateUsers=yes -p ProtectHome=yes \ -p PrivateUsers=yes -p ProtectHome=yes \
-P bash -c ' -P bash -c '
test "$(stat -c %a /home)" = "0" test "$(stat -c %a /home)" = "0"
@ -57,7 +57,7 @@ runas testuser systemd-run --wait --user --unit=test-protect-home-yes \
# namespace (no CAP_SETGID in the parent namespace to write the additional # namespace (no CAP_SETGID in the parent namespace to write the additional
# mapping of the user supplied group and thus cannot change groups to an # mapping of the user supplied group and thus cannot change groups to an
# unmapped group ID) # unmapped group ID)
! runas testuser systemd-run --wait --user --unit=test-group-fail \ ! runas testuser systemd-run --user --unit=test-group-fail \
-p PrivateUsers=yes -p Group=daemon \ -p PrivateUsers=yes -p Group=daemon \
-P true -P true

View File

@ -21,8 +21,11 @@ pip3 install ninja meson
cd $REPO_ROOT cd $REPO_ROOT
export PATH="$HOME/.local/bin/:$PATH" export PATH="$HOME/.local/bin/:$PATH"
# We use a subset of https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks instead of "undefined"
# because our fuzzers crash with "float-cast-overflow":
# https://github.com/systemd/systemd/pull/12812#issuecomment-502780455
# TODO: figure out what to do about unsigned-integer-overflow: https://github.com/google/oss-fuzz/issues/910 # TODO: figure out what to do about unsigned-integer-overflow: https://github.com/google/oss-fuzz/issues/910
export SANITIZER="address -fsanitize=undefined,unsigned-integer-overflow" export SANITIZER="address -fsanitize=alignment,array-bounds,bool,bounds,builtin,enum,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,pointer-overflow,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,unsigned-integer-overflow,vla-bound,vptr -fno-sanitize-recover=alignment,array-bounds,bool,bounds,builtin,enum,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,pointer-overflow,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
tools/oss-fuzz.sh tools/oss-fuzz.sh
FUZZING_TYPE=${1:-regression} FUZZING_TYPE=${1:-regression}