Index: netbsd32_ioctl.c =================================================================== RCS file: /cvsroot/src/sys/compat/netbsd32/netbsd32_ioctl.c,v retrieving revision 1.110 diff -u -u -r1.110 netbsd32_ioctl.c --- netbsd32_ioctl.c 14 Mar 2020 04:39:15 -0000 1.110 +++ netbsd32_ioctl.c 16 Mar 2020 01:58:54 -0000 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_ioctl.c,v 1.110 2020/03/14 04:39:15 maxv Exp $ */ +/* $NetBSD: netbsd32_ioctl.c,v 1.112 2020/03/16 01:37:51 christos Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.110 2020/03/14 04:39:15 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.112 2020/03/16 01:37:51 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ntp.h" @@ -64,6 +64,11 @@ #include #include +#include +#include +#include +extern const struct cdevsw clockctl_cdevsw __weak; + #ifdef __sparc__ #include #include @@ -1041,13 +1046,30 @@ #ifdef NTP static int -netbsd32_do_clockctl_ntp_adjtime(struct clockctl_ntp_adjtime *args) +netbsd32_do_clockctl_ntp_adjtime(struct file *fp, + struct clockctl_ntp_adjtime *args) { + struct vnode *vp; + struct specnode *sn; + const struct cdevsw *cdev; struct netbsd32_timex ntv32; struct timex ntv; int error; + /* Verify that the file descriptor is is to the clockctl device */ + if (fp->f_type != DTYPE_VNODE) + return EINVAL; + + vp = fp->f_vnode; + if (vp->v_type != VCHR) + return EINVAL; + + sn = vp->v_specnode; + cdev = cdevsw_lookup(sn->sn_rdev); + if (cdev == NULL || cdev != &clockctl_cdevsw) + return EINVAL; + if (vec_ntp_adjtime1 == NULL) return EINVAL; @@ -1469,7 +1491,7 @@ (const struct netbsd32_clockctl_ntp_adjtime *)data32, (struct clockctl_ntp_adjtime *)data, CLOCKCTL_NTP_ADJTIME); - error = netbsd32_do_clockctl_ntp_adjtime( + error = netbsd32_do_clockctl_ntp_adjtime(fp, (struct clockctl_ntp_adjtime *)data); netbsd32_from_clockctl_ntp_adjtime( (const struct clockctl_ntp_adjtime *)data,