On Fri, Sep 11, 2020 at 04:13:39PM +0200, David Sterba wrote: > On Fri, Aug 21, 2020 at 12:39:52AM -0700, Omar Sandoval wrote: > > +static int put_data_header(struct send_ctx *sctx, u32 len) > > +{ > > + struct btrfs_tlv_header *hdr; > > + > > + if (sctx->send_max_size - sctx->send_size < sizeof(*hdr) + len) > > + return -EOVERFLOW; > > + hdr = (struct btrfs_tlv_header *)(sctx->send_buf + sctx->send_size); > > + hdr->tlv_type = cpu_to_le16(BTRFS_SEND_A_DATA); > > + hdr->tlv_len = cpu_to_le16(len); > > I think we need put_unaligned_le16 here, it's mapping a random buffer to > a pointer, this is not alignment safe in general. I think you're right, although tlv_put() seems to have this same problem.