]> www.infradead.org Git - users/dwmw2/linux.git/commit
cachefiles: add consistency check for copen/cread
authorBaokun Li <libaokun1@huawei.com>
Wed, 22 May 2024 11:43:02 +0000 (19:43 +0800)
committerChristian Brauner <brauner@kernel.org>
Wed, 29 May 2024 11:03:30 +0000 (13:03 +0200)
commita26dc49df37e996876f50a0210039b2d211fdd6f
tree3694199b7034232b83d56cb649a82e55759576f4
parent3e6d704f02aa4c50c7bc5fe91a4401df249a137b
cachefiles: add consistency check for copen/cread

This prevents malicious processes from completing random copen/cread
requests and crashing the system. Added checks are listed below:

  * Generic, copen can only complete open requests, and cread can only
    complete read requests.
  * For copen, ondemand_id must not be 0, because this indicates that the
    request has not been read by the daemon.
  * For cread, the object corresponding to fd and req should be the same.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Link: https://lore.kernel.org/r/20240522114308.2402121-7-libaokun@huaweicloud.com
Acked-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/cachefiles/ondemand.c