]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Refactor dbuf_read() for safer decryption
authorAlexander Motin <mav@FreeBSD.org>
Mon, 22 Apr 2024 18:41:03 +0000 (14:41 -0400)
committerGitHub <noreply@github.com>
Mon, 22 Apr 2024 18:41:03 +0000 (11:41 -0700)
commit4036b8d027fb7fe1a629b08a0d23cac975ab2eb9
tree59854d445473c9951645b7b5bbd01eda3e22394b
parentc346068e5efeafd5676ab1644086877173ca4226
Refactor dbuf_read() for safer decryption

In dbuf_read_verify_dnode_crypt():
 - We don't need original dbuf locked there. Instead take a lock
on a dnode dbuf, that is actually manipulated.
 - Block decryption for a dnode dbuf if it is currently being
written.  ARC hash lock does not protect anonymous buffers, so
arc_untransform() is unsafe when used on buffers being written,
that may happen in case of encrypted dnode buffers, since they
are not copied by dbuf_dirty()/dbuf_hold_copy().

In dbuf_read():
 - If the buffer is in flight, recheck its compression/encryption
status after it is cached, since it may need arc_untransform().

Tested-by: Rich Ercolani <rincebrain@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #16104
module/zfs/dbuf.c