Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat remove special handling for symbolic links for CO...
details: https://anonhg.NetBSD.org/src/rev/efeaa4f54497
branches: trunk
changeset: 935082:efeaa4f54497
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Wed Jun 24 10:28:16 2020 +0000
description:
remove special handling for symbolic links for COMPAT_43 lstat, it's
not necessary; this removes the only places in kernel which did namei
LOOKUP with LOCKPARENT
fixes diagnostic KASSERT() in namei() code
Reported-by: syzbot+628382ecf1438e53d08d%syzkaller.appspotmail.com@localhost
diffstat:
sys/compat/common/vfs_syscalls_43.c | 64 +++-------------------------------
sys/compat/sunos32/sunos32_misc.c | 67 +++---------------------------------
2 files changed, 14 insertions(+), 117 deletions(-)
diffs (189 lines):
diff -r 0e70fc25c50c -r efeaa4f54497 sys/compat/common/vfs_syscalls_43.c
--- a/sys/compat/common/vfs_syscalls_43.c Wed Jun 24 10:07:13 2020 +0000
+++ b/sys/compat/common/vfs_syscalls_43.c Wed Jun 24 10:28:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls_43.c,v 1.65 2020/02/27 18:19:16 pgoyette Exp $ */
+/* $NetBSD: vfs_syscalls_43.c,v 1.66 2020/06/24 10:28:16 jdolecek Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.65 2020/02/27 18:19:16 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.66 2020/06/24 10:28:16 jdolecek Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -179,69 +179,19 @@
syscallarg(char *) path;
syscallarg(struct ostat *) ub;
} */
- struct vnode *vp, *dvp;
- struct stat sb, sb1;
+ struct stat sb;
struct stat43 osb;
int error;
- struct pathbuf *pb;
- struct nameidata nd;
- int ndflags;
- error = pathbuf_copyin(SCARG(uap, path), &pb);
- if (error) {
+ error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &sb);
+ if (error)
return error;
- }
- ndflags = NOFOLLOW | LOCKLEAF | LOCKPARENT | TRYEMULROOT;
-again:
- NDINIT(&nd, LOOKUP, ndflags, pb);
- if ((error = namei(&nd))) {
- if (error == EISDIR && (ndflags & LOCKPARENT) != 0) {
- /*
- * Should only happen on '/'. Retry without LOCKPARENT;
- * this is safe since the vnode won't be a VLNK.
- */
- ndflags &= ~LOCKPARENT;
- goto again;
- }
- pathbuf_destroy(pb);
- return (error);
- }
/*
- * For symbolic links, always return the attributes of its
+ * For symbolic links, BSD4.3 returned the attributes of its
* containing directory, except for mode, size, and links.
+ * This is no longer emulated, the parent directory is not consulted.
*/
- vp = nd.ni_vp;
- dvp = nd.ni_dvp;
- pathbuf_destroy(pb);
- if (vp->v_type != VLNK) {
- if ((ndflags & LOCKPARENT) != 0) {
- if (dvp == vp)
- vrele(dvp);
- else
- vput(dvp);
- }
- error = vn_stat(vp, &sb);
- vput(vp);
- if (error)
- return (error);
- } else {
- error = vn_stat(dvp, &sb);
- vput(dvp);
- if (error) {
- vput(vp);
- return (error);
- }
- error = vn_stat(vp, &sb1);
- vput(vp);
- if (error)
- return (error);
- sb.st_mode &= ~S_IFDIR;
- sb.st_mode |= S_IFLNK;
- sb.st_nlink = sb1.st_nlink;
- sb.st_size = sb1.st_size;
- sb.st_blocks = sb1.st_blocks;
- }
cvtstat(&sb, &osb);
error = copyout((void *)&osb, (void *)SCARG(uap, ub), sizeof (osb));
return (error);
diff -r 0e70fc25c50c -r efeaa4f54497 sys/compat/sunos32/sunos32_misc.c
--- a/sys/compat/sunos32/sunos32_misc.c Wed Jun 24 10:07:13 2020 +0000
+++ b/sys/compat/sunos32/sunos32_misc.c Wed Jun 24 10:28:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunos32_misc.c,v 1.83 2019/10/26 11:34:48 christos Exp $ */
+/* $NetBSD: sunos32_misc.c,v 1.84 2020/06/24 10:28:17 jdolecek Exp $ */
/* from :NetBSD: sunos_misc.c,v 1.107 2000/12/01 19:25:10 jdolecek Exp */
/*
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.83 2019/10/26 11:34:48 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.84 2020/06/24 10:28:17 jdolecek Exp $");
#define COMPAT_SUNOS 1
@@ -294,72 +294,19 @@
syscallarg(const netbsd32_charp) path;
syscallarg(netbsd32_stat43p_t) ub;
} */
- struct vnode *vp, *dvp;
- struct stat sb, sb1;
+ struct stat sb;
struct netbsd32_stat43 sb32;
int error;
- struct pathbuf *pb;
- struct nameidata nd;
- int ndflags;
- const char *path;
- path = SCARG_P32(uap, path);
-
- ndflags = NOFOLLOW | LOCKLEAF | LOCKPARENT | TRYEMULROOT;
-again:
- error = pathbuf_copyin(path, &pb);
- if (error) {
+ error = do_sys_stat(SCARG_P32(uap, path), NOFOLLOW, &sb);
+ if (error)
return error;
- }
- NDINIT(&nd, LOOKUP, ndflags, pb);
- if ((error = namei(&nd))) {
- pathbuf_destroy(pb);
- if (error == EISDIR && (ndflags & LOCKPARENT) != 0) {
- /*
- * Should only happen on '/'. Retry without LOCKPARENT;
- * this is safe since the vnode won't be a VLNK.
- */
- ndflags &= ~LOCKPARENT;
- goto again;
- }
- return (error);
- }
/*
- * For symbolic links, always return the attributes of its
+ * For symbolic links, SunOS returned the attributes of its
* containing directory, except for mode, size, and links.
+ * This is no longer emulated, the parent directory is not consulted.
*/
- vp = nd.ni_vp;
- dvp = nd.ni_dvp;
- pathbuf_destroy(pb);
- if (vp->v_type != VLNK) {
- if ((ndflags & LOCKPARENT) != 0) {
- if (dvp == vp)
- vrele(dvp);
- else
- vput(dvp);
- }
- error = vn_stat(vp, &sb);
- vput(vp);
- if (error)
- return (error);
- } else {
- error = vn_stat(dvp, &sb);
- vput(dvp);
- if (error) {
- vput(vp);
- return (error);
- }
- error = vn_stat(vp, &sb1);
- vput(vp);
- if (error)
- return (error);
- sb.st_mode &= ~S_IFDIR;
- sb.st_mode |= S_IFLNK;
- sb.st_nlink = sb1.st_nlink;
- sb.st_size = sb1.st_size;
- sb.st_blocks = sb1.st_blocks;
- }
sunos32_from___stat13(&sb, &sb32);
error = copyout((void *)&sb32, SCARG_P32(uap, ub), sizeof (sb32));
return (error);
Home |
Main Index |
Thread Index |
Old Index