freebsd-dev/sys
Mark Johnston d91d2b513e geom: Handle partial I/O in g_{read,write,delete}_data()
These routines are used internally by GEOM to dispatch I/O requests to a
provider, typically for tasting or for updating GEOM class metadata
blocks.

These routines assumed that partial I/O did not occur without setting
BIO_ERROR, but this is possible in at least two cases:
- Some or all of the I/O range is beyond the provider's mediasize.
  In this scenario g_io_check() truncates the bounds of the request
  before it is handed to the target provider.
- A read from vnode-backed md(4) device returns EOF (the backing vnode
  is allowed to be smaller than the device itself) or partial vnode I/O
  occurs.
In these scenarios g_read_data() could return a partially uninitialized
buffer.  Many consumers are not affected by the first case, since the
offsets used for provider metadata or tasting are relative to the
provider's mediasize, but in some cases metadata is read at fixed
offsets, such as when searching for a UFS superblock using the offsets
defined by SBLOCKSEARCH.

Thus, modify the routines to explicitly check for a non-zero residual
and return EIO in that case.  Remove a related check from the
DIOCGDELETE ioctl handler, it is handled within g_delete_data() now.

Reviewed by:	mav, imp, kib
Reported by:	KMSAN
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31293
2022-01-20 08:29:39 -05:00
..
amd64 exec: Remove the stack gap implementation 2022-01-17 16:11:54 -05:00
arm exec: Introduce the PROC_PS_STRINGS() macro 2022-01-17 16:11:54 -05:00
arm64 Add the Armv8.3-SPE registers 2022-01-19 12:07:35 +00:00
bsm
cam ses: minor cleanup 2022-01-19 12:08:03 -07:00
cddl Teach DTrace about BTI on arm64 2022-01-19 12:07:35 +00:00
compat LinuxKPI: Allow wake_up to be executed within a critical section 2022-01-18 23:14:13 +03:00
conf crypto: Stop compiling in chacha20poly1305 AEAD ciphers from libsodium. 2022-01-18 14:48:40 -08:00
contrib Revert "wpa: Import wpa 2.10." 2022-01-18 08:10:33 -08:00
crypto crypto: Add a simple API for [X]ChaCha20-Poly1035 on flat buffers. 2022-01-18 14:47:13 -08:00
ddb ddb: Remove SOFTWARE_SSTEP support 2022-01-07 09:25:33 -07:00
dev vtnet: Mark MRG_RXBUF headers as initialized before loading fields 2022-01-20 08:25:14 -05:00
dts add rk3328 overlay for enabling analog sound 2021-11-13 11:09:23 +02:00
fs fusefs: Address -Wunused-but-set-variable warnings 2022-01-20 08:25:00 -05:00
gdb
geom geom: Handle partial I/O in g_{read,write,delete}_data() 2022-01-20 08:29:39 -05:00
gnu
i386 exec: Reimplement stack address randomization 2022-01-17 16:12:36 -05:00
isa sys/isa: Use C99 fixed-width integer types. 2021-12-28 09:41:57 -08:00
kern clockcalib: Fix an overflow bug 2022-01-20 08:23:38 -05:00
kgssapi
libkern sys/libkern: Use C99 fixed-width integer types. 2021-12-28 09:42:11 -08:00
modules crypto: Add a simple API for [X]ChaCha20-Poly1035 on flat buffers. 2022-01-18 14:47:13 -08:00
net netmap: fix LOR in iflib_netmap_register 2022-01-14 21:09:04 +00:00
net80211 net80211: ieee80211_dump_node() cosmetics 2022-01-17 00:01:46 +00:00
netgraph domains: make domain_init() initialize only global state 2022-01-03 10:15:22 -08:00
netinet tcp: Warning cleanup from new compiler. 2022-01-18 07:41:18 -05:00
netinet6 domains: make domain_init() initialize only global state 2022-01-03 10:15:22 -08:00
netipsec syncache: accept packet with no SA when TCP_MD5SIG is set 2022-01-08 16:32:14 -09:00
netpfil pf: ensure we don't destroy an uninitialised lock 2022-01-16 09:04:57 +01:00
netsmb
nfs nfs: don't truncate directory cookies to 32-bits in the NFS server 2021-12-15 20:54:57 -07:00
nfsclient
nfsserver
nlm sys/nlm: Use C99 fixed-width integer types. 2021-12-28 09:42:42 -08:00
ofed domains: init with standard SYSINIT(9) or VNET_SYSINIT() 2022-01-03 10:15:22 -08:00
opencrypto cryptosoft: Avoid referencing end-of-buffer cursors 2022-01-17 19:01:24 -05:00
powerpc sysent: Add a sv_psstringssz field to struct sysentvec 2022-01-17 11:42:07 -05:00
riscv riscv: fix unused var in page_fault_handler() 2022-01-19 17:21:25 -04:00
rpc sys/rpc: Use C99 fixed-width integer types. 2021-12-28 09:43:15 -08:00
security Thread creation privilege for realtime group 2021-12-15 00:01:58 +02:00
sys Bump __FreeBSD_version for the addition of <crypto/chacha20_poly1305.h>. 2022-01-18 14:49:24 -08:00
teken
tests
tools Revert "syscallarg_t: Add a type for system call arguments" 2022-01-12 23:29:20 +00:00
ufs Avoid unnecessary setting of UFS flag requesting fsck(8) be run. 2022-01-09 16:18:28 -08:00
vm vm_phys: add essential segment bounds check 2022-01-19 00:42:39 -06:00
x86 x86/apic: remove apic_ops 2022-01-18 10:19:04 +01:00
xdr sys/xdr: Use C99 fixed-width integer types. 2021-12-28 09:43:26 -08:00
xen Create wrapper for Giant taken for newbus 2021-12-09 17:04:45 -07:00
Makefile Fix 'make cscope' with ALL_ARCH defined 2022-01-07 11:53:52 -04:00