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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 8CCE9C2D0EC for ; Tue, 7 Apr 2020 21:22:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 44AD220748 for ; Tue, 7 Apr 2020 21:22:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="cWtyAfRJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44AD220748 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D3B3E8E001F; Tue, 7 Apr 2020 17:22:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CEA978E0001; Tue, 7 Apr 2020 17:22:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C00368E001F; Tue, 7 Apr 2020 17:22:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id A63568E0001 for ; Tue, 7 Apr 2020 17:22:54 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5B09D181AEF3E for ; Tue, 7 Apr 2020 21:22:54 +0000 (UTC) X-FDA: 76682333868.19.pest96_53880068e502a X-HE-Tag: pest96_53880068e502a X-Filterd-Recvd-Size: 5222 Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Apr 2020 21:22:53 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id h6so3573556lfc.0 for ; Tue, 07 Apr 2020 14:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VqAA90EFEqaZqtfJsahs6rAmiP9w+6pABhPEUrk2J0s=; b=cWtyAfRJ6HZ9whZ7T1OwTqUkHj67UHyQLHNktG1URy3jMW58GkW80jxJjlj8gB7GhE 3F0b04BHhGAUviItNAlVtNpm1kMC4wyjt5JtQfw/V+AcyE9EB5lvlfGHC0oM8Tdjg/zB YwojkZl7/nVdBy5im39XCep/6nxy8E2TkGYTI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VqAA90EFEqaZqtfJsahs6rAmiP9w+6pABhPEUrk2J0s=; b=neKL3DUeGQdNeLZJitKzfrcnguOS6sus3l7Q3EtsCx+9xbnNb9sz2mdZ1dzA4HHK2X 5om3kthDSActF27EK9KITaIgDbv6XY/aeucW5B/WAYG3OsZPFfAi8+QrtEDHGpuQRCJD AaKMx05/jvXIkQdz4WOky/W0AUPQbmV2qRfxn5Z11OEhEcLg03yqrZkySS3feXnaFP2t +wJB6F7GHVz8V/AT2xpiUXT83KawQ6lL6PUYXHRSdVwHJzm4QVkINHEWloq4yXPQGEQx ZlxsY0Qd2U62bfQBmlYD2Zeax9Jmwg8sscSlPA1gUYR63Y4Xg+JWRo07MkNJambTE39L IyrA== X-Gm-Message-State: AGi0Pub5GwxyfXwoGnDkLeWQ0jRCGGdLZ2vH1juzRMUL95GJ+ocrHRkV j+VcBJsRIdkXD8CjeUCzxDvHnIzuxsU= X-Google-Smtp-Source: APiQypKV8JGSQ3Q8iXo3IMKoUh+GqGn/8i2M6/cRYxj4ImL7sAUbNIBmHkpbytHWbwd81CC8v5MPYA== X-Received: by 2002:ac2:58d7:: with SMTP id u23mr2643920lfo.182.1586294572053; Tue, 07 Apr 2020 14:22:52 -0700 (PDT) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com. [209.85.208.169]) by smtp.gmail.com with ESMTPSA id l3sm13999119lfk.53.2020.04.07.14.22.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Apr 2020 14:22:50 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id r24so5393340ljd.4 for ; Tue, 07 Apr 2020 14:22:50 -0700 (PDT) X-Received: by 2002:a2e:a58e:: with SMTP id m14mr2888317ljp.204.1586294570185; Tue, 07 Apr 2020 14:22:50 -0700 (PDT) MIME-Version: 1.0 References: <20200406185827.22249-1-longman@redhat.com> <699292.1586294051@warthog.procyon.org.uk> In-Reply-To: <699292.1586294051@warthog.procyon.org.uk> From: Linus Torvalds Date: Tue, 7 Apr 2020 14:22:33 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] mm: Add kvfree_sensitive() for freeing sensitive data objects To: David Howells Cc: Joe Perches , Waiman Long , Andrew Morton , Jarkko Sakkinen , James Morris , "Serge E. Hallyn" , Linux-MM , keyrings@vger.kernel.org, Linux Kernel Mailing List , Matthew Wilcox , David Rientjes Content-Type: text/plain; charset="UTF-8" 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 Tue, Apr 7, 2020 at 2:14 PM David Howells wrote: > > It might be worth asking the compiler folks to give us an __attribute__ for > that - even if they don't do anything with it immediately. So we might have > something like: > > void free(const volatile void *ptr) __attribute__((free(1))); Yeah, that sounds sane. > There are some for allocation functions, some of which we use, though I'm not > sure we do so as consistently as we should (should inline functions like > kcalloc() have them, for example?). I think that gcc supports a "malloc" attribute, but it's only used for alias analysis optimizations, afaik (ie it says that the pointer the function returns cannot alias anything else). So we do have that "__malloc" thing, but I'm not sure how much it actually matters. And adding it to inline functions shouldn't be _wrong_, but it shouldn't matter either, since I think the alias analysis would work regardless. I wonder how much of a code generation difference it makes. I suspect not a lot, but maybe I'd be surprsied. But yes, having the free attribute would be consistent (even if the syntax for it might be as you suggest, kind of like the __printf() attribute works). Even if it wasn't initially used for anything it wouldn't hurt, and maybe some day it would improve warnings (and allow the compiler to do the dead store elimination that started this whole long set of threads in the first place..) Linus