28 Commits

Author SHA1 Message Date
Luke Parker
a8ca3ea1dd Restore path specifications for when the stack size CI should be run
Also schedules a weekly run to ensure this doesn't inadvertently decay.
2025-12-09 00:55:16 -05:00
Luke Parker
bd6e4271e4 Add || true to handle how cmp was returning a non-zero code for the (expectedly) different files 2025-12-09 00:48:59 -05:00
Luke Parker
1ed4261cf0 Debug cmp call in CI 2025-12-09 00:42:31 -05:00
Luke Parker
6dffe8e805 Add debugging statements to figure where the CI workflow is erroring 2025-12-09 00:33:36 -05:00
Luke Parker
af085ba9c1 Remove head -c for cut, as head -c is not POSIX-compliant
`tail -c` is however. Since we used `head -c-`, to cut off characters from the
end, the POSIX-compliant `wc -c` is used for a `strlen` we can proceed to do
the necessary arithmetic off of.

Credit to @PlasmaPower for identifying this non-compliant behavior which
necessitated this fix in response.
2025-12-09 00:31:09 -05:00
Luke Parker
d881421e7e Extend debugging when comparing SHA-256 hashes 2025-12-09 00:06:06 -05:00
Luke Parker
48914aad0a Once again fix read_stack 2025-12-08 23:58:18 -05:00
Luke Parker
7d6bac9ab4 yash, brush shells 2025-12-08 23:52:36 -05:00
Luke Parker
dcb8cbad0d Correct read_stack function 2025-12-08 23:38:42 -05:00
Luke Parker
8ad88dce9a Remove non-POSIX tcsh from list of shells 2025-12-08 23:30:51 -05:00
Luke Parker
63133ae530 Call the shells via a sh symlink to trigger their POSIX-compliant behavior (if special-cased based on how the shell was invoked) 2025-12-08 23:22:55 -05:00
Luke Parker
1ab1cad7c5 Correct order symlinks are created in 2025-12-08 22:59:42 -05:00
Luke Parker
8a5cce2ce8 Use symlinks for ash, add hush 2025-12-08 22:57:56 -05:00
Luke Parker
ec0347a73e Alias ash since the busybox package on Ubuntu doesn't provide such a symlink 2025-12-08 22:52:43 -05:00
Luke Parker
6d2a496054 Prune output of sha256sum to the hash alone
This causes the equality not to fail simply because the file names are
different.
2025-12-08 22:50:12 -05:00
Luke Parker
48a3cf5027 Fix POSIX compliance of increase_default_stack_size.sh
It turns out `\xXX` is not part of POSIX. The Octal `\ddd` is however, and is
used here.
2025-12-08 22:47:10 -05:00
Luke Parker
34dbfedc5a Expand the amount of shells tested with 2025-12-08 21:09:56 -05:00
Luke Parker
f4efa76e3f ./chelf instead of chelf 2025-12-08 20:57:23 -05:00
Luke Parker
19c18af086 Explicitly call ./muslstack instead of muslstack 2025-12-08 20:55:52 -05:00
Luke Parker
b0e40cae58 Add debug ls command 2025-12-08 20:54:42 -05:00
Luke Parker
606e67f937 Set GOBIN env variable 2025-12-08 20:53:21 -05:00
Luke Parker
fee3e2fa21 go get -> go install 2025-12-08 20:51:09 -05:00
Luke Parker
52cbc90876 Update stack size CI to only run on Linux runners 2025-12-08 20:50:01 -05:00
Luke Parker
1f39eb16c8 Remove _all_ paths scoping for the stack size CI for now 2025-12-08 20:46:01 -05:00
Luke Parker
fbe515cf9b Have stack size CI run whenever it itself is modified 2025-12-08 20:44:13 -05:00
Luke Parker
1cb6cb608f Remove paths argument from workflow_dispatch trigger 2025-12-08 20:41:25 -05:00
Luke Parker
881353fb4a Correction action definition in stack size CI 2025-12-08 20:40:22 -05:00
Luke Parker
a5f8ce9ec6 Add CI to verify increase_default_stack_size.sh functions as expected 2025-12-08 20:36:43 -05:00
2 changed files with 15 additions and 24 deletions

View File

