Re[3]: sanitize_read: map errno=EPIPE to errno=0

From: Sertonix <sertonix_at_posteo.net>
Date: Tue, 30 Jun 2026 17:16:35 +0000

> There is no conflation, sanitize_read() is a bijection.

Disproven by counterexample :)

> If there is a reading function that can return -1 EPIPE someday,
> then I'll reassess. But I doubt it will ever happen.

/dev/kmsg can return EPIPE when messages was dropped after the fd was
opened.

Ref https://github.com/troglobit/sysklogd/issues/26
Ref https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/kernel/printk/printk.c?id=6a579050f8300adb794f09a5d1f4ff435d43ced5#n841

And I was able to reproduce in an alpine vm (with CONFIG_LOG_BUF_SHIFT=17):
# { timeout 10 tr '\0' 'a' < /dev/zero; strace cat | head -n1; } > /dev/kmsg < /dev/kmsg
Terminated
execve("/bin/cat", ["cat"], 0x7ffe2422d750 /* 12 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7fc4168bab28) = 0
set_tid_address(0x7fc4168baf90) = 3169
brk(NULL) = 0x55691b0d5000
brk(0x55691b0d7000) = 0x55691b0d7000
mmap(0x55691b0d5000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x55691b0d5000
mprotect(0x7fc4168b7000, 4096, PROT_READ) = 0
mprotect(0x5568f4356000, 16384, PROT_READ) = 0
getuid() = 0
sendfile(1, 0, NULL, 16777216) = -1 EINVAL (Invalid argument)
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc4167fc000
read(0, 0x7fc4167fc000, 65536) = -1 EPIPE (Broken pipe)
write(2, "cat: read error: Broken pipe\n", 29cat: read error: Broken pipe
) = 29
munmap(0x7fc4167fc000, 65536) = 0
exit_group(1) = ?
+++ exited with 1 +++
Received on Tue Jun 30 2026 - 19:16:35 CEST

This archive was generated by hypermail 2.4.0 : Tue Jun 30 2026 - 19:17:09 CEST