From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
To: David Laight <David.Laight@ACULAB.COM>,
Michael Ellerman <mpe@ellerman.id.au>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Ingo Molnar <mingo@kernel.org>
Subject: RE: [PATCH v2 1/5] kprobes: convert kprobe_lookup_name() to a function
Date: Wed, 19 Apr 2017 08:08:40 +0000 [thread overview]
Message-ID: <1492589122.ncy876vm18.astroid@naverao1-tp.none> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DCFFD3C07@AcuExch.aculab.com>
Excerpts from David Laight's message of April 18, 2017 18:22:
> From: Naveen N. Rao
>> Sent: 12 April 2017 11:58
> ...
>> +kprobe_opcode_t *kprobe_lookup_name(const char *name)
>> +{
> ...
>> + char dot_name[MODULE_NAME_LEN + 1 + KSYM_NAME_LEN];
>> + const char *modsym;
>> + bool dot_appended = false;
>> + if ((modsym = strchr(name, ':')) != NULL) {
>> + modsym++;
>> + if (*modsym != '\0' && *modsym != '.') {
>> + /* Convert to <module:.symbol> */
>> + strncpy(dot_name, name, modsym - name);
>> + dot_name[modsym - name] = '.';
>> + dot_name[modsym - name + 1] = '\0';
>> + strncat(dot_name, modsym,
>> + sizeof(dot_name) - (modsym - name) - 2);
>> + dot_appended = true;
>
> If the ':' is 'a way down' name[] then although the strncpy() won't
> overrun dot_name[] the rest of the code can.
Nice catch, thanks David!
We need to be validating the length of 'name'. I'll put out a patch for
that.
As an aside, I'm not sure I follow what you mean when you say that the
strncpy() won't overrun dot_name[]. If we have a name[] longer than
sizeof(dot_name) with the ':' after that, the strncpy() can also overrun
dot_name[].
- Naveen
>
> The strncat() call is particularly borked.
>
> David
>
>
next prev parent reply other threads:[~2017-04-19 8:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-12 10:58 [PATCH v2 0/5] powerpc: a few kprobe fixes and refactoring Naveen N. Rao
2017-04-12 10:58 ` [PATCH v2 1/5] kprobes: convert kprobe_lookup_name() to a function Naveen N. Rao
2017-04-13 3:09 ` Masami Hiramatsu
2017-04-18 12:52 ` David Laight
2017-04-19 8:08 ` Naveen N. Rao [this message]
2017-04-19 8:48 ` David Laight
2017-04-19 11:07 ` 'Naveen N. Rao'
2017-04-12 10:58 ` [PATCH v2 2/5] powerpc: kprobes: fix handling of function offsets on ABIv2 Naveen N. Rao
2017-04-13 4:28 ` Masami Hiramatsu
2017-04-12 10:58 ` [PATCH v2 3/5] powerpc: introduce a new helper to obtain function entry points Naveen N. Rao
2017-04-13 4:32 ` Masami Hiramatsu
2017-04-13 5:52 ` Naveen N. Rao
2017-04-12 10:58 ` [PATCH v2 4/5] powerpc: kprobes: factor out code to emulate instruction into a helper Naveen N. Rao
2017-04-13 4:34 ` Masami Hiramatsu
2017-04-13 5:53 ` Naveen N. Rao
2017-04-13 8:50 ` Naveen N. Rao
2017-04-12 10:58 ` [PATCH v2 5/5] powerpc: kprobes: emulate instructions on kprobe handler re-entry Naveen N. Rao
2017-04-13 4:37 ` Masami Hiramatsu
2017-04-13 5:53 ` Naveen N. Rao
2017-04-13 3:02 ` [PATCH v2 0/5] powerpc: a few kprobe fixes and refactoring Masami Hiramatsu
2017-04-13 5:50 ` Naveen N. Rao
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=1492589122.ncy876vm18.astroid@naverao1-tp.none \
--to=naveen.n.rao@linux.vnet.ibm.com \
--cc=David.Laight@ACULAB.COM \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=mpe@ellerman.id.au \
/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
all inboxes | Powered by JetHome®