* [PATCH] capability: Use current logging styles
@ 2014-02-21 22:19 Joe Perches
2014-02-21 22:48 ` Serge Hallyn
2014-02-24 3:45 ` James Morris
0 siblings, 2 replies; 3+ messages in thread
From: Joe Perches @ 2014-02-21 22:19 UTC (permalink / raw)
To: Serge Hallyn; +Cc: linux-security-module, LKML
Prefix logging output with "capability: " via pr_fmt.
Convert printks to pr_<level>.
Use pr_<level>_once instead of guard flags.
Coalesce formats.
Signed-off-by: Joe Perches <joe@perches.com>
---
kernel/capability.c | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/kernel/capability.c b/kernel/capability.c
index 34019c5..a8d63df 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -7,6 +7,8 @@
* 30 May 2002: Cleanup, Robert M. Love <rml@tech9.net>
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/audit.h>
#include <linux/capability.h>
#include <linux/mm.h>
@@ -42,15 +44,10 @@ __setup("no_file_caps", file_caps_disable);
static void warn_legacy_capability_use(void)
{
- static int warned;
- if (!warned) {
- char name[sizeof(current->comm)];
-
- printk(KERN_INFO "warning: `%s' uses 32-bit capabilities"
- " (legacy support in use)\n",
- get_task_comm(name, current));
- warned = 1;
- }
+ char name[sizeof(current->comm)];
+
+ pr_info_once("warning: `%s' uses 32-bit capabilities (legacy support in use)\n",
+ get_task_comm(name, current));
}
/*
@@ -71,16 +68,10 @@ static void warn_legacy_capability_use(void)
static void warn_deprecated_v2(void)
{
- static int warned;
+ char name[sizeof(current->comm)];
- if (!warned) {
- char name[sizeof(current->comm)];
-
- printk(KERN_INFO "warning: `%s' uses deprecated v2"
- " capabilities in a way that may be insecure.\n",
- get_task_comm(name, current));
- warned = 1;
- }
+ pr_info_once("warning: `%s' uses deprecated v2 capabilities in a way that may be insecure\n",
+ get_task_comm(name, current));
}
/*
@@ -380,7 +371,7 @@ bool has_capability_noaudit(struct task_struct *t, int cap)
bool ns_capable(struct user_namespace *ns, int cap)
{
if (unlikely(!cap_valid(cap))) {
- printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
+ pr_crit("capable() called with invalid cap=%u\n", cap);
BUG();
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] capability: Use current logging styles
2014-02-21 22:19 [PATCH] capability: Use current logging styles Joe Perches
@ 2014-02-21 22:48 ` Serge Hallyn
2014-02-24 3:45 ` James Morris
1 sibling, 0 replies; 3+ messages in thread
From: Serge Hallyn @ 2014-02-21 22:48 UTC (permalink / raw)
To: Joe Perches; +Cc: Serge Hallyn, linux-security-module, LKML
Quoting Joe Perches (joe@perches.com):
> Prefix logging output with "capability: " via pr_fmt.
> Convert printks to pr_<level>.
> Use pr_<level>_once instead of guard flags.
> Coalesce formats.
>
> Signed-off-by: Joe Perches <joe@perches.com>
Thanks.
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
> ---
> kernel/capability.c | 29 ++++++++++-------------------
> 1 file changed, 10 insertions(+), 19 deletions(-)
>
> diff --git a/kernel/capability.c b/kernel/capability.c
> index 34019c5..a8d63df 100644
> --- a/kernel/capability.c
> +++ b/kernel/capability.c
> @@ -7,6 +7,8 @@
> * 30 May 2002: Cleanup, Robert M. Love <rml@tech9.net>
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/audit.h>
> #include <linux/capability.h>
> #include <linux/mm.h>
> @@ -42,15 +44,10 @@ __setup("no_file_caps", file_caps_disable);
>
> static void warn_legacy_capability_use(void)
> {
> - static int warned;
> - if (!warned) {
> - char name[sizeof(current->comm)];
> -
> - printk(KERN_INFO "warning: `%s' uses 32-bit capabilities"
> - " (legacy support in use)\n",
> - get_task_comm(name, current));
> - warned = 1;
> - }
> + char name[sizeof(current->comm)];
> +
> + pr_info_once("warning: `%s' uses 32-bit capabilities (legacy support in use)\n",
> + get_task_comm(name, current));
> }
>
> /*
> @@ -71,16 +68,10 @@ static void warn_legacy_capability_use(void)
>
> static void warn_deprecated_v2(void)
> {
> - static int warned;
> + char name[sizeof(current->comm)];
>
> - if (!warned) {
> - char name[sizeof(current->comm)];
> -
> - printk(KERN_INFO "warning: `%s' uses deprecated v2"
> - " capabilities in a way that may be insecure.\n",
> - get_task_comm(name, current));
> - warned = 1;
> - }
> + pr_info_once("warning: `%s' uses deprecated v2 capabilities in a way that may be insecure\n",
> + get_task_comm(name, current));
> }
>
> /*
> @@ -380,7 +371,7 @@ bool has_capability_noaudit(struct task_struct *t, int cap)
> bool ns_capable(struct user_namespace *ns, int cap)
> {
> if (unlikely(!cap_valid(cap))) {
> - printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
> + pr_crit("capable() called with invalid cap=%u\n", cap);
> BUG();
> }
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] capability: Use current logging styles
2014-02-21 22:19 [PATCH] capability: Use current logging styles Joe Perches
2014-02-21 22:48 ` Serge Hallyn
@ 2014-02-24 3:45 ` James Morris
1 sibling, 0 replies; 3+ messages in thread
From: James Morris @ 2014-02-24 3:45 UTC (permalink / raw)
To: Joe Perches; +Cc: Serge Hallyn, linux-security-module, LKML
On Fri, 21 Feb 2014, Joe Perches wrote:
> Prefix logging output with "capability: " via pr_fmt.
> Convert printks to pr_<level>.
> Use pr_<level>_once instead of guard flags.
> Coalesce formats.
>
> Signed-off-by: Joe Perches <joe@perches.com>
Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next
--
James Morris
<jmorris@namei.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-24 3:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-21 22:19 [PATCH] capability: Use current logging styles Joe Perches
2014-02-21 22:48 ` Serge Hallyn
2014-02-24 3:45 ` James Morris
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®