Skip to content

Commit

Permalink
Fix bounds check in zio_crypt_do_objset_hmacs
Browse files Browse the repository at this point in the history
The current bounds check in zio_crypt_do_objset_hmacs() does not
properly handle the possible sizes of the objset_phys_t and
can therefore read outside the buffer's memory. If that memory
happened to match what the check was actually looking for, the
objset would fail to be owned, complaining that the MAC was
invalid.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #7210
  • Loading branch information
Tom Caputi authored and behlendorf committed Feb 22, 2018
1 parent 09302a4 commit f8478fc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions module/zfs/zio_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,13 +1196,17 @@ zio_crypt_do_objset_hmacs(zio_crypt_key_t *key, void *data, uint_t datalen,
bcopy(raw_portable_mac, portable_mac, ZIO_OBJSET_MAC_LEN);

/*
* The local MAC protects the user and group accounting. If these
* objects are not present, the local MAC is zeroed out.
* The local MAC protects the user, group and project accounting.
* If these objects are not present, the local MAC is zeroed out.
*/
if (datalen >= OBJSET_PHYS_SIZE_V2 &&
if ((datalen >= OBJSET_PHYS_SIZE_V3 &&
osp->os_userused_dnode.dn_type == DMU_OT_NONE &&
osp->os_groupused_dnode.dn_type == DMU_OT_NONE &&
osp->os_projectused_dnode.dn_type == DMU_OT_NONE) {
osp->os_projectused_dnode.dn_type == DMU_OT_NONE) ||
(datalen >= OBJSET_PHYS_SIZE_V2 &&
osp->os_userused_dnode.dn_type == DMU_OT_NONE &&
osp->os_groupused_dnode.dn_type == DMU_OT_NONE) ||
(datalen <= OBJSET_PHYS_SIZE_V1)) {
bzero(local_mac, ZIO_OBJSET_MAC_LEN);
return (0);
}
Expand Down

0 comments on commit f8478fc

Please sign in to comment.