glibc/hurd
Sergey Bugaev 8cbab3b729 hurd: Protect against servers returning bogus read/write lengths
There already was a branch checking for this case in _hurd_fd_read ()
when the data is returned out-of-line. Do the same for inline data, as
well as for _hurd_fd_write (). It's also not possible for the length to
be negative, since it's stored in an unsigned integer.

Not verifying the returned length can confuse the callers who assume
the returned length is always reasonable. This manifested as libzstd
test suite failing on writes to /dev/zero, even though the write () call
appeared to succeed. In fact, the zero store backing /dev/zero was
returning a larger written length than the size actually submitted to
it, which is a separate bug to be fixed on the Hurd side. With this
patch, EGRATUITOUS is now propagated to the caller.

Reported-by: Diego Nieto Cid <dnietoc@gmail.com>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20241204112915.540032-1-bugaevc@gmail.com>
2024-12-05 08:49:35 +01:00
..
hurd
alloc-fd.c
catch-exc.c
catch-signal.c
compat-20.c
ctty-input.c
ctty-output.c
Depend
dtable.c
exc2signal.c
faultexc.defs
fchroot.c
fcntl-internal.h
fd-cleanup.c
fd-close.c
fd-read.c hurd: Protect against servers returning bogus read/write lengths 2024-12-05 08:49:35 +01:00
fd-write.c hurd: Protect against servers returning bogus read/write lengths 2024-12-05 08:49:35 +01:00
fopenport.c
get-host.c
getdport.c
geteuids.c
getumask.c
hurd-raise.c
hurd.h
hurdauth.c
hurdchdir.c
hurdexec.c
hurdfault.c
hurdfault.h
hurdfchdir.c
hurdhost.h
hurdid.c
hurdinit.c
hurdioctl.c
hurdkill.c
hurdlock.c
hurdlock.h
hurdlookup.c
hurdmalloc.c
hurdmalloc.h
hurdmsg.c
hurdpid.c
hurdports.c
hurdprio.c
hurdrlimit.c
hurdselect.c
hurdsig.c
hurdsock.c
hurdsocket.h
hurdstartup.c
hurdstartup.h
intern-fd.c
intr-msg.c
intr-rpc.defs
intr-rpc.h
longjmp-ts.c
lookup-at.c
lookup-retry.c
Makefile
msgportdemux.c
new-fd.c
Notes
openport.c
path-lookup.c
pid2task.c
port2fd.c
port-cleanup.c
ports-get.c
ports-set.c
preempt-sig.c
privports.c
report-wait.c
RPC_gsync_wait_intr.c
set-hooks.h
set-host.c
setauth.c
seteuids.c
siginfo.c
sigunwind.c
stack_chk_fail_local.c
task2pid.c
thread-cancel.c
thread-self.c
trampoline.c
Versions
vpprintf.c
xattr.c