diff options
author | V3n3RiX <venerix@koprulu.sector> | 2023-01-11 11:44:03 +0000 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2023-01-11 11:44:03 +0000 |
commit | df26c7469c1f2af2e643d43e2e32a6c9142e4885 (patch) | |
tree | 1beee9b11d06bfcc69d1d6c8ab00566f8633aec1 /sys-apps/install-xattr/files | |
parent | ad391b961414c99124b93cb86695c04bd8d57937 (diff) |
gentoo auto-resync : 11:01:2023 - 11:44:03
Diffstat (limited to 'sys-apps/install-xattr/files')
-rw-r--r-- | sys-apps/install-xattr/files/0.8/0001-install-xattr-avoid-accessing-empty-storage.patch | 46 | ||||
-rw-r--r-- | sys-apps/install-xattr/files/0.8/0002-install-xattr-fix-small-memory-leak.patch | 50 |
2 files changed, 96 insertions, 0 deletions
diff --git a/sys-apps/install-xattr/files/0.8/0001-install-xattr-avoid-accessing-empty-storage.patch b/sys-apps/install-xattr/files/0.8/0001-install-xattr-avoid-accessing-empty-storage.patch new file mode 100644 index 000000000000..b77f74635e48 --- /dev/null +++ b/sys-apps/install-xattr/files/0.8/0001-install-xattr-avoid-accessing-empty-storage.patch @@ -0,0 +1,46 @@ +https://github.com/gentoo/elfix/pull/3 + +From 2a0dffbf0080dc74f82910a74f051d835cfd653f Mon Sep 17 00:00:00 2001 +From: Sam James <sam@gentoo.org> +Date: Fri, 6 Jan 2023 03:06:50 +0000 +Subject: [PATCH 1/2] install-xattr: avoid accessing empty storage + +UBSAN reports: +``` +install-xattr.c:124:16: runtime error: load of address 0x55555556d440 with insufficient space for an object of type 'char' +0x55555556d440: note: pointer points here + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 61 00 00 00 + ^ + #0 0x555555557a27 in copyxattr /home/sam/git/elfix//install-xattr.c:124 + #1 0x555555556a4d in main /home/sam/git/elfix//install-xattr.c:410 + #2 0x7ffff77c864f (/usr/lib64/libc.so.6+0x2364f) + #3 0x7ffff77c8708 in __libc_start_main (/usr/lib64/libc.so.6+0x23708) + #4 0x555555557114 in _start (/home/sam/git/elfix//install-xattr+0x3114) +``` + +Triggered with: +``` +mkdir /tmp/a +touch /tmp/foo +./install-xattr -c /tmp/foo /tmp/foo2 /tmp/a +``` + +I don't see this with Clang or < GCC 12, but I do with GCC 13 (13.0.0_pre20230101 p5); +I suspect it's because of object-size improvements. + +Signed-off-by: Sam James <sam@gentoo.org> +--- a/install-xattr.c ++++ b/install-xattr.c +@@ -119,6 +119,10 @@ copyxattr(const char *source, const char *target) + lxattr = xmalloc(lsize); + xlistxattr(source, lxattr, lsize); + ++ /* There's no xattrs at all. */ ++ if (lsize == 0) ++ return; ++ + i = 0; + while (1) { + while (lxattr[i++] == 0) +-- +2.39.0 diff --git a/sys-apps/install-xattr/files/0.8/0002-install-xattr-fix-small-memory-leak.patch b/sys-apps/install-xattr/files/0.8/0002-install-xattr-fix-small-memory-leak.patch new file mode 100644 index 000000000000..91c9d8885b9e --- /dev/null +++ b/sys-apps/install-xattr/files/0.8/0002-install-xattr-fix-small-memory-leak.patch @@ -0,0 +1,50 @@ +https://github.com/gentoo/elfix/pull/3 + +From 776afeae92d2afd3340cd753abc58ccd8daba48f Mon Sep 17 00:00:00 2001 +From: Sam James <sam@gentoo.org> +Date: Fri, 6 Jan 2023 06:39:30 +0000 +Subject: [PATCH 2/2] install-xattr: fix small memory leak + +There's another with strdup/malloc but it gets a bit messier +to fix so let's leave that for now (this is mostly about correctness +anyway, as the runtime of install-xattr is very small): +``` +Direct leak of 4097 byte(s) in 1 object(s) allocated from: + #0 0x7f4a2c22e257 in __interceptor_malloc /usr/src/debug/sys-devel/gcc-13.0.0_pre20230101/gcc-13-20230101/libsanitizer/asan/asan_malloc_linux.cpp:69 + #1 0x7f4a2c1d2b40 in __interceptor_realpath /usr/src/debug/sys-devel/gcc-13.0.0_pre20230101/gcc-13-20230101/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:3904 + #2 0x55da3adf5629 in realpath /usr/include/bits/stdlib.h:42 + #3 0x55da3adf5629 in main /home/sam/git/elfix/install-xattr.c:252 +``` + +Signed-off-by: Sam James <sam@gentoo.org> +--- a/install-xattr.c ++++ b/install-xattr.c +@@ -248,7 +248,6 @@ main(int argc, char* argv[]) + char *target = NULL; /* the target file or directory */ + char *path; /* path to the target file */ + +- char *mypath = realpath("/proc/self/exe", NULL); /* path to argv[0] */ + char *install; /* path to the system install */ + + struct stat s; /* test if a file is a regular file or a directory */ +@@ -353,7 +352,9 @@ main(int argc, char* argv[]) + case -1: + err(1, "fork() failed"); + +- case 0: ++ case 0: { ++ char *mypath = realpath("/proc/self/exe", NULL); /* path to argv[0] */ ++ + /* find system install avoiding mypath and portage_helper_path! */ + if (portage_helper_path) + portage_helper_canpath = realpath(portage_helper_path, NULL); +@@ -363,6 +364,7 @@ main(int argc, char* argv[]) + argv[0] = install; /* so coreutils' lib/program.c behaves */ + execv(install, argv); /* The kernel will free(install). */ + err(1, "execv() failed"); ++ } + + default: + wait(&status); +-- +2.39.0 |