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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 7F3BDC433DB for ; Mon, 18 Jan 2021 19:15:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E57A921D42 for ; Mon, 18 Jan 2021 19:15:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E57A921D42 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 4A7B66B02F7; Mon, 18 Jan 2021 14:15:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 458B96B02F9; Mon, 18 Jan 2021 14:15:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36EC76B02FA; Mon, 18 Jan 2021 14:15:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id 1FF886B02F7 for ; Mon, 18 Jan 2021 14:15:10 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E2766181AF5CC for ; Mon, 18 Jan 2021 19:15:09 +0000 (UTC) X-FDA: 77719848738.09.tail52_230cfc32754b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id BAC84180ACF16 for ; Mon, 18 Jan 2021 19:15:09 +0000 (UTC) X-HE-Tag: tail52_230cfc32754b X-Filterd-Recvd-Size: 4594 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Mon, 18 Jan 2021 19:15:09 +0000 (UTC) Received: by mail-lj1-f178.google.com with SMTP id p13so19416979ljg.2 for ; Mon, 18 Jan 2021 11:15:08 -0800 (PST) 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=/nyXt2BwkLcSSRby7WCMrmE+WdBMXZvF9/GDTDgxsVY=; b=FgEuPeyIPamZN1Ti5cyla9+JQiWchG5usHW0nz7RiFfN4ZG12cH4uk+0GptG8B/IWA J+9VHvATxzV0qZoPxsaWt52OJ2WeDAZZ0Ey4l9G4Byauek/KmFoS0wtarV9C1U/vQhcp zDcDF/LIEdOs4AuBkR07AWCI6pKVrt2L/RMZY= 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=/nyXt2BwkLcSSRby7WCMrmE+WdBMXZvF9/GDTDgxsVY=; b=Fp25NCY2/zGeZ93RxzhmjtWgYMU7pejiTw63UOMYTYC8viXtmNtSOfZRyAJqTnoYuy hjYH73x88HlgC4FwC9W1a6pi+gakI6FumDMqelHpcq30wihPniyvUfAUuIcy1H2nkmsX iKxlBThHcbnmGuZX7elF3artAllKd9ykXBEflg/o8IAQJSQgKrw5+S4qOosP+6+rLCPG nsC+zytqu9cUO1IwiVtPIuZiUh3bLwidqqyy6nvOILMtwjHMSdnBCL8oQRj/24Rx5j+A q+xJRglwyL+4dx/o0/+ckS1fpUBHZruDsdMszyUwr7Whlsff7BSxr0UvAL/n1LLPJOhH KEFA== X-Gm-Message-State: AOAM530aA4M6iMWJ0f6LuOsTSorZbMZYfuNNPoYNkVMdIEh/b8s92/D1 YgdFLBlFAmBP0i75EHvoh4BVXNuKSjYjNg== X-Google-Smtp-Source: ABdhPJxrZnwlh00K6LU9H0flhu+um4LSCmGCsD8IN1AW/1nDuKUqPD4Ee1o3ei3dRlnHQBwCohjgVg== X-Received: by 2002:a2e:97ce:: with SMTP id m14mr456183ljj.380.1610997306568; Mon, 18 Jan 2021 11:15:06 -0800 (PST) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id p13sm1761498ljc.112.2021.01.18.11.15.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Jan 2021 11:15:05 -0800 (PST) Received: by mail-lf1-f48.google.com with SMTP id x20so25567690lfe.12 for ; Mon, 18 Jan 2021 11:15:04 -0800 (PST) X-Received: by 2002:a05:6512:a8c:: with SMTP id m12mr234936lfu.253.1610997304440; Mon, 18 Jan 2021 11:15:04 -0800 (PST) MIME-Version: 1.0 References: <116c7669744404364651e3b380db2d82bb23f983.1610722473.git.gladkov.alexey@gmail.com> In-Reply-To: <116c7669744404364651e3b380db2d82bb23f983.1610722473.git.gladkov.alexey@gmail.com> From: Linus Torvalds Date: Mon, 18 Jan 2021 11:14:48 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v3 1/8] Use refcount_t for ucounts reference counting To: Alexey Gladkov Cc: LKML , io-uring , Kernel Hardening , Linux Containers , Linux-MM , Alexey Gladkov , Andrew Morton , Christian Brauner , "Eric W . Biederman" , Jann Horn , Jens Axboe , Kees Cook , Oleg Nesterov 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 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. Linus