Home | History | Annotate | Download | only in common
History log of /src/sys/compat/linux/common/linux_sysctl.c
RevisionDateAuthorComments
 1.48  10-Jul-2023  christos Add memfd_create(2) from GSoC 2023 by Theodore Preduta
 1.47  23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.46  21-Mar-2020  pgoyette Deal with having to teardown sysctl entries in multiple sub-trees.

(This used to work, but I broke it recently.)
 1.45  16-Mar-2020  pgoyette Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.
 1.44  29-Sep-2017  maxv branches: 1.44.4;
Remove compat_linux from the autoload list, and add a sysctl to enable or
disable it - which defaults to disabled. The following command is now
required to use linux binaries:

sysctl -w emul.linux.enabled=1

After a discussion on tech-kern@. All the other ideas to reduce the attack
surface have drawbacks, and this sysctl seems to be the best option.
 1.43  16-May-2014  martin Get rid of all sysc_init_field uses - initialize fields directly in C99
notation.
 1.42  25-Feb-2014  pooka branches: 1.42.2;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.41  18-Nov-2013  chs claim to be linux 3.11.6 (opensuse 13.1).
 1.40  07-Jul-2010  chs branches: 1.40.8; 1.40.18; 1.40.22;
many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.39  05-Jan-2009  njoly branches: 1.39.4; 1.39.6;
Make sysctl(2) fails with ENOTDIR (instead of EINVAL) for invalid mib
vector length.
 1.38  19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.37  12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.36  18-Jun-2008  tsutsui branches: 1.36.2; 1.36.4;
Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.
 1.35  28-Apr-2008  martin branches: 1.35.2; 1.35.4;
Remove clause 3 and 4 from TNF licenses
 1.34  07-Jan-2008  ad branches: 1.34.6; 1.34.8; 1.34.10;
Patch up sysctl locking:

- Lock processes, credentials, filehead etc correctly.
- Acquire a read hold on sysctl_treelock if only doing a query.
- Don't wire down the output buffer. It doesn't work correctly and the code
regularly does long term sleeps with it held - it's not worth it.
- Don't hold locks other than sysctl_lock while doing copyout().
- Drop sysctl_lock while doing copyout / allocating memory in a few places.
- Don't take kernel_lock for sysctl.
- Fix a number of bugs spotted along the way
 1.33  20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.32  19-Oct-2007  njoly branches: 1.32.2; 1.32.4; 1.32.8;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.31  15-Aug-2007  ad branches: 1.31.2; 1.31.6;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.30  10-May-2007  christos branches: 1.30.2; 1.30.6;
- linux uname -m on x86 returns i{3,4,5,6}86 make it so.
- delete the machine sysctl that never worked, and gc linux_machine.
 1.29  10-May-2007  christos move the #if 0 down a few lines so linux_machine gets initialized. Pointed
out by Joachim K�nig
 1.28  06-May-2007  christos Remove change that obviously was not tested (since it uses LINUX_KERN_VERSION
again, producing EEXIST). There is no machine sysctl in linux that corresponds
to this (at least on my i386 suse box)
 1.27  23-Apr-2007  manu Linux's uname should return x86_64 as machine_arch
 1.26  23-Mar-2007  mrg implement emul.linux.kern.machine, which can be set to "i686", like
some applications seem to want.
 1.25  09-Feb-2007  ad branches: 1.25.2; 1.25.6; 1.25.8; 1.25.10;
Merge newlock2 to head.
 1.24  16-Nov-2006  christos branches: 1.24.2;
__unused removal on arguments; approved by core.
 1.23  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.22  24-Sep-2006  dbj use _KERNEL_OPT instead of _LKM to check whether to include "opt_ktrace.h"
 1.21  24-Sep-2006  dogcow opt_ktrace.h doesn't exist when building LKMs.
 1.20  23-Sep-2006  manu Add sysctl tracing to emulations.
While we are there, fix a bug in FreeBSD sysctl emulation: use copyin for
moving data to the kernel
 1.19  08-Mar-2006  jonathan branches: 1.19.10; 1.19.12;
Rework Linux sysctl()-emulation, so that on amd64, we return the same
Linux kernel-version as on i386 and ppc (currently 2.4.18), and a date
in Feb 2002.

On all other NetBSD platforms we return a Linux-kernel version of
2.0.38 and a date sometime in 2000, which (AFAIK) predates the
existence of amd64, and therefore predates Linux support for amd64.

To me, it makes much more sense to return the same Linux-kernel-version
and date for both 32-bit x86 and 64-bit x86.

Empirically (and not least), this change also allows SuSE 10 amd64
binaries to run under our Linux amd64 binary emulation (both static
and dynamic-linked, given suitable setup) , which they didn't when we
reported a Linux/x86_64 kernel version of 2.0.38.
 1.18  11-Dec-2005  christos branches: 1.18.4; 1.18.6; 1.18.8; 1.18.10;
merge ktrace-lwp.
 1.17  20-Jun-2005  atatat branches: 1.17.2;
Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone. Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
 1.16  25-May-2004  atatat Sysctl descriptions under emul subtree.
 1.15  20-May-2004  atatat Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.

This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.

linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.14  27-Apr-2004  atatat Be consistent about using sysc_init_field()
 1.13  24-Mar-2004  atatat branches: 1.13.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.12  09-Mar-2004  atatat Remove useless comment about stuff that never happened.
 1.11  04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.10  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.9  29-Jun-2003  fvdl branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.8  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.7  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.6  25-Nov-2002  schmonz Report ourselves as Linux 2.4.18 on powerpc, too.
 1.5  04-Apr-2002  tron Set default kernel version of Linux emulation to 2.4.18 on the i386 port.
