curedump configuration additions
Subsystems (4)
Hi,
I have added some configuration options to the coredump abilities of the kernel. Please can this patch be considered for addition to the kernel.
I have added three sysctl variables which control the 'features' I have added. These are:
kernel.coredump_enabled
kernel.coredump_log
kernel.coredump_file_name
The first two are 'boolean' options which control if the creation of core files is globally enabled and if corefile generation if logged respectively.
The third option controls the filename of the coredump. It allows the use of a few tokens within the filename.
Please find the patch below and attached for convenience. This is a diff against a 2.4.4 kernel.
Many thanks
mike
--
Documentation/sysctl/kernel.txt +60 -0
@@ -41,6 +41,9 @@ - shmmax [ sysv ipc ] - version - zero-paged [ PPC only ] +- coredump_enabled +- coredump_file_name +- coredump_log ==============================================================
@@ -226,3 +229,60 @@ the idle loop, possibly speeding up get_free_pages. Since this only affects what the idle loop is doing, you should enable this and see if anything changes. + +============================================================== + +coredump_enabled: + +When enabled (which is the default), Linux will produce +coredumps. This mimics the previous behavior. Coredumps +will not be produced if processes have had their coredump +limit set. + +If disabled, no coredumps will be produced at all. This is +useful for systems where increased security is needed so +that coredumps are not produced, or for systems where coredumps +are unwanted due to disk space shortages. I'm sure there are +other reasons why you would want to disable coredumps too... + +============================================================== + +coredump_file_name: + +Coredump filenames are now configurable using this sysctl. + +For starters, to set the variable to emulate previous behavior (which +is still the default) you need to do: + sysctl -w kernel.coredump_filename=core + +The filename can either be a relative or absolute filename. The filename +can contain meta characters which will be expanded when the corefile is +written. The meta characters are: + + %c which is expanded to the process's command name + %p which is expanded to the process's PID + %u which is expanded to the process's UID + %U which is expanded to the process's EUID + %g which is expanded to the process's GID + %G which is expanded to the process's EGID + +Note that this is a global setting, so all coredumps are affected by +this. A future modification would be to enable per process coredump +parameters. + +============================================================== + +coredump_log: + +This controls if coredumps get logged by the kernel. Note that even +if coredump_enabled=0, you can still log attempts to generate a coredump. + +This sysctl variable is useful on machines which may be targets of hacking. +Hackers may cause a process to crash and generate a coredump. This option +allows such events to be logged, and hopefully alert sysadmins to hack +attempts. + +The default is to log coredumps. + +============================================================== +
fs/exec.c +72 -7
120 lines not on this page · raw message
include/linux/sysctl.h +4 -1
@@ -118,7 +118,10 @@KERN_SHMPATH =48 ,/* string: path to shm fs */ KERN_HOTPLUG =49 ,/* string: path to hotplug policy agent */ KERN_IEEE_EMULATION_WARNINGS =50 ,/* int: unimplemented ieee instructions */ - KERN_S390_USER_DEBUG_LOGGING=51 /* int: dumps of user faults */ +KERN_S390_USER_DEBUG_LOGGING =51 ,/* int: dumps of user faults */ +KERN_COREDUMP_ENABLED =52 ,/* are coredumps enabled on this system */ +KERN_COREDUMP_FILE_NAME =53 ,/*file name format of coredump files */ + KERN_COREDUMP_LOG=54 /*should coredumps get logged */ };
kernel/sysctl.c +11 -0
@@ -16,6 +16,8 @@* Wendling. * The list_for_each() macro wasn't appropriate for the sysctl loop. * Removed it and replaced it with older style, 03/23/00, Bill Wendling +* Added coredump_enable, coredump_log, coredump_file_name 2001/05/05, +* Michael Miller */ #include <linux/config.h>
@@ -47,6 +49,9 @@extern int max_threads;extern int nr_queued_signals, max_queued_signals;extern int sysrq_enabled; +extern int coredump_enabled; +extern int coredump_log; +extern char coredump_file_name[];/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ static int maxolduid =65535 ;
@@ -249,6 +254,12 @@ {KERN_S390_USER_DEBUG_LOGGING,"userprocess_debug", &sysctl_userprocess_debug,sizeof(int),0644,NULL,&proc_dointvec}, #endif + {KERN_COREDUMP_ENABLED,"coredump_enabled",&coredump_enabled, + sizeof(int), 0644, NULL, &proc_dointvec}, + {KERN_COREDUMP_FILE_NAME,"coredump_file_name",&coredump_file_name,256, + 0644,NULL,&proc_dostring, &sysctl_string}, + {KERN_COREDUMP_LOG,"coredump_log",&coredump_log, + sizeof(int), 0644, NULL, &proc_dointvec}, {0} };
Documentation/sysctl/kernel.txt +60 -0
69 lines not on this page · raw message
fs/exec.c +72 -7
120 lines not on this page · raw message
include/linux/sysctl.h +4 -1
@@ -118,7 +118,10 @@KERN_SHMPATH =48 ,/* string: path to shm fs */ KERN_HOTPLUG =49 ,/* string: path to hotplug policy agent */ KERN_IEEE_EMULATION_WARNINGS =50 ,/* int: unimplemented ieee instructions */ - KERN_S390_USER_DEBUG_LOGGING=51 /* int: dumps of user faults */ +KERN_S390_USER_DEBUG_LOGGING =51 ,/* int: dumps of user faults */ +KERN_COREDUMP_ENABLED =52 ,/* are coredumps enabled on this system */ +KERN_COREDUMP_FILE_NAME =53 ,/*file name format of coredump files */ + KERN_COREDUMP_LOG=54 /*should coredumps get logged */ };
kernel/sysctl.c +11 -0
@@ -16,6 +16,8 @@* Wendling. * The list_for_each() macro wasn't appropriate for the sysctl loop. * Removed it and replaced it with older style, 03/23/00, Bill Wendling +* Added coredump_enable, coredump_log, coredump_file_name 2001/05/05, +* Michael Miller */ #include <linux/config.h>
@@ -47,6 +49,9 @@extern int max_threads;extern int nr_queued_signals, max_queued_signals;extern int sysrq_enabled; +extern int coredump_enabled; +extern int coredump_log; +extern char coredump_file_name[];/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ static int maxolduid =65535 ;
@@ -249,6 +254,12 @@ {KERN_S390_USER_DEBUG_LOGGING,"userprocess_debug", &sysctl_userprocess_debug,sizeof(int),0644,NULL,&proc_dointvec}, #endif + {KERN_COREDUMP_ENABLED,"coredump_enabled",&coredump_enabled, + sizeof(int), 0644, NULL, &proc_dointvec}, + {KERN_COREDUMP_FILE_NAME,"coredump_file_name",&coredump_file_name,256, + 0644,NULL,&proc_dostring, &sysctl_string}, + {KERN_COREDUMP_LOG,"coredump_log",&coredump_log, + sizeof(int), 0644, NULL, &proc_dointvec}, {0} };
Quoted 4 lines · Michael Miller
Hi,
I have added some configuration options to the coredump abilities of the kernel. Please can this patch be considered for addition to the kernel.
Hi, just wanted to recommend that this goes in, in one form or another - it would help a lot around here. Today we have to manually "fix" the kernel source to get proper core.[executable] naming of core dumps.
I haven't looked at the patch though. I don't know if it meets the standards, but the functionaly it provides (or was meant to provide) would definitely be a
life-saver for me. And it would put an end to the quarrels about core dump
naming :)
Thanks,
Signature · 6 lines
................................................................ : [email protected] : And I see the elder races, : :.........................: putrid forms of man : : Jakob Østergaard : See him rise and claim the earth, : : OZ9ABN : his downfall is at hand. : :.........................:............{Konkhra}...............:
Quoted 2 lines · =?iso-8859-1?Q?Jak writes:
Hi, just wanted to recommend that this goes in, in one form or another - it would help a lot around here.
Yes, it looks very nice. The codes match those used by ps even.
Quoted 2 lines
Today we have to manually "fix" the kernel
source to get proper core.[executable] naming of core dumps.
That is just wrong. What about when "tar" dumps core? It will overwrite my /usr/src/linux/net/core backup.
On Sat, May 05, 2001 at 08:55:09PM +0100, Michael Miller wrote:
kernel.coredump_enabled
man ulimit
kernel.coredump_file_name
man file
I really don't see that either of these are required... am I missing something?
--cw
Quoted 2 lines · Michael Miller
(quoted diff) +2
-0+coredump_enabled: +When enabled (which is the default), Linux will produce
[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+coredump_log: +The default is to log coredumps.
The default looks like an effective way to DoS logging, fill system partition fast.
Nice other optional feature would be for development, debug, QA point of view to be able to dump set[ug]id or apps that changed its uid or gid, ala kern.sugid_coredump (FreeBSD)
kern.nosuidcoredump (OpenBSD)allow_setid_core (Solaris)
etc.
Szaka
Hi.
I have added
kernel.coredump_suid_enabled
which will allow the generation of core dumps for SUID processes. (Defaults to off).
Also I changed the default logging to off, as suggested to avoid a posible DOS.
Finally I have changed the logging messages to include EUID and EGID if different from UID/GID.
I am keen to try to create a similar feature set to Solaris's coreadm, but at this stage I am not sure of how would be best to go about doing this...
Adding a
/proc/${PID}/coredump
file perhaps- the the kernel source seems to indicate this would be a bad thing to do...
Try to implement some new syscalls perhaps? That sounds quite complex to me... Also, would involve using a usermode program to interface... I'd prefer being able to cat something into /proc
any advise would be greatly appreciated.
attached please find the new patch i
(PS: is an attachment prefered or simply put the patch in the message?) Mike
Quoted 16 lines
Hi,
I have added some configuration options to the coredump abilities of the kernel. Please can this patch be considered for addition to the kernel.
I have added three sysctl variables which control the 'features' I have added. These are:
kernel.coredump_enabled
kernel.coredump_log
kernel.coredump_file_nameThe first two are 'boolean' options which control if the creation of core files is globally enabled and if corefile generation if logged respectively.
Quoted 9 lines
The third option controls the filename of the coredump. It allows the use of a few tokens within the filename.
Please find the patch below and attached for convenience. This is a diff against a 2.4.4 kernel.
Many thanks
mike
Documentation/sysctl/kernel.txt +69 -0
@@ -41,6 +41,10 @@ - shmmax [ sysv ipc ] - version - zero-paged [ PPC only ] +- coredump_enabled +- coredump_file_name +- coredump_log +- coredump_suid_enabled ==============================================================
@@ -226,3 +230,68 @@ the idle loop, possibly speeding up get_free_pages. Since this only affects what the idle loop is doing, you should enable this and see if anything changes. + +============================================================== + +coredump_enabled: + +When enabled (which is the default), Linux will produce +coredumps. This mimics the previous behavior. Coredumps +will not be produced if processes have had their coredump +limit set. + +If disabled, no coredumps will be produced at all. This is +useful for systems where increased security is needed so +that coredumps are not produced, or for systems where coredumps +are unwanted due to disk space shortages. I'm sure there are +other reasons why you would want to disable coredumps too... + +============================================================== + +coredump_file_name: + +Coredump filenames are now configurable using this sysctl. + +For starters, to set the variable to emulate previous behavior (which +is still the default) you need to do: + sysctl -w kernel.coredump_filename=core + +The filename can either be a relative or absolute filename. The filename +can contain meta characters which will be expanded when the corefile is +written. The meta characters are: + + %c which is expanded to the process's command name + %p which is expanded to the process's PID + %u which is expanded to the process's UID + %U which is expanded to the process's EUID + %g which is expanded to the process's GID + %G which is expanded to the process's EGID + +Note that this is a global setting, so all coredumps are affected by +this. A future modification would be to enable per process coredump +parameters. + +============================================================== + +coredump_log: + +This controls if coredumps get logged by the kernel. Note that even +if coredump_enabled=0, you can still log attempts to generate a coredump. + +This sysctl variable is useful on machines which may be targets of hacking. +Hackers may cause a process to crash and generate a coredump. This option +allows such events to be logged, and hopefully alert sysadmins to hack +attempts. + +The default is not to log coredumps. + +============================================================== + +coredump_suid_enabled: + +This controls if coredumps are generated for SUID programs. + +The default is to not generate core dumps for SUID programs. + +============================================================== +
fs/exec.c +84 -8
135 lines not on this page · raw message
include/linux/sysctl.h +5 -1
@@ -118,7 +118,11 @@KERN_SHMPATH =48 ,/* string: path to shm fs */ KERN_HOTPLUG =49 ,/* string: path to hotplug policy agent */ KERN_IEEE_EMULATION_WARNINGS =50 ,/* int: unimplemented ieee instructions */ - KERN_S390_USER_DEBUG_LOGGING=51 /* int: dumps of user faults */ +KERN_S390_USER_DEBUG_LOGGING =51 ,/* int: dumps of user faults */ +KERN_COREDUMP_ENABLED =52 ,/* are coredumps enabled on this system */ +KERN_COREDUMP_FILE_NAME =53 ,/*file name format of coredump files */ +KERN_COREDUMP_LOG =54 ,/*should coredumps get logged */ + KERN_COREDUMP_SUID_ENABLED=55 /* are suid coredumps enabled */ };
kernel/sysctl.c +14 -0
@@ -16,6 +16,8 @@* Wendling. * The list_for_each() macro wasn't appropriate for the sysctl loop. * Removed it and replaced it with older style, 03/23/00, Bill Wendling +* Added coredump_enable, coredump_log, coredump_file_name 2001/05/05, +* Michael Miller */ #include <linux/config.h>
@@ -47,6 +49,10 @@extern int max_threads;extern int nr_queued_signals, max_queued_signals;extern int sysrq_enabled; +extern int coredump_enabled; +extern int coredump_log; +extern char coredump_file_name[]; +extern int coredump_suid_enabled;/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ static int maxolduid =65535 ;
@@ -249,6 +255,14 @@ {KERN_S390_USER_DEBUG_LOGGING,"userprocess_debug", &sysctl_userprocess_debug,sizeof(int),0644,NULL,&proc_dointvec}, #endif + {KERN_COREDUMP_ENABLED,"coredump_enabled",&coredump_enabled, + sizeof(int), 0644, NULL, &proc_dointvec}, + {KERN_COREDUMP_FILE_NAME,"coredump_file_name",&coredump_file_name,256, + 0644,NULL,&proc_dostring, &sysctl_string}, + {KERN_COREDUMP_LOG,"coredump_log",&coredump_log, + sizeof(int), 0644, NULL, &proc_dointvec}, + {KERN_COREDUMP_SUID_ENABLED,"coredump_suid_enabled", + &coredump_suid_enabled,sizeof(int), 0644, NULL, &proc_dointvec}, {0} };