Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp953168ima; Wed, 6 Feb 2019 11:05:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IYD9X3OJW8lmhgp7Kj7BU1Jv+K79B7KGA2gHgAwMmOlZMVziX6LuYgpvNr/e1eibCq22OCn X-Received: by 2002:a62:109b:: with SMTP id 27mr11786413pfq.227.1549479912600; Wed, 06 Feb 2019 11:05:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549479912; cv=none; d=google.com; s=arc-20160816; b=ELegRoiPT7MkBoQDgUkaUGu1w2V4W267DYmJ13NZj70LxHIWdz6BOJf93Dg3l0al74 Mz5oNhEBoK1Ga1UH1Bon4lmIQ2HLYWrrAamqKFvSpcdyCxjBqUyOIIuMj0rJtHdiuBSM oZ6o898OQJz0SRxVVLQyH0ewYWmxA6NRnv21rMi/9/KuMkp4FaC90zxlE9sjBhd3zCKJ FgMICmpOuDOEZ/jBSweIkJrWmsHsGP4gOfCa6jv+c7HYJj0UznmBvJ3vDvb4YuV+uURG guDGu4bQIc4S3lG6Efa69iDlIVxbIf7GfybxkeYBoQK7XgEH6nxKL2qqF9NZVj13jr5w AJBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=klSy/5o/caZZCHHRbmB4RvG+NvezEmL7CHN8nNJqOnk=; b=fMfGEk0+ZliXW15t42mcFM5KfkLlZf7fIgjOsI9CHgOpWxSN3dVu2kf6Sgkuc/ANg2 YADjgW++WMnSKXSnHT4coKHvwtzR6AipgVIHesQN+Odt7zv6HeQFRHk4GEVhKvJLSXJU 83jceHWVxcuaeL67z3u310Nf9KHZV39EIl1XQcSlauJ2F3AMIyeeVTuhyBu75KfBwJhb 02t90VkjYGGOzlL1yD3zkpFNiSqR+BR+ohquwA0UWR1wbQ5jmqjW8UvP9JiXaAx8ABuH SvfOhRynuTq4UxXss9ITxW8mXaZVCUTIruajPDwRcYor5d8hf2azeW4NzD+FZadaBKgv wW5Q== 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 v69si2671797pgd.284.2019.02.06.11.04.50; Wed, 06 Feb 2019 11:05:12 -0800 (PST) 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 S1726801AbfBFTA1 (ORCPT + 99 others); Wed, 6 Feb 2019 14:00:27 -0500 Received: from faui40.informatik.uni-erlangen.de ([131.188.34.40]:46668 "EHLO faui40.informatik.uni-erlangen.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726561AbfBFTA1 (ORCPT ); Wed, 6 Feb 2019 14:00:27 -0500 Received: from faui49copter1 (faui49copter1.informatik.uni-erlangen.de [131.188.42.149]) by faui40.informatik.uni-erlangen.de (Postfix) with SMTP id 93F36548859; Wed, 6 Feb 2019 20:00:21 +0100 (CET) Received: by faui49copter1 (sSMTP sendmail emulation); Wed, 06 Feb 2019 20:00:21 +0100 From: Andreas Ziegler To: Steven Rostedt Cc: Ingo Molnar , Masami Hiramatsu , linux-kernel@vger.kernel.org, Andreas Ziegler Subject: [PATCH v2 RESEND] tracing: probeevent: Correctly update remaining space in dynamic area Date: Wed, 6 Feb 2019 20:00:13 +0100 Message-Id: <20190206190013.16405-1-andreas.ziegler@fau.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190122152634.18957-1-andreas.ziegler@fau.de> References: <20190122152634.18957-1-andreas.ziegler@fau.de> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED=-1 autolearn=disabled version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on faui40.informatik.uni-erlangen.de Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 9178412ddf5a ("tracing: probeevent: Return consumed bytes of dynamic area") improved the string fetching mechanism by returning the number of required bytes after copying the argument to the dynamic area. However, this return value is now only used to increment the pointer inside the dynamic area but misses updating the 'maxlen' variable which indicates the remaining space in the dynamic area. This means that fetch_store_string() always reads the *total* size of the dynamic area from the data_loc pointer instead of the *remaining* size (and passes it along to strncpy_from_{user,unsafe}) even if we're already about to copy data into the middle of the dynamic area. Fixes: 9178412ddf5a ("tracing: probeevent: Return consumed bytes of dynamic area") Signed-off-by: Andreas Ziegler Acked-by: Masami Hiramatsu --- v2: follow coding guidelines for braces kernel/trace/trace_probe_tmpl.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h index 5c56afc17cf8..4737bb8c07a3 100644 --- a/kernel/trace/trace_probe_tmpl.h +++ b/kernel/trace/trace_probe_tmpl.h @@ -180,10 +180,12 @@ store_trace_args(void *data, struct trace_probe *tp, struct pt_regs *regs, if (unlikely(arg->dynamic)) *dl = make_data_loc(maxlen, dyndata - base); ret = process_fetch_insn(arg->code, regs, dl, base); - if (unlikely(ret < 0 && arg->dynamic)) + if (unlikely(ret < 0 && arg->dynamic)) { *dl = make_data_loc(0, dyndata - base); - else + } else { dyndata += ret; + maxlen -= ret; + } } } -- 2.17.1