Re: [PATCH v2 1/6] mm: introduce vma->vm_flags modifier functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[I'm just going to trim the incredibly long list of recipients.  Too
many bounces, and I doubt any of them really care]

On Wed, Jan 25, 2023 at 11:21:56AM -0800, Suren Baghdasaryan wrote:
> On Wed, Jan 25, 2023 at 10:37 AM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
> > Here's a trick I saw somewhere in the VFS:
> >
> >         union {
> >                 const vm_flags_t vm_flags;
> >                 vm_flags_t __private __vm_flags;
> >         };
> >
> > Now it can be read by anybody but written only by those using
> > ACCESS_PRIVATE.
> 
> Huh, this is quite nice! I think it does not save us from the cases
> when vma->vm_flags is passed by a reference and modified indirectly,
> like in ksm_madvise()? Though maybe such usecases are so rare (I found
> only 2 cases) that we can ignore this?

Taking the address of vma->vm_flags will give you a const-qualified
pointer, which gcc will then warn about passing to a non-const-qualified
function argument, so I think we're good?





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux