From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756125AbdDRMwa convert rfc822-to-8bit (ORCPT ); Tue, 18 Apr 2017 08:52:30 -0400 Received: from smtp-out6.electric.net ([192.162.217.183]:65019 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751374AbdDRMw1 (ORCPT ); Tue, 18 Apr 2017 08:52:27 -0400 From: David Laight To: "'Naveen N. Rao'" , Michael Ellerman CC: "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "Masami Hiramatsu" , Ingo Molnar Subject: RE: [PATCH v2 1/5] kprobes: convert kprobe_lookup_name() to a function Thread-Topic: [PATCH v2 1/5] kprobes: convert kprobe_lookup_name() to a function Thread-Index: AQHSs3x2ZIPKn/s80kmFhbluErF706HLHRUQ Date: Tue, 18 Apr 2017 12:52:10 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DCFFD3C07@AcuExch.aculab.com> References: <2780c632bc2c6e39f27920f8cc98e17430189e27.1491991939.git.naveen.n.rao@linux.vnet.ibm.com> In-Reply-To: <2780c632bc2c6e39f27920f8cc98e17430189e27.1491991939.git.naveen.n.rao@linux.vnet.ibm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuExch.aculab.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ > + 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