From: Richard Guy Briggs <rgb@redhat.com>
To: William Roberts <bill.c.roberts@gmail.com>
Cc: linux-audit@redhat.com
Subject: Re: Format specifier issue when building kernel
Date: Thu, 31 Oct 2013 14:45:24 -0400 [thread overview]
Message-ID: <20131031184524.GA24236@madcap2.tricolour.ca> (raw)
In-Reply-To: <CAFftDdrbBdFEuTHHu4Dfg_iO=FqvFnz_DAHqThQ9KBWhGqLy2w@mail.gmail.com>
On Mon, Oct 28, 2013 at 08:55:08PM -0700, William Roberts wrote:
> On Mon, Oct 28, 2013 at 6:43 PM, William Roberts
> <bill.c.roberts@gmail.com>wrote:
> > On Mon, Oct 28, 2013 at 6:35 PM, Richard Guy Briggs <rgb@redhat.com>wrote:
> >> On Mon, Oct 28, 2013 at 04:31:30PM -0700, William Roberts wrote:
> >> > On Mon, Oct 28, 2013 at 4:30 PM, William Roberts
> >> > <bill.c.roberts@gmail.com>wrote:
> >> > > I've been working off of Richard Guy Brigs git repo on branch
> >> > > audit-for-next prepping my patch and I noticed a build warning:
> >> > >
> >> > > kernel/audit.c:832:8: warning: format ‘%A’ expects argument of type
> >> > > ‘double’, but argument 3 has type ‘char *’ [-Wformat]
> >> > >
> >> > > Looking at the code, it looks wrong:
> >> > >
> >> > > audit_log_format(ab,
> >> > "
> >> > msg='%.AUDIT_MESSAGE_TEXT_MAXs'",
> >> > (char *)data);
> >> >
> >> > The issue appears on the % specifier in there, it picks it up as
> >> > %.A, which is of type double. Is this what was intended?
> >>
> >> Hmmm, that should have picked up a macro from 06051fbe in
> >> audit-for-next. It should be pre-processed to "%.8560s".
> >>
> >> > William C Roberts
> >>
> >> - RGB
> >
> > The qoutes are wrong for that.
>
> Ok I see the value is not a string, but a numeric constant. Dont you need
> to do something like this:
> diff --git a/kernel/audit.c b/kernel/audit.c
> index bf4b1af..81dde3d 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -825,10 +825,12 @@ static int audit_receive_msg(struct sk_buff *skb,
> struct nlmsghdr *nlh)
> if (err)
> break;
> }
> +#define STR_HELPER(x) #x
> +#define STR(x) STR_HELPER(x)
> audit_log_common_recv_msg(&ab, msg_type);
> if (msg_type != AUDIT_USER_TTY)
> audit_log_format(ab,
> - "
> msg='%.AUDIT_MESSAGE_TEXT_MAXs'",
> + "
> msg='%."STR(AUDIT_MESSAGE_TEXT_MAX)"s'",
> (char *)data);
> else {
> int size;
Ugh. That's not so easy to read... Slightly longer, how about this?
diff --git a/kernel/audit.c b/kernel/audit.c
index 8378c5e..3f569d1 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -824,11 +824,13 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
break;
}
audit_log_common_recv_msg(&ab, msg_type);
- if (msg_type != AUDIT_USER_TTY)
- audit_log_format(ab,
- " msg='%.AUDIT_MESSAGE_TEXT_MAXs'",
- (char *)data);
- else {
+ if (msg_type != AUDIT_USER_TTY) {
+ char fmt[64];
+ strcat(fmt, " msg='%.");
+ strcat(fmt, "AUDIT_MESSAGE_TEXT_MAX");
+ strcat(fmt, "s'");
+ audit_log_format(ab, fmt, (char *)data);
+ } else {
int size;
audit_log_format(ab, " data=");
> Unless their is some gnu-magic I don't know about.
>
> William C Roberts
- RGB
--
Richard Guy Briggs <rbriggs@redhat.com>
Senior Software Engineer
Kernel Security
AMER ENG Base Operating Systems
Remote, Ottawa, Canada
Voice: +1.647.777.2635
Internal: (81) 32635
Alt: +1.613.693.0684x3545
--
Linux-audit mailing list
Linux-audit@redhat.com
https://www.redhat.com/mailman/listinfo/linux-audit
next prev parent reply other threads:[~2013-10-31 18:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-28 23:30 Format specifier issue when building kernel William Roberts
2013-10-28 23:31 ` William Roberts
2013-10-29 1:35 ` Richard Guy Briggs
2013-10-29 1:43 ` William Roberts
2013-10-29 3:55 ` William Roberts
2013-10-31 18:45 ` Richard Guy Briggs [this message]
2013-10-31 19:25 ` William Roberts
2013-11-01 16:24 ` Richard Guy Briggs
2013-11-01 16:34 ` Steve Grubb
2013-11-01 16:38 ` Richard Guy Briggs
2013-11-01 19:57 ` Richard Guy Briggs
2013-11-01 22:10 ` William Roberts
2013-11-01 22:20 ` David Rebman
2013-11-01 22:22 ` William Roberts
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=20131031184524.GA24236@madcap2.tricolour.ca \
--to=rgb@redhat.com \
--cc=bill.c.roberts@gmail.com \
--cc=linux-audit@redhat.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