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=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 95500C433E6 for ; Tue, 16 Mar 2021 19:34:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 708FF601FF for ; Tue, 16 Mar 2021 19:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234147AbhCPTdr (ORCPT ); Tue, 16 Mar 2021 15:33:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237124AbhCPTdA (ORCPT ); Tue, 16 Mar 2021 15:33:00 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96EAFC06175F for ; Tue, 16 Mar 2021 12:32:59 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id e2so12179371pld.9 for ; Tue, 16 Mar 2021 12:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=m51X9CHwtfCE5IH0P5AqXawZY6zUnwHs3ugCFSUHYWY=; b=O7izbeJETQwKGKZ937uPGZzffYmkBls3HZoWUKMlGCiundJ7Esi6XAj8SgsJvWW0bv EJUFAG+4vJqYaQUGivkM98LHXg2BKzD8QVMa4YwQpHq1qpaDrWp8lpCb3ag0Q4QiV/vF 6tH4HcqcvVGLbNhOh8UgqfrH9b3TNRcSjeCPw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=m51X9CHwtfCE5IH0P5AqXawZY6zUnwHs3ugCFSUHYWY=; b=N7cgAyQ1iLKg2sUPCr+IuZ9byjQLRz0ryzKE6BAy5Atr5rsqT9bVbxPd1jeQieO5Hp +7ZDAIl9BwkI7nWauZpmmpBBXFR4AZfs/V38L2DMN+qNxu5iWjTX6A5EchG9FCehOjpx JEuz2RybrLpNAY2d3XIGfiwcunnT/fu7W7cVKOXHpsgylCELT+24Z7o3GCrNMoCtSZjJ u58zHvukLT5l4A/3+aJqjzZCzNkpFa5+8e4k0cJ7hF63+YE2+SAgp8Gx0ZopNxMvwJyH v8OJqwRQDAR7tWbWpbh62Os9yk3fkFhwYUmNkEpVV7/cCGn0L1lQUoJL/IGzm47l8DY6 7a/Q== X-Gm-Message-State: AOAM5328XZYv/FHz3/5WguUSMj9n/CG8+IRX7npeMMs0uEmgETPY9ZYY Gw0FnW0aZskzvxaCJTTmnlemOQ== X-Google-Smtp-Source: ABdhPJymLmZUQcJf9mTPzHM6y4qPylvnlWR8uKp+iBIhoMb95+cXNuw7H/BK680P/1W8mJYXiVs6sg== X-Received: by 2002:a17:902:c1d5:b029:e6:52e0:6bdd with SMTP id c21-20020a170902c1d5b02900e652e06bddmr902471plc.49.1615923179208; Tue, 16 Mar 2021 12:32:59 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id fr23sm193056pjb.22.2021.03.16.12.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 12:32:58 -0700 (PDT) Date: Tue, 16 Mar 2021 12:32:57 -0700 From: Kees Cook To: Linus Torvalds Cc: Alexey Gladkov , LKML , io-uring , Kernel Hardening , Linux Containers , Linux-MM , Alexey Gladkov , Andrew Morton , Christian Brauner , "Eric W . Biederman" , Jann Horn , Jens Axboe , Oleg Nesterov Subject: Re: [PATCH v8 3/8] Use atomic_t for ucounts reference counting Message-ID: <202103161229.75FDE42F@keescook> References: <59ee3289194cd97d70085cce701bc494bfcb4fd2.1615372955.git.gladkov.alexey@gmail.com> <202103151426.ED27141@keescook> <202103161146.E118DE5@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 16, 2021 at 12:26:05PM -0700, Linus Torvalds wrote: > Note that the above very intentionally does allow the "we can go over > the limit" case for another reason: we still have that regular > *unconditional* get_page(), that has a "I absolutely need a temporary > ref to this page, but I know it's not some long-term thing that a user > can force". That's not only our traditional model, but it's something > that some kernel code simply does need, so it's a good feature in > itself. That might be less of an issue for ucounts, but for pages, we > somethines do have "I need to take a ref to this page just for my own > use while I then drop the page lock and do something else". Right, get_page() has a whole other set of requirements. :) I just couldn't find the "we _must_ to get a reference to ucounts" code path, so I was scratching my head. > And it's possible that "refcount_t" could use that exact same model, > and actually then offer that option that ucounts wants, of a "try to > get a refcount, but if we have too many refcounts, then never mind, I > can just return an error to user space instead". Yeah, if there starts to be more of these cases, I think it'd be a nice addition. And with the recent performance work Will Deacon did on refcount_t, I think any general performance concerns are met now. But I'd love to just leave refcount_t alone until we can really show a need for an API change. :P -- Kees Cook