From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-f199.google.com (mail-io0-f199.google.com [209.85.223.199]) by kanga.kvack.org (Postfix) with ESMTP id BB0BF6B0292 for ; Thu, 31 Aug 2017 21:27:33 -0400 (EDT) Received: by mail-io0-f199.google.com with SMTP id 63so7229969ioe.1 for ; Thu, 31 Aug 2017 18:27:33 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 67sor307214iom.100.2017.08.31.18.27.32 for (Google Transport Security); Thu, 31 Aug 2017 18:27:32 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: 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> From: Linus Torvalds Date: Thu, 31 Aug 2017 18:27:31 -0700 Message-ID: Subject: Re: [PATCH 2/2] mm: introduce MAP_VALIDATE, a mechanism for for safely defining new mmap flags Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Dan Williams Cc: Christoph Hellwig , Linux MM , Jan Kara , Arnd Bergmann , "linux-nvdimm@lists.01.org" , Linux API , Andy Lutomirski , Andrew Morton 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. Of course, I also suspect that for nommu you might as well just always return -EINVAL anyway. The only people who would ever use MAP_SHARED_VALIDATE are the kinds of people who do things that just aren't likely relevant on nommu, but whatever.. Linus -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org