Re: CVS commit: src/sys/kern

2021-06-30 Thread David Holland
On Thu, Jul 01, 2021 at 12:25:51AM -0400, Christos Zoulas wrote:
 > Modified Files:
 >  src/sys/kern: vfs_vnops.c
 > 
 > Log Message:
 > don't clear the error before we use it to determine if we are moving or 
 > duping.

oh ffs...

*goes to soak head*

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src

2021-06-30 Thread David Holland
On Wed, Jun 30, 2021 at 06:42:21PM +0900, Rin Okuyama wrote:
 > /home/source/ab/HEAD/src/sys/kern/vfs_vnops.c:357:11: error: 'vp' may be 
 > used uninitialized in this function [-Werror=maybe-uninitialized]
 >   357 |   *ret_vp = vp;
 >   |   ^~~~
 > cc1: all warnings being treated as errors

If this still occurs (may depend on gcc version as usual), the fix is:

Index: sys/kern/vfs_vnops.c
===
RCS file: /cvsroot/src/sys/kern/vfs_vnops.c,v
retrieving revision 1.218
diff -u -p -r1.218 vfs_vnops.c
--- sys/kern/vfs_vnops.c30 Jun 2021 17:51:49 -  1.218
+++ sys/kern/vfs_vnops.c30 Jun 2021 17:53:56 -
@@ -214,8 +214,10 @@ vn_open(struct vnode *at_dvp, struct pat
l->l_dupfd = 0;
 
error = namei();
-   if (error)
+   if (error) {
+   vp = NULL;
goto out;
+   }
 
vp = nd.ni_vp;
 

This is the only remaining path I see that the compiler might
reasonably get confused about.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/external/bsd/compiler_rt/dist/lib/builtins/arm

2021-06-30 Thread Nick Hudson

On 30/06/2021 15:13, Joerg Sonnenberger wrote:

On Tue, Jun 29, 2021 at 11:26:00PM +, Rin Okuyama wrote:

Module Name:src
Committed By:   rin
Date:   Tue Jun 29 23:26:00 UTC 2021

Modified Files:
src/sys/external/bsd/compiler_rt/dist/lib/builtins/arm: aeabi_cfcmp.S
divmodsi4.S divsi3.S modsi3.S

Log Message:
Align sp to 8-byte boundary as required by EABI.


Why not just push/pop another register? That's how it is normally done
for generated code.


https://mail-index.netbsd.org/port-arm/2021/06/30/msg007341.html

Nick


Re: CVS commit: src/sys/external/bsd/compiler_rt/dist/lib/builtins/arm

2021-06-30 Thread Joerg Sonnenberger
On Tue, Jun 29, 2021 at 11:26:00PM +, Rin Okuyama wrote:
> Module Name:  src
> Committed By: rin
> Date: Tue Jun 29 23:26:00 UTC 2021
> 
> Modified Files:
>   src/sys/external/bsd/compiler_rt/dist/lib/builtins/arm: aeabi_cfcmp.S
>   divmodsi4.S divsi3.S modsi3.S
> 
> Log Message:
> Align sp to 8-byte boundary as required by EABI.

Why not just push/pop another register? That's how it is normally done
for generated code.

Joerg


Re: CVS commit: src

2021-06-30 Thread Martin Husemann
On Tue, Jun 29, 2021 at 10:40:54PM +, David A. Holland wrote:
> Module Name:  src
> Committed By: dholland
> Date: Tue Jun 29 22:40:54 UTC 2021
> 
> Modified Files:
>   src/external/cddl/osnet/sys/sys: vnode.h
>   src/share/man/man9: errno.9 vnsubr.9
>   src/sys/dev: firmload.c fss.c kloader.c vnd.c
>   src/sys/kern: kern_acct.c kern_core.c kern_descrip.c kern_ktrace_vfs.c
>   kern_module_vfs.c subr_exec_fd.c subr_kobj_vfs.c tty_ptm.c
>   vfs_syscalls.c vfs_vnops.c
>   src/sys/miscfs/fdesc: fdesc_vnops.c
>   src/sys/modules/lua: lua.c
>   src/sys/sys: filedesc.h vnode.h
>   src/sys/ufs/lfs: ulfs_extattr.c ulfs_quota1.c
>   src/sys/ufs/ufs: ufs_extattr.c ufs_quota1.c
> 
> Log Message:
> Add containment for the cloning devices hack in vn_open.
> 
> Cloning devices (and also things like /dev/stderr) work by allocating
> a struct file, stuffing it in the file table (which is a layer
> violation), stuffing the file descriptor number for it in a magic
> field of struct lwp (which is gross), and then "failing" with one of
> two magic errnos, EDUPFD or EMOVEFD.

bpf seems to be completely broken after this change. At least for me on
amd64 with a monolithic kernel (neither dhcpcd nor wpa_supplicant work).

Martin


Re: CVS commit: src

2021-06-30 Thread Rin Okuyama

Hi,

GCC warns maybe-uninitialized for this commit (for some architectures and
optimization levels: https://releng.netbsd.org/builds/HEAD/202106292250Z/):


/home/source/ab/HEAD/src/sys/kern/vfs_vnops.c: In function 'vn_open':
/home/source/ab/HEAD/src/sys/kern/vfs_vnops.c:357:11: error: 'vp' may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
  357 |   *ret_vp = vp;
  |   ^~~~
cc1: all warnings being treated as errors


Can you please double check and work around if no problem?

Thanks,
rin

On 2021/06/30 7:40, David A. Holland wrote:

Module Name:src
Committed By:   dholland
Date:   Tue Jun 29 22:40:54 UTC 2021

Modified Files:
src/external/cddl/osnet/sys/sys: vnode.h
src/share/man/man9: errno.9 vnsubr.9
src/sys/dev: firmload.c fss.c kloader.c vnd.c
src/sys/kern: kern_acct.c kern_core.c kern_descrip.c kern_ktrace_vfs.c
kern_module_vfs.c subr_exec_fd.c subr_kobj_vfs.c tty_ptm.c
vfs_syscalls.c vfs_vnops.c
src/sys/miscfs/fdesc: fdesc_vnops.c
src/sys/modules/lua: lua.c
src/sys/sys: filedesc.h vnode.h
src/sys/ufs/lfs: ulfs_extattr.c ulfs_quota1.c
src/sys/ufs/ufs: ufs_extattr.c ufs_quota1.c

Log Message:
Add containment for the cloning devices hack in vn_open.

Cloning devices (and also things like /dev/stderr) work by allocating
a struct file, stuffing it in the file table (which is a layer
violation), stuffing the file descriptor number for it in a magic
field of struct lwp (which is gross), and then "failing" with one of
two magic errnos, EDUPFD or EMOVEFD.

Before this commit, all callers of vn_open in the kernel (there are
quite a few) were expected to check for these errors and handle the
situation. Needless to say, none of them except for open() itself did,
resulting in internal negative errnos being returned to userspace.

This hack is fairly deeply rooted and cannot be eliminated all at
once. This commit adds logic to handle the magic errnos inside
vn_open; now on success vn_open returns either a vnode or an integer
file descriptor, along with a flag that says whether the underlying
code requested EDUPFD or EMOVEFD. Callers not prepared to cope with
file descriptors can pass NULL for the extra return values, in which
case if a file descriptor would be produced vn_open fails with
EOPNOTSUPP.

Since I'm rearranging vn_open's signature anyway, stop exposing struct
nameidata. Instead, take three arguments: an optional vnode to use as
the starting point (like openat()), the path, and additional namei
flags to use, restricted to NOCHROOT and TRYEMULROOT. (Other namei
behavior, e.g. NOFOLLOW, can be requested via the open flags.)

This change requires a kernel bump. Ride the one an hour ago.
(That was supposed to be coordinated; did not intend to let an hour
slip by. My fault.)


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/external/cddl/osnet/sys/sys/vnode.h
cvs rdiff -u -r1.5 -r1.6 src/share/man/man9/errno.9
cvs rdiff -u -r1.47 -r1.48 src/share/man/man9/vnsubr.9
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/firmload.c
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/fss.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/kloader.c
cvs rdiff -u -r1.281 -r1.282 src/sys/dev/vnd.c
cvs rdiff -u -r1.97 -r1.98 src/sys/kern/kern_acct.c
cvs rdiff -u -r1.34 -r1.35 src/sys/kern/kern_core.c
cvs rdiff -u -r1.250 -r1.251 src/sys/kern/kern_descrip.c
cvs rdiff -u -r1.2 -r1.3 src/sys/kern/kern_ktrace_vfs.c
cvs rdiff -u -r1.17 -r1.18 src/sys/kern/kern_module_vfs.c
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/subr_exec_fd.c \
 src/sys/kern/subr_kobj_vfs.c
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/tty_ptm.c
cvs rdiff -u -r1.549 -r1.550 src/sys/kern/vfs_syscalls.c
cvs rdiff -u -r1.215 -r1.216 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.137 -r1.138 src/sys/miscfs/fdesc/fdesc_vnops.c
cvs rdiff -u -r1.24 -r1.25 src/sys/modules/lua/lua.c
cvs rdiff -u -r1.68 -r1.69 src/sys/sys/filedesc.h
cvs rdiff -u -r1.296 -r1.297 src/sys/sys/vnode.h
cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/lfs/ulfs_extattr.c
cvs rdiff -u -r1.11 -r1.12 src/sys/ufs/lfs/ulfs_quota1.c
cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ufs/ufs_extattr.c
cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/ufs/ufs_quota1.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.