cachefiles: Set object to close if ondemand_id < 0 in copen
authorZizhi Wo <wozizhi@huawei.com>
Wed, 22 May 2024 11:43:06 +0000 (19:43 +0800)
committerChristian Brauner <brauner@kernel.org>
Wed, 29 May 2024 11:03:30 +0000 (13:03 +0200)
commit4f8703fb3482f92edcfd31661857b16fec89c2c0
tree87749db91367792d846c561c7b30f495e3b17e46
parent4b4391e77a6bf24cba2ef1590e113d9b73b11039
cachefiles: Set object to close if ondemand_id < 0 in copen

If copen is maliciously called in the user mode, it may delete the request
corresponding to the random id. And the request may have not been read yet.

Note that when the object is set to reopen, the open request will be done
with the still reopen state in above case. As a result, the request
corresponding to this object is always skipped in select_req function, so
the read request is never completed and blocks other process.

Fix this issue by simply set object to close if its id < 0 in copen.

Signed-off-by: Zizhi Wo <wozizhi@huawei.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Link: https://lore.kernel.org/r/20240522114308.2402121-11-libaokun@huaweicloud.com
Acked-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jia Zhu <zhujia.zj@bytedance.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/cachefiles/ondemand.c