OpenAFS Master Repository branch, master, updated. openafs-devel-1_9_2-374-g2a05e2a
Gerrit Code Review
gerrit@openafs.org
Tue, 11 Nov 2025 16:39:17 -0500
The following commit has been merged in the master branch:
commit 2a05e2ac728fb390baffc34647cf84e15302b076
Author: Andrew Deason <adeason@sinenomine.net>
Date: Fri Nov 7 14:28:48 2025 -0600
vol: Always return -1 on namei_SetLinkCount errors
It appears that namei_SetLinkCount() is intended to return -1 when it
encounters any error; it returns -1 for various early errors, and many
callers check for an error by checking for a negative return value. But
if FDH_PREAD() returns any value between 0 and sizeof(row), or if the
subsequent FDH_PWRITE() call fails, we'll return a positive value.
So some callers of namei_SetLinkCount() may fail to detect an error
(notably in namei_inc() and namei_dec()), possibly resulting in the
linkcount for some inodes being too high or too low. This appears to
have been the case since before OpenAFS 1.0; the relevant code has seen
some changes since then, but the bug has always been there.
To fix this, stop using the same variable for the return code and
the number of bytes read, and instead use a separate 'code' that is
always set to either -1 or 0. Also change all namei_SetLinkCount()
callers to check for a nonzero return value, just to be safe, since
there's no reason to only check for negative values.
Thanks to mbarbosa@sinenomine.net and cwills@sinenomine.net for pointing
out this issue.
Change-Id: I458682ca9827b4ec5edb9fd0296674462d1c83c6
Reviewed-on: https://gerrit.openafs.org/16614
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
src/vol/namei_ops.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
--
OpenAFS Master Repository