Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8123068ybi; Tue, 9 Jul 2019 09:34:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQ6kCmseiyD4dH8NQaAv0Yf7V6NKKcMMBhhwmWTbXQqyTWBsp1kh1vRP/1fyR7/HHAG2Ur X-Received: by 2002:a17:90a:f498:: with SMTP id bx24mr1038438pjb.91.1562690073547; Tue, 09 Jul 2019 09:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562690073; cv=none; d=google.com; s=arc-20160816; b=qTJFvJ3zicfPaW3P8LTaNpv+Cqq0YR2JW9AwTh1hMPsfizbzY8cMHGVKIWAzdr0QNV TyQ4lnHq+hY5IfjhaF/DWb4p18maeeO8rj2K/NeS2deE+C0y13D+NGMpCXiE2wyuxJl+ iCXeEa6bN7GZoYh0U2IWCv8fYJhgmJH36Ckit2MKCReJFAt2grlAOKAy279Lwgduz0QB CIr2IgDtpqb79Mh6BlYeSJVc5kAW0raAMjiqBKvrhLkF590hsEobmEzxgr3uNZ2wBcQk Q98tfc3MW/Uv6IJsZ6OpJji5XEGyPfOnKmn8C9dASZBS4XchfhNmBt1UWwm6Xt4WDltY Xvxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:cc:references:to:subject :dkim-signature; bh=450XATkvD/Vqevc8O/AWiOpwscos3xewaorD9OcX+RU=; b=rOdRuN6M3bq2llRs9h7PsAiAjtfbzZxWls1SIAxreI1PALM+FyYnX78Bzawqpqc2TM OgzqFF5HHvLpX8MEMOyShdmu75Rv1dGYZpQV5bpboCxDBFqrrZgDAHUnLMlpiuGPI4cb qCpQPkW3mIAdtO2J/sOWBoUDBZ3qrtV3Wa2KRnlXdZFWSyvKvr9vTsltVLkHSp2yw59B I6Yd9BsLcUUMski5t9aJv/ViIGHJtUdGr1DTTlPa4UKc91fhaogKBB3o3uZTLTP9+4sy TEQ930NdaJ9HPYXvHYVIAO8SxDMDolJO8pWgnLfpMRhN4UE1DRomVnsLkLEXzfrUfoN+ KzuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=K950Vt9k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o30si23696253pgl.575.2019.07.09.09.34.17; Tue, 09 Jul 2019 09:34:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=K950Vt9k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726601AbfGIQd5 (ORCPT + 99 others); Tue, 9 Jul 2019 12:33:57 -0400 Received: from sonic310-22.consmr.mail.bf2.yahoo.com ([74.6.135.196]:33889 "EHLO sonic310-22.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726324AbfGIQd5 (ORCPT ); Tue, 9 Jul 2019 12:33:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1562690035; bh=450XATkvD/Vqevc8O/AWiOpwscos3xewaorD9OcX+RU=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject; b=K950Vt9kNK+0webohErxUoNFu7CaHL6fJ79AJFqqixIAnutrIXFyWm/tvOWW4M8z/TUFFYpe0ktmcgpiqJjF0LvKdM6bpE/yUaFSJcJaizyU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2xCClCLjBNRbdp8IISTQLBdUNCRulQiu3U0PzfDl1BMVNZtLevs3KMiilplvhogNCQQxc9Ah VKtMDZy0GE7R5S4K4TBSsuuD80W_KSED5Us9jjUTGCyT7nFrISHCVzTPVEGKMMnOL0UV6e_4RDe2 aG2u_KwJGnQXCWjhx6eh212tCjBcyEnN6Ot0eCdhlXV9wAdYE23G.guKMr5zrzsxFMy5Ey6s1A6h C3E1s9Q.Gz9.bd1ktck7svRJh6HnbpyhXpde4fcy8KNI9jYt69gjHH.gbAEh8JF8rHufOXtqIok1 OvaXj8oqzTOHP8Mr5zegRUyIv7SU40NbhUd8SuZyVL9886QnU.jIJCsuqCvfDJrPsIW0bNP6B73t VWlTw8HdLkx11CoaWNHQvNzCXDNmu1ndtLslS5bPM9bUEid1TXWeXsNmN6CxnIJ3BXnQ..T9dpPl LWt5QW6exoOcfwM4pFxs- Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.bf2.yahoo.com with HTTP; Tue, 9 Jul 2019 16:33:55 +0000 Received: by smtp418.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID df006fca287792004bba6df3e350b334; Tue, 09 Jul 2019 16:33:54 +0000 (UTC) Subject: Re: RFC: BUG: overlayfs getxattr recursion leaves a poison sid. To: Mark Salyzyn , linux-kernel@vger.kernel.org, Stephen Smalley , Miklos Szeredi , James Morris , "Serge E. Hallyn" , Paul Moore , Eric Paris , selinux@vger.kernel.org, kernel-team@android.com, Linux Security Module list References: Cc: casey@schaufler-ca.com From: Casey Schaufler Openpgp: preference=signencrypt Autocrypt: addr=casey@schaufler-ca.com; keydata= mQINBFzV9HABEAC/mmv3jeJyF7lR7QhILYg1+PeBLIMZv7KCzBSc/4ZZipoWdmr77Lel/RxQ 1PrNx0UaM5r6Hj9lJmJ9eg4s/TUBSP67mTx+tsZ1RhG78/WFf9aBe8MSXxY5cu7IUwo0J/CG vdSqACKyYPV5eoTJmnMxalu8/oVUHyPnKF3eMGgE0mKOFB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pRV8jEPIEWkzEACKFUnpp+wIVHpckMfBqN8BE5dUbWJc GyQ7wXWajLtlPdw1nNw0Wrv+ob2RCT7qQlUo6GRLcvj9Fn5tR4hBvR6D3m8aR0AGHbcC62cq I7LjaSDP5j/em4oVL2SMgNTrXgE2w33JMGjAx9oBzkxmKUqprhJomPwmfDHMJ0t7y39Da724 oLPTkQDpJL1kuraM9TC5NyLe1+MyIxqM/8NujoJbWeQUgGjn9uxQAil7o/xSCjrWCP3kZDID vd5ZaHpdl8e1mTExQoKr4EWgaMjmD/a3hZ/j3KfTVNpM2cLfD/QwTMaC2fkK8ExMsz+rUl1H icmcmpptCwOSgwSpPY1Zfio6HvEJp7gmDwMgozMfwQuT9oxyFTxn1X3rn1IoYQF3P8gsziY5 qtTxy2RrgqQFm/hr8gM78RhP54UPltIE96VywviFzDZehMvuwzW//fxysIoK97Y/KBZZOQs+ /T+Bw80Pwk/dqQ8UmIt2ffHEgwCTbkSm711BejapWCfklxkMZDp16mkxSt2qZovboVjXnfuq wQ1QL4o4t1hviM7LyoflsCLnQFJh6RSBhBpKQinMJl/z0A6NYDkQi6vEGMDBWX/M2vk9Jvwa v0cEBfY3Z5oFgkh7BUORsu1V+Hn0fR/Lqq/Pyq+nTR26WzGDkolLsDr3IH0TiAVH5ZuPxyz6 abzjfg== Message-ID: <7b6eb68e-44ae-5df8-9ebd-d334fc134938@schaufler-ca.com> Date: Tue, 9 Jul 2019 09:33:52 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/9/2019 9:23 AM, Mark Salyzyn wrote: > For EACCES return for getxattr, sid appears to be expected updated in parent node. For some accesses purely cosmetic for correct avc logging, and depending on kernel vintage for others (older than 4.4) the lack of the corrected sid in the parent overlay inode poisons the security cache and results in false denials. > > The avc denials would contain an (incorrect) unlabelled target references, we could fix this by copying up the sid to the parent inode. However the test (below) needs to refactored to the pleasure of the security, selinux and overlayfs maintainers. The security_socket_accept function is _close_, it will copy sid and class from the old socket to the new. Along those lines, we probably need to add a new security_copy_to_upper handler that takes the upper and lower dentries and ensures that the upper contains all the security information associated with the lower. Please include the LSM (CCed) list on all LSM impacting discussions. Your mailer mangled the patch. Please resend in plain text. Thank you. > > Prototype adjustment (tested in 3.18 to ToT) > > int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name, { ssize_t res; const struct cred *old_cred; struct dentry *realdentry = ovl_i_dentry_upper(inode) ?: ovl_dentry_lower(dentry); old_cred = ovl_override_creds(dentry->d_sb); res = vfs_getxattr(realdentry, name, value, size); ovl_revert_creds(old_cred); + if (res == -EACCES) { + selinux_copy_sid(dentry, realdentry); return res; } > > . . . > > + void selinux_copy_sid(struct dentry *parent, struct dentry *child) + { + struct inode *pinode, *cinode; + struct inode_security_struct *pisec, *cisec; + + if (!parent || !child) + return; + pinode = parent->d_inode; + cinode = child->d_inode; + if (!pinode || !cinode) + return; + pisec = pinode->i_security; + cisec = cinode->i_security; + if (!pisec || !cisec) + return; + pisec->sid = cisec->sid; + } + EXPORT_SYMBOL_GPL(selinux_copy_sid); > > Sincerely -- Mark Salyzyn > >