freebsd-nq/sys/geom
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
..
bde geom(4): Fix some of the "set but not used" warnings 2021-12-18 11:42:34 +00:00
cache geom(4): Mark all sysctls as CTLFLAG_MPSAFE. 2021-08-10 20:18:46 -04:00
concat gconcat: Zero the metadata block before writing 2021-07-13 17:45:59 -04:00
eli Use G_ELI_IVKEYLEN as the size of IV in the user test code. 2022-01-13 17:22:06 -08:00
gate geom_gate: ensure readprov is null-terminated 2022-01-02 18:01:23 -07:00
journal geom(4): Fix some of the "set but not used" warnings 2021-12-18 11:42:34 +00:00
label geom label msdosfs: sanity check BPB before using it for io request 2022-01-08 05:41:44 +02:00
linux_lvm Make g_attach() return ENXIO for orphaned providers; update various 2020-10-18 16:24:08 +00:00
mirror geom_mirror: plug set-but-not-unused vars 2021-12-09 18:00:27 +00:00
mountver Make g_attach() return ENXIO for orphaned providers; update various 2020-10-18 16:24:08 +00:00
multipath geom_multipath: plug set-but-not-used vars 2021-11-25 11:31:50 +00:00
nop Make MAXPHYS tunable. Bump MAXPHYS to 1M. 2020-11-28 12:12:51 +00:00
part sys/geom: Use C99 fixed-width integer types. 2021-12-28 09:41:51 -08:00
raid sys/geom: Use C99 fixed-width integer types. 2021-12-28 09:41:51 -08:00
raid3 geom_raid3: plug set-but-not-unused vars 2021-12-09 18:08:03 +00:00
shsec geom(4): Fix some of the "set but not used" warnings 2021-12-18 11:42:34 +00:00
stripe geom(4): Fix some of the "set but not used" warnings 2021-12-18 11:42:34 +00:00
uzip Make MAXPHYS tunable. Bump MAXPHYS to 1M. 2020-11-28 12:12:51 +00:00
vinum geom(4): Fix some of the "set but not used" warnings 2021-12-18 11:42:34 +00:00
virstor geom(4): Fix some of the "set but not used" warnings 2021-12-18 11:42:34 +00:00
zero geom(4): Mark all sysctls as CTLFLAG_MPSAFE. 2021-08-10 20:18:46 -04:00
geom_bsd_enc.c
geom_ccd.c sys/geom: Use C99 fixed-width integer types. 2021-12-28 09:41:51 -08:00
geom_ctl.c geom_ctl.c: remove stale header files 2020-10-20 20:59:13 +00:00
geom_ctl.h
geom_dbg.h
geom_dev.c geom: Handle partial I/O in g_{read,write,delete}_data() 2022-01-20 08:29:39 -05:00
geom_disk.c Fix "set but not used" for geom 2021-12-03 23:40:24 -07:00
geom_disk.h Use a more specific type for geom_disk.d_event. 2021-07-29 16:34:46 -07:00
geom_dump.c geom: clean up empty lines in .c and .h files 2020-09-01 22:14:09 +00:00
geom_event.c GEOM: Minor polishing in geom_event. 2021-12-27 21:01:08 -05:00
geom_flashmap.c
geom_flashmap.h geom: clean up empty lines in .c and .h files 2020-09-01 22:14:09 +00:00
geom_int.h Remove duplicate g_debugflags declaration. 2019-12-05 15:07:32 +00:00
geom_io.c geom: Handle partial I/O in g_{read,write,delete}_data() 2022-01-20 08:29:39 -05:00
geom_kern.c geom(4): Mark all sysctls as CTLFLAG_MPSAFE. 2021-08-10 20:18:46 -04:00
geom_map.c geom: clean up empty lines in .c and .h files 2020-09-01 22:14:09 +00:00
geom_redboot.c geom_map and geom_redboot: Remove unused ctlreq handler. 2020-07-26 22:30:01 +00:00
geom_slice.c Pass BIO_SPEEDUP through all the geom layers 2020-01-17 01:15:55 +00:00
geom_slice.h
geom_subr.c geom: Remove g_class.config 2021-11-18 23:17:07 -07:00
geom_vfs.c g_vfs_close(): vp is unused 2021-11-18 05:02:59 +02:00
geom_vfs.h
geom.h GEOM: Minor polishing in geom_event. 2021-12-27 21:01:08 -05:00
notes