Re: [PATCH 2/3] pstore/ram: Switch to persistent_ram routines

From: Anton Vorontsov
Date: Fri May 18 2012 - 17:51:07 EST


On Thu, May 17, 2012 at 09:34:19AM -0700, Kees Cook wrote:
[...]
> > - Â Â Â memcpy(buf, cxt->pstore.buf, size);
> > - Â Â Â memset(buf + size, '\0', available - size);
> > + Â Â Â hlen = ramoops_write_kmsg_hdr(prz);
> > + Â Â Â if (size + hlen > prz->buffer_size)
> > + Â Â Â Â Â Â Â size = prz->buffer_size - hlen;
> > + Â Â Â persistent_ram_write(prz, cxt->pstore.buf, size);
>
> This still needs to wipe out the remaining bytes in the buffer (the
> second memset above).
[...]
> > - Â Â Â buf = cxt->virt_addr + (id * cxt->record_size);
> > - Â Â Â memset(buf, '\0', cxt->record_size);
> > + Â Â Â persistent_ram_free_old(cxt->przs[id]);
>
> Same here -- erasing the buffer means wiping it with NULL bytes.

Well, with persistent_ram we don't need to actually erase buffers
(with persistent_ram we might even hold binary data). But yes,
we'd better reset size pointer, otherwise the unlinked buffer
will show up on the next reboot. Thanks for noticing!

--
Anton Vorontsov
Email: cbouatmailru@xxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/