Commit Graph

538 Commits

Author SHA1 Message Date
pgoyette
c166c1c602 Move the set-up of the net.oroute... sysctl tree to compat_50 since
the new AF_ROUTE was introduced in NetBSD-6.0
2019-04-29 08:31:29 +00:00
pgoyette
aa343ec34c For the rtsock compat code, make sure we create the "oroute" sysctl
tree.  Otherwise a 5.2 version of getifaddrs(2) gets errors.

This makes the 5.2 version of ifconfig(8) behave the same on both
NetBSD-8 and -current.  HOWEVER, both of them print nothing (for
``ifconfig -l'' command) so there's still a bug somewhere.

As reported originally by der Mouse.
2019-04-29 05:42:09 +00:00
msaitoh
e19818fbdb KNF. No functional change. 2019-04-23 07:45:06 +00:00
christos
b52554b0d5 Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
2019-04-18 17:45:12 +00:00
msaitoh
2a1efa7be4 KNF. No functional change. 2019-04-17 09:21:57 +00:00
msaitoh
d6117c1651 Rename ifreqo2n() and ifreqo2n() to IFREQO2N_43() and IFREQN2O_43():
- ifreqo2n() and ifreqn2o() are for COMPAT_43, so add _43 to the name.
 - Uppercase to make it clear those are macros.
2019-04-16 04:31:42 +00:00
pgoyette
a17761b205 Clean up this mess and simplify, so that all the socket options get
handled correctly whether or not the compat_50 module is loaded.
2019-04-15 10:53:17 +00:00
pgoyette
68c01b4b73 Split the COMPAT_50 socket-timeout stuff out of kern/uipc_socket.c
and into its own source file, which is now included in the compat_50
module.

(Not sure how this got missed during the original [pgoyette-compat] work)
2019-04-15 02:07:11 +00:00
pgoyette
7757535d97 Only need to #include sys/vnode.h once 2019-04-14 11:35:54 +00:00
pgoyette
8c2f80f160 Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
2019-03-01 11:06:55 +00:00
pgoyette
c1283e70fa Normalize all the compat hooks' names to the form
<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
2019-01-29 09:28:50 +00:00
pgoyette
d35e644178 Rename the if43_20_hook to if43_cvtcmd_20_hook 2019-01-29 04:10:10 +00:00
pgoyette
88446f58e4 The if43_20_hook function returns an errno; use it to determine whether
to allow conversion of the ioctl cmd --> ncmd

Should address issue reported by msaitoh@ on irc as well as via e-mail
from Patrick Welche and Ryo ONODERA.
2019-01-29 04:01:45 +00:00
christos
40fd447032 - Don't expose random data conversion functions, but expose the high level
entry point (such as ioctl) instead.
- Attempt to autoload the module before using it.

Naming: Should the names of the hooks be:
    <category>_<version>_<function>_hook_t
or:
    <category>_<function>_<version>_hook_t

