• Bug#1063097: /usr/bin/mkimage: opens image and device trees (-d, -b) O_

    From Vagrant Cascadian@21:1/5 to All on Tue Mar 19 22:50:02 2024
    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) = 0xffffafecd000
    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(0xffffafecd000, 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

    --=-=-Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iHUEARYKAB0WIQRlgHNhO/zFx+LkXUXcUY/If5cWqgUCZfoGeQAKCRDcUY/If5cW qncoAP9lW8W4RREMvefZXwLP/YMmMEN94o1leulY25EPAFq0qwD/Zm1uuw2ePAlH 0VGzOelev+XUIuO7T9nP4tB+kBYLzgM=6q4w
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?=D0=BD=D0=B0=D0=B1?=@21:1/5 to Vagrant Cascadian on Wed Mar 20 13:30:01 2024
    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=0x7fffffffe587 "Image-6.6.15.lz4", oflag=2) at ../sysdeps/unix/sysv/linux/open64.c:30
    #1 0x000055555555f0f7 in fdt_property_file ()
    #2 0x000055555555def9 in fit_handle_file ()
    #3 0x000055555557d1da in main ()
    so I'll post a patch there probably.

    Best,

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmX61OoACgkQvP0LAY0m WPFVqw/+Nf1dRDzeoiOMFN9dhlaf3lPukcLnkimbkRfSJSs7SaS7iTTPm5v/aNpK mKSYEJh1mfWG6hwj+JUlngHSFNv2nIgyL3S6e/csQGM7sTzcSwF8PCrelG51UOct rf8480vqe/OTliF1nrll33NiQXEYNP6lJVNkpkCS3t0fNVipZ/pKJCCIXDulNKAr i7SYQ26B5SzNylZ+JJ3CSZyZkZql05q3E5k39SB4+sEG/w9DvjjjFDeklWLmhTC/ 9UsyyLtbsPjiAeJTO2E2MTSnQnPx+swoT/NjTXecwTFOLUNB8RYg26Cm3ZGBlWTz wJvQoONLo2iOxOaj7YPj18CBMBzbmkaSPcsmshb8CrpvMXhLdwJkYOVgGLwBRc7w jd4gWwl6DTu6GF5hmrz1ys4LGB+6Iqp3Krqt1g5zmsRI0cbI2CV+GtGqejFUqB9R oDsNWBw3nUSwRHWOo6XZG052/OmDt2Xbb2G77uIORyq+pDfd37WBf9oLRi+22lVE CbJgbBJm0Jojqbh4UuaE/TOh3PkIu9jCK/IchDzWgGfIVqAMoHQd9RR0+lrnkgg9 UKs2FfbgHlbKLkkJlurRJxauF4rBgcqtNFpKS5BeUI9aQe/zQJ12FN/e/2bWow1a aAeI9f1496MAjqYUwcs5XQkJYmHbnBjRxHA/lPKdsZHA0cqTCcY=
    =XCe3
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)