summaryrefslogtreecommitdiffstats
path: root/tests/f_badsymlinks
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:49:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:49:25 +0000
commit464df1d5e5ab1322e2dd0a7796939fff1aeefa9a (patch)
tree6a403684e0978f0287d7f0ec0e5aab1fd31a59e1 /tests/f_badsymlinks
parentInitial commit. (diff)
downloade2fsprogs-upstream.tar.xz
e2fsprogs-upstream.zip
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/f_badsymlinks/expect.161
-rw-r--r--tests/f_badsymlinks/expect.27
-rw-r--r--tests/f_badsymlinks/image.gzbin0 -> 1767 bytes
-rw-r--r--tests/f_badsymlinks/name1
-rw-r--r--tests/f_badsymlinks2/expect.1114
-rw-r--r--tests/f_badsymlinks2/expect.27
-rw-r--r--tests/f_badsymlinks2/image.gzbin0 -> 14302 bytes
-rwxr-xr-xtests/f_badsymlinks2/mkimage.sh127
-rw-r--r--tests/f_badsymlinks2/name1
9 files changed, 318 insertions, 0 deletions
diff --git a/tests/f_badsymlinks/expect.1 b/tests/f_badsymlinks/expect.1
new file mode 100644
index 0000000..b28b57d
--- /dev/null
+++ b/tests/f_badsymlinks/expect.1
@@ -0,0 +1,61 @@
+Pass 1: Checking inodes, blocks, and sizes
+Special (device/socket/fifo/symlink) file (inode 18) has immutable
+or append-only flag set. Clear? yes
+
+Inode 19 has illegal block(s). Clear? yes
+
+Illegal block #0 (1234567890) in inode 19. CLEARED.
+Inode 19, i_blocks is 2, should be 0. Fix? yes
+
+Special (device/socket/fifo/symlink) file (inode 20) has immutable
+or append-only flag set. Clear? yes
+
+Inode 21 is too big. Truncate? yes
+
+Block #1 (22) causes symlink to be too big. CLEARED.
+Inode 21, i_blocks is 4, should be 2. Fix? yes
+
+Pass 2: Checking directory structure
+Symlink /empty_link (inode #17) is invalid.
+Clear? yes
+
+Symlink /long_fastlink (inode #13) is invalid.
+Clear? yes
+
+Symlink /long_link (inode #14) is invalid.
+Clear? yes
+
+Symlink /high_fastlink (inode #15) is invalid.
+Clear? yes
+
+Symlink /high_link (inode #16) is invalid.
+Clear? yes
+
+Symlink /empty_fastlink (inode #12) is invalid.
+Clear? yes
+
+Symlink /bad_link_block (inode #19) is invalid.
+Clear? yes
+
+Symlink /extra_link_block (inode #21) is invalid.
+Clear? yes
+
+Symlink /bad_link_size (inode #22) is invalid.
+Clear? yes
+
+Symlink /bad_fastlink_size (inode #23) is invalid.
+Clear? yes
+
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Free blocks count wrong for group #0 (1000, counted=1001).
+Fix? yes
+
+Free blocks count wrong (1000, counted=1001).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 13/32 files (7.7% non-contiguous), 23/1024 blocks
+Exit status is 1
diff --git a/tests/f_badsymlinks/expect.2 b/tests/f_badsymlinks/expect.2
new file mode 100644
index 0000000..1499551
--- /dev/null
+++ b/tests/f_badsymlinks/expect.2
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 13/32 files (0.0% non-contiguous), 23/1024 blocks
+Exit status is 0
diff --git a/tests/f_badsymlinks/image.gz b/tests/f_badsymlinks/image.gz
new file mode 100644
index 0000000..4ebacde
--- /dev/null
+++ b/tests/f_badsymlinks/image.gz
Binary files differ
diff --git a/tests/f_badsymlinks/name b/tests/f_badsymlinks/name
new file mode 100644
index 0000000..630858f
--- /dev/null
+++ b/tests/f_badsymlinks/name
@@ -0,0 +1 @@
+corrupted symlinks
diff --git a/tests/f_badsymlinks2/expect.1 b/tests/f_badsymlinks2/expect.1
new file mode 100644
index 0000000..939edce
--- /dev/null
+++ b/tests/f_badsymlinks2/expect.1
@@ -0,0 +1,114 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Symlink /default/empty (inode #13) is invalid.
+Clear? yes
+
+Symlink /default/fast_isize_too_small (inode #15) is invalid.
+Clear? yes
+
+Symlink /default/fast_isize_too_large (inode #16) is invalid.
+Clear? yes
+
+Symlink /default/slow_isize_too_small (inode #19) is invalid.
+Clear? yes
+
+Symlink /default/slow_isize_too_large (inode #20) is invalid.
+Clear? yes
+
+Symlink /default/one_too_long (inode #22) is invalid.
+Clear? yes
+
+Symlink /default/too_long (inode #23) is invalid.
+Clear? yes
+
+Symlink /encrypted/empty (inode #25) is invalid.
+Clear? yes
+
+Symlink /encrypted/fast_isize_too_large (inode #28) is invalid.
+Clear? yes
+
+Symlink /encrypted/fast_isize_too_small (inode #27) is invalid.
+Clear? yes
+
+Symlink /encrypted/one_too_long (inode #34) is invalid.
+Clear? yes
+
+Symlink /encrypted/slow_isize_too_large (inode #32) is invalid.
+Clear? yes
+
+Symlink /encrypted/slow_isize_too_small (inode #31) is invalid.
+Clear? yes
+
+Symlink /encrypted/too_long (inode #35) is invalid.
+Clear? yes
+
+Symlink /extents/empty (inode #38) is invalid.
+Clear? yes
+
+Symlink /extents/fast_isize_too_small (inode #40) is invalid.
+Clear? yes
+
+Symlink /extents/fast_isize_too_large (inode #41) is invalid.
+Clear? yes
+
+Symlink /extents/slow_isize_too_small (inode #44) is invalid.
+Clear? yes
+
+Symlink /extents/slow_isize_too_large (inode #45) is invalid.
+Clear? yes
+
+Symlink /extents/one_too_long (inode #47) is invalid.
+Clear? yes
+
+Symlink /extents/too_long (inode #48) is invalid.
+Clear? yes
+
+Symlink /extents_encrypted/empty (inode #50) is invalid.
+Clear? yes
+
+Symlink /extents_encrypted/fast_isize_too_large (inode #53) is invalid.
+Clear? yes
+
+Symlink /extents_encrypted/fast_isize_too_small (inode #52) is invalid.
+Clear? yes
+
+Symlink /extents_encrypted/one_too_long (inode #59) is invalid.
+Clear? yes
+
+Symlink /extents_encrypted/slow_isize_too_large (inode #57) is invalid.
+Clear? yes
+
+Symlink /extents_encrypted/slow_isize_too_small (inode #56) is invalid.
+Clear? yes
+
+Symlink /extents_encrypted/too_long (inode #60) is invalid.
+Clear? yes
+
+Symlink /inline_data/empty (inode #63) is invalid.
+Clear? yes
+
+Symlink /inline_data/fast_isize_too_small (inode #65) is invalid.
+Clear? yes
+
+Symlink /inline_data/fast_isize_too_large (inode #66) is invalid.
+Clear? yes
+
+Symlink /inline_data/slow_isize_too_small (inode #69) is invalid.
+Clear? yes
+
+Symlink /inline_data/slow_isize_too_large (inode #70) is invalid.
+Clear? yes
+
+Symlink /inline_data/one_too_long (inode #72) is invalid.
+Clear? yes
+
+Symlink /inline_data/too_long (inode #73) is invalid.
+Clear? yes
+
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 36/80 files (0.0% non-contiguous), 31/150 blocks
+Exit status is 1
diff --git a/tests/f_badsymlinks2/expect.2 b/tests/f_badsymlinks2/expect.2
new file mode 100644
index 0000000..3da98a8
--- /dev/null
+++ b/tests/f_badsymlinks2/expect.2
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 36/80 files (0.0% non-contiguous), 31/150 blocks
+Exit status is 0
diff --git a/tests/f_badsymlinks2/image.gz b/tests/f_badsymlinks2/image.gz
new file mode 100644
index 0000000..d1f314c
--- /dev/null
+++ b/tests/f_badsymlinks2/image.gz
Binary files differ
diff --git a/tests/f_badsymlinks2/mkimage.sh b/tests/f_badsymlinks2/mkimage.sh
new file mode 100755
index 0000000..6bbf020
--- /dev/null
+++ b/tests/f_badsymlinks2/mkimage.sh
@@ -0,0 +1,127 @@
+#!/bin/bash
+
+# This is the script that was used to create the image.gz in this directory.
+
+set -e -u
+
+BLOCKSIZE=4096
+
+do_debugfs() {
+ umount mnt
+ debugfs -w "$@" image
+ mount image mnt
+}
+
+do_tune2fs() {
+ umount mnt
+ tune2fs $@ image
+ mount image mnt
+}
+
+symlink() {
+ local len=$1
+ local src=$2
+ local target=$(perl -e 'print "A" x '$len)
+ ln -s $target $src
+ stat -c %i $src
+}
+
+# Overwrite the length in the header of the encrypted symlink target
+set_encrypted_symlink_len() {
+ local ino=$1
+ local len=$2
+
+ echo "zap_block -f <$ino> -p $((len%256)) -o 0 -l 1 0"
+ echo "zap_block -f <$ino> -p $((len/256)) -o 1 -l 1 0"
+}
+
+create_symlinks() {
+ local dir=$1
+ local encrypted=${2:-false}
+ local overhead=0
+ local ino
+
+ if $encrypted; then
+ overhead=2
+ fi
+
+ mkdir -p $dir
+
+ {
+ ino=$(symlink 1 $dir/empty)
+ echo "set_inode_field <$ino> i_size 10"
+ echo "set_inode_field <$ino> block[0] 0"
+
+ symlink 1 $dir/fast_min > /dev/null
+
+ ino=$(symlink 10 $dir/fast_isize_too_small)
+ echo "set_inode_field <$ino> i_size 1"
+
+ ino=$(symlink 10 $dir/fast_isize_too_large)
+ echo "set_inode_field <$ino> i_size 20"
+
+ symlink $((59 - overhead)) $dir/fast_max > /dev/null
+
+ symlink $((60 - overhead)) $dir/slow_min > /dev/null
+
+ ino=$(symlink 100 $dir/slow_isize_too_small)
+ echo "set_inode_field <$ino> i_size 80"
+
+ ino=$(symlink 100 $dir/slow_isize_too_large)
+ echo "set_inode_field <$ino> i_size 120"
+
+ symlink $((BLOCKSIZE - 1 - overhead)) $dir/slow_max > /dev/null
+
+ ino=$(symlink $((BLOCKSIZE - 1 - overhead)) $dir/one_too_long)
+ echo "set_inode_field <$ino> i_size $BLOCKSIZE"
+ echo "zap_block -f <$ino> -p 65 0"
+ if $encrypted; then
+ set_encrypted_symlink_len $ino $((BLOCKSIZE - overhead))
+ fi
+
+ ino=$(symlink $((BLOCKSIZE - 1 - overhead)) $dir/too_long)
+ echo "set_inode_field <$ino> i_size $((BLOCKSIZE + 1000))"
+ echo "zap_block -f <$ino> -p 65 0"
+ if $encrypted; then
+ set_encrypted_symlink_len $ino $((BLOCKSIZE + 1000 - overhead))
+ fi
+
+ } >> debugfs_commands
+ do_debugfs < debugfs_commands
+}
+
+create_encrypted_symlinks() {
+ local dir=$1 link
+
+ mkdir $dir
+ echo | e4crypt add_key $dir
+ create_symlinks $dir true
+
+ # Move symlinks into an unencrypted directory (leaving their targets
+ # encrypted). This makes the fsck output consistent.
+ mv $dir ${dir}~encrypted
+ mkdir $dir
+ mv ${dir}~encrypted/* $dir
+}
+
+mkdir -p mnt
+umount mnt &> /dev/null || true
+dd if=/dev/zero of=image bs=1024 count=600
+
+mke2fs -O 'encrypt,^extents,^64bit' -b $BLOCKSIZE -I 256 image
+mount image mnt
+
+create_symlinks mnt/default
+create_encrypted_symlinks mnt/encrypted
+
+do_tune2fs -O extents
+create_symlinks mnt/extents
+create_encrypted_symlinks mnt/extents_encrypted
+
+do_debugfs -R 'feature inline_data'
+create_symlinks mnt/inline_data
+
+rm -rf debugfs_commands mnt/*~encrypted
+umount mnt
+rmdir mnt
+gzip -9 -f image
diff --git a/tests/f_badsymlinks2/name b/tests/f_badsymlinks2/name
new file mode 100644
index 0000000..81d3285
--- /dev/null
+++ b/tests/f_badsymlinks2/name
@@ -0,0 +1 @@
+more types of corrupted symlinks