From: Michael Halcrow <mhalcrow@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, Chris Wright <chrisw@osdl.org>,
Serge Hallyn <serue@us.ibm.com>,
mhalcrow@us.ibm.com
Subject: Re: [updated patch 1/7] BSD Secure Levels: printk overhaul
Date: Thu, 19 May 2005 15:55:25 -0500 [thread overview]
Message-ID: <20050519205525.GB16215@halcrow.us> (raw)
In-Reply-To: <20050517152303.GA2814@halcrow.us>
On Thu, May 19, 2005 at 12:39:45PM +0200, Bernd Petrovitsch wrote:
> On Wed, 2005-05-18 at 18:29 -0700, Dave Hansen wrote:
> > On Tue, 2005-05-17 at 10:23 -0500, Michael Halcrow wrote:
> [...]
> > > @@ -198,15 +196,15 @@
> > > static int seclvl_sanity(int reqlvl)
> > > {
> > > if ((reqlvl < -1) || (reqlvl > 2)) {
> > > - seclvl_printk(1, KERN_WARNING, "Attempt to set seclvl out of "
> > > - "range: [%d]\n", reqlvl);
> > > + seclvl_printk(1, KERN_WARNING "%s: Attempt to set seclvl out "
> > > + "of range: [%d]\n", __FUNCTION__, reqlvl);
> >
> > Instead of changing each and every seclvl_printk() call to add
> > __FUNCTION__, why not do this:
> >
> > +static void __seclvl_printk(int verb, const char *fmt, ...)
> > ...
> >
> > #define seclvl_printk(verb, fmt, arg...) \
> > __seclvl_printk(verb, __FUNCTION__ ": " fmt, arg)
> >
> > It requires that the fmt be a string literal, but it saves a lot
> > of code
> > duplication. I'm sure there are some more examples of this around
> > as
>
> And it duplicates identical format strings in different functions
> (besides violating another unwritten rule). What about:
> ---- snip ----
> #define seclvl_printk(verb, fmt, arg...) \
> __seclvl_printk((verb), "%s: " fmt, __FUNCTION__, arg)
> ---- snip ----
More than one person has mentioned to me that global rate limiting
does not make as much sense as per message rate limiting. The
original macro ate up a bit of text area. The non-patched module
occupies 22701 bytes in my build. The recent patch, which rate-limits
globally, results in a module size of 18443. This patch, which
rate-limits on a per message basis, results in a module size of
20733.
Signed-off by: Michael Halcrow <mhalcrow@us.ibm.com
Index: linux-2.6.12-rc4-mm2-seclvl/security/seclvl.c
===================================================================
--- linux-2.6.12-rc4-mm2-seclvl.orig/security/seclvl.c 2005-05-19 15:44:25.000000000 -0500
+++ linux-2.6.12-rc4-mm2-seclvl/security/seclvl.c 2005-05-19 15:49:02.000000000 -0500
@@ -102,21 +102,32 @@
#define MY_NAME "seclvl"
/**
- * This time-limits log writes to one per second.
+ * This time-limits log writes to one per second for every message
+ * type.
*/
-#define seclvl_printk(verb, type, fmt, arg...) \
- do { \
- if (verbosity >= verb) { \
- static unsigned long _prior; \
- unsigned long _now = jiffies; \
- if ((_now - _prior) > HZ) { \
- printk(type "%s: %s: " fmt, \
- MY_NAME, __FUNCTION__ , \
- ## arg); \
- _prior = _now; \
- } \
- } \
- } while (0)
+static void
+__seclvl_printk(unsigned long *_prior, int verb, const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ unsigned long _now = jiffies;
+ if (time_after(_now, (*_prior) + HZ)) {
+ vprintk(fmt, args);
+ }
+ *_prior = _now;
+ va_end(args);
+}
+
+/**
+ * Breaking the printk up into a macro and a function saves some text
+ * space.
+ */
+#define seclvl_printk(verb, type, fmt, arg...) \
+ if (verbosity >= verb ) { \
+ static unsigned long _prior; \
+ __seclvl_printk(&_prior, (verb), type "%s: " fmt, \
+ __FUNCTION__, ## arg); \
+ }
/**
* kobject stuff
@@ -711,7 +722,7 @@
goto exit;
}
seclvl_printk(0, KERN_INFO, "seclvl: Successfully initialized.\n");
- exit:
+ exit:
if (rc) {
printk(KERN_ERR "seclvl: Error during initialization: rc = "
"[%d]\n", rc);
next prev parent reply other threads:[~2005-05-19 20:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-17 15:23 [patch " Michael Halcrow
2005-05-17 15:25 ` [patch 2/7] BSD Secure Levels: move bd claim from inode to filp Michael Halcrow
2005-05-17 16:09 ` Christoph Hellwig
2005-05-17 16:49 ` Al Viro
2005-05-17 16:57 ` Al Viro
2005-05-17 19:46 ` Michael Halcrow
2005-05-17 20:13 ` Al Viro
2005-05-17 15:26 ` [patch 3/7] BSD Secure Levels: allow suid and sgid on directories Michael Halcrow
2005-05-17 15:27 ` [patch 4/7] BSD Secure Levels: memory alloc failure check Michael Halcrow
2005-05-17 17:27 ` Alexey Dobriyan
2005-05-17 15:30 ` [patch 5/7] BSD Secure Levels: allow setuid/setgid on root user processes Michael Halcrow
2005-05-17 15:31 ` [patch 6/7] BSD Secure Levels: trivial code and comment changes Michael Halcrow
2005-05-17 15:31 ` [patch 7/7] BSD Secure Levels: remove redundant ptrace check Michael Halcrow
2005-05-17 17:33 ` [patch 1/7] BSD Secure Levels: printk overhaul dean gaudet
2005-05-19 1:29 ` Dave Hansen
2005-05-19 10:39 ` Bernd Petrovitsch
2005-05-19 20:55 ` Michael Halcrow [this message]
2005-05-19 21:41 ` [updated patch " Michael Halcrow
2005-05-20 5:19 ` aq
2005-05-20 15:03 ` [updated patch 2/7] BSD Secure Levels: bd_claim fixes Michael Halcrow
2005-05-20 15:06 ` [updated patch 3/7] BSD Secure Levels: allow suid and sgid on directories Michael Halcrow
2005-05-20 15:09 ` [updated patch 4/7] BSD Secure Levels: memory alloc failure check Michael Halcrow
2005-05-20 15:10 ` [updated patch 5/7] BSD Secure Levels: allow setuid/setgid on root user processes Michael Halcrow
2005-05-20 15:13 ` [updated patch 6/7] BSD Secure Levels: trivial code and comment changes Michael Halcrow
2005-05-20 15:15 ` [updated patch 7/7] BSD Secure Levels: remove redundant ptrace check Michael Halcrow
2005-05-20 15:20 ` [patch 8/7] BSD Secure Levels: unregister on sysfs failure Michael Halcrow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050519205525.GB16215@halcrow.us \
--to=mhalcrow@us.ibm.com \
--cc=akpm@osdl.org \
--cc=chrisw@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=serue@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®