Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2429535iof; Wed, 8 Jun 2022 04:57:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa8JDIUe1qnRM+UEvF7NY7W0psb92XA2zUOPGkkGb71UMgjSuXMYKUPIJTXiT6/z2bsuhh X-Received: by 2002:a63:f715:0:b0:3fd:ebe6:d116 with SMTP id x21-20020a63f715000000b003fdebe6d116mr9344024pgh.230.1654689477025; Wed, 08 Jun 2022 04:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654689477; cv=none; d=google.com; s=arc-20160816; b=Y+g5M3DLcVGxXVVT+0mOQc8tARfyyrMuU/tN2zULPEXdkmmOQKcAqXem4vJMppCxlA Xt/GeO23lthwh6RNio8WVlbi5d/i+guDSvq2eAg+7CzLroBmjb3lLrpPXSzmLs/G9qhx BuIVcqffE7BXl0nVfxyUO/8xs/Ugr8T7CqThLTZKWbeAslWcIMvABtVsn4Y7aggr5NpH 0Gg3IEWtV43A4LG8MDT8g80rc4xH8vkl+XJxGe4Xy2D7Zson7ZKHTJkZfW9qTe9D5Wwq lbNv215TP/UztSiPCt8rhp6CJhUNnrgCSKdeNmtd1pl0WtHFb4J0Yz7tMwgn5p9LeZfp ZspQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wPsT6O+ctmIXj+Fji7onCisWOhfXodHTYPAYE+NGvyQ=; b=0J+250jNHvHJ1iIrPOe94WXFCNIHBu+wtQNN+0CYP2cPdaH+CKJl1TZgp4ux9JqQej 5LF0MJhmEoNiFTHSkJs+8dHewUr/+fjicqJDHvxotX1LJYaZh/aj3bHtwlqzQsU8ZHFE bx3CJWWYjywAH81RVQvl8FFtozEdhAgyUVi4RjC9gdux+2IJW5l3Fb70/oDEwbv3U5FD hrd8KBdiFLvmpFLKuzM4loq1FjzP4oNm35E94LLF/FEBuNAnVtjUlZCUbcvtwao28s0s INjQYje2z3OuMSu9iOCN+T/aL17VhNXT0bAr6KD6ak4w8+VTn39mdWJm3ZYfE24+n8gL cI+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WlFAibnC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y16-20020a170902b49000b00163fc5e39a0si16034976plr.227.2022.06.08.04.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 04:57:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WlFAibnC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AD90C1796E0; Wed, 8 Jun 2022 04:27:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238180AbiFHL1k (ORCPT + 99 others); Wed, 8 Jun 2022 07:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238209AbiFHL1f (ORCPT ); Wed, 8 Jun 2022 07:27:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C541673D1; Wed, 8 Jun 2022 04:27:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 35337615B3; Wed, 8 Jun 2022 11:27:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F0B3C34116; Wed, 8 Jun 2022 11:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654687653; bh=mw/8TTzcVjw2Heammx4s/Kl/78h76VgQk6zFg4QLP4w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WlFAibnCvGU1+f/+rCYQSyeyXOW0jQAf3vYCJG3DfXUYZInQ2s6gx5FLhQCF/Y/K2 XqQPblVMpU4oDHt6uMyraFdx8J77OTimMxURh0L93rSDmYWaayZbHkgNbl+FZZQ5np V10Un2CYmhO52QU3XYCdDD30hf25xyC8HQca5jqlIEh++sUqua1biWtWQnSbzA9F8c 3D9BP2yb6WSxk5Qvpsos2Zy/oVoOESAQ4xhogmLsi43jDtEZwP8G/9evFnl4qtf8gD 1KMcIQqvj/LCWtDip4MIkSxumkP3WCj2sP7RQxZ2BmcaJSs+YEGerBBIqkx3YPl2F1 J0yiCCDxbJdpA== Date: Wed, 8 Jun 2022 13:27:28 +0200 From: Christian Brauner To: Christian =?utf-8?B?R8O2dHRzY2hl?= Cc: selinux@vger.kernel.org, Miklos Szeredi , linux-api@vger.kernel.org, linux-man@vger.kernel.org, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] f*xattr: allow O_PATH descriptors Message-ID: <20220608112728.b4xrdppxqmyqmtwf@wittgenstein> References: <20220607153139.35588-1-cgzones@googlemail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220607153139.35588-1-cgzones@googlemail.com> X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_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: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 07, 2022 at 05:31:39PM +0200, Christian Göttsche wrote: > From: Miklos Szeredi > > Support file descriptors obtained via O_PATH for extended attribute > operations. > > Extended attributes are for example used by SELinux for the security > context of file objects. To avoid time-of-check-time-of-use issues while > setting those contexts it is advisable to pin the file in question and > operate on a file descriptor instead of the path name. This can be > emulated in userspace via /proc/self/fd/NN [1] but requires a procfs, > which might not be mounted e.g. inside of chroots, see[2]. > > [1]: https://github.com/SELinuxProject/selinux/commit/7e979b56fd2cee28f647376a7233d2ac2d12ca50 > [2]: https://github.com/SELinuxProject/selinux/commit/de285252a1801397306032e070793889c9466845 > > Original patch by Miklos Szeredi > https://patchwork.kernel.org/project/linux-fsdevel/patch/20200505095915.11275-6-mszeredi@redhat.com/ > > > While this carries a minute risk of someone relying on the property of > > xattr syscalls rejecting O_PATH descriptors, it saves the trouble of > > introducing another set of syscalls. > > > > Only file->f_path and file->f_inode are accessed in these functions. > > > > Current versions return EBADF, hence easy to detect the presense of > > this feature and fall back in case it's missing. > > CC: linux-api@vger.kernel.org > CC: linux-man@vger.kernel.org > Signed-off-by: Christian Göttsche > --- I'd be somewhat fine with getxattr and listxattr but I'm worried that setxattr/removexattr waters down O_PATH semantics even more. I don't want O_PATH fds to be useable for operations which are semantically equivalent to a write. In sensitive environments such as service management/container runtimes we often send O_PATH fds around precisely because it is restricted what they can be used for. I'd prefer to not to plug at this string.