Fix handling of embedded symbolic links (and history lesson).

Sponsored by: Netflix

(cherry picked from commit 9a2fac6ba6)
This commit is contained in:
Kirk McKusick 2021-05-16 17:02:42 -07:00
parent 43acee0cdd
commit 57d877348b
4 changed files with 5 additions and 8 deletions

View file

@ -4403,7 +4403,8 @@ DB_SHOW_COMMAND(mount, db_show_mount)
mp->mnt_lazyvnodelistsize);
db_printf(" mnt_writeopcount = %d (with %d in the struct)\n",
vfs_mount_fetch_counter(mp, MNT_COUNT_WRITEOPCOUNT), mp->mnt_writeopcount);
db_printf(" mnt_maxsymlinklen = %d\n", mp->mnt_maxsymlinklen);
db_printf(" mnt_maxsymlinklen = %jd\n",
(uintmax_t)mp->mnt_maxsymlinklen);
db_printf(" mnt_iosize_max = %d\n", mp->mnt_iosize_max);
db_printf(" mnt_hashseed = %u\n", mp->mnt_hashseed);
db_printf(" mnt_lockref = %d (with %d in the struct)\n",

View file

@ -222,7 +222,7 @@ struct mount {
int mnt_writeopcount; /* (i) write syscalls pending */
struct vfsoptlist *mnt_opt; /* current mount options */
struct vfsoptlist *mnt_optnew; /* new options passed to fs */
int mnt_maxsymlinklen; /* max size of short symlink */
uint64_t mnt_maxsymlinklen; /* max size of short symlink */
struct statfs mnt_stat; /* cache of filesystem stats */
struct ucred *mnt_cred; /* credentials of mounter */
void * mnt_data; /* private data */

View file

@ -329,9 +329,7 @@ ffs_truncate(vp, length, flags, cred)
}
if ((flags & IO_NORMAL) == 0)
return (0);
if (vp->v_type == VLNK &&
(ip->i_size < vp->v_mount->mnt_maxsymlinklen ||
datablocks == 0)) {
if (vp->v_type == VLNK && ip->i_size < vp->v_mount->mnt_maxsymlinklen) {
#ifdef INVARIANTS
if (length != 0)
panic("ffs_truncate: partial truncate of symlink");

View file

@ -2458,10 +2458,8 @@ ufs_readlink(ap)
doff_t isize;
isize = ip->i_size;
if ((isize < vp->v_mount->mnt_maxsymlinklen) ||
DIP(ip, i_blocks) == 0) { /* XXX - for old fastlink support */
if (isize < vp->v_mount->mnt_maxsymlinklen)
return (uiomove(SHORTLINK(ip), isize, ap->a_uio));
}
return (VOP_READ(vp, ap->a_uio, 0, ap->a_cred));
}