From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBC68C433E0 for ; Fri, 17 Jul 2020 14:44:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A18BB208DB for ; Fri, 17 Jul 2020 14:44:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A18BB208DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2FAF08D0009; Fri, 17 Jul 2020 10:44:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 282178D0003; Fri, 17 Jul 2020 10:44:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 171958D0009; Fri, 17 Jul 2020 10:44:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id F25D48D0003 for ; Fri, 17 Jul 2020 10:44:25 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7DAFA180AE7E2 for ; Fri, 17 Jul 2020 14:44:25 +0000 (UTC) X-FDA: 77047838490.04.ducks84_611145526f0b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id AFE098014BDC for ; Fri, 17 Jul 2020 14:44:06 +0000 (UTC) X-HE-Tag: ducks84_611145526f0b X-Filterd-Recvd-Size: 6234 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 17 Jul 2020 14:44:05 +0000 (UTC) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06HEUmGP056868; Fri, 17 Jul 2020 10:43:59 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 32b61k6jhm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Jul 2020 10:43:58 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06HEeAsW001138; Fri, 17 Jul 2020 14:43:58 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma02dal.us.ibm.com with ESMTP id 32752a5vre-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Jul 2020 14:43:58 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06HEhsdp2425390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jul 2020 14:43:55 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 878AB78060; Fri, 17 Jul 2020 14:43:56 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9E9D78067; Fri, 17 Jul 2020 14:43:53 +0000 (GMT) Received: from [153.66.254.194] (unknown [9.85.141.100]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 17 Jul 2020 14:43:53 +0000 (GMT) Message-ID: <1594997031.3344.27.camel@linux.ibm.com> Subject: Re: [RFC PATCH v2 0/5] mm: extend memfd with ability to create "secret" memory areas From: James Bottomley Reply-To: jejb@linux.ibm.com To: Pavel Machek , Mike Rapoport Cc: linux-kernel@vger.kernel.org, Alan Cox , Andrew Morton , Andy Lutomirski , Christopher Lameter , Dave Hansen , Idan Yaniv , "Kirill A. Shutemov" , Matthew Wilcox , Peter Zijlstra , "Reshetova, Elena" , Thomas Gleixner , Tycho Andersen , linux-api@vger.kernel.org, linux-mm@kvack.org, Mike Rapoport Date: Fri, 17 Jul 2020 07:43:51 -0700 In-Reply-To: <20200717083601.GB1027@bug> References: <20200706172051.19465-1-rppt@kernel.org> <20200717083601.GB1027@bug> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-17_06:2020-07-17,2020-07-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_spam_definite policy=outbound score=100 lowpriorityscore=0 spamscore=100 clxscore=1011 bulkscore=0 mlxlogscore=-1000 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 mlxscore=100 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007170103 X-Rspamd-Queue-Id: AFE098014BDC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, 2020-07-17 at 10:36 +0200, Pavel Machek wrote: > Hi! > > > This is a second version of "secret" mappings implementation backed > > by a file descriptor. > > > > The file descriptor is created using memfd_create() syscall with a > > new MFD_SECRET flag. The file descriptor should be configured using > > ioctl() to define the desired protection and then mmap() of the fd > > will create a "secret" memory mapping. The pages in that mapping > > will be marked as not present in the direct map and will have > > desired protection bits set in the user page table. For instance, > > current implementation allows uncached mappings. > > > > Hiding secret memory mappings behind an anonymous file allows > > (ab)use of the page cache for tracking pages allocated for the > > "secret" mappings as well as using address_space_operations for > > e.g. page migration callbacks. > > > > The anonymous file may be also used implicitly, like hugetlb files, > > to implement mmap(MAP_SECRET) and use the secret memory areas with > > "native" mm ABIs. > > I believe unix userspace normally requires mappings to be... well... > protected from other users. How is this "secret" thing different? How > do you explain the difference to userland programmers? That's true in the normal case, but for the container cloud the threat model we're considering is a hostile other tenant trying to trick the kernel into giving them access to your mappings. In the FOSDEM talk we did about this: https://fosdem.org/2020/schedule/event/kernel_address_space_isolation/ We demonstrated the case where the hostile tenant obtained host root and then tried to get access via ptrace. The point being that pushing the pages out of the direct map means that even root can't get access to the secret by any means the OS provides. If you want to play with this yourself, we have a userspace library: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/secret-memory-preloader.git/ It does two things: the first is act as a preloader for openssl to redirect all the OPENSSL_malloc calls to secret memory meaning any secret keys get automatically protected this way and the other thing it does is expose the API to the user who needs it. I anticipate that a lot of the use cases would be like the openssl one: many toolkits that deal with secret keys already have special handling for the memory to try to give them greater protection, so this would simply be pluggable into the toolkits without any need for user application modification. James