From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Williams Subject: Re: [PATCH 2/2] mm: introduce MAP_VALIDATE, a mechanism for for safely defining new mmap flags Date: Thu, 31 Aug 2017 18:40:08 -0700 Message-ID: References: <150413449482.5923.1348069619036923853.stgit@dwillia2-desk3.amr.corp.intel.com> <150413450616.5923.7069852068237042023.stgit@dwillia2-desk3.amr.corp.intel.com> <20170831100359.GD21443@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Linus Torvalds Cc: Christoph Hellwig , Linux MM , Jan Kara , Arnd Bergmann , "linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org" , Linux API , Andy Lutomirski , Andrew Morton List-Id: linux-api@vger.kernel.org On Thu, Aug 31, 2017 at 6:27 PM, Linus Torvalds wrote: > On Thu, Aug 31, 2017 at 6:01 PM, Dan Williams wrote: >> >> Ugh, nommu defeats the MAP_SHARED_VALIDATE proposal from Linus. >> >> if ((flags & MAP_TYPE) != MAP_PRIVATE && >> (flags & MAP_TYPE) != MAP_SHARED) >> return -EINVAL; >> >> ...parisc strikes again. > > Why? That's no different from the case statement for the mmu case, > just written differently. > > You *want* existing kernels to fail, since they don't test the bits > you want to test. > > So you just want to rewrite these all as > > switch (flags & MAP_TYPE) { > case MAP_SHARED_VALIDATE: > .. validate the other bits... > /* fallhtough */ > case MAP_SHARED: > .. do the shared case .. > case MAP_PRIVATE: > .. do the private case .. > default: > return -EINVAL; > } > > and you're all good. > > I'm not seeing the problem. Right, I went cross-eyed for a second. There is no problem.