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=-5.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 E1A94C433B4 for ; Thu, 6 May 2021 17:27:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 40C29610CE for ; Thu, 6 May 2021 17:27:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40C29610CE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:Subject: From:References:Cc:To:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9gLhicMprq3XoyV3ytuEN8S/ByPkO+ayYb0UIq/I+iM=; b=hQ0lM3HGobVLGdtjFmAU1fDN4 yAv+lbvtMoIDp3S0+1jqQotRKNSG+QLgf1I8bYwEEmrq2Bo/7eKU9iorGS10wGpWv1HEHXBBUn3ZB KC9U8QbeNPDUk8KsP3e5Ws984KbTbPO/vEetKX+JqoLWzB6iqFCR3npBdPV/nXm4PhY8bG+voGHpc zRL5mRHeruzg8JZ3FM8KMan3cML6jz1eZTDvXCmkz7+FXsDwoOSw8zoIiB8iypQliswGNmO0wk6Ta 7ow9bEn8KiCxzxriVCzL/hY2+5Gu223zPquIW0PfxjriBEXGoOW9YgDzKtB1KvgD+8wo2JDDn4QDY s9S1x8n5Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lehk7-004vO5-Ts; Thu, 06 May 2021 17:24:56 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lehk4-004vNm-Ow for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 17:24:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:Subject:From:References :Cc:To:Sender:Reply-To:Content-ID:Content-Description; bh=jExgBas4mYe2R7HQ1xBXEHvzUr1CEHDDU82ObrbRp1A=; b=BvyqpQmGrfS+APlPQP5MrrUjJl 1qUUn5runFs6SghYo8Dc2g84N1Q1dzXB4TYG8LX6GHTlW4k7XyEgJIAVxsD28uBdDDtKYOeZeGa5F sS3ZMeuutDNIw+IBdcPW684yIqdUpyyUOpUp2mGd/GXc1hosns5tGT24y9B52JtG1U8Uf1f1Bb1lb pUaEU2QhGqwdN9523A6eh2KrG/JGDWP4APTjLTJo4lNaiQDPgoQHGTY0zfVpBepVGjU7GFICQx7MP eZMRrwQRPJfIG5/bDyAISPxrQf7Si569wFshyy3NsAND7Lro2LCCZ9YzA/GKAORaeikt5hiWencD7 QCWRTixg==; Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lehk1-006FeN-TO for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 17:24:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620321888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jExgBas4mYe2R7HQ1xBXEHvzUr1CEHDDU82ObrbRp1A=; b=QtVNeNVBZoVRRAuiNP78gT1sJKEnULmVO68qyZuBcqbL7awurrRGeJQ8iS4h8wz48b8muR dXobEqs++IXNq34ozp96iD3Y1J3M0U7P0LnkglPH0VVd1i5U+Qar1HA8C+rAW8BrjMi41s LQLuwr3LTKfz40AtXAW2WODjHL64w9g= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-448-jdQM6h_UOWaZVBJw-lC1CA-1; Thu, 06 May 2021 13:24:47 -0400 X-MC-Unique: jdQM6h_UOWaZVBJw-lC1CA-1 Received: by mail-ed1-f72.google.com with SMTP id f8-20020a0564020688b029038840895df2so3016903edy.17 for ; Thu, 06 May 2021 10:24:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=jExgBas4mYe2R7HQ1xBXEHvzUr1CEHDDU82ObrbRp1A=; b=pcYEKiUHWF44alvkrsscuRXHIsJ7EV3U2vMq8+XhVzYWw0IMY96vf5ngO/2QxL195N /C5CmXUrxX4+nOduojIirDdjekloSUXBlSHAEwl3GPf3OkykztG9Qf8/sDX1KQrZ7hV0 5wZCYCPmPPpp4JuRqMO87N580wwMVN4eXciJO86GLD47VsN4duY6kzPmon9C1XYjvJbg EnCA3J4iPqqY9BvzTTI5C1ZzefTD/G4MP9/hW3FTlBHK7Mrtq7f53Nn7P+VbzQnf0zJM e6E1vsJd3skwoPUa5+uWIvtgDvzhJczEiyiWBQVN/c2luHCSWJQRwjlef0gQBIWrfrQX EqOw== X-Gm-Message-State: AOAM531A1UBBAg1RA+uaguEB5cED+mXXgfK6eaFEOmNnUfLQwndXHgzq YOB17es8Fzhnyz1l+IkU03GUtiNECJ4KGo/hDp5hs+BMqK7pTSWTXG8XUAcyqotyaGR26QyvRdd j1vDhfV/T3K9KT/p267rgTJEAF11w6GKFsM8= X-Received: by 2002:aa7:d952:: with SMTP id l18mr6506583eds.83.1620321886025; Thu, 06 May 2021 10:24:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0HYEbkAPLbEzE0RQH/Kg006zDXqRhpGiJee/o6TGxungGJENUOS9lWTxREQMEK2RJtQPDnQ== X-Received: by 2002:aa7:d952:: with SMTP id l18mr6506560eds.83.1620321885798; Thu, 06 May 2021 10:24:45 -0700 (PDT) Received: from [192.168.3.132] (p5b0c64ae.dip0.t-ipconnect.de. [91.12.100.174]) by smtp.gmail.com with ESMTPSA id y19sm2147544edc.73.2021.05.06.10.24.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 May 2021 10:24:45 -0700 (PDT) To: jejb@linux.ibm.com, Andrew Morton , Mike Rapoport Cc: Alexander Viro , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christopher Lameter , Dan Williams , Dave Hansen , Elena Reshetova , "H. Peter Anvin" , Ingo Molnar , "Kirill A. Shutemov" , Matthew Wilcox , Matthew Garrett , Mark Rutland , Michal Hocko , Mike Rapoport , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , "Rafael J. Wysocki" , Rick Edgecombe , Roman Gushchin , Shakeel Butt , Shuah Khan , Thomas Gleixner , Tycho Andersen , Will Deacon , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, linux-riscv@lists.infradead.org, x86@kernel.org References: <20210303162209.8609-1-rppt@kernel.org> <20210505120806.abfd4ee657ccabf2f221a0eb@linux-foundation.org> <996dbc29-e79c-9c31-1e47-cbf20db2937d@redhat.com> <8eb933f921c9dfe4c9b1b304e8f8fa4fbc249d84.camel@linux.ibm.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v18 0/9] mm: introduce memfd_secret system call to create "secret" memory areas Message-ID: Date: Thu, 6 May 2021 19:24:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <8eb933f921c9dfe4c9b1b304e8f8fa4fbc249d84.camel@linux.ibm.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210506_102450_045664_304228D0 X-CRM114-Status: GOOD ( 28.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org >>>> Is this intended to protect keys/etc after the attacker has >>>> gained the ability to run arbitrary kernel-mode code? If so, >>>> that seems optimistic, doesn't it? >>> >>> Not exactly: there are many types of kernel attack, but mostly the >>> attacker either manages to effect a privilege escalation to root or >>> gets the ability to run a ROP gadget. The object of this code is >>> to be completely secure against root trying to extract the secret >>> (some what similar to the lockdown idea), thus defeating privilege >>> escalation and to provide "sufficient" protection against ROP >>> gadget. >> >> What stops "root" from mapping /dev/mem and reading that memory? > > /dev/mem uses the direct map for the copy at least for read/write, so > it gets a fault in the same way root trying to use ptrace does. I > think we've protected mmap, but Mike would know that better than I. > I'm more concerned about the mmap case -> remap_pfn_range(). Anybody going via the VMA shouldn't see the struct page, at least when vma_normal_page() is properly used; so you cannot detect secretmem memory mapped via /dev/mem reliably. At least that's my theory :) [...] >> Also, there is a way to still read that memory when root by >> >> 1. Having kdump active (which would often be the case, but maybe not >> to dump user pages ) >> 2. Triggering a kernel crash (easy via proc as root) >> 3. Waiting for the reboot after kump() created the dump and then >> reading the content from disk. > > Anything that can leave physical memory intact but boot to a kernel > where the missing direct map entry is restored could theoretically > extract the secret. However, it's not exactly going to be a stealthy > extraction ... > >> Or, as an attacker, load a custom kexec() kernel and read memory >> from the new environment. Of course, the latter two are advanced >> mechanisms, but they are possible when root. We might be able to >> mitigate, for example, by zeroing out secretmem pages before booting >> into the kexec kernel, if we care :) > > I think we could handle it by marking the region, yes, and a zero on > shutdown might be useful ... it would prevent all warm reboot type > attacks. Right. But I guess when you're actually root, you can just write a kernel module to extract the information you need (unless we have signed modules, so it could be harder/impossible). -- Thanks, David / dhildenb _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel