From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sonic.asd.mail.yahoo.com (sonic310-30.consmr.mail.ne1.yahoo.com [66.163.186.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EFD72A8C1 for ; Thu, 31 Jul 2025 15:01:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.163.186.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753974072; cv=none; b=T+D3S796Otfww9FUYPECYbvfuHSHX5zOnof6FbyglZDjB7s//B93jjstnvPeT/zdIrNSWHaUokaPC/y8wqion6k1JJp1GwBMn1klgB7zZuqfzXCxL2ePsKkV/CTJjzgKkcdboB3WedOYVMXyMxpd3vRoS6vfnb5uWcXljtdGKlM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753974072; c=relaxed/simple; bh=yF70jT5zZihJChERM7/8WsqLm75Xwk4VVMdeZOCWEGo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ernw66R8jTNvatA73ZVyKIE72w16UOdCUCnQ1Q4cWvxFxVqbgYk8zYsFrAer4RoVhJkntqllDnn2uDNB7tB738aRuvfZgDnymdN1sDIGEqXG0dmoturqtlJJAInbDwIwyofRILC7nH4vypj9ctGu0duNOLKvBByclGqPjqXd08w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com; spf=none smtp.mailfrom=schaufler-ca.com; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b=qULecYV7; arc=none smtp.client-ip=66.163.186.211 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b="qULecYV7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1753974063; bh=yF70jT5zZihJChERM7/8WsqLm75Xwk4VVMdeZOCWEGo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=qULecYV7ZKv3DcGJP7YAKTPw1Et8pq2u80jal+2b8VOfFVJmHMCnsfXthf1JUWY4WdeUXRQV8Qe417pG6n4HvMsfd/09o/bufrfL1gzm7uxwMZXcAvhoz+eyq6kZlgf03LAqXqSGJkyDSEDSOzJv3KcB90O1aM7QPW5zbLUeLt1A1kQPuLajX9fowZghT2b0CztdHfru5fPsvyDwAccplRjvucHbjU67SzvHL1T3LEa4QWWUNJCcRY6gY9KwAawAJGMd9LzXVUeDK22+c0NEc7hXXatavty3D4vWmvdjpcEH95KdazDmiTfLwRy6ery9A2gvFpGyxiqqWyurRr9+3A== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1753974063; bh=gP2lmCIzQWZVtg3PpiJsfmyKf4DpqJPtggQ3WJ3ZDQm=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=AUcoGv6UTDQ+T9OrExnKgjrDWOJloqZC9AyOqqlWyPskm+ExbqEeOG7/S7Q1e+dgpMJdty24eaeK2jzf+kqr7R8VNHPM6kepEbd2djcxNvNkbh/E/alm07+86MGvJUC7FD9BgK7cIfcPqnh+tBxTvwiYT+3TGRAp8YW+qDCA9pZXfw7lfzw+fCpP+mf6wS4N3A4RC6bBAzd70woH2X+8D8sLn7fzaTnX1XOELJc6/umwwCF2wq+6CVQR3NbAsjKI7ae+2qv6dxAJc4GYHD7q31r+SU9XkkC8CLu9l1H9OwPj2xYuNxPJggm3dEOEhUM6j17VzJ+W0U030JADqTbGiQ== X-YMail-OSG: HfvcoZgVM1ki3y_4yxzOigs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xZE0bEgZb9AaIrNyG7pa.EvZ4ip 1i9sCq20Cn4WKAlF4nPcr8aL.nz3FLvgKoVpSBOZ5cD8N8cLMMNyaYNZ.sMvIMc8dPOQ6ybYs3Vd LxMh90dzTM.it7k2PZjmeaXHicfKqKHfmVca09Do.ol8lnO9aNfEjEVaOc5rON71Y.brrwyemCz2 dBnlLqQyERhNMKpc- X-Sonic-MF: X-Sonic-ID: 8b95bc7b-b260-44f9-b6a1-9753808c2201 Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Thu, 31 Jul 2025 15:01:03 +0000 Received: by hermes--production-gq1-74d64bb7d7-74ntb (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID da4533f52ef555abea23905bd1b25012; Thu, 31 Jul 2025 15:00:57 +0000 (UTC) Message-ID: <9dc21c28-1a4b-4d88-a67c-7b5050cdf0b8@schaufler-ca.com> Date: Thu, 31 Jul 2025 08:00:54 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] lsm: simplify security_inode_copy_up_xattr() To: "tianjia.zhang" , Paul Moore Cc: James Morris , "Serge E. Hallyn" , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Casey Schaufler References: <20250729090933.94942-1-tianjia.zhang@linux.alibaba.com> <2aa4da27-28fc-46e0-8d1a-d9e63b03d502@linux.alibaba.com> Content-Language: en-US From: Casey Schaufler In-Reply-To: <2aa4da27-28fc-46e0-8d1a-d9e63b03d502@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailer: WebService/1.1.24260 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo On 7/31/2025 4:59 AM, tianjia.zhang wrote: > > > On 7/29/25 11:09 PM, Paul Moore wrote: >> On Tue, Jul 29, 2025 at 10:43 AM Casey Schaufler >> wrote: >>> On 7/29/2025 2:09 AM, Tianjia Zhang wrote: >>>> The implementation of function security_inode_copy_up_xattr can be >>>> simplified to directly call call_int_hook(). >>>> >>>> Signed-off-by: Tianjia Zhang >>>> --- >>>>   security/security.c | 8 +------- >>>>   1 file changed, 1 insertion(+), 7 deletions(-) >>>> >>>> diff --git a/security/security.c b/security/security.c >>>> index 596d41818577..a5c2e5a8009f 100644 >>>> --- a/security/security.c >>>> +++ b/security/security.c >>>> @@ -2774,13 +2774,7 @@ EXPORT_SYMBOL(security_inode_copy_up); >>>>    */ >>>>   int security_inode_copy_up_xattr(struct dentry *src, const char >>>> *name) >>>>   { >>>> -     int rc; >>>> - >>>> -     rc = call_int_hook(inode_copy_up_xattr, src, name); >>>> -     if (rc != LSM_RET_DEFAULT(inode_copy_up_xattr)) >>>> -             return rc; >>>> - >>>> -     return LSM_RET_DEFAULT(inode_copy_up_xattr); >>>> +     return call_int_hook(inode_copy_up_xattr, src, name); >>> >>> Both the existing code and the proposed change are incorrect. >>> If two LSMs supply the hook, and the first does not recognize >>> the attribute, the second, which might recognize the attribute, >>> will not be called. As SELinux and EVM both supply this hook >>> there may be a real problem here. >> >> It appears that Smack also supplies a inode_copy_up_xattr() callback >> via smack_inode_copy_up_xattr(). >> >> Someone should double check this logic, but looking at it very >> quickly, it would appear that LSM framework should run the individual >> LSM callbacks in order so long as they return -EOPNOTSUPP, if they do >> not return -EOPNOTSUPP, the return value should be returned to the >> caller without executing any further callbacks.  As a default return >> value, or if all of the LSM callbacks succeed with -EOPNOTSUPP, the >> hook should return -EOPNOTSUPP. >> >> Tianjia Zhang, would you be able to develop and test a patch for this? >> > > I carefully checked the logic of security_inode_copy_up_xattr(). I think > there is no problem with the current code. The default return value of > inode_copy_up_xattr LSM is -EOPNOTSUPP. Therefore, when -EOPNOTSUPP is > returned in the LSM callback, the next callback function will be called > in a loop. When an LSM module recognizes the attribute name that needs > to be ignored, it will return -ECANCELED to indicate > security_inode_copy_up_xattr() to jump out of the loop and ignore the > copy of this attribute in overlayfs. > > Currently, the SELinux, EVM, and Smack that supply inode_copy_up_xattr > callback all return -ECANCELED after recognizing the extended attribute > name they are concerned about, to indicate overlayfs to discard the > copy_up operation of this attribute. I think this is in line with > expectations. I looked at the code more carefully and I think you're right. My objection was based on the behavior of a much earlier version of call_int_hook(). With that, I think your proposed change is reasonable. > > Tianjia, > Cheers