report size of printk buffer
Subsystems (3)
PATCH 1/1 report size of printk buffer
In the old days the printk log buffer had a constant size, and dmesg asked for the 4096, later 8192, later 16384 bytes in there. These days the printk log buffer has variable size, and it is not easy for dmesg to do the right thing, especially when doing a "read and clear".
The patch below adds a syslog subfuntion that reports the buffer size.
Andries
kernel/printk.c +4 -0
@@ -240,6 +240,7 @@ __setup("log_buf_len=", log_buf_len_setu* 7 -- Enable printk's to console * 8 -- Set level of messages printed to console * 9 -- Return number of unread characters in the log buffer +* 10 -- Return size of the log buffer */ int do_syslog (int type,char __user * buf,int len) {
@@ -359,6 +360,9 @@ int do_syslog(int type, char __user * bucase 9 :/* Number of chars in the log buffer */ error = log_end - log_start;break ; +case 10 :/* Size of the log buffer */ + error = log_buf_len; +break ;default : error = -EINVAL ;break ;
Quoted 8 lines · On 04-May-04, [email protected] wrote:
In the old days the printk log buffer had a constant size, and dmesg asked for the 4096, later 8192, later 16384 bytes in there. These days the printk log buffer has variable size, and it is not easy for dmesg to do the right thing, especially when doing a "read and clear".
The patch below adds a syslog subfuntion that reports the buffer size.[...]
Please also consider allowing everyone to read the ring buffer size. This way dmesg will continue to behave the same for users and root when they read the log buffer. (And other options will continue to be denied to the user.)
Please note that users are already allowed to read the ring buffer (case 3).
Short security analysis:
There is no dynamic information provided. So system behaviour cannot be infered from reading the ring buffer size.
The information provided can already be infered from the architecture and release of the distribution. And there are other methods as well.
security/selinux/hooks.c +1 -0
@@ -1467,6 +1467,7 @@switch (type) {case 3 :/* Read last kernel messages */ +case 10 :/* Return size of the log buffer */ rc =task_has_system (current,SYSTEM__SYSLOG_READ );break ;case 6 :/* Disable logging to console */
security/commoncap.c +1 -1
@@ -293,7 +293,7 @@int cap_syslog (int type) { -if ((type !=3 ) && !capable (CAP_SYS_ADMIN )) +if ((type !=3 && type !=10 ) && !capable (CAP_SYS_ADMIN ))return -EPERM ;return 0 ; }
security/dummy.c +1 -1
@@ -97,7 +97,7 @@static int dummy_syslog (int type) { -if ((type !=3 ) && current->euid) +if ((type !=3 && type !=10 ) && current->euid)return -EPERM ;return 0 ; }
Signature · 1 line
Olaf Dabrunz (od/odabrunz), SUSE Linux AG, Nürnberg
Hi,
Quoted 5 lines · On Tue, 4 May 2004 [email protected] wrote:
In the old days the printk log buffer had a constant size, and dmesg asked for the 4096, later 8192, later 16384 bytes in there. These days the printk log buffer has variable size, and it is not easy for dmesg to do the right thing, especially when doing a "read and clear".
Why don't you simply change it into "read and clear read data"? E.g. something like below.
bye, Roman
Index: kernel/printk.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.6/kernel/printk.c,v retrieving revision 1.1.1.6
kernel/printk.c +1 -1
@@ -305,7 +305,7 @@ int do_syslog(int type, char __user * buif (count > logged_chars) count = logged_chars;if (do_clear) - logged_chars =0 ; + logged_chars -= count; limit = log_end;/* * __put_user() could sleep, and while we sleep
Quoted 21 lines · Roman Zippel
Quoted 5 lines · On Tue, 4 May 2004 [email protected] wrote:
In the old days the printk log buffer had a constant size, and dmesg asked for the 4096, later 8192, later 16384 bytes in there. These days the printk log buffer has variable size, and it is not easy for dmesg to do the right thing, especially when doing a "read and clear".
Why don't you simply change it into "read and clear read data"? E.g. something like below.
bye, Roman
Index:
kernel/printk.c
===================================================================
RCS file:/usr/src/cvsroot/linux-2.6/kernel/printk.c,vretrieving revision 1.1.1.6
diff -u -p -r1.1.1.6printk.c
kernel/printk.c int do_syslog(int type, char __user * bu · line 310
Quoted 7 lines
kernel/printk.c +1
-1@@ -305,7 +305,7 @@ int do_syslog(int type, char __user * buif (count > logged_chars) count = logged_chars;if (do_clear) - logged_chars =0 ; + logged_chars -= count; limit = log_end;/*
No, that is buggy.
If one asks for count bytes, one gets the last count bytes of output, not the first.
Andries
Hi,
Quoted 2 lines · Andries Brouwer
If one asks for count bytes, one gets the last count bytes of output, not the first.
That doesn't answer the question, why don't you just clear the data that was read?
bye, Roman
Quoted 5 lines · Roman Zippel
Quoted 2 lines
If one asks for count bytes, one gets the last count bytes of output, not the first.
That doesn't answer the question, why don't you just clear the data that was read?
Think about it.
The buffer is 131072 bytes. We read the final 16384 bytes. Now what?
[There are other problems as well, but I do not want to start a complicated conversation for a triviality.]