Skip to content

Commit

Permalink
ARC changes to fix memory related crashes with encryption
Browse files Browse the repository at this point in the history
- Bail early in arc_buf_fill() when hdr->b_crypt_hdr.b_rabd is NULL
- In arc_write(), avoid arc_hdr_free_abd() when HDR_IO_IN_PROGRESS
  indicates it's still in use.

Sponsored-By: Odoo SA
Sponsored-By: Klara Inc.
Signed-off-by: Don Brady <don.brady@klarasystems.com>
  • Loading branch information
allanjude authored and don-brady committed Jan 17, 2024
1 parent a0b2a93 commit 38f7449
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,9 @@ arc_buf_fill(arc_buf_t *buf, spa_t *spa, const zbookmark_phys_t *zb,
* further transforms on it.
*/
if (encrypted) {
if (hdr->b_crypt_hdr.b_rabd == NULL)
return (ECKSUM);

ASSERT(HDR_HAS_RABD(hdr));
abd_copy_to_buf(buf->b_data, hdr->b_crypt_hdr.b_rabd,
HDR_GET_PSIZE(hdr));
Expand Down Expand Up @@ -2056,6 +2059,11 @@ arc_buf_fill(arc_buf_t *buf, spa_t *spa, const zbookmark_phys_t *zb,

if (hash_lock != NULL)
mutex_enter(hash_lock);
if (hdr->b_l1hdr.b_pabd == NULL) {
if (hash_lock != NULL)
mutex_exit(hash_lock);
return (EACCES);
}
arc_buf_untransform_in_place(buf);
if (hash_lock != NULL)
mutex_exit(hash_lock);
Expand Down Expand Up @@ -6704,7 +6712,7 @@ arc_write(zio_t *pio, spa_t *spa, uint64_t txg,
VERIFY3P(buf->b_data, !=, NULL);
}

if (HDR_HAS_RABD(hdr))
if (HDR_HAS_RABD(hdr) && !HDR_IO_IN_PROGRESS(hdr))
arc_hdr_free_abd(hdr, B_TRUE);

if (!(zio_flags & ZIO_FLAG_RAW))
Expand Down

0 comments on commit 38f7449

Please sign in to comment.