Bug#1063097: /usr/bin/mkimage: opens image and device trees (-d, -b) O_RDONLY, then O_RDWR, and fails if they're read-only (it doesn't write to them)
Control: tags -1 + upstream On Tue, Mar 19, 2024 at 02:41:13PM -0700, Vagrant Cascadian wrote: > It would be helpful to list the exact command you are running, whoops! mkimage -f auto -A arm64 \ -T kernel -C lz4 -d Image-6.6.15.lz4 \ -b mt8173-elm-hana-6.6.15.dtb outf > although best to take this upstream. Yeah, can repro on mkimage from upstream checkout: $ strace -oss tools/mkimage -f auto -A arm64 -T kernel -C lz4 -d Image-6.6.15.lz4 -b mt8173-elm-hana-6.6.15.dtb /dev/null tools/mkimage: Can't open Image-6.6.15.lz4: Permission denied tools/mkimage: Failed to build FIT image tools/mkimage: failed to build FIT Error: Bad parameters for FIT image type $ grep Image ss execve("tools/mkimage", ["tools/mkimage", "-f", "auto", "-A", "arm64", "-T", "kernel", "-C", "lz4", "-d", "Image-6.6.15.lz4", "-b", "mt8173-elm-hana-6.6.15.dtb", "/dev/null"], 0x7ffdbed66100 /* 30 vars */) = 0 openat(AT_FDCWD, "Image-6.6.15.lz4", O_RDONLY) = 3 openat(AT_FDCWD, "Image-6.6.15.lz4", O_RDWR) = -1 EACCES (Permission denied) write(2, "tools/mkimage: Can't open Image-"..., 62) = 62 $ gdb --args tools/mkimage -f auto -A arm64 -T kernel -C lz4 -d Image-6.6.15.lz4 -b mt8173-elm-hana-6.6.15.dtb /dev/null #0 __libc_open64 (file=0x7fffe587 "Image-6.6.15.lz4", oflag=2) at ../sysdeps/unix/sysv/linux/open64.c:30 #1 0xf0f7 in fdt_property_file () #2 0xdef9 in fit_handle_file () #3 0x5557d1da in main () so I'll post a patch there probably. Best, signature.asc Description: PGP signature
Bug#1063097: /usr/bin/mkimage: opens image and device trees (-d, -b) O_RDONLY, then O_RDWR, and fails if they're read-only (it doesn't write to them)
On 2024-02-05, наб wrote: > From a strace: > 1390 openat(AT_FDCWD, "/tmp/tmp.j2DX6x1MgV/Image-6.6.11.lz4", O_RDONLY) = 3 > 1390 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=12611929, ...}, > AT_EMPTY_PATH) = 0 > 1390 close(3) = 0 > 1390 openat(AT_FDCWD, "mt8173-elm-hana-6.6.11.dtb", O_RDONLY) = 3 > 1390 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=43853, ...}, > AT_EMPTY_PATH) = 0 > 1390 close(3) = 0 > 1390 mmap(NULL, 12660736, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, > -1, 0) = 0xafecd000 > 1390 openat(AT_FDCWD, "/tmp/tmp.j2DX6x1MgV/Image-6.6.11.lz4", O_RDWR) = 3 > 1390 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=12611929, ...}, > AT_EMPTY_PATH) = 0 > 1390 read(3, "\4\"M\30dp\271\361K!\0\225\37 \3\325'\360X\24\0\1\0 > \243\1\6\0/\n\0\1"..., 12611929) = 12611929 > 1390 close(3) = 0 > 1390 openat(AT_FDCWD, "mt8173-elm-hana-6.6.11.dtb", O_RDWR) = -1 EACCES > (Permission denied) > 1390 write(2, "mkimage: Can't open mt8173-elm-h"..., 66) = 66 > 1390 write(2, "mkimage: Failed to build FIT ima"..., 35) = 35 > 1390 munmap(0xafecd000, 12660736) = 0 > here, the dtb is unwritable. > > An analogous error happens if the Image is unwritable, > but as we can see here, it doesn't write to it anyway. > (Nor should it, given this is an input file.) > > Please turn this into an O_RDONLY. It would be helpful to list the exact command you are running, although best to take this upstream. live well, vagrant signature.asc Description: PGP signature
Bug#1063097: /usr/bin/mkimage: opens image and device trees (-d, -b) O_RDONLY, then O_RDWR, and fails if they're read-only (it doesn't write to them)
Package: u-boot-tools Version: 2024.01+dfsg-1 Severity: normal File: /usr/bin/mkimage Dear Maintainer, From a strace: 1390 openat(AT_FDCWD, "/tmp/tmp.j2DX6x1MgV/Image-6.6.11.lz4", O_RDONLY) = 3 1390 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=12611929, ...}, AT_EMPTY_PATH) = 0 1390 close(3) = 0 1390 openat(AT_FDCWD, "mt8173-elm-hana-6.6.11.dtb", O_RDONLY) = 3 1390 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=43853, ...}, AT_EMPTY_PATH) = 0 1390 close(3) = 0 1390 mmap(NULL, 12660736, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xafecd000 1390 openat(AT_FDCWD, "/tmp/tmp.j2DX6x1MgV/Image-6.6.11.lz4", O_RDWR) = 3 1390 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=12611929, ...}, AT_EMPTY_PATH) = 0 1390 read(3, "\4\"M\30dp\271\361K!\0\225\37 \3\325'\360X\24\0\1\0 \243\1\6\0/\n\0\1"..., 12611929) = 12611929 1390 close(3) = 0 1390 openat(AT_FDCWD, "mt8173-elm-hana-6.6.11.dtb", O_RDWR) = -1 EACCES (Permission denied) 1390 write(2, "mkimage: Can't open mt8173-elm-h"..., 66) = 66 1390 write(2, "mkimage: Failed to build FIT ima"..., 35) = 35 1390 munmap(0xafecd000, 12660736) = 0 here, the dtb is unwritable. An analogous error happens if the Image is unwritable, but as we can see here, it doesn't write to it anyway. (Nor should it, given this is an input file.) Please turn this into an O_RDONLY. Best, наб -- System Information: Debian Release: trixie/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: arm64 (aarch64) Kernel: Linux 6.6.11 (SMP w/4 CPU threads) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) Versions of packages u-boot-tools depends on: ii libc62.37-15 ii libgnutls30 3.8.3-1 ii libssl3 3.1.4-2 ii libtinfo66.4+20240113-1 ii libuuid1 2.39.3-6 Versions of packages u-boot-tools recommends: pn device-tree-compiler pn libubootenv-tool u-boot-tools suggests no packages. -- no debconf information signature.asc Description: PGP signature