aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2023-12-21 18:26:13 +0000
committerMark Johnston <markj@FreeBSD.org>2023-12-28 03:04:22 +0000
commitb525eaaa4aafeee857d1abef27d7ddf1af76846f (patch)
tree894c1e151bd2ba438b162126061edd25a6079525
parentf765ef3aabcdfd69cb4501422906f0b30bc7de51 (diff)
downloadsrc-b525eaaa4aafeee857d1abef27d7ddf1af76846f.tar.gz
src-b525eaaa4aafeee857d1abef27d7ddf1af76846f.zip
ufs: Update *eofflag upon a read of an unlinked directory
If the directory is unlinked, no further entries will be returned, but we return no error. At least one caller (vn_dir_next_dirent()) asserts that a VOP_READDIR call which returns no error and no entries will set *eofflag != 0, so the current behaviour of UFS can trigger an assertion failure. Simply set *eofflag in this scenario. Reviewed by: olce, kib Reported by: syzkaller MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43089 (cherry picked from commit 3ff574c5e1d1d5d07763a14f22d6f9d7291550c6)
-rw-r--r--sys/ufs/ufs/ufs_vnops.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 949e7bcc1bec..954f85e17a9f 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -2434,8 +2434,10 @@ ufs_readdir(
if (uio->uio_offset < 0)
return (EINVAL);
ip = VTOI(vp);
- if (ip->i_effnlink == 0)
+ if (ip->i_effnlink == 0) {
+ *ap->a_eofflag = 1;
return (0);
+ }
if (ap->a_ncookies != NULL) {
if (uio->uio_resid < 0)
ncookies = 0;