Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7531612imu; Tue, 22 Jan 2019 07:29:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN5WPUy/prUJamH64sczinFIaC4iavj/4xmyH96Be/Mk0C78MxGdLZC1ocEpFVYWteF5Nluz X-Received: by 2002:a63:88c7:: with SMTP id l190mr31820062pgd.110.1548170987493; Tue, 22 Jan 2019 07:29:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548170987; cv=none; d=google.com; s=arc-20160816; b=LC+P096PALQv1CSmLSF4Vb1A9F/nI+ITGRS2sK1zKInjSqMr/KwRU7QeNealWD0Kh7 e2oGDt7dBuYcKx+WRbu3ppYywF5acTO768RfsbtR9vBnFOFhxxQuW19IXiPUutI9FFV3 An65TR/6hfyQ4i3X46JVr0KIui9Mj2hZEPzNBG9bH6p5zrz2dWXaduDEHU84KlcT+CDa bIg3DqWtmAbLqRoJS3+D0lNmQBZZ66W58V5KK1qdHhMq5HnY8xc6YpQ9Qkq9vJoQrLIA MYQ8cLbzvmqZDfRYV/dTrxzh32LLNjeJo6zoLlCm35qAsjQp5Y0bdZVoX2GnJvZG4WQJ N4RQ== 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=lMdHUKeHNwJwFAqQCbJHl1X8nPbI14CqBx9AAZeDEZo9KGhVA0DCwWdxea6+CL++HR 7EH5/kz9FpTvV2bMDcJLQnCYFvwYw/6ViIIzmQtphXcFZ/Du2OSKxm/wMpNh4y7KEk0/ Xrk3YGv+MOnwFAlB3pHeQUh45XINL841gtw0Qxz3AxTofqFlpsWre8qgJiMWc7Q2EuQS hhpSJE9QHUM2EkA1gyVMGprQ1iz86LyH55emBSUxx4bELkYknW2UgYnf97y1mgrwSOIj d9/H/PQaMCIVV+37vIpcA7x3U67OisrLmpzAYBHzaVzRm8oxOv5pmPra7xPYMVn9DPvG rByg== 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 v68si15537180pgb.70.2019.01.22.07.29.32; Tue, 22 Jan 2019 07:29:47 -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 S1730091AbfAVP0l (ORCPT + 99 others); Tue, 22 Jan 2019 10:26:41 -0500 Received: from faui40.informatik.uni-erlangen.de ([131.188.34.40]:49706 "EHLO faui40.informatik.uni-erlangen.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729793AbfAVP0k (ORCPT ); Tue, 22 Jan 2019 10:26:40 -0500 Received: from faui49copter1 (faui49copter1.informatik.uni-erlangen.de [131.188.42.149]) by faui40.informatik.uni-erlangen.de (Postfix) with SMTP id 3FE9E548875; Tue, 22 Jan 2019 16:26:35 +0100 (CET) Received: by faui49copter1 (sSMTP sendmail emulation); Tue, 22 Jan 2019 16:26:35 +0100 From: Andreas Ziegler To: Steven Rostedt Cc: Ingo Molnar , Masami Hiramatsu , linux-kernel@vger.kernel.org, Andreas Ziegler Subject: [PATCH v2] tracing: probeevent: Correctly update remaining space in dynamic area Date: Tue, 22 Jan 2019 16:26:34 +0100 Message-Id: <20190122152634.18957-1-andreas.ziegler@fau.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190122221434.419e956dd91da0516ff4cc04@kernel.org> References: <20190122221434.419e956dd91da0516ff4cc04@kernel.org> 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