Rishabh Dave cda4672da1 ceph: prevent use-after-free in encode_cap_msg()
In fs/ceph/caps.c, in encode_cap_msg(), "use after free" error was
caught by KASAN at this line - 'ceph_buffer_get(arg->xattr_buf);'. This
implies before the refcount could be increment here, it was freed.

In same file, in "handle_cap_grant()" refcount is decremented by this
line - 'ceph_buffer_put(ci->i_xattrs.blob);'. It appears that a race
occurred and resource was freed by the latter line before the former
line could increment it.

encode_cap_msg() is called by __send_cap() and __send_cap() is called by
ceph_check_caps() after calling __prep_cap(). __prep_cap() is where
arg->xattr_buf is assigned to ci->i_xattrs.blob. This is the spot where
the refcount must be increased to prevent "use after free" error.

Cc: stable@vger.kernel.org
Link: https://tracker.ceph.com/issues/59259
Signed-off-by: Rishabh Dave <ridave@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2024-02-07 14:58:02 +01:00
..
2024-01-11 20:11:35 -08:00
2024-01-11 20:11:35 -08:00
2023-10-30 09:47:13 -10:00
2023-11-07 12:11:26 -08:00
2023-11-07 12:11:26 -08:00
2024-01-08 11:11:51 -08:00
2023-12-29 11:58:34 -08:00
2024-01-10 17:44:36 -08:00
2024-01-19 09:10:23 -08:00
2024-01-25 10:26:52 -08:00
2024-01-11 20:11:35 -08:00
2024-01-10 17:44:36 -08:00
2023-11-07 12:11:26 -08:00
2024-01-10 17:44:36 -08:00
2023-10-30 09:47:13 -10:00
2024-01-06 23:49:50 +01:00
2024-01-11 10:07:29 -08:00
2024-01-10 17:44:36 -08:00
2023-12-21 13:17:54 +01:00
2023-10-30 19:28:19 -10:00
2023-10-30 19:28:19 -10:00
2024-01-11 20:11:35 -08:00
2024-01-24 13:32:29 -08:00
2024-01-11 20:11:35 -08:00
2023-12-12 14:24:14 +01:00
2024-01-11 20:00:22 -08:00
2024-01-11 20:11:35 -08:00
2024-01-19 09:10:23 -08:00
2024-01-11 20:11:35 -08:00
2024-01-19 09:10:23 -08:00
2023-11-25 02:49:43 -05:00
2024-01-08 11:11:51 -08:00
2024-01-10 17:44:36 -08:00
2024-01-08 10:57:34 -08:00
2024-01-10 10:24:49 -08:00
2024-01-17 13:03:37 -08:00