diff options
| author | Chuck Lever <chuck.lever@oracle.com> | 2024-12-28 12:55:17 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-01 17:21:22 +0100 |
| commit | 3b3b2b47c71683825e5dae74b5bc08ae639199ac (patch) | |
| tree | 4d2371c95485137adf730a358c1537c5afe391b3 /fs | |
| parent | 5bb1fd0855bb0abc7d97e44758d6ffed7882d2d0 (diff) | |
| download | linux-3b3b2b47c71683825e5dae74b5bc08ae639199ac.tar.gz linux-3b3b2b47c71683825e5dae74b5bc08ae639199ac.tar.bz2 linux-3b3b2b47c71683825e5dae74b5bc08ae639199ac.zip | |
libfs: Return ENOSPC when the directory offset range is exhausted
commit 903dc9c43a155e0893280c7472d4a9a3a83d75a6 upstream.
Testing shows that the EBUSY error return from mtree_alloc_cyclic()
leaks into user space. The ERRORS section of "man creat(2)" says:
> EBUSY O_EXCL was specified in flags and pathname refers
> to a block device that is in use by the system
> (e.g., it is mounted).
ENOSPC is closer to what applications expect in this situation.
Note that the normal range of simple directory offset values is
2..2^63, so hitting this error is going to be rare to impossible.
Fixes: 6faddda69f62 ("libfs: Add directory operations for stable offsets")
Cc: stable@vger.kernel.org # v6.9+
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Yang Erkun <yangerkun@huawei.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Link: https://lore.kernel.org/r/20241228175522.1854234-2-cel@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/libfs.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/libfs.c b/fs/libfs.c index 748ac5923154..3da58a92f48f 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -292,8 +292,8 @@ int simple_offset_add(struct offset_ctx *octx, struct dentry *dentry) ret = mtree_alloc_cyclic(&octx->mt, &offset, dentry, DIR_OFFSET_MIN, LONG_MAX, &octx->next_offset, GFP_KERNEL); - if (ret < 0) - return ret; + if (unlikely(ret < 0)) + return ret == -EBUSY ? -ENOSPC : ret; offset_set(dentry, offset); return 0; |
