]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
unionfs: rework pathname handling
authorJason A. Harmening <jah@FreeBSD.org>
Sun, 29 Aug 2021 21:36:15 +0000 (14:36 -0700)
committerJason A. Harmening <jah@FreeBSD.org>
Wed, 1 Sep 2021 14:55:09 +0000 (07:55 -0700)
commitabe95116ba10c8ab56f3ccd72a969ee29a9eef0b
treee38e5d5ca25f1873c84416246486f7f7c2577c07
parentc98bf2a45e0527e7c1958f0a311cb2be072f1411
unionfs: rework pathname handling

Running stress2 unionfs tests reliably produces a namei_zone corruption
panic due to unionfs_relookup() attempting to NUL-terminate a newly-
allocate pathname buffer without first validating the buffer length.

Instead, avoid allocating new pathname buffers in unionfs entirely,
using already-provided buffers while ensuring the the correct flags
are set in struct componentname to prevent freeing or manipulation
of those buffers at lower layers.

While here, also compute and store the path length once in the unionfs
node instead of constantly invoking strlen() on it.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D31728
sys/fs/unionfs/union.h
sys/fs/unionfs/union_subr.c
sys/fs/unionfs/union_vnops.c