We should make those consistent.
2019-01-28 21:13:58 +00:00
christos
c3850d5f86 - provide a hook for the 43 tty ioctls
- make the 60 tty ioctl hook look the same
- fix the tty code to call both hooks and remove unused lock
2019-01-28 15:46:49 +00:00
pgoyette
fd56c8ff4f Include new header from correct directory 2019-01-27 21:25:24 +00:00
christos
8c89d50112 - autoload the compat_80 for modstat
- move compat struct to a compat header
2019-01-27 18:29:10 +00:00
christos
90ff083305 make this compile again (enable #if 0 code) 2019-01-27 03:00:48 +00:00
pgoyette
d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00
riastradh
1c1a78241c Paranoia: zero COMPAT_30 ntptimeval and 32-bit ntptimeval too.
These structs don't have padding but safer to keep the code
structured the same way between the various ntp_gettimes in case
anyone makes more copypasta of it for future updates.
2018-10-30 14:43:38 +00:00
riastradh
cc8a85962e Zero ntptimeval50 too to prevent 4-byte kernel stack disclosure.
From Thomas Barabosch of Fraunhofer FKIE.

XXX pullup-7, pullup-8 (along with rev. 1.60 of kern_ntptime.c)
2018-10-30 14:35:16 +00:00
msaitoh
621f6a129f Fix a bug that SIOC[GZ]IFDATA returned old ifreq structure. 2018-09-12 02:24:25 +00:00
maxv
f922b0f6bd Remove the network ATM code. 2018-09-06 06:41:59 +00:00
riastradh
d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
christos
a2d8a0afcb use the standard rules, instead of rolling our own. 2018-06-05 00:58:17 +00:00
christos
c50a4e606c - Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Revert :Q to work as before.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@
XXX: pullup 8
2018-05-27 01:14:50 +00:00
nonaka
bfd90ae7d7 Added missing ifi_link_state at compat_50_rt_oifmsg() and compat_50_iflist(). 2018-05-10 09:33:46 +00:00
pgoyette
b42bc35ca8 Clean up a stray #ifdef _MODULE - it prevented definition of
COMPAT_SIGCONTEXT which in turn prevented building of the
SYS_compat16_sigaction_14 code.

Should address PR kern/53260

XXX Pull-up to netbsd-8
2018-05-04 08:55:25 +00:00
christos
331cb3c9dd Fix COMPAT_NETBSD32 cmsg handling:
1. alignment was wrong for > 1 message
2. macros were doing incorrect pointer comparisons, fortunately ending
   the iteration early after the fists cmsg instead of crashing.
3. don't output 32 bit ktrace records for cmsg. 32 bit programs running
   under emulation on 64 bit systems should produce 64 bit ktrace records
   so that the native ktrace can handle the records; remove extra arguments
   that are now not needed (the 32 bit msghdr).
4. output the correct type for cmsg trace records.
5. output all the cmsg records in traces instead of just the first one.

Welcome to 8.99.15 because of the argument removal.

XXX: Really all the code should be changed to use the CMSG_{FIRST,NXT}HDR
macros...
2018-05-03 21:43:33 +00:00
roy
e3e276e2f2 Test for valid interface for ioctls that demand it.
Thanks to Robert Swindells for the patch.
2018-04-26 08:11:18 +00:00
christos
93433845a4 If we are modular, allow us to use modules for compat; don't load all the
compat code in.
2018-04-12 20:36:59 +00:00
christos
061fe5a110 provide vectors for the ifconf compat code and ifdatareq compat code. 2018-04-12 18:50:13 +00:00
martin
de52eb4819 XXX stub it completely for now to make it compile 2018-03-19 13:26:02 +00:00
christos
16ebd747ed XXX: don't reference the global for now so that kernels without ccd build. 2018-03-19 13:04:01 +00:00
christos
2256e8d4b1 remove another error decl. 2018-03-19 00:21:50 +00:00
christos
664f132ddf remove error decl 2018-03-18 23:26:38 +00:00
christos
6c5623dc1b - use the conditional from the header file
- fix compilation
2018-03-18 23:22:15 +00:00
pgoyette
17d316f55e Declare 'error' if needed 2018-03-18 22:48:00 +00:00
christos
e634efa8ef factor out the ccd COMPAT_60 code. 2018-03-18 20:33:52 +00:00
christos
4ca63f4c79 include compat/sys/cpuio.h and multiple include protection. 2018-03-18 04:10:39 +00:00
christos
cf143c3723 finish MD glue for compat ucode module. 2018-03-18 00:51:45 +00:00
christos
ab151d3e85 redo the cpu ucode compat code. 2018-03-17 19:00:23 +00:00
christos
8cb1b0010b PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken
The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.
2018-03-16 17:25:04 +00:00
christos
cf6b63b172 add uvm swap compat code. 2018-03-15 03:13:51 +00:00
maya
854802fe20 Pass LDFLAGS to ld.
Without this, mips64-ld thinks we want to link our n64 objects with the
default ABI, n32.
2017-12-20 04:46:19 +00:00
maxv
e9069ab139 compat_util.c must be compiled by default in the kernel. It is needed by
generic non-compat code, so it must not depend on anything (libcompat or
whatever option we choose to associate it to).
2017-12-16 10:15:12 +00:00
maxv
cd4e50d80d Build these functions regardless of whether COMPAT_50 or COMPAT_70 are
enabled. They must be there, because they are needed in rtsock.c even
when no compat option is enabled.
2017-12-16 09:10:30 +00:00
maxv
b1fa3d10bb Build libcompat as an object, not as a library. We want all of its
functions compiled in, because compat modules loaded from the filesystem
may depend on them.
2017-12-16 08:31:36 +00:00
mrg
56320bfe05 remove check for netbsd 1.5 without 5.0. it doesn't happen. 2017-12-16 07:59:14 +00:00
christos
6d44e11a08 Make code look the same, in particular zero out the rest of the directory
record.
XXX: pullup-8
2017-12-03 15:23:30 +00:00
martin
3f44d155bc #idef the label next_ifa: just like the only goto using it. 2017-11-22 15:25:34 +00:00
ozaki-r
a78ad86cbf Fix and make consistent of usages of psz/psref in ifconf variants 2017-11-22 10:19:14 +00:00
maxv
7f006e6030 typos 2017-08-04 09:33:03 +00:00
riastradh
37bfd4eb93 Kill needless nested extern of vec_compat_cvtcmd/ioctl.
Already declared in if_43.h.
2017-07-29 04:08:47 +00:00
riastradh
cf25436d17 Declare mountcompatnames in sys/vfs_syscalls.h to kill nested extern. 2017-07-29 04:02:49 +00:00
riastradh
39f1e86852 Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.

From Ilja Van Sprundel.
2017-07-28 15:34:06 +00:00
christos
001c3fa330 remove extra S 2017-04-29 13:25:27 +00:00
christos
1dd20c251a move MAP_COPY in compat 2017-04-29 01:15:40 +00:00
hannken
8fd5bc95f8 Switch compat_20_sys_getfsstat() to mountlist iterator. 2017-04-13 09:41:28 +00:00
ozaki-r
0eaf4e5356 Use if_acquire and if_release instead of using psref API directly
- Provide if_release for consistency to if_acquire
- Use if_acquire and if_release for ifp iterations
- Make ifnet_psref_class static
2017-03-14 09:03:08 +00:00
christos
a2e94ed719 use bdp, to avoid compiler warning. 2017-01-13 22:29:59 +00:00
christos
d352a1f1ba convert strcpy to a bounded copy to avoid compiler warnings, although the
reclen test prevents overflow.
2017-01-13 20:58:59 +00:00
christos
fb2eabe89d convert strcpy to a bounded copy to avoid compiler warnings, although the
reclen test prevents overflow.
2017-01-13 20:24:37 +00:00
pgoyette
94bd54f794 Move if_43.c back into the shared Makefile.sysio where it really
belongs.

Update the code to invoke the two routines compat_cvtcmd() and
compat_ifioctl() through indirect pointers.  Initialize those
pointers in sys/net/if.c and update them in the compat module's
initialization code.

Addresses the issue pointed out in PR kern/51598
2016-11-05 23:30:22 +00:00
pgoyette
d671bf9bca Move if_43.c out of Makefile.sysio and into the main Makefile.
The former location gets included in both libcompat and the compat
module, leading to redefined symbols when the module is loaded.  By
moving it to the main Makefile, it gets included only in libcompat.

XXX This still isn't an ideal solution, but it will suffice until
XXX PR kern/51598 is addressed.
2016-11-03 22:23:03 +00:00
pgoyette
9f1344db25 Hmmm, if we omit if_43.c from the SRCS list, then we break the i386
build for one of the XEN kernels.

Adding it back to the list.  At least the build will be successful.

XXX This is probably not the end of this saga, as we still have the
XXX redefined-symbol issue when loading the compat module on amd64.
XXX But for now, a working build for the vast majority of users
XXX (including our automated test suites) is more important than a
XXX successfully-loadable compat module.
2016-11-03 11:32:15 +00:00
pgoyette
2cc02dd108 Really comment out if_43.c this time. (I need sleep and/or caffeine.) 2016-11-03 06:54:08 +00:00
pgoyette
67c9692b56 Use proper characgter to introduce comments! 2016-11-03 06:28:04 +00:00
pgoyette
f54cbfd20b if_43.o gets included from libcompat automatically, due to two calls
to compat_cvtcmd() in if.c.  Ideally, if.c would be modified to have
a pointer to a no-op compat_cvtcmd() and that pointer would get
replaced by compat_modcmd(MODULE_CMD_INIT, ...) code.  But for now,
just don't include it in the compat module at all.
2016-11-03 06:22:29 +00:00
riastradh
2903f566e2 Reorganize SRCS lists for libcompat, compat.kmod, sysv_ipc.kmod.
- Share lists between the libcompat and module makefiles.
- Include some omitted entries in compat.kmod:
  . if_43.c
  . kern_sa_60.c
  . kern_time_30.c
  . rndpseudo_50.c
  . rtsock_14.c
  . rtsock_50.c
  . rtsock_70.c
  . uipc_syscalls_40.c
  . uipc_syscalls_50.c
- Exclude a (harmless) spurious entry in sysv_ipc.kmod on LP64 systems:
  . kern_ipc_10.c

Should fix broken ifconfig on modular current kernels.

ok pgoyette
2016-11-03 04:26:58 +00:00
riastradh
00d7b5f1e4 Sprinkle #ifdef _KERNEL_OPT. 2016-11-03 03:37:06 +00:00
roy
98b0d70fff Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.
2016-09-21 10:50:22 +00:00
martin
1766e4eee1 Make the ktrace record written by do_sys_sendmsg/do_sys_recvmsg overridable
by the caller. Use this in compat_netbsd32 to log the 32bit version, so
the 32bit userland kdump is happy.
2016-09-13 07:01:07 +00:00
mrg
1d6ce431db fill in the tv_nsec parts of the converted timespec in cvtstat(). 2016-08-20 00:34:42 +00:00
ozaki-r
a403cbd4f5 Apply pserialize and psref to struct ifaddr and its variants
This change makes struct ifaddr and its variants (in_ifaddr and in6_ifaddr)
MP-safe by using pserialize and psref. At this moment, pserialize_perform
and psref_target_destroy are disabled because (1) we don't need them
because of softnet_lock (2) they cause a deadlock because of softnet_lock.
So we'll enable them when we remove softnet_lock in the future.
2016-08-01 03:15:30 +00:00
ozaki-r
3a0f73376f Apply if_get/if_put to compat_ifioctl 2016-07-25 08:30:19 +00:00
ozaki-r
9e4c2bda8a Switch the address list of intefaces to pslist(9)
As usual, we leave the old list to avoid breaking kvm(3) users.
2016-07-07 09:32:01 +00:00
ozaki-r
e1135cd9b9 Use curlwp_bind and curlwp_bindx instead of open-coding LP_BOUND 2016-06-16 02:38:40 +00:00
ozaki-r
040205ae93 Protect ifnet list with psz and psref
The change ensures that ifnet objects in the ifnet list aren't freed during
list iterations by using pserialize(9) and psref(9).

Note that the change adds a pslist(9) for ifnet but doesn't remove the
original ifnet list (ifnet_list) to avoid breaking kvm(3) users. We
shouldn't use the original list in the kernel anymore.
2016-05-12 02:24:16 +00:00
roy
bb67ec8f00 Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.
2016-04-06 19:45:45 +00:00
mrg
65f5251eae remove a bunch of "@echo done" from the tail of rules. these messages
were vaguely useful back when we didn't run make -j, but now you end
up with a single line "done" every so often, with no idea what it is
for.  very few other targets claim they're done so just remove these.
2016-03-22 08:25:22 +00:00
christos
8cc2b02f1c PR/50947: David Binderman: sprinkle parens 2016-03-11 18:32:29 +00:00
pgoyette
8285edda53 Modularize the clockctl pseudo-device and link to the build. 2015-12-07 03:25:57 +00:00
pgoyette
5d8b2e34a2 The COMPAT_10 code for SYSVxxx is now part of the sysv_ipc module, so
don't install syscall function pointers from the compat module.
2015-12-05 01:59:51 +00:00
pgoyette
65fae32d98 Merge the compat_sysv module into the sysv_ipc module - it should
never have been a separate module in the first place (my bad).

Adjust dependencies as appropriate.
2015-12-03 02:51:00 +00:00
pgoyette
0bc066df68 Add comment to #ifdef - it's a long way from its original #if 2015-12-03 00:28:55 +00:00
maxv
ea498aca7e Change do_sys_mount() so that it only takes as argument the type of the
drive instead of its associated vfsops. Makes it more friendly, and allows
compat binaries to autoload VFS modules if needed.

sent on tech-kern@, ok christos@
2015-10-23 19:40:10 +00:00
christos
e2746c9719 Handle both ioctls in both places :-) 2015-10-22 15:18:25 +00:00
uebayasi
ea72de740f Order library object build. 2015-09-07 03:44:19 +00:00
uebayasi
9068ec741b Sprinkle more done messages. 2015-09-07 03:20:18 +00:00
uebayasi
dd204a345e In kernel lib build, print message when things not only start bug also end. 2015-09-06 15:34:55 +00:00
pooka
d8e04c9094 to garnish, dust with _KERNEL_OPT 2015-08-24 22:50:32 +00:00
maxv
6647020bbc Unused inits (harmless).
Found by Brainy.
2015-07-24 13:02:52 +00:00
njoly
fc005ae43f Handle case where compat_ifioctl() is called with ocmd != cmd, as found in
compat Linux. Do not crash by ensuring that oifr is correctly set.

