Re: [PATCH v4 1/3] kasan: support backing vmalloc space with real shadow memory
From: Andy Lutomirski
Date: Mon Aug 19 2019 - 18:21:04 EST
> On Aug 18, 2019, at 8:58 PM, Daniel Axtens <dja@xxxxxxxxxx> wrote:
>>> Each page of shadow memory represent 8 pages of real memory. Could we use
>>> page_ref to count how many pieces of a shadow page are used so that we can
>>> free it when the ref count decreases to 0.
> I'm not sure how much of a difference it will make, but I'll have a look.
There are a grand total of eight possible pages that could require a
given shadow page. I would suggest that, instead of reference
counting, you just check all eight pages.
Or, better yet, look at the actual vm_area_struct and are where prev
and next point. That should tell you exactly which range can be freed.