tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ptrace modularization



With the recent introduction of the compat_netbsd32_ptrace module (thanks, Nick!) I would like to complete the modularization of ptrace functionality.

My proposal includes the following:

1. Introduce a new ptrace module which contains the ptrace methods for
   the native emulation.  This would be very similar to what Nick did
   for compat_netbsd32_ptrace.  The existing "options PTRACE" would
   continue to include this code as a built-in module.  The
   syscalls_master file would be updated to mark the native ptrace(2)
   syscall modular.

2. Introduce a new ptrace_common module which, in essence, contains the
   do_sys_ptrace() code.  The compat_netbsd32_ptrace module and the new
   module from #1 would both "require" the ptrace_common module.  As
   with #1, "options PTRACE" would include this as a built-in module.

3. There are still a few places where #ifdef PTRACE controls some
   in-line code.  All of these would be changed to #ifdef PTRACE_HOOKS
   and sys/conf/std would be updated to include "options PTRACE_HOOKS"
   in addition to "options PTRACE".

4. The ptrace_common module will need to have some mechanism to "probe"
   the kernel for inclusion of the PTRACE_HOOKS code - perhaps a new
   boolean sysctl kern.ptrace should be introduced?

For default kernels which have everything "built-in", the only change would be the new sysctl variable from #4, and the existence of a couple new built-in modules; ptrace_init() would be called differently, as a result of module initialization rather than directly from init_main().

For custom kernels, inclusion of "no options PTRACE" would exclude the syscall code (for common, native_emul, and compat_netbsd32 cases) from the kernel. If a process were to call ptrace(2), the code would be auto-loaded in the same manner as any other modular syscall. (Auto-loading the module can be controlled via the presence of a "noautoload" entry in the module's plist/prop_dictionary, while still retaining the ability to manually load the module.)

If "no options PTRACE_HOOKS" is used, then the auto-load will fail (the module will detect the absence of the hooks, and its xxx_modcmd() will return an error).


Comments?  Suggestions?



+------------------+--------------------------+------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+


Home | Main Index | Thread Index | Old Index