@@ -37,21 +37,21 @@ jobs:
cd chelf
git checkout b2994186cea7b7d61a588fd06c1cc1ae75bcc21a
make
./chelf -s "$STACK" ../monerod-chelf
./chelf -s $STACK ../monerod-chelf
cd ..
cp monerod monerod-muslstack
GOBIN=$(pwd) go install github.com/yaegashi/muslstack@d19cc5866abce3ca59dfc1666df7cc97097d0933
./muslstack -s "$STACK" ./monerod-muslstack
./muslstack -s $STACK ./monerod-muslstack
sudo apt update -y
sudo apt install -y ksh bash dash zsh busybox mksh posh yash
sudo ln -s "$(which busybox)" /usr/bin/ash
sudo ln -s "$(which busybox)" /usr/bin/hush
sudo apt install -y ksh bash dash zsh busybox mksh yash
sudo ln -s $(which busybox) /usr/bin/ash
sudo ln -s $(which busybox) /usr/bin/hush
cargo install brush-shell
for shell in sh ksh bash dash zsh ash hush mksh lksh posh yash brush; do
for shell in sh ksh bash dash zsh ash hush mksh yash brush; do
cp monerod monerod-idss-$shell
ln -s "$(which $shell)" sh
ln -s $(which $shell) sh
./sh ./orchestration/increase_default_stack_size.sh monerod-idss-$shell
rm ./sh
done
@@ -70,7 +70,7 @@ jobs:
read_stack() {
STACK_INFO=$(readelf "$1" -l | grep STACK -A1)
MEMSZ=$(printf "%s\n" "$STACK_INFO" | tail -n1 | sed -E s/^[[:space:]]*//g | cut -f2 -d' ')
MEMSZ=$(echo "$STACK_INFO" | tail -n1 | sed -E s/^[[:space:]]*//g | cut -f2 -d' ')
printf "%i" $((MEMSZ))
}
INITIAL_STACK=$(read_stack monerod)

View File

@@ -27,8 +27,7 @@ read_bytes() {
dd bs=1 skip="$1" count="$2" if="$ELF" 2> /dev/null | hex
}
hex_to_octal() {
HEX=$(printf "%s" "$1" | tr "[:lower:]" "[:upper:]")
printf "ibase=16; obase=8; %s\n" "$HEX" | bc
printf "ibase=16; obase=8; %s\n" "$1" | bc
}
write_bytes() {
POS=$1
@@ -48,7 +47,7 @@ write_bytes() {
# Magic
MAGIC=$(read_bytes 0 4)
# shellcheck disable=SC2059
EXPECTED_MAGIC=$(printf \\"$(hex_to_octal 7f)"ELF | hex)
EXPECTED_MAGIC=$(printf \\"$(hex_to_octal 7F)"ELF | hex)
if [ ! "$MAGIC" = "$EXPECTED_MAGIC" ]; then
echo "Not ELF"
exit 2
@@ -79,12 +78,6 @@ read_integer_by_offset() {
OFFSET=$(value_per_bits "$1" "$2")
BYTES=$(read_bytes "$OFFSET" "$3")
BYTES=$(swap_native_endian "$BYTES")
BYTES=$(printf "%s" "$BYTES" | tr "[:lower:]" "[:upper:]")
LESS_THAN_SANITY=$(printf "ibase=16; if(%s < 6FFFFFFF)1;\n" "$BYTES" | bc)
if [ ! "$LESS_THAN_SANITY" = "1" ]; then
echo "Integer value is approximate to 2**31, risking a signed long overflow"
exit 4
fi
printf "%i" $(( 0x$BYTES ))
}
@@ -95,7 +88,7 @@ case $LITTLE_ENDIAN in
"02") LITTLE_ENDIAN=0;;
*)
echo "Not little- or big- endian"
exit 5
exit 4
;;
esac
@@ -126,13 +119,13 @@ swap_native_endian() {
ELF_VERSION=$(read_bytes 6 1)
if [ ! "$ELF_VERSION" = "01" ]; then
echo "Unknown ELF Version ($ELF_VERSION)"
exit 6
exit 5
fi
ELF_VERSION_2=$(read_bytes $((0x14)) 4)
if [ ! "$ELF_VERSION_2" = "$(swap_native_endian 00000001)" ]; then
echo "Unknown secondary ELF Version ($ELF_VERSION_2)"
exit 7
exit 6
fi
# Find where the program headers are
@@ -141,7 +134,7 @@ PROGRAM_HEADER_SIZE=$(value_per_bits 0x20 0x38)
DECLARED_PROGRAM_HEADER_SIZE=$(read_integer_by_offset 0x2a 0x36 2)
if [ ! "$PROGRAM_HEADER_SIZE" -eq "$DECLARED_PROGRAM_HEADER_SIZE" ]; then
echo "Unexpected size of a program header ($DECLARED_PROGRAM_HEADER_SIZE)"
exit 8
exit 7
fi
program_header_start() {
printf "%i" $((PROGRAM_HEADERS_OFFSET + ($1 * PROGRAM_HEADER_SIZE)))
@@ -169,8 +162,6 @@ while [ "$NEXT_PROGRAM_HEADER" -ne -1 ]; do
fi
FOUND=1
# This line is the only line really risking an arithmetic overflow, yet the bound on the start of
# the section, combined with a maximum section length of `0xffff * 0x38`, makes this fit
MEMSZ_OFFSET=$(( $(program_header_start "$THIS_PROGRAM_HEADER") + $(value_per_bits 0x14 0x28) ))
MEMSZ_LEN=$(value_per_bits 4 8)
# `MEMSZ_OFFSET MEMSZ_OFFSET` as we've already derived it depending on the amount of bits
@@ -187,7 +178,7 @@ done
if [ "$FOUND" -eq 0 ]; then
echo "\`PT_GNU_STACK\` program header not found"
exit 9
exit 8
fi
echo "All instances of \`PT_GNU_STACK\` patched to be at least 8 MB"