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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 B3DB3C43470 for ; Thu, 1 Apr 2021 18:03:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BF1060FE6 for ; Thu, 1 Apr 2021 18:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234729AbhDASDB (ORCPT ); Thu, 1 Apr 2021 14:03:01 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:36320 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236891AbhDARsB (ORCPT ); Thu, 1 Apr 2021 13:48:01 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lS1QF-00BMjZ-Mk; Thu, 01 Apr 2021 11:47:59 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=fess.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1lS1QE-00063A-Tr; Thu, 01 Apr 2021 11:47:59 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Kees Cook Cc: Josh Hunt , Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org References: <20210401033156.7262-1-johunt@akamai.com> <202104010039.A134EC56@keescook> Date: Thu, 01 Apr 2021 12:47:54 -0500 In-Reply-To: <202104010039.A134EC56@keescook> (Kees Cook's message of "Thu, 1 Apr 2021 00:50:57 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1lS1QE-00063A-Tr;;;mid=;;;hst=in01.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+9kKaosOHZQa/CHlshDAMlvxbI/RV1V68= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH] psi: allow unprivileged users with CAP_SYS_RESOURCE to write psi files X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kees Cook writes: > On Wed, Mar 31, 2021 at 11:36:28PM -0500, Eric W. Biederman wrote: >> Josh Hunt writes: >> >> > 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. >> >> The test for CAP_SYS_RESOURCE really needs to be in open rather >> than in write. >> >> Otherwise a suid root executable could have stdout redirected >> into these files. > > Right. Or check against f_cred. (See uses of kallsyms_show_value()) > https://www.kernel.org/doc/html/latest/security/credentials.html#open-file-credentials We really want to limit checking against f_cred to those cases where we break userspace by checking in open. AKA the cases where we made the mistake of putting the permission check in the wrong place and now can't fix it. Since this change is change the permissions that open uses already I don't see any reason we can't perform a proper check in open. Eric