Skip to content

Commit

Permalink
Zero end of embedded block buffer in dump_write_embedded()
Browse files Browse the repository at this point in the history
This fixes a kernel stack leak.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Tested-by: Nicholas Sherlock <n.sherlock@gmail.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes openzfs#13778
Closes openzfs#14255
  • Loading branch information
ryao authored and tonyhutter committed Jan 19, 2023
1 parent 3207803 commit a2aabac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion module/zfs/dmu_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,13 @@ dump_write_embedded(dmu_send_cookie_t *dscp, uint64_t object, uint64_t offset,

decode_embedded_bp_compressed(bp, buf);

if (dump_record(dscp, buf, P2ROUNDUP(drrw->drr_psize, 8)) != 0)
uint32_t psize = drrw->drr_psize;
uint32_t rsize = P2ROUNDUP(psize, 8);

if (psize != rsize)
memset(buf + psize, 0, rsize - psize);

if (dump_record(dscp, buf, rsize) != 0)
return (SET_ERROR(EINTR));
return (0);
}
Expand Down

0 comments on commit a2aabac

Please sign in to comment.