You are not logged in.
I have a weird one here.
Broken PKGBUILD:
pkgname=btrfs-progs-git
_gitname=abcdefghijlm
_ver=3.17
pkgver=3.17.1_17_ga1c3bcf
pkgrel=1
pkgdesc="Btrfs filesystem utilities"
arch=("i686" "x86_64")
url="http://btrfs.wiki.kernel.org/index.php/Main_Page"
license=('GPL')
depends=('glibc' 'e2fsprogs' 'lzo2' 'zlib')
makedepends=('git' 'asciidoc' 'xmlto')
provides=('btrfs-progs')
conflicts=('btrfs-progs')
_url=https://projects.archlinux.org/svntogit/packages.git/plain/trunk/
source=($_gitname::git+"http://repo.or.cz/r/btrfs-progs-unstable/devel.git#branch=v${_ver}.x"
"initcpio-hook-btrfs::${_url}initcpio-hook-btrfs?h=packages/btrfs-progs"
"initcpio-install-btrfs::${_url}initcpio-install-btrfs?h=packages/btrfs-progs")
md5sums=('SKIP'
'b09688a915a0ec8f40e2f5aacbabc9ad'
'7241ba3a4286d08da0d50b7176941112')
pkgver() {
cd "$_gitname"
git describe --long | sed -e 's:^v::' -e 's:-:_:g'
}
build() {
cd "$_gitname"
make CFLAGS="$CFLAGS" all btrfs-select-super
}
package() {
# install mkinitcpio files
install -Dm644 initcpio-hook-btrfs "$pkgdir/usr/lib/initcpio/hooks/btrfs"
install -Dm644 initcpio-install-btrfs "$pkgdir/usr/lib/initcpio/install/btrfs"
cd "$_gitname"
# install compiled software + readme
make prefix="$pkgdir/usr" install
install -m755 btrfs-select-super "$pkgdir/usr/bin/btrfs-select-super"
install -Dm644 INSTALL "$pkgdir/usr/share/doc/btrfs/README"
}
check() {
cd "$_gitname"
make test
}
Working PKGBUILD:
pkgname=btrfs-progs-git
_gitname=abcdefghijl
_ver=3.17
pkgver=3.17.1_17_ga1c3bcf
pkgrel=1
pkgdesc="Btrfs filesystem utilities"
arch=("i686" "x86_64")
url="http://btrfs.wiki.kernel.org/index.php/Main_Page"
license=('GPL')
depends=('glibc' 'e2fsprogs' 'lzo2' 'zlib')
makedepends=('git' 'asciidoc' 'xmlto')
provides=('btrfs-progs')
conflicts=('btrfs-progs')
_url=https://projects.archlinux.org/svntogit/packages.git/plain/trunk/
source=($_gitname::git+"http://repo.or.cz/r/btrfs-progs-unstable/devel.git#branch=v${_ver}.x"
"initcpio-hook-btrfs::${_url}initcpio-hook-btrfs?h=packages/btrfs-progs"
"initcpio-install-btrfs::${_url}initcpio-install-btrfs?h=packages/btrfs-progs")
md5sums=('SKIP'
'b09688a915a0ec8f40e2f5aacbabc9ad'
'7241ba3a4286d08da0d50b7176941112')
pkgver() {
cd "$_gitname"
git describe --long | sed -e 's:^v::' -e 's:-:_:g'
}
build() {
cd "$_gitname"
make CFLAGS="$CFLAGS" all btrfs-select-super
}
package() {
# install mkinitcpio files
install -Dm644 initcpio-hook-btrfs "$pkgdir/usr/lib/initcpio/hooks/btrfs"
install -Dm644 initcpio-install-btrfs "$pkgdir/usr/lib/initcpio/install/btrfs"
cd "$_gitname"
# install compiled software + readme
make prefix="$pkgdir/usr" install
install -m755 btrfs-select-super "$pkgdir/usr/bin/btrfs-select-super"
install -Dm644 INSTALL "$pkgdir/usr/share/doc/btrfs/README"
}
check() {
cd "$_gitname"
make test
}
Diff of the two:
--- btrfs-progs-git-broken/PKGBUILD 2014-11-14 21:35:11.198414821 +0000
+++ btrfs-progs-git-fixed/PKGBUILD 2014-11-14 21:38:46.553134015 +0000
@@ -1,5 +1,5 @@
pkgname=btrfs-progs-git
-_gitname=abcdefghijlm
+_gitname=abcdefghijl
_ver=3.17
pkgver=3.17.1_17_ga1c3bcf
pkgrel=1
Failure message of the broken PKGBUILD:
==> Starting check()...
[TEST] fsck-tests.sh
[TEST] 001-bad-file-extent-bytenr.img
[TEST] 002-bad-transid.img
[TEST] 003-shift-offsets.img
[TEST] 004-no-dir-index.img
[TEST] 005-bad-item-offset.img
[TEST] 006-bad_root_items_fs.tar.xz
[TEST] 007-bad_root_items_fs_skinny.tar.xz
[TEST] 010-no-dir-item-or-index.img
[TEST] 011-no-rootdir-inode-item.img
[TEST] 012-no-inode-item.img
[NOTRUN] extent tree rebuild
[TEST] convert-tests.sh
[TEST] ext2
*** buffer overflow detected ***: /tmp/btrfs/btrfs-progs-git-broken/src/abcdefghijlm/btrfs-convert terminated
======= Backtrace: =========
/usr/lib/libc.so.6(+0x734c7)[0x7fb2ca22a4c7]
/usr/lib/libc.so.6(__fortify_fail+0x37)[0x7fb2ca2af9a7]
/usr/lib/libc.so.6(+0xf6b10)[0x7fb2ca2adb10]
/usr/lib/libc.so.6(+0xf6049)[0x7fb2ca2ad049]
/usr/lib/libc.so.6(_IO_default_xsputn+0x81)[0x7fb2ca22d6d1]
/usr/lib/libc.so.6(_IO_vfprintf+0x39fd)[0x7fb2ca1ff39d]
/usr/lib/libc.so.6(__vsprintf_chk+0x88)[0x7fb2ca2ad0d8]
/usr/lib/libc.so.6(__sprintf_chk+0x85)[0x7fb2ca2ad035]
/tmp/btrfs/btrfs-progs-git-broken/src/abcdefghijlm/btrfs-convert[0x402dcf]
/usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7fb2ca1d7040]
/tmp/btrfs/btrfs-progs-git-broken/src/abcdefghijlm/btrfs-convert[0x403b3e]
======= Memory map: ========
00400000-0043c000 r-xp 00000000 00:42 265627 /tmp/btrfs/btrfs-progs-git-broken/src/abcdefghijlm/btrfs-convert
0063c000-0063d000 r--p 0003c000 00:42 265627 /tmp/btrfs/btrfs-progs-git-broken/src/abcdefghijlm/btrfs-convert
0063d000-0063e000 rw-p 0003d000 00:42 265627 /tmp/btrfs/btrfs-progs-git-broken/src/abcdefghijlm/btrfs-convert
00820000-00841000 rw-p 00000000 00:00 0 [heap]
7fb2c9d85000-7fb2c9d9b000 r-xp 00000000 00:10 2704057 /usr/lib/libgcc_s.so.1
7fb2c9d9b000-7fb2c9f9a000 ---p 00016000 00:10 2704057 /usr/lib/libgcc_s.so.1
7fb2c9f9a000-7fb2c9f9b000 rw-p 00015000 00:10 2704057 /usr/lib/libgcc_s.so.1
7fb2c9f9b000-7fb2c9fb2000 r-xp 00000000 00:10 2485308 /usr/lib/libpthread-2.20.so
7fb2c9fb2000-7fb2ca1b1000 ---p 00017000 00:10 2485308 /usr/lib/libpthread-2.20.so
7fb2ca1b1000-7fb2ca1b2000 r--p 00016000 00:10 2485308 /usr/lib/libpthread-2.20.so
7fb2ca1b2000-7fb2ca1b3000 rw-p 00017000 00:10 2485308 /usr/lib/libpthread-2.20.so
7fb2ca1b3000-7fb2ca1b7000 rw-p 00000000 00:00 0
7fb2ca1b7000-7fb2ca350000 r-xp 00000000 00:10 2485291 /usr/lib/libc-2.20.so
7fb2ca350000-7fb2ca550000 ---p 00199000 00:10 2485291 /usr/lib/libc-2.20.so
7fb2ca550000-7fb2ca554000 r--p 00199000 00:10 2485291 /usr/lib/libc-2.20.so
7fb2ca554000-7fb2ca556000 rw-p 0019d000 00:10 2485291 /usr/lib/libc-2.20.so
7fb2ca556000-7fb2ca55a000 rw-p 00000000 00:00 0
7fb2ca55a000-7fb2ca55d000 r-xp 00000000 00:10 2538512 /usr/lib/libcom_err.so.2.1
7fb2ca55d000-7fb2ca75c000 ---p 00003000 00:10 2538512 /usr/lib/libcom_err.so.2.1
7fb2ca75c000-7fb2ca75d000 r--p 00002000 00:10 2538512 /usr/lib/libcom_err.so.2.1
7fb2ca75d000-7fb2ca75e000 rw-p 00003000 00:10 2538512 /usr/lib/libcom_err.so.2.1
7fb2ca75e000-7fb2ca7a2000 r-xp 00000000 00:10 2538515 /usr/lib/libext2fs.so.2.4
7fb2ca7a2000-7fb2ca9a1000 ---p 00044000 00:10 2538515 /usr/lib/libext2fs.so.2.4
7fb2ca9a1000-7fb2ca9a2000 r--p 00043000 00:10 2538515 /usr/lib/libext2fs.so.2.4
7fb2ca9a2000-7fb2ca9a4000 rw-p 00044000 00:10 2538515 /usr/lib/libext2fs.so.2.4
7fb2ca9a4000-7fb2ca9df000 r-xp 00000000 00:10 2676361 /usr/lib/libblkid.so.1.1.0
7fb2ca9df000-7fb2cabdf000 ---p 0003b000 00:10 2676361 /usr/lib/libblkid.so.1.1.0
7fb2cabdf000-7fb2cabe2000 r--p 0003b000 00:10 2676361 /usr/lib/libblkid.so.1.1.0
7fb2cabe2000-7fb2cabe3000 rw-p 0003e000 00:10 2676361 /usr/lib/libblkid.so.1.1.0
7fb2cabe3000-7fb2cabe4000 rw-p 00000000 00:00 0
7fb2cabe4000-7fb2cabe8000 r-xp 00000000 00:10 2676364 /usr/lib/libuuid.so.1.3.0
7fb2cabe8000-7fb2cade7000 ---p 00004000 00:10 2676364 /usr/lib/libuuid.so.1.3.0
7fb2cade7000-7fb2cade8000 r--p 00003000 00:10 2676364 /usr/lib/libuuid.so.1.3.0
7fb2cade8000-7fb2cade9000 rw-p 00004000 00:10 2676364 /usr/lib/libuuid.so.1.3.0
7fb2cade9000-7fb2cae0a000 r-xp 00000000 00:10 2485292 /usr/lib/ld-2.20.so
7fb2cafda000-7fb2cafdf000 rw-p 00000000 00:00 0
7fb2cb009000-7fb2cb00a000 rw-p 00000000 00:00 0
7fb2cb00a000-7fb2cb00b000 r--p 00021000 00:10 2485292 /usr/lib/ld-2.20.so
7fb2cb00b000-7fb2cb00c000 rw-p 00022000 00:10 2485292 /usr/lib/ld-2.20.so
7fb2cb00c000-7fb2cb00d000 rw-p 00000000 00:00 0
7fff95b10000-7fff95b32000 rw-p 00000000 00:00 0 [stack]
7fff95bfc000-7fff95bfe000 r--p 00000000 00:00 0 [vvar]
7fff95bfe000-7fff95c00000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
tests/convert-tests.sh: line 17: 6821 Aborted (core dumped) $here/btrfs-convert $here/test.img >> convert-tests-results.txt 2>&1
btrfs-convert failed
Makefile:144: recipe for target 'test' failed
make: *** [test] Error 1
==> ERROR: A failure occurred in check().
Aborting...
Can anyone shed some light on what is going wrong here? I'm guessing there's a bug in btrfs' code somewhere, but it seems odd that one extra letter in a file path can cause such a spectacular error message.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
What is the test for ext2 doing? I doubt it's a coincidence that that path is 65 bytes (one longer than a nice 'round' base two value). Could that test use a 64-byte string buffer somewhere?
EDIT: it seems it's one of these four commands from convert-tests.sh that is failing (where "here" is a 64-byte path):
truncate -s 256M $here/test.img >> convert-tests-results.txt 2>&1
mke2fs -b 4096 -F $here/test.img >> convert-tests-results.txt 2>&1
$here/btrfs-convert $here/test.img >> convert-tests-results.txt 2>&1
$here/btrfsck $here/test.img >> convert-tests-results.txt 2>&1
Could you edit/patch convert-tests.sh to be more verbose between those commands to see which one actually fails?
EDIT 2: I just did this as the dependencies weren't any trouble to tinker with this. The command that fails in any path longer that 64 bytes is the following:
$here/btrfs-convert $here/test.img >> convert-tests-results.txt 2>&1
Now to see whether it is the location of the binary, or the length of the parameter that matters ... standby
EDIT 3: it's the location of the binary. Likely there is a reference to argv[0] to get the command name and it assumes the path is less that 64 bytes. That doesn't seem like a great idea, but generally it'd be a safe assumption ... a binary would be in /usr/bin/ normally, right? Let me check the source to see if this explanation holds.
EDIT 4: Found it! Several of these tools use a set_argv0 function from utils.c which stores argv[0] in a string declared with length ARGV0_BUF_SIZE. This constant is defined in utils.h as 64. So either build in a shorter path, or patch utils.h to use a longer buffer length.
If you want to submit a patch upstream, the following would at least avoid the really nasty error:
--- utils.c 2014-11-14 18:41:22.060881599 -0500
+++ utils-new.c 2014-11-14 18:42:21.867224267 -0500
@@ -66,7 +66,7 @@
void set_argv0(char **argv)
{
- sprintf(argv0_buf, "%s", argv[0]);
+ snprintf(argv0_buf, ARGV0_BUF_SIZE, "%s", argv[0]);
}
int check_argc_exact(int nargs, int expected)
Last edited by Trilby (2014-11-14 23:21:01)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Oh wow, well sleuthed, Trilby!
I came back to say that I'd been playing with the length of the path outside of makepkg, and found that:
1) building at /tmp/btrfs/abcdefghijklmnopqrstuvwxyz12345678901234 fails at the ext2 test, while
2) building at /tmp/btrfs/abcdefghijklmnopqrstuvwxyz123456789012345 fails at the 001-bad-file-extent-bytenr.img test, with the same sort of error. From your analysis, it's quite likely that one of the tools used in the latter test has a path just short enough to be legal in 1), but not in 2).
Given your explanation, I'm not sure if this is can really be considered a bug. But I'll mention it on the btrfs mailing list and see if there's any interest in addressing it. In the meantime, I guess I'll just not enable tests by default in my btrfs PKGBUILDs.
Thanks for you fast and detailed response, Trilby!
EDIT, and the patch!
EDIT EDIT: Aaaand it's fixed. :D
Last edited by WorMzy (2014-11-18 20:49:07)
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline