libfs: Return ENOSPC when the directory offset range is exhausted
[ Upstream commit903dc9c43a] 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:6faddda69f("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> [ cel: adjusted to apply to origin/linux-6.6.y ] Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
2b6da3fa94
commit
a01bb1c5ca
+2
-2
@@ -287,8 +287,8 @@ int simple_offset_add(struct offset_ctx *octx, struct dentry *dentry)
|
||||
|
||||
ret = xa_alloc_cyclic(&octx->xa, &offset, dentry, limit,
|
||||
&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;
|
||||
|
||||
Reference in New Issue
Block a user