Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2221028imm; Thu, 7 Jun 2018 07:16:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKTD9Q08rGiJhblWzOBQPWzDUGzI42veeG0Vd6xHW2FClHZUxbhGdRm8WTjShFCYIJbVbUB X-Received: by 2002:a63:66c2:: with SMTP id a185-v6mr1786942pgc.347.1528381003595; Thu, 07 Jun 2018 07:16:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528381003; cv=none; d=google.com; s=arc-20160816; b=V7ZXH/Gc/MzybtugJ8ONos5xaAsmIGdc4EFUwMqEY8uGDqLKYiwW5CCDhnJOuwPlaB W8gThnGKP2aN27F0rKZ4BK880nFIDT0vvTHbjWGt58pqalqI/rwwzZrhTkWDuZTFjQVL Lzkj70D5oB57bl+DJEsiiPHeBy6mW94LgwI8A2YmTAztKwAGZhS+AfwuRXxwcplZTEyP HlKBq5/2YVokGt2G11BrZEW8gnx9llEulNe8X3IPazNr94xjm3eDuZOPZmO1Mayl3HRT 9P76foBHxpPqjZFoPobomlwMjjjMIbERSLLcHyOq1DbOe1Ig77g7uasEQ8DSZ8s4OG3S E8Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=ALeK46Rqo5mC4NIbkU+gJQlILD+sH6lIjjWWdF3Z480=; b=dKV1s6idFu0kZPpU9BLks1/IduN9f3Eu2lKjhRfPIMzWveAWpI6RxaFp3jGLFaYynz wpbigkjmhvs8undUTyozJ+j8YcGjRs0ZEBx7ZBCZwbxjJ/Mb/bWS4+0ucA4epgBzlKae k3LtpLsgy3gKODTC+yp0RFTgDxD1bHXL0ItC5N0HRffYQN1NJ1o+9U6FDNXrprqxMO3V BSFTwH9SmozrBQeI0UfXNLjPAWVQlOd1DYVL7/1QzH50r0JWEnSK63rbw6eb4iiKkvPi cbSpU1vf2tlAJR/2K8HzMnPrmVTAcyJWYEZKP1WvPGcWpklIHgJTmqjxAiT01XoBQ9AJ HPpw== 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 y18-v6si6599410pgv.388.2018.06.07.07.16.29; Thu, 07 Jun 2018 07:16:43 -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 S933360AbeFGON5 (ORCPT + 99 others); Thu, 7 Jun 2018 10:13:57 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39496 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933158AbeFGOJi (ORCPT ); Thu, 7 Jun 2018 10:09:38 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbJ-0005dI-Fn; Thu, 07 Jun 2018 15:09:18 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbE-0003IR-Uk; Thu, 07 Jun 2018 15:09:12 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Steven Rostedt (VMware)" , "Masami Hiramatsu" , "Ingo Molnar" , "Ravi Bangoria" , "Arnaldo Carvalho de Melo" , "Tom Zanussi" , "Namhyung Kim" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 392/410] tracing: probeevent: Fix to support minus offset from symbol In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 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 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: Ben Hutchings --- 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 @@ -611,7 +611,7 @@ static int create_trace_kprobe(int argc, bool is_return = false, is_delete = false; char *symbol = NULL, *event = NULL, *group = NULL; char *arg; - unsigned long offset = 0; + long offset = 0; void *addr = NULL; char buf[MAX_EVENT_NAME_LEN]; @@ -684,7 +684,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 @@ -291,7 +291,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; @@ -299,13 +299,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 @@ -341,7 +341,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,