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.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,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 84FCEC433E0 for ; Mon, 18 Jan 2021 19:46:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 29BB420848 for ; Mon, 18 Jan 2021 19:46:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29BB420848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7D4FB8D0026; Mon, 18 Jan 2021 14:46:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7873E8D0024; Mon, 18 Jan 2021 14:46:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C4B88D0026; Mon, 18 Jan 2021 14:46:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id 58B0B8D0024 for ; Mon, 18 Jan 2021 14:46:13 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 21451180AD802 for ; Mon, 18 Jan 2021 19:46:13 +0000 (UTC) X-FDA: 77719927026.30.doll84_371582c2754b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id F07EB180B3C96 for ; Mon, 18 Jan 2021 19:46:12 +0000 (UTC) X-HE-Tag: doll84_371582c2754b X-Filterd-Recvd-Size: 2959 Received: from raptor.unsafe.ru (raptor.unsafe.ru [5.9.43.93]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Mon, 18 Jan 2021 19:46:12 +0000 (UTC) Received: from example.org (ip-89-103-122-167.net.upcbroadband.cz [89.103.122.167]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by raptor.unsafe.ru (Postfix) with ESMTPSA id 3C0D820479; Mon, 18 Jan 2021 19:45:56 +0000 (UTC) Date: Mon, 18 Jan 2021 20:45:51 +0100 From: Alexey Gladkov To: Linus Torvalds Cc: LKML , io-uring , Kernel Hardening , Linux Containers , Linux-MM , Andrew Morton , Christian Brauner , "Eric W . Biederman" , Jann Horn , Jens Axboe , Kees Cook , Oleg Nesterov Subject: Re: [RFC PATCH v3 1/8] Use refcount_t for ucounts reference counting Message-ID: <20210118194551.h2hrwof7b3q5vgoi@example.org> References: <116c7669744404364651e3b380db2d82bb23f983.1610722473.git.gladkov.alexey@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.1 (raptor.unsafe.ru [5.9.43.93]); Mon, 18 Jan 2021 19:46:07 +0000 (UTC) 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 Mon, Jan 18, 2021 at 11:14:48AM -0800, Linus Torvalds wrote: > On Fri, Jan 15, 2021 at 6:59 AM Alexey Gladkov wrote: > > > > @@ -152,10 +153,7 @@ static struct ucounts *get_ucounts(struct user_namespace *ns, kuid_t uid) > > ucounts = new; > > } > > } > > - if (ucounts->count == INT_MAX) > > - ucounts = NULL; > > - else > > - ucounts->count += 1; > > + refcount_inc(&ucounts->count); > > spin_unlock_irq(&ucounts_lock); > > return ucounts; > > } > > This is wrong. > > It used to return NULL when the count saturated. > > Now it just silently saturates. > > I'm not sure how many people care, but that NULL return ends up being > returned quite widely (through "inc_uncount()" and friends). > > The fact that this has no commit message at all to explain what it is > doing and why is also a grounds for just NAK. Sorry about that. I thought that this code is not needed when switching from int to refcount_t. I was wrong. I'll think about how best to check it. -- Rgrds, legion