Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3140613ybx; Sun, 3 Nov 2019 11:39:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxBZOZKDoZmue54C3QfWnVba42GBODYDO6phkRe0w8eksGBfJ8oLfJDx6OmqHpb7Q/m0NgI X-Received: by 2002:aa7:cf97:: with SMTP id z23mr11611306edx.245.1572809995584; Sun, 03 Nov 2019 11:39:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572809995; cv=none; d=google.com; s=arc-20160816; b=UDOY3UsL5WJmo/iiimqSJQ5EZyFUpGfiVVnvNo/zy9UobvKNNKuc5BqUwF9sMelEb6 NmcGs3IoNFB2SiWX0EMSZs7aHTejk+xcSLeoYOmMWglIrBnP8m2Bpx64Z3XxCP5NgEz+ N+yojsWXRUfd+NG4+vmf39cuMPlUv473iH0Wf39ovLEo77zDi587edTi2EJtcuCuu76j V61tnRP4eLf8QvOD9A0gRplhVzg+XFYWgH3ZGCuu0+X33+AkrWWBT71hFrMHOJhRgxiN as+ksCCdlBjw9OyF60CnSrHulJwuLWF+Y+uiucY0BXBfhVNcGK0AOZNXELIlRV9sXk4f QTIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject:dkim-signature; bh=DA97c1OVaZrH8SvTZWoH5od6ijrQ6ybNR3pRj3cE098=; b=xMHyk2GTQ4xlzDL0+KRQ1U4uznP52llEVeW7ecU8rSF9DqxYBco/wMzn62POuvextX OPcUQmFZW30xDVH2PAN/pqt9beouYvn7gGI8+RVpsOmNKfb3q6AyTqweQX8GXHJ2YBYP HvV9IIwAqJZI42+1ZxSmOQF5XyjSi5kKN4IGQxZ2apRrdxApHHnhePaQK5lb7YEYgmKJ WiFtsqf2IpyD6DEBNB/TbFUshPh+7JmHBpw9NJ2ViZUL/uFsEHCFnKxLs0vPX2SqZGlx L+4bCiWk4uz3aIXEVqCUn0fY8wiVap7rCb5vnbWv857TFhumYBykswIFQivjKRymg4Qx Y3bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FyDID7sV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ec22si9644673ejb.232.2019.11.03.11.39.29; Sun, 03 Nov 2019 11:39:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FyDID7sV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728078AbfKCTiy (ORCPT + 99 others); Sun, 3 Nov 2019 14:38:54 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:38238 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727913AbfKCTiy (ORCPT ); Sun, 3 Nov 2019 14:38:54 -0500 Received: by mail-lj1-f194.google.com with SMTP id y23so14887480ljc.5; Sun, 03 Nov 2019 11:38:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=DA97c1OVaZrH8SvTZWoH5od6ijrQ6ybNR3pRj3cE098=; b=FyDID7sVwcKA8u2OXigUOGeLpN0r0KJ3r2nEpMx0KzYOU04J9slKn6GMoVITpEqJuO NI4tMie2/xsh3jpLitK6dLyd8M8EaccIOt1TejbOamSIFRby8AV4N5sL2uJqUwFFKXMU N9d0oRR17KcF7aPixdnvTWNo4upGstyhwdGfP0mop5EWgRttjYfFxPP/m/IQdMnvSRZz K4MYMdzB4JUaqpB45vL4aYjyrhEJLQgfLQdmRAdMPNTdlQtjzfCsOnjYVEqcgKTFv3WX H+a7bWb5dLZI8JvzdxWN8m9e91gPfgdQTAGflmeuSSA4F//w3eGcuFkjgD4Fym33dRe2 0hYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=DA97c1OVaZrH8SvTZWoH5od6ijrQ6ybNR3pRj3cE098=; b=PMoTSYxPhzxHAU9hIvOtUOix0XiqtPo3mtjrVpu44J6HHaEW9HS7rmppQFSYwSH+w7 8B4OwRy5+fa9EL7usQsIBuR4Z3ej6wJu/Ze8zUGrTTwphWHa4+I/bkv6IsAeQd99iza3 ni1eJw63tAPJWR7hiIQIQv1gD13EV3yYErSYWeGW2tMwcdCupuqIbjBOuvXVmHBi3JYr hSItAjGlT+vfHp0haQmbTbn27CuPzZOtBK/Sq7BX93Wtoh0Wza5FQCzNYwFCTTZq870r oTvIJrog6t4/uqjiMidLpH7l8NjhElPg/g6oGhFuAUJXoi9jn1q9RgyEUXvcw0B/eRlh N1uA== X-Gm-Message-State: APjAAAXdbHiYSAr/5kNZZNR/qMRSVaiaZrX741TV3j5JvEBwEAuPC4NO /lORtvYg4tbdQ/rb/6G0vf3v5Au9 X-Received: by 2002:a2e:3a1a:: with SMTP id h26mr16166320lja.25.1572809931956; Sun, 03 Nov 2019 11:38:51 -0800 (PST) Received: from [192.168.1.36] (88-114-211-119.elisa-laajakaista.fi. [88.114.211.119]) by smtp.gmail.com with ESMTPSA id v9sm5897917ljk.56.2019.11.03.11.38.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 03 Nov 2019 11:38:51 -0800 (PST) Subject: Re: [PATCH] Allow restricting permissions in /proc/sys To: "Eric W. Biederman" Cc: Luis Chamberlain , Kees Cook , Alexey Dobriyan , "linux-kernel@vger.kernel.org" , "open list:FILESYSTEMS (VFS and infrastructure)" References: <74a91362-247c-c749-5200-7bdce704ed9e@gmail.com> <87d0e8g5f4.fsf@x220.int.ebiederm.org> From: Topi Miettinen Message-ID: Date: Sun, 3 Nov 2019 21:38:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <87d0e8g5f4.fsf@x220.int.ebiederm.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3.11.2019 20.50, Eric W. Biederman wrote: > Topi Miettinen writes: > >> Several items in /proc/sys need not be accessible to unprivileged >> tasks. Let the system administrator change the permissions, but only >> to more restrictive modes than what the sysctl tables allow. > > This looks quite buggy. You neither update table->mode nor > do you ever read from table->mode to initialize the inode. > I am missing something in my quick reading of your patch? inode->i_mode gets initialized in proc_sys_make_inode(). I didn't want to touch the table, so that the original permissions can be used to restrict the changes made. In case the restrictions are removed as suggested by Theodore Ts'o, table->mode could be changed. Otherwise I'd rather add a new field to store the current mode and the mode field can remain for reference. As the original author of the code from 2007, would you let the administrator to chmod/chown the items in /proc/sys without restrictions (e.g. 0400 -> 0777)? > The not updating table->mode almost certainly means that as soon as the > cached inode is invalidated the mode changes will disappear. Not to > mention they will fail to propogate between different instances of > proc. > > Loosing all of your changes at cache invalidation seems to make this a > useless feature. At least different proc instances seem to work just fine here (they show the same changes), but I suppose you are right about cache invalidation. -Topi