* [PATCH] report size of printk buffer
@ 2004-05-04 16:09 Andries.Brouwer
2004-05-05 13:12 ` Olaf Dabrunz
2004-05-05 20:42 ` Roman Zippel
0 siblings, 2 replies; 6+ messages in thread
From: Andries.Brouwer @ 2004-05-04 16:09 UTC (permalink / raw)
To: akpm, torvalds; +Cc: linux-kernel
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
diff -uprN -X /linux/dontdiff a/kernel/printk.c b/kernel/printk.c
--- a/kernel/printk.c 2004-03-28 17:11:55.000000000 +0200
+++ b/kernel/printk.c 2004-05-04 18:00:27.000000000 +0200
@@ -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 * bu
case 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;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] report size of printk buffer
2004-05-04 16:09 [PATCH] report size of printk buffer Andries.Brouwer
@ 2004-05-05 13:12 ` Olaf Dabrunz
2004-05-05 20:42 ` Roman Zippel
1 sibling, 0 replies; 6+ messages in thread
From: Olaf Dabrunz @ 2004-05-05 13:12 UTC (permalink / raw)
To: linux-kernel; +Cc: Andries.Brouwer
On 04-May-04, Andries.Brouwer@cwi.nl 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 2004-05-04 16:36:25.000000000 +0200
+++ ./security/selinux/hooks.c 2004-05-04 16:36:27.000000000 +0200
@@ -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 2004-05-04 17:26:08.758271491 +0200
+++ ./security/commoncap.c 2004-05-04 17:25:05.256269096 +0200
@@ -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 2004-05-04 16:36:38.000000000 +0200
+++ ./security/dummy.c 2004-05-04 16:34:22.000000000 +0200
@@ -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;
}
--
Olaf Dabrunz (od/odabrunz), SUSE Linux AG, Nürnberg
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] report size of printk buffer
2004-05-04 16:09 [PATCH] report size of printk buffer Andries.Brouwer
2004-05-05 13:12 ` Olaf Dabrunz
@ 2004-05-05 20:42 ` Roman Zippel
2004-05-06 13:36 ` Andries Brouwer
1 sibling, 1 reply; 6+ messages in thread
From: Roman Zippel @ 2004-05-05 20:42 UTC (permalink / raw)
To: Andries.Brouwer; +Cc: akpm, torvalds, linux-kernel
Hi,
On Tue, 4 May 2004 Andries.Brouwer@cwi.nl 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
diff -u -p -r1.1.1.6 printk.c
--- a/kernel/printk.c 11 Mar 2004 18:34:55 -0000 1.1.1.6
+++ b/kernel/printk.c 5 May 2004 20:39:05 -0000
@@ -305,7 +305,7 @@ int do_syslog(int type, char __user * bu
if (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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] report size of printk buffer
2004-05-05 20:42 ` Roman Zippel
@ 2004-05-06 13:36 ` Andries Brouwer
2004-05-06 15:11 ` Roman Zippel
0 siblings, 1 reply; 6+ messages in thread
From: Andries Brouwer @ 2004-05-06 13:36 UTC (permalink / raw)
To: Roman Zippel; +Cc: Andries.Brouwer, akpm, torvalds, linux-kernel
On Wed, May 05, 2004 at 10:42:10PM +0200, Roman Zippel wrote:
> On Tue, 4 May 2004 Andries.Brouwer@cwi.nl 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
> diff -u -p -r1.1.1.6 printk.c
> --- a/kernel/printk.c 11 Mar 2004 18:34:55 -0000 1.1.1.6
> +++ b/kernel/printk.c 5 May 2004 20:39:05 -0000
> @@ -305,7 +305,7 @@ int do_syslog(int type, char __user * bu
> if (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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] report size of printk buffer
2004-05-06 13:36 ` Andries Brouwer
@ 2004-05-06 15:11 ` Roman Zippel
2004-05-06 15:23 ` Andries Brouwer
0 siblings, 1 reply; 6+ messages in thread
From: Roman Zippel @ 2004-05-06 15:11 UTC (permalink / raw)
To: Andries Brouwer; +Cc: akpm, torvalds, linux-kernel
Hi,
On Thu, 6 May 2004, Andries Brouwer wrote:
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] report size of printk buffer
2004-05-06 15:11 ` Roman Zippel
@ 2004-05-06 15:23 ` Andries Brouwer
0 siblings, 0 replies; 6+ messages in thread
From: Andries Brouwer @ 2004-05-06 15:23 UTC (permalink / raw)
To: Roman Zippel; +Cc: Andries Brouwer, akpm, torvalds, linux-kernel
On Thu, May 06, 2004 at 05:11:26PM +0200, Roman Zippel wrote:
> > 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.]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-05-06 15:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-04 16:09 [PATCH] report size of printk buffer Andries.Brouwer
2004-05-05 13:12 ` Olaf Dabrunz
2004-05-05 20:42 ` Roman Zippel
2004-05-06 13:36 ` Andries Brouwer
2004-05-06 15:11 ` Roman Zippel
2004-05-06 15:23 ` Andries Brouwer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox