Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp257987pxf; Wed, 31 Mar 2021 23:49:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4/5H1jWbiSLrnf1yNXGzCkYm3eV3JwzBdnG9vX3ukQBBJLTITeyhJKlCamqQjGVXyr1rH X-Received: by 2002:a17:906:4e91:: with SMTP id v17mr7539615eju.331.1617259775334; Wed, 31 Mar 2021 23:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617259775; cv=none; d=google.com; s=arc-20160816; b=eYN4K9VlDuipkiCUgMd6Ydmn1pBYU+/RruK3GhZx7uNBsxL2XTnJt/kGKZrWT46/jh T75mlvEtZPZ60R7ddgBV8xrbwLdp5Qy3dTHVH9mPI/ZJY6icqRhhNb40s/5w2fw7i1y5 Znp6EJ763Pa4QbjJDwGstNBLt4nMwdSk2N9wusqN9Ee3AWfZpY82MwwV/iYPte45F2Sq Q+z+ztf+mBGSgWdhlbkgeLfZFZweJI80Tc4VYtvXIN6LKu0GSAzU1otMChDODhSroUiG VPt2txoj76cGH9agB3NYL8FGKZrRRPkFn7lpy7VWnFsiGD+JPg8apKnWsE5GwddK1sx3 gK7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BWgtyJ0RQt3FZgtPXdA8u22FETTOqA6uOVFPAZEg1FQ=; b=ZZL/ux5leaW9KkybY6DGrcg/c4IlzIhEfv2VlJCBV1BTUHmChlme7OsLPdvSWa4u+v tRTXuAOnct7MjzzR4DEg3C7wVu9FfnhEmIlRGqsV4pIZxZetZGQeh/u29XC2SBMa7uYE WvUODMyyQWx4fLWAeVX77gHAiDCJNHwMMw/E/NxE3r+cYO8iXN0Y4FQko/WTBvzlej8L Jsa5Rhwi0X17GYKuXOmKzLgmmQVRZF0hqUqQ3nMqmvm2qfaWE4hq4oJRln3x2vNIEG3M t+OVsWpQuGChUtosFamDuHEUI32LCtf5gbbU1PpvRh0krQz6qLDx+/TSNOqHLnEJBzN7 HTTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=it88p1U1; 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 l18si3585261edc.152.2021.03.31.23.49.13; Wed, 31 Mar 2021 23:49:35 -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=@infradead.org header.s=desiato.20200630 header.b=it88p1U1; 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 S233240AbhDAGrz (ORCPT + 99 others); Thu, 1 Apr 2021 02:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230291AbhDAGrk (ORCPT ); Thu, 1 Apr 2021 02:47:40 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ADD3C0613E6 for ; Wed, 31 Mar 2021 23:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=BWgtyJ0RQt3FZgtPXdA8u22FETTOqA6uOVFPAZEg1FQ=; b=it88p1U1o0kQE4LYo1rQrPEZvg nM8A4OA0sV9SX5rpRpUt7eopmRgvV6bgQJB0x+aXFwXuAz0Vzjs2nhXFg8L0P/Wqg20mBKPKunfeh G0b/iwYvU0P9wschSjXpu9ushNVY8EywbbU1qgerm1S67R2z08XBsHnPwbBifeQv+wUNq76xaq0JJ ZG5G12+rG6JTmWToS0Gb7rHf1ewI31k5Z8IEXGaz9XaoPeU3nrYaVEsCrZqIkv/zZxAMNs6WvSMOM 0GdTK36YTQHpfGvz3eSk9mb0xp0RSLXQUAVJF6hM4l3CfI2GsZq2UIviP5jNRgaFUGeDi++V40K2u s9RmrDLw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lRr78-008iwS-JY; Thu, 01 Apr 2021 06:47:34 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1A40F3003E5; Thu, 1 Apr 2021 08:47:34 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 08A2B235FA3BF; Thu, 1 Apr 2021 08:47:34 +0200 (CEST) Date: Thu, 1 Apr 2021 08:47:33 +0200 From: Peter Zijlstra To: Josh Hunt Cc: Ingo Molnar , linux-kernel@vger.kernel.org, hannes@cmpxchg.org Subject: Re: [PATCH] psi: allow unprivileged users with CAP_SYS_RESOURCE to write psi files Message-ID: References: <20210401033156.7262-1-johunt@akamai.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210401033156.7262-1-johunt@akamai.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 31, 2021 at 11:31:56PM -0400, Josh Hunt wrote: > Currently only root can write files under /proc/pressure. Relax this to > allow tasks running as unprivileged users with CAP_SYS_RESOURCE to be > able to write to these files. > > Signed-off-by: Josh Hunt I suppose that's ok, but lets also ask Johannes. > --- > kernel/sched/psi.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c > index b1b00e9bd7ed..98ff7baf1ba8 100644 > --- a/kernel/sched/psi.c > +++ b/kernel/sched/psi.c > @@ -1270,6 +1270,9 @@ static ssize_t psi_write(struct file *file, const char __user *user_buf, > if (!nbytes) > return -EINVAL; > > + if (!capable(CAP_SYS_RESOURCE)) > + return -EPERM; > + > buf_size = min(nbytes, sizeof(buf)); > if (copy_from_user(buf, user_buf, buf_size)) > return -EFAULT; > @@ -1353,9 +1356,9 @@ static int __init psi_proc_init(void) > { > if (psi_enable) { > proc_mkdir("pressure", NULL); > - proc_create("pressure/io", 0, NULL, &psi_io_proc_ops); > - proc_create("pressure/memory", 0, NULL, &psi_memory_proc_ops); > - proc_create("pressure/cpu", 0, NULL, &psi_cpu_proc_ops); > + proc_create("pressure/io", 0666, NULL, &psi_io_proc_ops); > + proc_create("pressure/memory", 0666, NULL, &psi_memory_proc_ops); > + proc_create("pressure/cpu", 0666, NULL, &psi_cpu_proc_ops); > } > return 0; > } > -- > 2.17.1 >