It has been successfully tested using SuSE 7.3 libraries and binaries with
many applications.
 1.4  02-Apr-2002  jdolecek rename sysctl_linux() to linux_sysctl() and hook it into emul_linux
 1.3  20-Mar-2002  christos emulation specific sysctls. Also change the kernel date to nov 11 as requested
by bad.
 1.2  20-Feb-2002  christos branches: 1.2.2; 1.2.8;
allow writing of kernel.version, kernel.osrelease, kernel.ostype... I might
revert that l8r if I come up with something better.
 1.1  15-Feb-2002  christos s/printf/uprintf/
 1.2.8.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.2  16-Mar-2002  jdolecek Catch up with -current.
 1.2.8.1  20-Feb-2002  jdolecek file linux_sysctl.c was added on branch kqueue on 2002-03-16 16:00:39 +0000
 1.2.2.7  11-Dec-2002  thorpej Sync with HEAD.
 1.2.2.6  29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.2.2.5  17-Apr-2002  nathanw Catch up to -current.
 1.2.2.4  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.3  28-Feb-2002  nathanw LWPify linux_{set/get}rlimit(); move and LWPify linux_sysctl().
 1.2.2.2  28-Feb-2002  nathanw Catch up to -current.
 1.2.2.1  20-Feb-2002  nathanw file linux_sysctl.c was added on branch nathanw_sa on 2002-02-28 04:12:57 +0000
 1.9.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.9.2.2  03-Aug-2004  skrll Sync with HEAD
 1.9.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.13.2.3  26-May-2004  he Pull up revision 1.16 (requested by atatat in ticket #387):
Add sysctl descriptions under emul subtree.
 1.13.2.2  23-May-2004  tron Pull up revision 1.15 (requested by atatat in ticket #374):
Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.
This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.
linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.13.2.1  29-Apr-2004  jmc Pullup rev 1.14 (requested by atatat in ticket #206)

Be consistent about using sysc_init_field()
 1.17.2.6  21-Jan-2008  yamt sync with head
 1.17.2.5  27-Oct-2007  yamt sync with head.
 1.17.2.4  03-Sep-2007  yamt sync with head.
 1.17.2.3  26-Feb-2007  yamt sync with head.
 1.17.2.2  30-Dec-2006  yamt sync with head.
 1.17.2.1  21-Jun-2006  yamt sync with head.
 1.18.10.1  19-Apr-2006  elad sync with head.
 1.18.8.1  13-Mar-2006  yamt sync with head.
 1.18.6.1  22-Apr-2006  simonb Sync with head.
 1.18.4.1  09-Sep-2006  rpaulo sync with head
 1.19.12.2  10-Dec-2006  yamt sync with head.
 1.19.12.1  22-Oct-2006  yamt sync with head
 1.19.10.2  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.19.10.1  18-Nov-2006  ad Sync with head.
 1.24.2.1  29-Apr-2007  bouyer Pull up following revision(s) (requested by manu in ticket #596):
sys/compat/linux/arch/amd64/linux_machdep.h: revision 1.8
sys/compat/linux/common/linux_sysctl.c: revision 1.27
Linux's uname should return x86_64 as machine_arch
 1.25.10.1  29-Mar-2007  reinoud Pullup to -current
 1.25.8.1  11-Jul-2007  mjf Sync with head.
 1.25.6.3  20-Aug-2007  ad Sync with HEAD.
 1.25.6.2  27-May-2007  ad Sync with head.
 1.25.6.1  10-Apr-2007  ad Sync with head.
 1.25.2.3  17-May-2007  yamt sync with head.
 1.25.2.2  07-May-2007  yamt sync with head.
 1.25.2.1  24-Mar-2007  yamt sync with head.
 1.30.6.2  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.30.6.1  16-Aug-2007  jmcneill Sync with HEAD.
 1.30.2.1  03-Sep-2007  skrll Sync with HEAD.
 1.31.6.1  25-Oct-2007  bouyer Sync with HEAD.
 1.31.2.2  09-Jan-2008  matt sync with HEAD
 1.31.2.1  06-Nov-2007  matt sync with HEAD
 1.32.8.2  08-Jan-2008  bouyer Sync with HEAD
 1.32.8.1  02-Jan-2008  bouyer Sync with HEAD
 1.32.4.1  26-Dec-2007  ad Sync with head.
 1.32.2.1  18-Feb-2008  mjf Sync with HEAD.
 1.34.10.3  11-Aug-2010  yamt sync with head.
 1.34.10.2  04-May-2009  yamt sync with head.
 1.34.10.1  16-May-2008  yamt sync with head.
 1.34.8.1  18-May-2008  yamt sync with head.
 1.34.6.3  17-Jan-2009  mjf Sync with HEAD.
 1.34.6.2  29-Jun-2008  mjf Sync with HEAD.
 1.34.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.35.4.1  18-Jun-2008  simonb Sync with head.
 1.35.2.3  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.35.2.2  14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.35.2.1  10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.36.4.1  19-Jan-2009  skrll Sync with HEAD.
 1.36.2.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.39.6.1  05-Mar-2011  rmind sync with head
 1.39.4.1  17-Aug-2010  uebayasi Sync with HEAD.
 1.40.22.1  18-May-2014  rmind sync with head
 1.40.18.2  03-Dec-2017  jdolecek update from HEAD
 1.40.18.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.40.8.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.42.2.1  10-Aug-2014  tls Rebase.
 1.44.4.1  08-Apr-2020  martin Merge changes from current as of 20200406

RSS XML Feed