Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3077102pxb; Tue, 19 Jan 2021 13:10:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7qtDx8KnwQ/1afCq+zl+w+kJFpMPZ8meJFxQTtqm/AUkfcW+gCrOHyZ1DqayBmpIbKmhI X-Received: by 2002:a05:6402:134b:: with SMTP id y11mr4825747edw.88.1611090636929; Tue, 19 Jan 2021 13:10:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611090636; cv=none; d=google.com; s=arc-20160816; b=gINsdWASs3lwvIxD/VRdc7SmMmpa33IlCuDfPScAsufyvZeoiw6LIOHvuLLnz4QAIB m+CTko9HKxrkjLFvRPj89K8UG431/8LMAqN9RNA9RW8Y5Jno8pctK1ChL8Z/NfJCoLCe Bp61aXMSJOZ1feQhMnYuaVUWNcQDW0a3mxkro+seFrJ9CQspS+esSEh3akiKVflUa60r JmANZwcKrmM3k1WEqi+z/+7CtNjVeiqoGJEohwwOBBTWDenKZRQELfauiOKhe7vd2jeW ejSwr4xoJZ0BoawzGd4gILPI9zjeLK2lxSp5f3dbocTNXCWu7Rer7Rvw0L9x3NfmQwUy 3vQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:mime-version:user-agent:message-id :in-reply-to:date:references:cc:to:from; bh=0O5qZ++/W2cayBAtvaT4ECfV5M5mruYj7hdkn5LczWE=; b=TCl/C081dS/N+CSQhmSDHReqp4zt682uyPutpdt2/NVzgit5q3jt1wXigBmpn/e7h6 ZJE9w882GNoFTXgwuUWIrA0Uvn0NUKrLHX39djhBkBSlQ2sf+aJAklYMwPftwEhUmYsf PCyT+HLBV2JgoNdG9Pl4x6DW0sskiqtO+Yq1BFB76KXiE+undS3crpnfpsg5u2FpQg4G bVdOKlmtKyBrPdq5EU9pxOoVj46qL5nUUq5cSV+BXFads0VuzqUceAU9SdXkYWamEvTv APlllMLNOfx/Ev3xLrAOLsPJLLWIrJUpDsCbaGewc2NK5R4Gax1otSeGreGPoz61f5LP uP9g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u13si9339528ejn.694.2021.01.19.13.10.13; Tue, 19 Jan 2021 13:10:36 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729955AbhASVIv (ORCPT + 99 others); Tue, 19 Jan 2021 16:08:51 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:49448 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388912AbhASVIF (ORCPT ); Tue, 19 Jan 2021 16:08:05 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1l1yDh-008bE6-7d; Tue, 19 Jan 2021 14:07:21 -0700 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1l1yDg-009tuJ-7a; Tue, 19 Jan 2021 14:07:20 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Miklos Szeredi Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, "Serge E . Hallyn" , Tyler Hicks References: <20210119162204.2081137-1-mszeredi@redhat.com> <20210119162204.2081137-2-mszeredi@redhat.com> Date: Tue, 19 Jan 2021 15:06:10 -0600 In-Reply-To: <20210119162204.2081137-2-mszeredi@redhat.com> (Miklos Szeredi's message of "Tue, 19 Jan 2021 17:22:03 +0100") Message-ID: <87a6t4ab7h.fsf@x220.int.ebiederm.org> 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=1l1yDg-009tuJ-7a;;;mid=<87a6t4ab7h.fsf@x220.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX192I2sk61mecKt+hRhFGN4NPXzT2CICcgs= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01,XMNoVowels, XMSubLong autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Miklos Szeredi X-Spam-Relay-Country: X-Spam-Timing: total 453 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 13 (2.8%), b_tie_ro: 11 (2.5%), parse: 1.02 (0.2%), extract_message_metadata: 16 (3.5%), get_uri_detail_list: 1.65 (0.4%), tests_pri_-1000: 15 (3.2%), tests_pri_-950: 1.34 (0.3%), tests_pri_-900: 1.09 (0.2%), tests_pri_-90: 169 (37.3%), check_bayes: 159 (35.1%), b_tokenize: 7 (1.5%), b_tok_get_all: 37 (8.1%), b_comp_prob: 2.8 (0.6%), b_tok_touch_all: 109 (24.0%), b_finish: 1.01 (0.2%), tests_pri_0: 226 (49.8%), check_dkim_signature: 0.61 (0.1%), check_dkim_adsp: 2.3 (0.5%), poll_dns_idle: 0.61 (0.1%), tests_pri_10: 2.1 (0.5%), tests_pri_500: 6 (1.4%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 1/2] ecryptfs: fix uid translation for setxattr on security.capability X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Miklos Szeredi writes: > Prior to commit 7c03e2cda4a5 ("vfs: move cap_convert_nscap() call into > vfs_setxattr()") the translation of nscap->rootid did not take stacked > filesystems (overlayfs and ecryptfs) into account. > > That patch fixed the overlay case, but made the ecryptfs case worse. > > Restore old the behavior for ecryptfs that existed before the overlayfs > fix. This does not fix ecryptfs's handling of complex user namespace > setups, but it does make sure existing setups don't regress. Today vfs_setxattr handles handles a delegated_inode and breaking leases. Code that is enabled with CONFIG_FILE_LOCKING. So unless I am missing something this introduces a different regression into ecryptfs. > > Reported-by: Eric W. Biederman > Cc: Tyler Hicks > Fixes: 7c03e2cda4a5 ("vfs: move cap_convert_nscap() call into vfs_setxattr()") > Signed-off-by: Miklos Szeredi > --- > fs/ecryptfs/inode.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c > index e23752d9a79f..58d0f7187997 100644 > --- a/fs/ecryptfs/inode.c > +++ b/fs/ecryptfs/inode.c > @@ -1016,15 +1016,19 @@ ecryptfs_setxattr(struct dentry *dentry, struct inode *inode, > { > int rc; > struct dentry *lower_dentry; > + struct inode *lower_inode; > > lower_dentry = ecryptfs_dentry_to_lower(dentry); > - if (!(d_inode(lower_dentry)->i_opflags & IOP_XATTR)) { > + lower_inode = d_inode(lower_dentry); > + if (!(lower_inode->i_opflags & IOP_XATTR)) { > rc = -EOPNOTSUPP; > goto out; > } > - rc = vfs_setxattr(lower_dentry, name, value, size, flags); > + inode_lock(lower_inode); > + rc = __vfs_setxattr_locked(lower_dentry, name, value, size, flags, NULL); > + inode_unlock(lower_inode); > if (!rc && inode) > - fsstack_copy_attr_all(inode, d_inode(lower_dentry)); > + fsstack_copy_attr_all(inode, lower_inode); > out: > return rc; > } Eric