Message ID | 1853230.1684516880@warthog.procyon.org.uk |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1413965vqo; Fri, 19 May 2023 10:48:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7l8thy1x7GSYRM8Y9TaoJNzCNdk9egftbUxyCmAK7MQIu6wAU1ORXucuBxdzqr4nZ0wxOn X-Received: by 2002:a05:6a20:4ba5:b0:101:cf58:e666 with SMTP id fu37-20020a056a204ba500b00101cf58e666mr2270743pzb.56.1684518506953; Fri, 19 May 2023 10:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684518506; cv=none; d=google.com; s=arc-20160816; b=VzPPyzxwAbtMX6hdqqptGTuiAybvQVJNBwwa/I6kkh5LVQ8RtY6Z5qwoNutHdtWn25 ErdBZPCI0xa2rxs/Il5wpEWFZNS+N8RAT3+xI9LxPrHsex6LvDGE1xZ0U12GfVK/pdOs VGCoLp35v2sZC76rVGX7kfbT9jQ0EUtVix/kgSNnXOcXbILfACwEIleHSzIkpS90UkWE 52E9nQOH9yHUhFuD6NHDCeszNSZLxyuABnEin6spFNCNuWqULFd5RtVDffmGiVldxnf4 ns+YVetL5yKZKRBMzuaU93PVd4WSo1vxrNvDlZOJTZWrZLUOiGOUtUvLiA+eMM7DDy5Q uHDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:from:organization :dkim-signature; bh=2KKXfGDHxrX+6XLdqChQuTj9B0h9lQtkKNegqRI3p6E=; b=Nw2NJioHVKCDJ9QwwMBqr5gMC9A8GquHLqjQmWRLwJ5aqoAWIMxSvvfOP49V281Q3q MmP0tl4PVBaaGnOAb8DXCk1qhBMVmq/HMWOeFtRY+nlzaV8HoDxm2PprvmBiPmZjgiwu UhEzjGXBIY5YoDvONvQqIqhb0opD5fHGD6IxV1+gJWaNlZ/nDzjC6qdD6OJWO21gU2XX 5ffgCC1WJCaN/PKuEQ2CbQGUO2pZ21voT+1XkbB6yiARMUws0kvhOF11/xytieRycAzl P2sYeO2OAw9jVmCvs+6Dwjd2H7cUU4Okui2Nbomn2zAy6AfXBzfRbS8X1HDf44MSZ0/b Vtjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dowl3uz1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020a632b0b000000b0051b32aa267asi3760890pgr.671.2023.05.19.10.48.11; Fri, 19 May 2023 10:48:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dowl3uz1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231539AbjESRXu (ORCPT <rfc822;wlfightup@gmail.com> + 99 others); Fri, 19 May 2023 13:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230110AbjESRXf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 19 May 2023 13:23:35 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E11E719A3 for <linux-kernel@vger.kernel.org>; Fri, 19 May 2023 10:22:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684516887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2KKXfGDHxrX+6XLdqChQuTj9B0h9lQtkKNegqRI3p6E=; b=dowl3uz1qy5reIHD8vdLlRZYl5H488JdhFTSjwZiP1EFmgDu9N0iAumPwLiULCQm5cml5z x1fpjObxSU+ca+0TYEfwnsvA/Wt82uXXAfWpAeHmEkIB4vaZ1sHKo8DPdWuT+nyymjZd3W f8+I8x0q1rtJnPKwzeXJXrtllq7eC8s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-27-OtPTiJeUNUe2Hj4TZRRGtg-1; Fri, 19 May 2023 13:21:21 -0400 X-MC-Unique: OtPTiJeUNUe2Hj4TZRRGtg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 712A785A5A8; Fri, 19 May 2023 17:21:21 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA3C640D1B60; Fri, 19 May 2023 17:21:20 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells <dhowells@redhat.com> To: linux-cachefs@redhat.com cc: dhowells@redhat.com, Jeff Layton <jlayton@kernel.org>, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cachefiles: Allow the cache to be non-root MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1853229.1684516880.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 19 May 2023 18:21:20 +0100 Message-ID: <1853230.1684516880@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766344476028950985?= X-GMAIL-MSGID: =?utf-8?q?1766345677957277565?= |
Series |
cachefiles: Allow the cache to be non-root
|
|
Commit Message
David Howells
May 19, 2023, 5:21 p.m. UTC
Set mode 0600 on files in the cache so that cachefilesd can run as an
unprivileged user rather than leaving the files all with 0. Directories
are already set to 0700.
Userspace then needs to set the uid and gid before issuing the "bind"
command and the cache must've been chown'd to those IDs.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: David Howells <dhowells@redhat.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
cc: linux-erofs@lists.ozlabs.org
cc: linux-fsdevel@vger.kernel.org
---
fs/cachefiles/namei.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On 2023/5/20 10:21, David Howells wrote: > > Set mode 0600 on files in the cache so that cachefilesd can run as an > unprivileged user rather than leaving the files all with 0. Directories > are already set to 0700. > > Userspace then needs to set the uid and gid before issuing the "bind" > command and the cache must've been chown'd to those IDs. > > Signed-off-by: David Howells <dhowells@redhat.com> > cc: David Howells <dhowells@redhat.com> > cc: Jeff Layton <jlayton@kernel.org> > cc: linux-cachefs@redhat.com > cc: linux-erofs@lists.ozlabs.org > cc: linux-fsdevel@vger.kernel.org It seems useful on our side as well and safe: Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Thanks, Gao Xiang
On Fri, 19 May 2023 18:21:20 +0100, David Howells wrote: > > Set mode 0600 on files in the cache so that cachefilesd can run as an > unprivileged user rather than leaving the files all with 0. Directories > are already set to 0700. > > Userspace then needs to set the uid and gid before issuing the "bind" > command and the cache must've been chown'd to those IDs. > > [...] Applied to the vfs.misc branch of the vfs/vfs.git tree. Patches in the vfs.misc branch should appear in linux-next soon. Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it. It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated. tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.misc [1/1] cachefiles: Allow the cache to be non-root https://git.kernel.org/vfs/vfs/c/a64498ff493f
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 82219a8f6084..66482c193e86 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -451,7 +451,8 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object) ret = cachefiles_inject_write_error(); if (ret == 0) { - file = vfs_tmpfile_open(&nop_mnt_idmap, &parentpath, S_IFREG, + file = vfs_tmpfile_open(&nop_mnt_idmap, &parentpath, + S_IFREG | 0600, O_RDWR | O_LARGEFILE | O_DIRECT, cache->cache_cred); ret = PTR_ERR_OR_ZERO(file);