Re: [PATCH 4/7] mm: Introduce verify_page_range()

2021-04-19 Thread Kees Cook
On Tue, Apr 13, 2021 at 08:54:06AM +0200, Peter Zijlstra wrote: > On Mon, Apr 12, 2021 at 01:05:09PM -0700, Kees Cook wrote: > > On Mon, Apr 12, 2021 at 10:00:16AM +0200, Peter Zijlstra wrote: > > > +struct vpr_data { > > > + int (*fn)(pte_t pte, unsigned long addr, void *data); > > > + void *data;

Re: [PATCH 4/7] mm: Introduce verify_page_range()

2021-04-14 Thread Peter Zijlstra
On Tue, Apr 13, 2021 at 08:01:08PM -0700, Kees Cook wrote: > So the addr can just be encoded in "int", and no structure is needed at: > > typedef bool (*vpr_fn_t)(pte_t pte); > > static int vpr_fn(pte_t *pte, unsigned long addr, void *data) > { > vpr_fn_t callback = data; > > if (!ca

Re: [PATCH 4/7] mm: Introduce verify_page_range()

2021-04-13 Thread Kees Cook
On Tue, Apr 13, 2021 at 09:36:32AM +0200, Peter Zijlstra wrote: > On Mon, Apr 12, 2021 at 01:05:09PM -0700, Kees Cook wrote: > > On Mon, Apr 12, 2021 at 10:00:16AM +0200, Peter Zijlstra wrote: > > > +struct vpr_data { > > > + int (*fn)(pte_t pte, unsigned long addr, void *data); > > > + void *data;

Re: [PATCH 4/7] mm: Introduce verify_page_range()

2021-04-13 Thread Peter Zijlstra
On Mon, Apr 12, 2021 at 01:05:09PM -0700, Kees Cook wrote: > On Mon, Apr 12, 2021 at 10:00:16AM +0200, Peter Zijlstra wrote: > > +struct vpr_data { > > + int (*fn)(pte_t pte, unsigned long addr, void *data); > > + void *data; > > +}; > > Eeerg. This is likely to become an attack target itself.

Re: [PATCH 4/7] mm: Introduce verify_page_range()

2021-04-12 Thread Peter Zijlstra
On Mon, Apr 12, 2021 at 01:05:09PM -0700, Kees Cook wrote: > On Mon, Apr 12, 2021 at 10:00:16AM +0200, Peter Zijlstra wrote: > > +struct vpr_data { > > + int (*fn)(pte_t pte, unsigned long addr, void *data); > > + void *data; > > +}; > > Eeerg. This is likely to become an attack target itself.

Re: [PATCH 4/7] mm: Introduce verify_page_range()

2021-04-12 Thread Kees Cook
On Mon, Apr 12, 2021 at 10:00:16AM +0200, Peter Zijlstra wrote: > +struct vpr_data { > + int (*fn)(pte_t pte, unsigned long addr, void *data); > + void *data; > +}; Eeerg. This is likely to become an attack target itself. Stored function pointer with stored (3rd) argument. This doesn't se

Re: [PATCH 4/7] mm: Introduce verify_page_range()

2021-04-12 Thread Peter Zijlstra
On Mon, Apr 12, 2021 at 10:28:05AM +0200, Christoph Hellwig wrote: > On Mon, Apr 12, 2021 at 10:00:16AM +0200, Peter Zijlstra wrote: > > +extern int verify_page_range(struct mm_struct *mm, > > No need for the extern here. It's consistent with the rest of the functions there. Also, I personally li

Re: [PATCH 4/7] mm: Introduce verify_page_range()

2021-04-12 Thread Christoph Hellwig
On Mon, Apr 12, 2021 at 10:00:16AM +0200, Peter Zijlstra wrote: > +extern int verify_page_range(struct mm_struct *mm, No need for the extern here. > +int verify_page_range(struct mm_struct *mm, > + unsigned long addr, unsigned long size, > + int (*fn)(pte_t pte

[PATCH 4/7] mm: Introduce verify_page_range()

2021-04-12 Thread Peter Zijlstra
Introduce and EXPORT a read-only counterpart to apply_to_page_range(). It only exposes the PTE value, not a pointer to the pagetables itself and is thus quite a bit safer to export. A number of apply_to_page_range() users can be converted to this primitive. Signed-off-by: Peter Zijlstra (Intel)