lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri, 6 Aug 2021 17:53:54 +0800
From:   Zhihao Cheng <chengzhihao1@...wei.com>
To:     <miklos@...redi.hu>, <amir73il@...il.com>
CC:     <linux-unionfs@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <chengzhihao1@...wei.com>, <yukuai3@...wei.com>
Subject: [PATCH] ovl: nfs_export: Parse index inode's nlink when 'd_inode(lowerdentry)->i_nlink == 1'

For overlayfs mounted by "nfs_export=on", all files/directories will be
indexed regardless of whether 'nlink > 1' satisfies. Following process
may cause breaking hard links on copy up:

  mkdir low upper work merge
  touch low/file
  mount -t overlay over
    -oupperdir=upper,lowerdir=low,workdir=work,nfs_export=on merge
  chmod +x merge/file
  #  Now nlink of upper/file's correspoding index file equals to 2,
     and we have xattr "trusted.overlay.nlink=U-1" on upper/file
  echo 3 > /proc/sys/vm/drop_caches
  # merge/file's nlink changes to 2

For nfs_export enabled overlayfs, don't ignore parsing index inode's nlink
when 'd_inode(lowerdentry)->i_nlink == 1'.

Fixes: f168f1098dd9038 ("ovl: add support for "nfs_export" configuration")
Signed-off-by: Zhihao Cheng <chengzhihao1@...wei.com>
---
 fs/overlayfs/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 5e828a1c98a8..75a61243371c 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -832,7 +832,8 @@ unsigned int ovl_get_nlink(struct ovl_fs *ofs, struct dentry *lowerdentry,
 	char buf[13];
 	int err;
 
-	if (!lowerdentry || !upperdentry || d_inode(lowerdentry)->i_nlink == 1)
+	if (!lowerdentry || !upperdentry ||
+		(!ofs->config.nfs_export && d_inode(lowerdentry)->i_nlink == 1))
 		return fallback;
 
 	err = ovl_do_getxattr(ofs, upperdentry, OVL_XATTR_NLINK,
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