Fix crash reported by Robert Swindells on tech-kern@.
2015-07-11 07:43:32 +00:00
pgoyette
9681555f60 The compat_sysv module now depends on sysv_ipc module. 2015-05-13 02:08:20 +00:00
christos
6ebc227033 rump is compiled with COMPAT_OSOCK not COMPAT_OIFREQ and the code in if.c
is not handling this case properly. Make this work by checking again if
we need to convert struct ifreq here, and if we do, we do it ourselves.
2015-05-12 20:42:46 +00:00
pgoyette
0caf2564d1 Fix the #ifdef _MODULE stuff so that the syscall packages and sysctl stuff
gets handled properly even in built-in module case.

XXX
Whatever was I thinking when I put those conditionals in?  And wouldn't it
be a wonderful thing to have some atf regression tests to actually catch
errors in the compat{,_sysv} modules?   :)
2015-05-11 10:32:13 +00:00
pgoyette
ff00f0b594 Split the SYSV* compat code out into a separate compat_sysv module.
For monolithic kernels, both modules will be compiled as "built-ins",
while modular environments will be able to load the SYSVSEM, SYSVSHM,
and SYSVMSG code independant from the rest of compat.

This is a necessary precursor step to making the "STD" SYSV* code
into a separate module.

Tested in both monolithic and modular environments with no errors
seen.
2015-05-10 07:41:15 +00:00
ozaki-r
1d0321acf8 Tweak ifconf variants
The tweaks make the code intention clear and make further changes easy.

No functional change.
2014-11-26 09:53:53 +00:00
maxv
eda7c7bbe4 Do not uselessly include <sys/malloc.h>. 2014-11-09 17:48:07 +00:00