* the format string of printf to print audit status is wrong
@ 2008-07-31 5:07 Yu Zhiguo
2008-07-31 13:07 ` Eric Paris
2008-08-04 20:06 ` Steve Grubb
0 siblings, 2 replies; 5+ messages in thread
From: Yu Zhiguo @ 2008-07-31 5:07 UTC (permalink / raw)
To: Steve Grubb, audit-list
Hello Steve,
all audit status's type is __u32, so '%u' should be used
in format string of printf rather than '%d', otherwise the
value outputted to user will be wraparound.
For example:
# auditctl -r 4294967295
AUDIT_STATUS: enabled=1 flag=1 pid=8999 rate_limit=-1 backlog_limit=320
lost=2241 backlog=0
but it should be
# auditctl -r 4294967295
AUDIT_STATUS: enabled=1 flag=1 pid=8999 rate_limit=4294967295
backlog_limit=320 lost=2270 backlog=0
This is the patch. Can you apply it?
Signed-off-by: Yu Zhiguo<yuzg@cn.fujitsu.com>
---
src/auditctl.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/auditctl.c b/src/auditctl.c
index d740509..5416e9b 100644
--- a/src/auditctl.c
+++ b/src/auditctl.c
@@ -1349,8 +1349,8 @@ static int audit_print_reply(struct audit_reply *rep)
printed = 1;
return 0;
case AUDIT_GET:
- printf("AUDIT_STATUS: enabled=%d flag=%d pid=%d"
- " rate_limit=%d backlog_limit=%d lost=%d backlog=%d\n",
+ printf("AUDIT_STATUS: enabled=%u flag=%u pid=%u"
+ " rate_limit=%u backlog_limit=%u lost=%u backlog=%u\n",
rep->status->enabled, rep->status->failure,
rep->status->pid, rep->status->rate_limit,
rep->status->backlog_limit, rep->status->lost,
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: the format string of printf to print audit status is wrong
2008-07-31 5:07 the format string of printf to print audit status is wrong Yu Zhiguo
@ 2008-07-31 13:07 ` Eric Paris
2008-08-01 9:21 ` Yu Zhiguo
2008-08-04 20:11 ` Steve Grubb
2008-08-04 20:06 ` Steve Grubb
1 sibling, 2 replies; 5+ messages in thread
From: Eric Paris @ 2008-07-31 13:07 UTC (permalink / raw)
To: Yu Zhiguo; +Cc: audit-list
On Thu, 2008-07-31 at 13:07 +0800, Yu Zhiguo wrote:
> Hello Steve,
>
> all audit status's type is __u32, so '%u' should be used
> in format string of printf rather than '%d', otherwise the
> value outputted to user will be wraparound.
>
> For example:
> # auditctl -r 4294967295
> AUDIT_STATUS: enabled=1 flag=1 pid=8999 rate_limit=-1 backlog_limit=320
> lost=2241 backlog=0
>
> but it should be
> # auditctl -r 4294967295
> AUDIT_STATUS: enabled=1 flag=1 pid=8999 rate_limit=4294967295
> backlog_limit=320 lost=2270 backlog=0
>
>
> This is the patch. Can you apply it?
>
> Signed-off-by: Yu Zhiguo<yuzg@cn.fujitsu.com>
> ---
> src/auditctl.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/auditctl.c b/src/auditctl.c
> index d740509..5416e9b 100644
> --- a/src/auditctl.c
> +++ b/src/auditctl.c
> @@ -1349,8 +1349,8 @@ static int audit_print_reply(struct audit_reply *rep)
> printed = 1;
> return 0;
> case AUDIT_GET:
> - printf("AUDIT_STATUS: enabled=%d flag=%d pid=%d"
> - " rate_limit=%d backlog_limit=%d lost=%d backlog=%d\n",
> + printf("AUDIT_STATUS: enabled=%u flag=%u pid=%u"
> + " rate_limit=%u backlog_limit=%u lost=%u backlog=%u\n",
In kernel the types are:
int audit_enabled;
static int audit_failure = AUDIT_FAIL_PRINTK;
typedef int __kernel_pid_t;
static int audit_rate_limit;
static int audit_backlog_limit = 64;
static atomic_t audit_lost = ATOMIC_INIT(0); (atomic_t is just volatile int)
backlog comes from:
static inline __u32 skb_queue_len()
So it seems reasonable to switch backlog=%d to backlog=%u but all of the
other values "could" be negative and should be shown as ints.
-Eric
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: the format string of printf to print audit status is wrong
2008-07-31 13:07 ` Eric Paris
@ 2008-08-01 9:21 ` Yu Zhiguo
2008-08-04 20:11 ` Steve Grubb
1 sibling, 0 replies; 5+ messages in thread
From: Yu Zhiguo @ 2008-08-01 9:21 UTC (permalink / raw)
To: Eric Paris; +Cc: audit-list
Hello Eric,
CC Steve,
Eric Paris wrote:
> So it seems reasonable to switch backlog=%d to backlog=%u but all of the
> other values "could" be negative and should be shown as ints.
>
Thanks for your kindness remind.
I also think all of the other values "could" be negative and should
be shown as ints.
A new patch for auditctl:
---
src/auditctl.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/auditctl.c b/src/auditctl.c
index d740509..44ca038 100644
--- a/src/auditctl.c
+++ b/src/auditctl.c
@@ -1350,7 +1350,7 @@ static int audit_print_reply(struct audit_reply *rep)
return 0;
case AUDIT_GET:
printf("AUDIT_STATUS: enabled=%d flag=%d pid=%d"
- " rate_limit=%d backlog_limit=%d lost=%d backlog=%d\n",
+ " rate_limit=%d backlog_limit=%d lost=%d backlog=%u\n",
rep->status->enabled, rep->status->failure,
rep->status->pid, rep->status->rate_limit,
rep->status->backlog_limit, rep->status->lost,
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: the format string of printf to print audit status is wrong
2008-07-31 5:07 the format string of printf to print audit status is wrong Yu Zhiguo
2008-07-31 13:07 ` Eric Paris
@ 2008-08-04 20:06 ` Steve Grubb
1 sibling, 0 replies; 5+ messages in thread
From: Steve Grubb @ 2008-08-04 20:06 UTC (permalink / raw)
To: Yu Zhiguo; +Cc: audit-list
On Thursday 31 July 2008 01:07:48 Yu Zhiguo wrote:
> all audit status's type is __u32, so '%u' should be used
> in format string of printf rather than '%d', otherwise the
> value outputted to user will be wraparound.
>
> This is the patch. Can you apply it?
Applied. Thanks!
-Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: the format string of printf to print audit status is wrong
2008-07-31 13:07 ` Eric Paris
2008-08-01 9:21 ` Yu Zhiguo
@ 2008-08-04 20:11 ` Steve Grubb
1 sibling, 0 replies; 5+ messages in thread
From: Steve Grubb @ 2008-08-04 20:11 UTC (permalink / raw)
To: Eric Paris; +Cc: audit-list
On Thursday 31 July 2008 09:07:30 Eric Paris wrote:
> So it seems reasonable to switch backlog=%d to backlog=%u but all of the
> other values "could" be negative and should be shown as ints.
Good point. I updated the patch.
-Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-08-04 20:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-31 5:07 the format string of printf to print audit status is wrong Yu Zhiguo
2008-07-31 13:07 ` Eric Paris
2008-08-01 9:21 ` Yu Zhiguo
2008-08-04 20:11 ` Steve Grubb
2008-08-04 20:06 ` Steve Grubb
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox