URL:
  <https://savannah.gnu.org/bugs/?67624>

                 Summary: echo: write error: Invalid argument
                   Group: The GNU Bourne-Again SHell
               Submitter: peppergrayxyz
               Submitted: Thu 23 Oct 2025 11:35:32 PM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Thu 23 Oct 2025 11:35:32 PM UTC By: Pepper Gray <peppergrayxyz>
Writing to the kernel causes an error, when appending '\n', when bash is
linked against musl. e.g.:

- register binfmt

> # printf '%s\n'
> ':qemu-riscv64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-riscv64:'"${QEMU_BINFMT_FLAGS}"
>>/proc/sys/fs/binfmt_misc/register"
> bash: line 1: printf: write error: Invalid argument


- unregister binfmt

> # strace -f -o 'strace-remove.log' bash -c 'echo "-1" >
> /proc/sys/fs/binfmt_misc/qemu-riscv64'
> bash: line 1: echo: write error: Invalid argument


This behavior seems to be present for a long time:
https://www.openwall.com/lists/musl/2013/05/05/1

Commands that cause the error:
-printf '%s\n', echo '..' on musl
Commands that work:
-printf '%s', echo -n '..' on musl
-printf '%s\n', echo '..' on glibc
-all commands work on sh and zsh (glibc and musl)

Traces for the failing commands are available in the downstream bug report:
https://bugs.gentoo.org/964994








    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?67624>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to