]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Explicitly initialize rather than reading newly allocated UFS inodes.
authorKirk McKusick <mckusick@FreeBSD.org>
Sat, 13 Aug 2022 20:50:08 +0000 (13:50 -0700)
committerKirk McKusick <mckusick@FreeBSD.org>
Sat, 13 Aug 2022 20:51:25 +0000 (13:51 -0700)
commit6b9d4fbb7fe550788d82168e7beeabcd5ad238ce
tree26d22ad93b7de0924c3b6a5fda265ee0148e9496
parent30f6269155927423eda4ed0bea2c903ef008b2d6
Explicitly initialize rather than reading newly allocated UFS inodes.

The function ffs_vgetf() is used to find or load UFS inodes into a
vnode. It first looks up the inode and if found in the cache its
vnode is returned. If it is not already in the cache, a new vnode
is allocated and its associated inode read in from the disk. The
read is done even for inodes that are being initially created.
The contents for the inode on the disk are assumed to be empty. If
the on-disk contents had been corrupted either due to a hardware
glitch or an agent deliberately trying to exploit the system, the
UFS code could panic from the unexpected partially-allocated inode.

Rather then having fsck_ffs(8) verify that all unallocated inodes
are properly empty, it is easier and quicker to add a flag to
ffs_vgetf() to indicate that the request is for a newly allocated
inode. When set, the disk read is skipped and the inode is set to
its expected empty (zero'ed out) initial state. As a side benefit,
an unneeded disk I/O is avoided.

Reported by:  Peter Holm
Sponsored by: The FreeBSD Foundation
sys/ufs/ffs/ffs_alloc.c
sys/ufs/ffs/ffs_extern.h
sys/ufs/ffs/ffs_vfsops.c