Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp642592ybk; Wed, 13 May 2020 09:13:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXbvIqRvM4WJntAgBxKGup3a3m1Q3pUnlR4liKrF1qGSG9s6vh3X6kwhvp3RFfOJDdX1h+ X-Received: by 2002:a05:6402:c0e:: with SMTP id co14mr344704edb.177.1589386433535; Wed, 13 May 2020 09:13:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589386433; cv=none; d=google.com; s=arc-20160816; b=STe091HUPYMLCIIoROvoeh5+y1EJS0g8mnc0vsFociHhCkDaVO5kThHY6G+HkSvQ3Z O+GEr72H8Kv2hgCNfR+AyO9DwNZm3i2/hSGSuMp1fYpEdi7bZCXttN8fhy9tgGCCvuKO sPPnd8gzMCf9KvyGhpYDj0xAZGb01HXzIyKkcIM4rLPyedPWl3Bg8fM8R10kzCA/SSFl K1rUL0T57Ztb8IlLta9wH2LGXDBQXnps8OU7im2PpeFvXFVtYV17crJngHgMWwibS5Ln qh63VMvYkjD9mKto8EZ1+F6znQwdqgxBJEuRGqpWZZbW9uVPmlGoMmlEckl9VoAclEF1 JjBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=WpsJK+ng0lEV5+B39pvVYDwNbMP3HTpuDClnFH8rXFo=; b=EuF9wL+lx9olgh6eOCAH0O0ZZf5zTGVmqe4qg4b2w1VHsSthHHZp7+ZjBzQuFdGq9k LJdlR0x6Ou+GXQYCIFYR/bKK73JzScDGM3Ly9+ipos/AjdnavR15P2x9yBKF/zd6pfJl 6XL1D3eHsEbzEAd9EB3Ahpp7W7jY/JqnWB2ETehjavBo7QNBhhgHCzDrcYKxl6Unp57R qHmW3tAQjyJteIAKH+SBMk0pQtK4EMxxUmvkhhpnoWlfxVpKNTIw/POhqqp0aNTtowkQ IAkWlMXuJ82Mc2FspOdiyDehL0vuUdTdkRoY+sgOElGtdH6prwNSElQFf6HV525Kw6jZ F/0A== ARC-Authentication-Results: i=1; mx.google.com; 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 v28si14177edd.176.2020.05.13.09.13.29; Wed, 13 May 2020 09:13:53 -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; 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 S1730291AbgEMQL1 (ORCPT + 99 others); Wed, 13 May 2020 12:11:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728692AbgEMQL1 (ORCPT ); Wed, 13 May 2020 12:11:27 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAF32C061A0C for ; Wed, 13 May 2020 09:11:26 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jYtyT-007b0k-8h; Wed, 13 May 2020 16:11:13 +0000 Date: Wed, 13 May 2020 17:11:13 +0100 From: Al Viro To: Patrick Donnelly Cc: open list Subject: Re: file system permissions regression affecting root Message-ID: <20200513161113.GU23230@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 13, 2020 at 08:00:28AM -0700, Patrick Donnelly wrote: > In newer kernels (at least 5.6), it appears root is not able to write > to files owned by other users in a sticky directory: Yes. Controlled by /proc/sys/fs/protected_regular, which systemd crowd has decided to enable in commit 2732587540035227fe59e4b64b60127352611b35 Author: Lucas Werkmeister Date: Wed Jan 16 00:16:10 2019 +0100 Enable regular file and FIFO protection These sysctls were added in Linux 4.19 (torvalds/linux@30aba6656f), and we should enable them just like we enable the older hardlink/symlink protection since v199. Implements #11414. in their tree. The relevant part is this: diff --git a/sysctl.d/50-default.conf b/sysctl.d/50-default.conf index b0645f33e7..27084f6242 100644 --- a/sysctl.d/50-default.conf +++ b/sysctl.d/50-default.conf @@ -36,3 +36,7 @@ net.core.default_qdisc = fq_codel # Enable hard and soft link protection fs.protected_hardlinks = 1 fs.protected_symlinks = 1 + +# Enable regular file and FIFO protection +fs.protected_regular = 1 +fs.protected_fifos = 1 so if you want the normal behaviour (and I certainly agree that the value of that "protection" is not terribly high - I don't enable it on any of my boxen and I don't use systemd, so they can't make those decisions for me), I would suggest going into /etc/sysctl.d/ and telling the damn thing _not_ to enable that. From the same commit: + * The fs.protected_regular and fs.protected_fifos sysctls, which were + added in Linux 4.19 to make some data spoofing attacks harder, are + now enabled by default. While this will hopefully improve the + security of most installations, it is technically a backwards + incompatible change; to disable these sysctls again, place the + following lines in /etc/sysctl.d/60-protected.conf or a similar file: + + fs.protected_regular = 0 + fs.protected_fifos = 0 + + Note that the similar hardlink and symlink protection has been + enabled since v199, and may be disabled likewise.