Commit Graph

538 Commits

Author SHA1 Message Date
riastradh
9fc453562f Round of uvm.h cleanup.
The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
  to query whether curlwp is the pagedaemon, which should maybe be
  exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
  by it.  We should split up uvm_extern.h but this will serve for now
  to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
  UVMHIST(ubchist), since ubchist is declared in uvm.h but the
  reference evaporates if UVMHIST is not defined, so we reduce header
  file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
  here.

ok chs@
2020-09-05 16:30:10 +00:00
christos
bed7e9544b Fix the OTIOCGETD emulation. Line discipline 0 is NTTYDISC. 2020-08-08 19:04:58 +00:00
msaitoh
0be10c48cf Don't accept negative value.
Reported-by: syzbot+e71a77402d6668f1868d@syzkaller.appspotmail.com
2020-07-16 15:02:08 +00:00
christos
c3242d1442 Fix struct entry size (thanks kre@) 2020-06-28 14:37:53 +00:00
jdolecek
039c10d987 reduce stack usage in compat_60_ptmget_ioctl() - allocate struct ptmget
via kmem_alloc()
2020-06-24 17:47:52 +00:00
jdolecek
3e5fbb6583 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
2020-06-24 10:28:16 +00:00
roy
b05648aa26 Remove in-kernel handling of Router Advertisements
This is much better handled by a user-land tool.
Proposed on tech-net here:
https://mail-index.netbsd.org/tech-net/2020/04/22/msg007766.html

Note that the ioctl SIOCGIFINFO_IN6 no longer sets flags. That now
needs to be done using the pre-existing SIOCSIFINFO_FLAGS ioctl.

Compat is fully provided where it makes sense, but trying to turn on
RA handling will obviously throw an error as it no longer exists.

Note that if you use IPv6 temporary addresses, this now needs to be
turned on in dhcpcd.conf(5) rather than in sysctl.conf(5).
2020-06-12 11:04:44 +00:00
ad
0eaaa024ea Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
2020-05-23 23:42:41 +00:00
riastradh
6bf9fb1500 Omit needless #include <sys/rnd.h>. 2020-04-30 03:30:10 +00:00
pgoyette
799a3b19cf When using SYSCTL_SETUP there is no guarantee of the order in which
the set-up functions will be called, so it is perfectly acceptable
for a compat code's routine to be called ahead of the code in other
parts of the kernel.

So make sure that the 2nd level sysctl node ``vfs.generic'' exists
before trying to add the 3rd level entries.

XXX Rather than creating the 2nd level node in two places, we could
XXX add the shared ``vfs.generic'' node to sysctl_init_base.c but
XXX this is left for another day.
2020-03-26 13:39:29 +00:00
pgoyette
3d2be0a63f The compat_50_quota code needs quota support from ufs. Add dependency. 2020-03-09 00:42:36 +00:00
pgoyette
7455fbbd30 Include all of the vfs syscalls in the syscall_package, not just oquota.
Should fix PR kern/55025

XXX pullup-9
2020-02-27 18:19:16 +00:00
pgoyette
e846f6f4a5 Ooppss - SYSCTL_SETUP() functions return void. 2020-02-27 17:42:33 +00:00
pgoyette
72450a671b Remove explicit calls to the sysctl setup routines, since this is now
handled by the module infrastructure.
2020-02-27 16:41:59 +00:00
ad
6bbef11ebd Don't bother with kernel_lock for kern_reboot(). 2020-02-23 15:57:09 +00:00
maxv
11fc230787 pass the address of the field, instead of relying on it being the first
field of the structure, no functional change
2020-02-22 09:42:20 +00:00
maxv
b5b20b3eea Fix copyout overflows in fhstat, found by the LGTM bot. Not a big problem
since this syscall is privileged.
2020-01-31 09:01:23 +00:00
christos
7f15810560 - make sure size is not used uninitialized
- limit size range
- fix type botch for "size"
from maxv@
2020-01-30 14:07:40 +00:00
ad
d1c42b4f7b - Track LWPs in a per-process radixtree. It uses no extra memory in the
single threaded case.  Replace scans of p->p_lwps with lookups in the
  tree.  Find free LIDs for new LWPs in the tree.  Replace the hashed sleep
  queues for park/unpark with lookups in the tree under cover of a RW lock.

- lwp_wait(): if waiting on a specific LWP, find the LWP via tree lookup and
  return EINVAL if it's detached, not ESRCH.

