mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'Naveen N. Rao'" <naveen.n.rao@linux.vnet.ibm.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: Tue, 18 Apr 2017 12:52:10 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DCFFD3C07@AcuExch.aculab.com> (raw)
In-Reply-To: <2780c632bc2c6e39f27920f8cc98e17430189e27.1491991939.git.naveen.n.rao@linux.vnet.ibm.com>

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.

The strncat() call is particularly borked.

	David

  parent reply	other threads:[~2017-04-18 12:52 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 [this message]
2017-04-19  8:08     ` Naveen N. Rao
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=063D6719AE5E284EB5DD2968C1650D6DCFFD3C07@AcuExch.aculab.com \
    --to=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 \
    --cc=naveen.n.rao@linux.vnet.ibm.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

all inboxes | Powered by JetHome®