Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1630922rwl; Thu, 5 Jan 2023 17:08:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXt51XDSo5OpIED5cNwzXoumJUz1JTGmX+3com3uTVxm9rTcDMJ3ROYKf7xTxfc/oh1z3nr6 X-Received: by 2002:a62:e80c:0:b0:583:17ff:4f72 with SMTP id c12-20020a62e80c000000b0058317ff4f72mr5670079pfi.12.1672967300618; Thu, 05 Jan 2023 17:08:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672967300; cv=none; d=google.com; s=arc-20160816; b=T5fafk5okoxehBQ5mtEVEJiUjViIVFBuXWK0OVxAS9+dhzMsjJxN5L6yTV4AQfMFHG HE+Z2uykJ49JpRWvzIezNSH0RmodKgBy/uSr/JXMwRBa1CiD+qAB2xaLEf3Blv5KxA3O 7XCXPfMC9KXF04tnJSixADqKqtyDWq781c9Q6+EobRbcbztZ58RR71QvQLtrhebj1CgG H8/ASClDRjZdQ+rPZ5LKncAlryYhQnrsgUb0yf98Y9k8+0Wh1TbXgAEb/7+CN1+3WZgv C+iWnvxutEqLRXcfZ2tOgjug3sfU1eS1hjOoiAArCCOcwXY6sT0XvWp5KsirNmuicTCD J+WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=E2zTyAKcMSHj1NuBZpldWBfP/uR4r0Oo4FG0pR0Pc4o=; b=Yem1qMZ1hzYSKItGKgAkH8KjZlkL0LfDY2X210D2aZmlu+673etvfnvGzSFJ80TCIt rs4QQHX5s6NIm0lRATW/6Ljva4pJ3dzPs5TGRaZT0wyOsQznCyKrfZe9AXQDN2RzRMCP NRJcTAmSEb939zBTqChP+fm0geDNEJLWBzMyl57P9pbpSVVfO919TMJTV5OzcR8OvonY mZnQ3cN/0j+mBZJB5SRg0/aJwoLEarIrXu/60cZlJkDq3gh054tslUbjeHKFWGEZWIsL lg337fGErbwjml9NVLNiApxE2UP5fxOPjV1IWbFZOLYp4zhJjSD+UP5UgW2xyaEbxaWo Ak6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=groJ1iJJ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020aa78d91000000b0052dd9f10a47si36774917pfr.363.2023.01.05.17.08.00; Thu, 05 Jan 2023 17:08:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=groJ1iJJ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236522AbjAFBH7 (ORCPT + 99 others); Thu, 5 Jan 2023 20:07:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236747AbjAFBHv (ORCPT ); Thu, 5 Jan 2023 20:07:51 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7185F6E43A for ; Thu, 5 Jan 2023 17:07:45 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id z9-20020a17090a468900b00226b6e7aeeaso245629pjf.1 for ; Thu, 05 Jan 2023 17:07:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=E2zTyAKcMSHj1NuBZpldWBfP/uR4r0Oo4FG0pR0Pc4o=; b=groJ1iJJAbzkeoFY5z0vFFmU8BFSk2iIyzy4jspxCVqwwWmPsIsjEfRdLdBElbBGOT EmrM5lijkGvSvr3nKF/I3GI8riFE7PasAhLLNA/4T+m976ixjVmwz3IcMaPuxSRT3Kgg txcqpXsJ9kof2smhhnslMFaxYEJR/ApjGac1A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=E2zTyAKcMSHj1NuBZpldWBfP/uR4r0Oo4FG0pR0Pc4o=; b=2EcaLQBONJu0Su6EWafof2zq+YwtoCppAF4hMEpHOk3WK3rCH2/92k5nyYWTQAo4Yo sCM1IwH7rE4l0AB2XPwjUfPxkC03ys9W5Gspar2OFOCrlp3k0+iN9iSho506TBbtMsSa PTB5f5HQiyn6kU3LnUzbL6ae4mgogTIRN78/db/SwOMZz2jrXACzahCErkqgiOX9BBCg d5z0vSEzLfe5X3oY5TofjMIQ98iBHGam65JX+nsPq7iV3U1jyXYsj774DwPRZL3EYbjL 80/9YskQ2jFn+J/dJwbBBqAh2UVvQQoskMQeRx0o8ld77UIHiyLbMNPj1dlNBnOkrubU ofww== X-Gm-Message-State: AFqh2kqJKJ6wlbuG+e6YVhXzirugHxFX3sC2ymJpRITqtjzFZcG1LlwK eDme8j6zQrtCesSnxoMXPeMO1T3HH/Nu8yL4 X-Received: by 2002:a05:6a20:cb58:b0:a4:255b:f3bd with SMTP id hd24-20020a056a20cb5800b000a4255bf3bdmr54022111pzb.45.1672967264704; Thu, 05 Jan 2023 17:07:44 -0800 (PST) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com. [209.85.216.45]) by smtp.gmail.com with ESMTPSA id q9-20020a170902bd8900b00186ad73e2d5sm26555778pls.208.2023.01.05.17.07.44 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Jan 2023 17:07:44 -0800 (PST) Received: by mail-pj1-f45.google.com with SMTP id fz16-20020a17090b025000b002269d6c2d83so4759794pjb.0 for ; Thu, 05 Jan 2023 17:07:44 -0800 (PST) X-Received: by 2002:a05:6214:1185:b0:4c6:608c:6b2c with SMTP id t5-20020a056214118500b004c6608c6b2cmr2487246qvv.130.1672966941474; Thu, 05 Jan 2023 17:02:21 -0800 (PST) MIME-Version: 1.0 References: <20230101162910.710293-3-Jason@zx2c4.com> <10302240-51ec-0854-2c86-16752d67a9be@opteya.com> In-Reply-To: From: Linus Torvalds Date: Thu, 5 Jan 2023 17:02:05 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v14 2/7] mm: add VM_DROPPABLE for designating always lazily freeable mappings To: "Jason A. Donenfeld" Cc: Yann Droneaud , Andy Lutomirski , Ingo Molnar , linux-kernel@vger.kernel.org, patches@lists.linux.dev, tglx@linutronix.de, linux-crypto@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, Greg Kroah-Hartman , Adhemerval Zanella Netto , "Carlos O'Donell" , Florian Weimer , Arnd Bergmann , Jann Horn , Christian Brauner , linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Jan 5, 2023 at 2:57 PM Jason A. Donenfeld wrote: > > On Thu, Jan 05, 2023 at 10:57:48PM +0100, Yann Droneaud wrote: > > > > To hold secret material, we need MADV_WIPEONFORK | MADV_DONTDUMP and the side effect of mlock() (pages' content never written to swap), inherited across fork(). > > And I want mlock() without paying the price. > > > > Jason's proposed semantics, which I call MADV_WIPEONSWAP, provide a mean to hold /unlimited/ amount secrets in userspace memory (not limited by RLIMIT_MEMLOCK). > > The only constraint for userspace is to handle the case pages are wiped, which is already the case of userspace arc4random()'s implementation. > > If you're actually serious about wanting a generic mechanism for > userspace, I think the moral of yesterday's poo-poo'ing all over this > cool new idea is that the Linux innercircle doesn't really care for > "security things" as a motivator No. We don't take stupid statements as a motivator. Stop with the histrionics and silly security theater BS. There is *nop* security in "MADV_WIPEONFORK". You claiming that that is "security" is just making you less believable and me ignoring your arguments more. It's a complete make-believe fairy tale. Why would it be "security" to dump random state data? In most situations it's a complete non-issue, and nobody cares. And those situations that want to be extra careful, and are actually generating keys, those situations can do all of this very carefully on their own using existing machinery. If you don't want a core-dump because you have sensitive information, you do "ulimit -c 0". Or you use MADV_DONTDUMP that we've had forever. And you don't want to have wipe-on-fork, because (a) if you want things to be wiped on fork, you just wipe it before the fork (duh!) (b) but more likely, and more relevantly, you want to make *DAMN SURE* you wiped things much earlier than that if you are really security-conscious and just generated a secret key, because you don't want to leak things accidentally other ways. (c) and you can use MADV_DONTFORK to not copy it at all, which again we've had for a long time. And if you don't want to have it written to swap, you're just making sh*t up at that point. First off, it's a purely theoretical thing in the first place. See (b) above. Don't keep those random things around long enough (and untouched enough) to hit the disk. Secondly, anybody who can read swap space can already ptrace you and read things much more easily that way. Thirdly, you can just use mlock, and make sure you never have so much super-sikret stuff pending for long times and in big buffers. Fourth, if your keys are *that* sensitive, and *that* secret, just use /dev/random or getrandom(), because you're not generating that kind of volume of long-term keys, so the whole "I have a huge random buffer that is super-secret" is a complete non-issue. So stop making stupid arguments. The kernel is not supposed to baby-sit programs that do things wrong on purpose, and that are literally trying to do things wrong, and leaving secret stuff around while they do a lot of other things. You guys have literally MADE UP bad examples of so-called "security", and then you use those as arguments for bad coding, and for bad-mouthing kernel developers who just don't happen to believe in that bad model. None of what you ask for is for any kind of real security, it's all just crazy "but I want to feel the warm and fuzzies and take shortcuts elsewhere, and push my pain onto other people". Linus