- Group the locks in struct proc at the end of the struct in their own cache
  line.

- Add some comments.
2020-01-29 15:47:51 +00:00
thorpej
79b0645161 Don't reference ifp->if_data directly; use if_export_if_data(). 2020-01-29 05:47:12 +00:00
pgoyette
9d7a921fe1 Split the module glue out from the rest of opencrypto/ocryptodev to
make rump happy.

Rump doesn't have compat modules (the compat code is included in the
relevant librump*.so), so there's no module compat_50 listed in
link_set_modules, and thus ocryptodev's MODULE(...) can't "require"
it.

This fixes the problem of "built-in module compat_50 not found" when
starting up rump_allserver (or rump_server with -l rumpdev_opencrypto).

XXX This does not resolve the long-standing "crypto: unable to
XXX register devsw, error 17" message noted at line 78 of
XXX sys/rump/dev/lib/libopencrypto/opencrypto_component.c
2020-01-27 17:09:17 +00:00
pgoyette
320866888c Since this used to be part of the compat_50 module, make it depend on
compat_50 rather than compat_60 module.
2020-01-22 23:41:29 +00:00
pgoyette
09a5fcaf68 Split the compat_50 module into two, separating the QUOTA-related
stuff from the rest of the module.  This allows loading of the
(main) compat_50 module on kernels that don't include ``options
QUOTA''.

Welcome to 9.99.40 !

Addresses PR kern/54875
2020-01-21 02:37:16 +00:00
ad
c2e9cb9413 VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode.  Matches
FreeBSD.
2020-01-17 20:08:06 +00:00
pgoyette
4e7fb68a54 Resurrect boottime, but only in the compat_90 module (whether built-in
or separately loaded).  This will enable running of old vmstat(1) images
on newer kernels.
2020-01-04 02:40:22 +00:00
thorpej
d6c967bb85 - Eliminate the global "boottime" variable, which was being accessed
without any synchronization against changes by e.g. clock_settime().
- Replace with new getbinboottime() / getnanoboottime() / getmicroboottime()
  functions (naming mirrors that of other time access functions in kern_tc.c).
  It returns the (maybe-converted) value of timebasebin, which also tracks
  our estimate of when the system was booted (i.e. the legacy "boottime" was
  redundant).

XXX There needs to be a lockless synchronization mechanism for reading
timebasebin, but this is a problem in kern_tc.c that pre-existed these
"boottime" changes.  At least now the problem is centralized in one location.
2020-01-02 15:42:26 +00:00
thorpej
599c240526 - Introduce a new global kernel variable "shutting_down" to indicate that
the system is shutting down or rebooting.
- Set this global in a new function called kern_reboot(), which is currently
  just a basic wrapper around cpu_reboot().
- Call kern_reboot() instead of cpu_reboot() almost everywhere; a few
  places remain where it's still called directly, but those are in early
  pre-main() machdep locations.

Eventually, all of the various cpu_reboot() functions should be re-factored
and common functionality moved to kern_reboot(), but that's for another day.
2020-01-01 22:57:16 +00:00
pgoyette
6865a3028c Emove vestigial remains of the monolithic compat module. 2020-01-01 19:35:21 +00:00
maxv
8822fe6d97 Fix three stack info leaks, found by kMSan when just invoking all syscalls
with a zero page as argument.

MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb32' From compat_20_netbsd32_getfsstat()
MSan: Uninitialized Stack Memory In copyout() At Offset 12, Variable 'oss' From compat_43_sys_sigstack()
MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb' From compat_50_netbsd32___fhstat40()
2020-01-01 14:52:38 +00:00
pgoyette
7e5e70ef9c For the built-in COMPAT_30 module code, make sure to initialize the
uipc_syscalls_30 stuff, notably to include compat_30_socket().

PR kern/54804

XXX Pullup-9 XXX
2019-12-28 15:39:52 +00:00
tsutsui
1e72df6a03 Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
2019-12-15 16:48:25 +00:00
pgoyette
8a031a1d1e Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
2019-12-12 02:15:42 +00:00
maxv
48d18df02a Fix a bunch of unimportant "Local variable hides global variable" warnings
from the LGTM bot.
2019-12-06 08:35:21 +00:00
pgoyette
7b0f5c9e07 Convert the sendsig_sigcontext_16 function pointer to use the new
compat_hook mechanism.

