On Wed, May 11, 2022 at 11:20:15AM +0300, Vitaliy Makkoveev wrote:
> sys_umask() only modifies `fd_cmask', which modification is already
> protected by `fd_lock' rwlock(9).

I found this in sys/filedesc.h

        u_short fd_cmask;               /* [f/w] mask for file creation */
        u_short fd_refcnt;              /* [K] reference count */

We have two short variables that are protected by different locks.
I think 16 bit values are not MP independent on all architectures.

When one CPU modifies the lower 16 bit and another CPU writes to
the higher 16 bit the result in the full 32 bit is not defined.
This is at least my understanding.

I have seen problems in real live with two shorts when one 16 bit
part was changed without spl protection and the other 16 bits were
written by interrupt.

Should we convert them to u_int?

bluhm

> Index: sys/kern/syscalls.master
> ===================================================================
> RCS file: /cvs/src/sys/kern/syscalls.master,v
> retrieving revision 1.223
> diff -u -p -r1.223 syscalls.master
> --- sys/kern/syscalls.master  24 Feb 2022 07:41:51 -0000      1.223
> +++ sys/kern/syscalls.master  11 May 2022 08:14:59 -0000
> @@ -146,7 +146,7 @@
>                           char *buf, size_t count); }
>  59   STD             { int sys_execve(const char *path, \
>                           char * const *argp, char * const *envp); }
> -60   STD             { mode_t sys_umask(mode_t newmask); }
> +60   STD NOLOCK      { mode_t sys_umask(mode_t newmask); }
>  61   STD             { int sys_chroot(const char *path); }
>  62   STD             { int sys_getfsstat(struct statfs *buf, size_t bufsize, 
> \
>                           int flags); }

Reply via email to