Received: by 10.213.65.68 with SMTP id h4csp873631imn; Tue, 27 Mar 2018 10:20:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/oSGTOE2IFKYbM7XapKAyCf90+3Vnbdmch+N2SGEbTCoFSdbSevmAoGJ1tUMTwNkwL6jtR X-Received: by 2002:a17:902:604f:: with SMTP id a15-v6mr203438plt.184.1522171249418; Tue, 27 Mar 2018 10:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522171249; cv=none; d=google.com; s=arc-20160816; b=aFTHWMvs5htCCYqiYgV7KsLF8WhZPP/m1UiBUCQ9XZDAZuBU9WWFlukZW3nIra6JXD 7qiRsjMVv7g7A2MloFWkfDzlZsLVszLQyiVDKenK7gjJvG6z6VXtDWNllBvpDOKaqW+d 3P8JYLK5G5hTdGB2C3EFPeCdv97SQtIjEBhdWSKfTe+LcR0eU8jxBDUpObrT4Yl0Iu1e VxPPvvNGydPsFv4UbsntzqlJ76Kbzk2I9amFsQ1ZSCo0AgtZszpw52E6Nd8jQhwpC2/n LxFWqB85aZ4fwP1uJQ7qdYd89nBhZTlKY2f4wwlTYTBJYz7LPsF7hYXy9fPGKSIy5z4R Xw2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+pioxM4/uPI5pyDbJ2QwlcfOYW+VlA1zyuHyl8/PhHo=; b=fUuQNiPW9L31qGL447O/gXpYbOg2tbAR1V9A/qp4qeN4BNv7WI+35ys3rIRb1qYnO4 kGTbUPFqPeFfO4q1QmSDfEj8SJqLwrhxrhXNC3+2s4zq6gcCi7N/3NhZAx90J2gEsJrL fQThEQwWQfh2mHTvGcwTpkgNG7fPCJjlcdoHFWJaF1HoE8J6vOBFKCwlYkVDsJGsI1gI Jz80YnOEnMSG8HYM2CO7mlkSOIhp+X5zm+tUM4ZWdD21+xgOiddmeZ3vBW578l5x6kNy XyK5w6bMu3cMNrIRNDumCPE/Y/YmCvthIS5nLgqlPfbITUZOfNEZw+frqZPf3fyotR2H AaLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u74si1143838pgc.264.2018.03.27.10.20.35; Tue, 27 Mar 2018 10:20:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755154AbeC0QiM (ORCPT + 99 others); Tue, 27 Mar 2018 12:38:12 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46646 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755140AbeC0QiK (ORCPT ); Tue, 27 Mar 2018 12:38:10 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E368CFF7; Tue, 27 Mar 2018 16:38:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ingo Molnar , Tom Zanussi , Arnaldo Carvalho de Melo , Ravi Bangoria , Namhyung Kim , Masami Hiramatsu , "Steven Rostedt (VMware)" Subject: [PATCH 4.14 064/101] tracing: probeevent: Fix to support minus offset from symbol Date: Tue, 27 Mar 2018 18:27:36 +0200 Message-Id: <20180327162753.928778968@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162749.993880276@linuxfoundation.org> References: <20180327162749.993880276@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Masami Hiramatsu commit c5d343b6b7badd1f5fe0873eff2e8d63a193e732 upstream. In Documentation/trace/kprobetrace.txt, it says @SYM[+|-offs] : Fetch memory at SYM +|- offs (SYM should be a data symbol) However, the parser doesn't parse minus offset correctly, since commit 2fba0c8867af ("tracing/kprobes: Fix probe offset to be unsigned") drops minus ("-") offset support for kprobe probe address usage. This fixes the traceprobe_split_symbol_offset() to parse minus offset again with checking the offset range, and add a minus offset check in kprobe probe address usage. Link: http://lkml.kernel.org/r/152129028983.31874.13419301530285775521.stgit@devbox Cc: Ingo Molnar Cc: Tom Zanussi Cc: Arnaldo Carvalho de Melo Cc: Ravi Bangoria Cc: stable@vger.kernel.org Fixes: 2fba0c8867af ("tracing/kprobes: Fix probe offset to be unsigned") Acked-by: Namhyung Kim Signed-off-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_kprobe.c | 4 ++-- kernel/trace/trace_probe.c | 8 +++----- kernel/trace/trace_probe.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -635,7 +635,7 @@ static int create_trace_kprobe(int argc, char *symbol = NULL, *event = NULL, *group = NULL; int maxactive = 0; char *arg; - unsigned long offset = 0; + long offset = 0; void *addr = NULL; char buf[MAX_EVENT_NAME_LEN]; @@ -723,7 +723,7 @@ static int create_trace_kprobe(int argc, symbol = argv[1]; /* TODO: support .init module functions */ ret = traceprobe_split_symbol_offset(symbol, &offset); - if (ret) { + if (ret || offset < 0 || offset > UINT_MAX) { pr_info("Failed to parse either an address or a symbol.\n"); return ret; } --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -320,7 +320,7 @@ static fetch_func_t get_fetch_size_funct } /* Split symbol and offset. */ -int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset) +int traceprobe_split_symbol_offset(char *symbol, long *offset) { char *tmp; int ret; @@ -328,13 +328,11 @@ int traceprobe_split_symbol_offset(char if (!offset) return -EINVAL; - tmp = strchr(symbol, '+'); + tmp = strpbrk(symbol, "+-"); if (tmp) { - /* skip sign because kstrtoul doesn't accept '+' */ - ret = kstrtoul(tmp + 1, 0, offset); + ret = kstrtol(tmp, 0, offset); if (ret) return ret; - *tmp = '\0'; } else *offset = 0; --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -354,7 +354,7 @@ extern int traceprobe_conflict_field_nam extern void traceprobe_update_arg(struct probe_arg *arg); extern void traceprobe_free_probe_arg(struct probe_arg *arg); -extern int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset); +extern int traceprobe_split_symbol_offset(char *symbol, long *offset); extern ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos,