From: Alexei Starovoitov <ast@plumgrid.com>
To: David Miller <davem@davemloft.net>
Cc: mingo@kernel.org, rostedt@goodmis.org, wangnan0@huawei.com,
hekuang@huawei.com, daniel@iogearbox.net,
brendan.d.gregg@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] bpf: add support for %s specifier to bpf_trace_printk()
Date: Thu, 27 Aug 2015 16:06:14 -0700 [thread overview]
Message-ID: <55DF97E6.9050108@plumgrid.com> (raw)
In-Reply-To: <20150827.153409.893765406170260565.davem@davemloft.net>
On 8/27/15 3:34 PM, David Miller wrote:
> From: Alexei Starovoitov <ast@plumgrid.com>
> Date: Wed, 26 Aug 2015 23:26:59 -0700
>
>> +/* similar to strncpy_from_user() but with extra checks */
>> +static void probe_read_string(char *buf, int size, long unsafe_ptr)
>> +{
>> + char dst[4];
>> + int i = 0;
>> +
>> + size--;
>> + for (;;) {
>> + if (probe_kernel_read(dst, (void *) unsafe_ptr, 4))
>> + break;
>
> I don't think this does the right thing when the string is not a multiple
> of 3 and ends at the last byte of a page that ends a valid region of
> kernel memory.
>
> Seeing this kind of error makes me skeptical to the overall value of
> optimizing this :-/
I've considered the case when first two bytes are valid, but the
other two are in a different page. In such case the probe_read_string()
will trim the string and won't be printing these two valid bytes.
I think that's very rare, so I'm picking higher performance for common
case. The strings over > 64 bytes also will be trimmed to 64.
It's a debugging facility, so I felt that's ok.
Fair or you still think it should be per byte copy?
next prev parent reply other threads:[~2015-08-27 23:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 6:26 [PATCH net-next] bpf: add support for %s specifier to bpf_trace_printk() Alexei Starovoitov
2015-08-27 22:34 ` David Miller
2015-08-27 23:06 ` Alexei Starovoitov [this message]
2015-08-27 23:20 ` David Miller
2015-08-27 23:43 ` Steven Rostedt
2015-08-28 1:58 ` Alexei Starovoitov
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=55DF97E6.9050108@plumgrid.com \
--to=ast@plumgrid.com \
--cc=brendan.d.gregg@gmail.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hekuang@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=wangnan0@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.