From: David Miller <davem@davemloft.net>
To: daniel@iogearbox.net
Cc: james.hogan@imgtec.com, ast@fb.com, netdev@vger.kernel.org
Subject: Re: [PATCH net] bpf: fix bpf_trace_printk on 32 bit archs
Date: Tue, 15 Aug 2017 17:32:57 -0700 (PDT) [thread overview]
Message-ID: <20170815.173257.21810623154828496.davem@davemloft.net> (raw)
In-Reply-To: <dd122e1ec0eadaf3f8fc11107f7a57177dcd8588.1502840567.git.daniel@iogearbox.net>
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Wed, 16 Aug 2017 01:45:33 +0200
> James reported that on MIPS32 bpf_trace_printk() is currently
> broken while MIPS64 works fine:
>
> bpf_trace_printk() uses conditional operators to attempt to
> pass different types to __trace_printk() depending on the
> format operators. This doesn't work as intended on 32-bit
> architectures where u32 and long are passed differently to
> u64, since the result of C conditional operators follows the
> "usual arithmetic conversions" rules, such that the values
> passed to __trace_printk() will always be u64 [causing issues
> later in the va_list handling for vscnprintf()].
>
> For example the samples/bpf/tracex5 test printed lines like
> below on MIPS32, where the fd and buf have come from the u64
> fd argument, and the size from the buf argument:
>
> [...] 1180.941542: 0x00000001: write(fd=1, buf= (null), size=6258688)
>
> Instead of this:
>
> [...] 1625.616026: 0x00000001: write(fd=1, buf=009e4000, size=512)
>
> One way to get it working is to expand various combinations
> of argument types into 8 different combinations for 32 bit
> and 64 bit kernels. Fix tested by James on MIPS32 and MIPS64
> as well that it resolves the issue.
>
> Fixes: 9c959c863f82 ("tracing: Allow BPF programs to call bpf_trace_printk()")
> Reported-by: James Hogan <james.hogan@imgtec.com>
> Tested-by: James Hogan <james.hogan@imgtec.com>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Applied and queued up for -stable, thanks Daniel.
prev parent reply other threads:[~2017-08-16 0:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-15 23:45 [PATCH net] bpf: fix bpf_trace_printk on 32 bit archs Daniel Borkmann
2017-08-16 0:32 ` David Miller [this message]
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=20170815.173257.21810623154828496.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=james.hogan@imgtec.com \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).