Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4662965pxv; Tue, 29 Jun 2021 12:25:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxY/+Boj5dM4+aSZMSfGBbSXkcjcXEqqy31Cwu/sNV+u+0QrXeOgoLFxAL/SKYQ62d8FeZY X-Received: by 2002:a92:7b0f:: with SMTP id w15mr23887529ilc.150.1624994727549; Tue, 29 Jun 2021 12:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624994727; cv=none; d=google.com; s=arc-20160816; b=J646iPFCJYb9A5bd7kMHog/vFnACLJ8s0EQBFrxpucyiJyWWZqVjeYKzT4fjzdu0ks IWBrPVmT31FmyITnGVYTcaiJH9kTrbvnE4LLMfIR3RHch7Zw5eabmLP/8xiMG7OXWykB m1eUP/xouL1T8bu0HEQ9ZSldLi1geYcZLKwran6Uyuj1LtyossjLJK+s1tMmn0QIaRPQ 5Pwb2KC+SwabTgDGoDATS3y0o3MAg0nywTA4K7DCFjmnS3ZfKP27noQ8EBl6Er8UKrg2 maBVsPNdjntqbEDrTH4bJmeH/HyTjeuJbi3CdAqKaijzvKODAwvZc0PVRw3iCPPhNIaj lBeg== 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=RrPyRQ5IO5eewgSwjbnscAxAW9L+6cXFp6QTzBqY4/w=; b=kpfwPnypsQD089PjR1lhtuWLOgQe2ffiKBzZHkzP4aHB8a2BM+DB2QMpfCb0RJWSmh goMnKSE4SN/j9ssoC83S/DDFHM2TvVU4nZY6AghrHbUhi178siriKrcn7Do3gqGM8i+P AEMMcja0NInHlAFYL7GosfjG7FdKUdGUegkUYbjt2lkZPAD6+rAVhQlt06yoi2nnRpFl BdwnpNNrGC15i3PT1I552/AkdNH69iD02GyR/D998WVbEELQCeGj0ya0BMTPbSVDwZKi ATIVfZ1229xY4GDRNL9wq/zY5TWo1vKbro2NkR2DBl00ASq+ZCezaqG2FcodeBvsoOdS /JTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=DwLkNq7S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u14si3331158ilv.41.2021.06.29.12.25.14; Tue, 29 Jun 2021 12:25:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=DwLkNq7S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234871AbhF2SJ7 (ORCPT + 99 others); Tue, 29 Jun 2021 14:09:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233944AbhF2SJ7 (ORCPT ); Tue, 29 Jun 2021 14:09:59 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50D42C061760 for ; Tue, 29 Jun 2021 11:07:31 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id a15so33176119lfr.6 for ; Tue, 29 Jun 2021 11:07:31 -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=RrPyRQ5IO5eewgSwjbnscAxAW9L+6cXFp6QTzBqY4/w=; b=DwLkNq7SHWRjgUjXov7smOgfFqoIqfdHao/1+I+k6kXqTB0ouzJ2e3lTxDYIKpVJtx 36G6M4NcrwNK/ZnKdheqPNTEAHi9hS4WBY4wAUpV8OHUzqzjYLXvUEa2URrzj4q0A4gL GDI1gvURikS6TbLfSGHymcR86Fx1v041Ly1Co= 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=RrPyRQ5IO5eewgSwjbnscAxAW9L+6cXFp6QTzBqY4/w=; b=HxrfDpC+1V5WvhJil7WDdmP8MXSCmRyGs4AV0BaRQTYmXSnli6f8/Q0xbIim86T2C1 xByXuiynrzcB4rDXkIJ8MIBEhtGLPuPLkTixdR4KmISnL11hBT5hqm6y9Rh59/vAEoZ+ XHS3moGzX+O9oRL/t5YG9M87l/P2xmke3JnYTBmdP5N48Mfsd4z11RmotATM+XM18cis IIR4NG/2eQpKQlQy67rX8UJED39/XQf1/chJ3IccI6yT0Hq8ZLkCa4mlB9bK2aC4aU0W r9dBrWeSjLh8JZt1dlM+Tp5ASz1xLRDqAkfbilR0Yr1a06ukIG8BajO0TGX6/YHuBmTC QXUw== X-Gm-Message-State: AOAM533Lll316eX4VmqsTcZNBCeRXMJb6UpwKiIHI4/95D0ipa+OVq2g PdzW9IsHp5bJ6hoTJ8DpNqUcvHAP5NFGSzJySuM= X-Received: by 2002:a19:f70b:: with SMTP id z11mr25308278lfe.156.1624990049567; Tue, 29 Jun 2021 11:07:29 -0700 (PDT) Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com. [209.85.208.182]) by smtp.gmail.com with ESMTPSA id q15sm1627593ljg.126.2021.06.29.11.07.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Jun 2021 11:07:27 -0700 (PDT) Received: by mail-lj1-f182.google.com with SMTP id r16so32158779ljk.9 for ; Tue, 29 Jun 2021 11:07:27 -0700 (PDT) X-Received: by 2002:a2e:b553:: with SMTP id a19mr4820656ljn.507.1624990047466; Tue, 29 Jun 2021 11:07:27 -0700 (PDT) MIME-Version: 1.0 References: <87fsx1vcr9.fsf@disp2133> <20210629171757.shyr222zjpm6ev5t@example.org> In-Reply-To: <20210629171757.shyr222zjpm6ev5t@example.org> From: Linus Torvalds Date: Tue, 29 Jun 2021 11:07:11 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] ucounts: Count rlimits in each user namespace To: Alexey Gladkov Cc: "Eric W. Biederman" , Linux Kernel Mailing List , Linux Containers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 29, 2021 at 10:18 AM Alexey Gladkov wrote: > > > > And why test for "ucounts" being non-NULL in > > > > if (ucounts && dec_rlimit_ucounts(ucounts, > > UCOUNT_RLIMIT_SIGPENDING, 1)) > > put_ucounts(ucounts); > > > > when afaik both of those should be happy with a NULL 'ucounts' pointer > > (if it was NULL, we certainly already used it for the reverse > > operations for get_ucounts() and inc_rlimit_ucounts()..) > > The get_ucount() can theoretically return NULL. It increments the > reference counter and if it overflows, the function will return NULL. .. but my point is that dec_rlimit_ucounts() and put_ucounts() should be fine with whatever get_ucounts() returned. No It looks like put_ucounts() is unhappy with a NULL ucounts argument, but I think _that_ is what should get fixed. I think that conceptually we should have two clear alternatives: (a) either "get_ucounts()" returning NULL should be an error, and we would have returned long before or (b) a NULL uncounts is usable, and a sequence like put_ucounts(get_ucounts()) should just always work. And honestly, a lot of the other ucounts funcrtions seem to take that (b) approach. Example in that very function: ucounts = task_ucounts(t); sigpending = inc_rlimit_ucounts(ucounts, UCOUNT_RLIMIT_SIGPENDING, 1); which at no point tested for NULL or returned an error. (And that also implies that the comment in dec_rlimit_ucounts() about "Silence compiler warning" should just go away, because it's not just a compiler warning, it's a required initialization). Linus