Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp581314rdh; Thu, 26 Oct 2023 09:55:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFC7gMKsfWYrDtAVNfGD3J/Psz7MBSqXWq9OO5M/FgU9zoIxIklz6RkE2iQcNevomUr5oZh X-Received: by 2002:a05:6358:92a:b0:168:e01b:4f2d with SMTP id r42-20020a056358092a00b00168e01b4f2dmr268864rwi.28.1698339354696; Thu, 26 Oct 2023 09:55:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698339354; cv=none; d=google.com; s=arc-20160816; b=h1tOy5EYvziwKpPj2zdQLxJZ5Dwmb20fjPWdv0FHgqGcylofxJgM6+PLDHgVnGW/bp G8j0YzaDcktMFpFAtZlZthWHqvOHgOCj94A07X7qcoapvs33/MdTQa7m5n5f+G6AuLgf V+ZqR2dfiLJtwahDGZAVeKEP21gl2E+Mpq+KRhac8t2piCNAJSC9VOoLUuHmNjQc1Gw7 uPrUOi6Zzo/QwNvixUrqCEoKLAJl0dax1ygYMYmrC/WtL0+qKeSA6jmoBKcsKt1AVVYH spU8CPp19QD9REu9RJyL+VEG9PXk9d9dEnk5fhK6Kfxnxg37W6UW2mSMfQYiwXijz446 jXuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=nYYr9jMJ2V9M7XS/9+HHih8eXTUxgWOr4GXFFSjebJY=; fh=do+n1mJvNi55ZAx2lyu84OYGTD32+unPvYBcab+Yz3o=; b=uOQ9QgSk2XRWsR69j0D71PXpRldD+bZJdKqIYzV6X5+b8jdFMtZlQxwTP5QQU8kboH ujgCOhSG46oVxljlxt3xuYdVBjIDCnh7dBDuyCUfWNMozHF2+McUlNJC+g/SME5OrUuS ZanqzcTj/wNKz3LqDiXb363+I4ZjWB9a0pmxcVkEkHzVZqbF9DGEg2OAPJ6v3+SjLeIN jT8vLaqyNvnVWCDqcrfZitEYtLnrO0LltXp+wzG5brJfnmUatP7ix/VUaLQwHg1+gD7+ lcg9jkUr4u6mo/tq9qIkTVzJdWDm+NhiusdPU2h0BuBMlRUyEpCaHTOeOkGmgAYHsj5z uZPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yotIMnmB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id x124-20020a817c82000000b005a4e9a61e1esi14831270ywc.15.2023.10.26.09.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 09:55:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yotIMnmB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E2AF8816EF8B; Thu, 26 Oct 2023 09:55:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231140AbjJZQzi (ORCPT + 99 others); Thu, 26 Oct 2023 12:55:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjJZQzh (ORCPT ); Thu, 26 Oct 2023 12:55:37 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89EE4194 for ; Thu, 26 Oct 2023 09:55:35 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5a7afd45199so8939857b3.0 for ; Thu, 26 Oct 2023 09:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698339335; x=1698944135; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nYYr9jMJ2V9M7XS/9+HHih8eXTUxgWOr4GXFFSjebJY=; b=yotIMnmBwRU8hN1N0WEZHC4RbijY4OrWT6YAQHfnDYiRhpn0IqXaVCEYcQW7V8DKZK eKL/6u62ha5II8v4zzp0Rirkpd4dfiklLfMwAMPP0qw+NBwP0jBisr7q5gzJemL0Wdn0 Z7wiCeb2aDAgmTr4u346jvswWjDLIalqDHWwueoBeNVWwNiw+6qMeXDvTN5Gr00bRzFW HvEw8dbhsuNjyjr0/1JwGPRoUUubZ+IF4P6NUhYHwV++vrlDyBloe+R6EXTF+7cJmR10 Jw4riRw3Qt+LRHX2kR5SQfRXw1yoBy1kToQkP9rMSBQLXUqcLrtImNKNiMXn54aoZBjO Wo3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698339335; x=1698944135; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nYYr9jMJ2V9M7XS/9+HHih8eXTUxgWOr4GXFFSjebJY=; b=QgZDZOZyXGFkYMMU4skErRnPViBy6Evef7591pjnaw+s4eOe2Zd0F1Jhn1g/ALF8Nb 6bf8FlGiHxuZ3ZFYm7vM3ffMsxmm9lLTBoxR3wh+Lamb7IKJ086wjYYxcwaUEE7y8zoZ xpbHbhQ/1MNb0NrE0ESaiLbrPivk5F6R30KA0LHGmS5vYBBuhHWyxB9Ze2RfokEXQaLd zCWZZChLX8faeGGCDTU2CNpilw0AFu9XWUZK7GBI65CHhy+mZ0Oai8UYQyK+ahY+Ae++ 3GfILCLh5+9SOSMveEGhWeBWEPT6F9mYVuX2e+xAf4QVQGUJJw99CP7WvlnLwHKImxVE RkJQ== X-Gm-Message-State: AOJu0Yw9KvcjbHdBc3ashQB6reLwNsoynVqrUERpJePhK43GF9lNbAok E5foIYIlh0S880UylUDewE18TVVe4J4Q3i/IfGDVqwM9FJastyfkOMVdyQ== X-Received: by 2002:a81:9209:0:b0:5a7:b464:ff1a with SMTP id j9-20020a819209000000b005a7b464ff1amr20779809ywg.6.1698339334461; Thu, 26 Oct 2023 09:55:34 -0700 (PDT) MIME-Version: 1.0 References: <20231026164114.2488682-1-hannes@cmpxchg.org> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 26 Oct 2023 09:55:23 -0700 Message-ID: Subject: Re: [PATCH] sched: psi: fix unprivileged polling against cgroups To: Luca Boccassi Cc: Johannes Weiner , Peter Zijlstra , Domenico Cerasuolo , linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 26 Oct 2023 09:55:49 -0700 (PDT) On Thu, Oct 26, 2023 at 9:49=E2=80=AFAM Luca Boccassi wr= ote: > > On Thu, 26 Oct 2023 at 17:41, Johannes Weiner wrote: > > > > 519fabc7aaba ("psi: remove 500ms min window size limitation for > > triggers") breaks unprivileged psi polling on cgroups. > > > > Historically, we had a privilege check for polling in the open() of a > > pressure file in /proc, but were erroneously missing it for the open() > > of cgroup pressure files. > > > > When unprivileged polling was introduced in d82caa273565 ("sched/psi: > > Allow unprivileged polling of N*2s period"), it needed to filter > > privileges depending on the exact polling parameters, and as such > > moved the CAP_SYS_RESOURCE check from the proc open() callback to > > psi_trigger_create(). Both the proc files as well as cgroup files go > > through this during write(). This implicitly added the missing check > > for privileges required for HT polling for cgroups. > > > > When 519fabc7aaba ("psi: remove 500ms min window size limitation for > > triggers") followed right after to remove further restrictions on the > > RT polling window, it incorrectly assumed the cgroup privilege check > > was still missing and added it to the cgroup open(), mirroring what we > > used to do for proc files in the past. > > > > As a result, unprivileged poll requests that would be supported now > > get rejected when opening the cgroup pressure file for writing. Ah, I see the problem. In our discussion https://lore.kernel.org/all/ZADj4YX4uftK%2FFrh@cmpxchg.org/ we decided to have the check in open() to fail early but we never considered unprivileged processes which only poll and never create any triggers. Makes sense. > > > > Remove the cgroup open() check. psi_trigger_create() handles it. > > > > Fixes: 519fabc7aaba ("psi: remove 500ms min window size limitation for = triggers") > > Cc: stable@vger.kernel.org # 6.5+ > > Reported-by: Luca Boccassi > > Signed-off-by: Johannes Weiner > > Acked-by: Luca Boccassi Acked-by: Suren Baghdasaryan > > Thank you very much for the quick fix - this was reported originally > on the systemd bug tracker by Daniel Black (I do not have an email > address): > > https://github.com/systemd/systemd/issues/29723 > > It is very important for systemd services to be able to do this > without capabilities, as using capabilities means in turn user > namespaces cannot be used (PrivateUsers=3Dyes in systemd parlance). > > Kind regards, > Luca Boccassi