diff options
author | Dmitry Chagin <dchagin@FreeBSD.org> | 2023-06-13 12:24:25 +0000 |
---|---|---|
committer | Dmitry Chagin <dchagin@FreeBSD.org> | 2023-06-13 12:24:25 +0000 |
commit | cea7c564c70aa660d833e9a571aaca4119c0b714 (patch) | |
tree | c63b13501db0e373121046f2905f44c8d266a623 | |
parent | 861abdadf9db4dd7ba577537ba262fcda29869dd (diff) | |
download | src-cea7c564c70aa660d833e9a571aaca4119c0b714.tar.gz src-cea7c564c70aa660d833e9a571aaca4119c0b714.zip |
namei: Reset the lookup to start from the real root for abs symlink target
Since fd745e1d Linux ABI specifies alternative root directory to reroot
lookups. First, an attempt is made to lookup the file in /ABI/original-path.
If that fails, the lookup is done in /original-path. In case of lookup
symbolic link with leading / in target namei() fails due to reroot reloads
original file name.
To avoid this handle restart in a special maner, without origin path name
reloading.
Reported by: Goran Mekić, Vincent Milum Jr
Tested by: Goran Mekić
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D40479
-rw-r--r-- | sys/kern/vfs_lookup.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 20919fb38b4d..dd6282a45d97 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -721,6 +721,14 @@ restart: */ cnp->cn_nameptr = cnp->cn_pnbuf; if (*(cnp->cn_nameptr) == '/') { + /* + * Reset the lookup to start from the real root without + * origin path name reloading. + */ + if (__predict_false(ndp->ni_rootdir != pwd->pwd_rdir)) { + cnp->cn_flags |= ISRESTARTED; + ndp->ni_rootdir = pwd->pwd_rdir; + } vrele(dp); error = namei_handle_root(ndp, &dp); if (error != 0) |