Commit 62834c28 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Yang Yingliang
Browse files

ovl: fix WARN_ON nlink drop to zero



mainline inclusion
from mainline-5.7-rc1
commit 83552eac
category: bugfix
bugzilla: 37632
CVE: NA

---------------------------

Changes to underlying layers should not cause WARN_ON(), but this repro
does:

 mkdir w l u mnt
 sudo mount -t overlay -o workdir=w,lowerdir=l,upperdir=u overlay mnt
 touch mnt/h
 ln u/h u/k
 rm -rf mnt/k
 rm -rf mnt/h
 dmesg

 ------------[ cut here ]------------
 WARNING: CPU: 1 PID: 116244 at fs/inode.c:302 drop_nlink+0x28/0x40

After upper hardlinks were added while overlay is mounted, unlinking all
overlay hardlinks drops overlay nlink to zero before all upper inodes
are unlinked.

After unlink/rename prevent i_nlink from going to zero if there are still
hashed aliases (i.e. cached hard links to the victim) remaining.

Reported-by: default avatarPhasip <phasip@gmail.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>

Conflicts:
	fs/overlayfs/dir.c
	[ Non bugfix patch 0e32992f("ovl: remove the 'locked'
	  argument of ovl_nlink_{start,end}") removed all locked
	  arg is not applied. ]

Signed-off-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: default avatarzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 682c799b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment