Re: [RFC PATCH v5 2/4] mseal: add mseal syscall

From: Jeff Xu
Date: Wed Jan 10 2024 - 21:59:13 EST


On Tue, Jan 9, 2024 at 12:36 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
>
> On Tue, Jan 09, 2024 at 03:45:40PM +0000, jeffxu@xxxxxxxxxxxx wrote:
> > +extern bool can_modify_mm(struct mm_struct *mm, unsigned long start,
> > + unsigned long end);
> > +extern bool can_modify_mm_madv(struct mm_struct *mm, unsigned long start,
> > + unsigned long end, int behavior);
>
> unnecessary use of extern.
>
> > +static inline unsigned long get_mmap_seals(unsigned long prot,
> > + unsigned long flags)
>
> needs more than one tab indent so it doesn't look like part of the body.
>
> > +{
> > + unsigned long vm_seals;
> > +
> > + if (prot & PROT_SEAL)
> > + vm_seals = VM_SEALED | VM_SEALABLE;
> > + else
> > + vm_seals = (flags & MAP_SEALABLE) ? VM_SEALABLE:0;
>
> need spaces around the :
>
> > +++ b/include/uapi/asm-generic/mman-common.h
> > @@ -17,6 +17,11 @@
> > #define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
> > #define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
> >
> > +/*
> > + * The PROT_SEAL defines memory sealing in the prot argument of mmap().
> > + */
> > +#define PROT_SEAL _BITUL(26) /* 0x04000000 */
>
> why not follow the existing style?
>
> > +static inline void set_vma_sealed(struct vm_area_struct *vma)
> > +{
> > + vma->__vm_flags |= VM_SEALED;
> > +}
>
> uhh ... vm_flags_set() ?
>
Thanks. I agree with all the comments above and will update in the next version.

-Jeff