XXX Despite being a kernel<-->module abi change, this should be
XXX pulled up to -9
2019-11-10 13:28:06 +00:00
christos
800dbef3ae Don't ignore EBUSY from disestablish or we can crash by unloading busy
syscalls.
2019-10-28 23:32:15 +00:00
msaitoh
62266216d2 Make clog static. Found by lgtm bot. 2019-10-04 05:48:11 +00:00
christos
c8863f455b deduplicate the conversion function from statvfs -> statfs12 2019-10-04 01:28:02 +00:00
pgoyette
423739174a Since we now have a compat_90 module, the compat_80 module should depend
on it.
2019-10-03 19:56:16 +00:00
pgoyette
ccc3f35b62 Actually return the updated pointer-to-mbuf-pointer to the caller
rather than discarding-after-assignment.  Introduced from the
[pgoyette-compat] branch work.

Welcome to 9.99.14 !!!  (Module hook routine prototype changed.)

Found by the lgtm bot, reported via private Email from maxv@
2019-09-27 00:32:03 +00:00
christos
535ba13aa8 fix sign-compare issues. 2019-09-26 01:28:27 +00:00
maxv
c07e170550 Remove unused assignment. Found by the lgtm bot. 2019-09-23 06:53:09 +00:00
christos
02cdd248ec Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
2019-09-22 22:59:37 +00:00
kamil
68ab6f5a50 Validate usec ranges in compat_50_sys_select()
Later in the code selcommon() checks for proper timespec, check only
correct usec of timeval before type conversions.
2019-09-20 15:05:22 +00:00
kamil
3c0a7f49e5 Drop unused retval pointer from do_sys_mknod{,at}()
No functional change intended.
2019-06-18 22:34:25 +00:00
christos
21723bf302 Add QUOTA ifdef (Paul Goyette) 2019-06-17 14:59:15 +00:00
pgoyette
194cbb504c Use tabs, not spaces, for indentation. NFCI 2019-06-17 14:13:13 +00:00
christos
f7d8c70c63 If we don't compile a kernel with QUOTA, we don't support the compat quota
syscalls. XXX: need to fix the modules build.
2019-06-17 12:27:40 +00:00
msaitoh
bf354a0797 The max subtype of the ifmedia word is 31. It's too small for Ethernet now.
We currently use use it up to 30. We should extend the limit to be able to use
more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem
so we should redesign the interface, but it's too late for netbsd-9 to do it.
So, we keep the data structure size and modify the structure a bit. The
strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet
have not used, so use some of them for Ethernet's subtype.

The differences against FreeBSD are:
 - We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA).
 - FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though
   IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15".
 - FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should
   not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH()
   macro for matching both TYPE and SUBTYPE.
 - Added up to 400GBASE-SR16.

New layout of the media word is as follows (from ifmedia_h):

 * if_media Options word:
 *	Bits	Use
 *	----	-------
 *	0-4	Media subtype	MAX SUBTYPE == 255 for ETH and 31 for others
 *	5-7	Media type
 *	8-15	Type specific options
 *	16-18	Mode (for multi-mode devices)
 *	19	(Reserved for Future Use)
 *	20-27	Shared (global) options
 *	28-31	Instance
 *
 *   3                     2                   1
 *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
 *  +-------+---------------+-+-----+---------------+-----+---------+
 *  |       |               |R|     |               |     |         |
 *  | IMASK |     GMASK     |F|MMASK+-----+ OMASK   |NMASK|  TMASK  |
 *  |       |               |U|     |XTMSK|         |     |         |
 *  +-------+---------------+-+-----+-----+---------+-----+---------+
 *   <----->                   <--->                 <--->
 *  IFM_INST()               IFM_MODE()            IFM_TYPE()
 *
 *                              IFM_SUBTYPE(other than ETH)<------->
 *
 *                                   <---> IFM_SUBTYPE(ETH)<------->
 *
 *
 *           <------------->         <------------->
 *                        IFM_OPTIONS()
2019-05-17 07:37:11 +00:00
roy
2e9156b7e4 Introduce rt_addrmsg_src which adds RTA_AUTHOR to the message.
Use this when we notify userland of a duplicate address
and set RTA_AUTHOR to the hardware address of the sender.

While here, match the logging diagnostic of INET6 to the simpler one
of INET so it's consistent.
2019-04-29 16:12:30 +00:00
roy
4af7afb834 rtsock: Route address message simplification
Rename rt_newaddrmsg to rt_addrmsg_rt.
Add rt_addrmsg which drops the error and route arguments which are only
needed by one caller.
2019-04-29 11:57:22 +00:00