Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7358576imu; Tue, 22 Jan 2019 04:51:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN7iwhLExZgFwbco6wf6zhTfy8D9A+E5WAM/VqOIHQ+BCEuGIOjmK7yyiS5WqhtN3ff9e4xJ X-Received: by 2002:a17:902:27e6:: with SMTP id i35mr33410447plg.222.1548161471535; Tue, 22 Jan 2019 04:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548161471; cv=none; d=google.com; s=arc-20160816; b=rV9zGRQnzi+pNmFqHdlgvzyXks/bfQr3t/a3A5GGiAlDBMYVVcTzCNzKCg5uA1x48x bzluWq+vFGae4OJBD7x3T7kkcIjTEFGJ6V4IXs8bCAx77fHwAda4oYyfsrUU+v0Sr+CF lnT8pfcCjH4fJ3h6vGpuiZRaKc/wuTSa4dYwpusYihM5KUuEtY5DlHF5Yj+WR6ktMLCj fdNQD2toLmqFXE+or/kDlr7dF2o5JWVpXrEmcz3s7Xw0CuDx8t/597egMHAinQvC9EWa BADtLYOZPThPx3vgzVCi4hl2sWPVQZ8latPlcmO5vwkrQxcu5NW3vHJYimnCEKbu7uc9 X+pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=ZuHlpdXmReloqfTJc7iBeAtR85SQCV+H1lqGcQ9y+E8=; b=fHNXk23Ja9hqhOISArRNhGLppoVIZOBOhXbzHesHXYYu3i519nMHIdzoMKvgtTGtjO dHgTUN+y9J5ztOgio9nL734ByNzl0Tz9gpF4rsiZHR/iFFeYCyNQno9/txHRAjumdy4L wfAMer1gf/Vn2a1VBql3NwPpbiEBwPqmLART89iDjBBeU+rQOO5r3sLFXdpS3ez4KOM9 bDqP7S7KtB6Wvjt4P+WcHygUzZEogAlNW0G4BINSr7fWE4LfaaDNai2N52TbtSPl3TfS sImlftXIZya6Aj9su7dukO+XnsnE+29QUkNAN3Ed4NureUJZ3EmtR4pjIRVNM3VQEtjS L2qg== 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 v8si15314622plp.215.2019.01.22.04.50.55; Tue, 22 Jan 2019 04:51:11 -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 S1728372AbfAVMs7 (ORCPT + 99 others); Tue, 22 Jan 2019 07:48:59 -0500 Received: from faui40.informatik.uni-erlangen.de ([131.188.34.40]:59222 "EHLO faui40.informatik.uni-erlangen.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728209AbfAVMs6 (ORCPT ); Tue, 22 Jan 2019 07:48:58 -0500 Received: from faui49copter1 (faui49copter1.informatik.uni-erlangen.de [131.188.42.149]) by faui40.informatik.uni-erlangen.de (Postfix) with SMTP id 70E65548040; Tue, 22 Jan 2019 13:48:53 +0100 (CET) Received: by faui49copter1 (sSMTP sendmail emulation); Tue, 22 Jan 2019 13:48:53 +0100 From: Andreas Ziegler To: Steven Rostedt Cc: Ingo Molnar , Masami Hiramatsu , linux-kernel@vger.kernel.org, Andreas Ziegler Subject: [PATCH] tracing: probeevent: Correctly update remaining space in dynamic area Date: Tue, 22 Jan 2019 13:48:48 +0100 Message-Id: <20190122124848.17774-1-andreas.ziegler@fau.de> X-Mailer: git-send-email 2.17.1 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 --- kernel/trace/trace_probe_tmpl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h index 5c56afc17cf8..0cf953e47584 100644 --- a/kernel/trace/trace_probe_tmpl.h +++ b/kernel/trace/trace_probe_tmpl.h @@ -182,8 +182,10 @@ store_trace_args(void *data, struct trace_probe *tp, struct pt_regs *regs, ret = process_fetch_insn(arg->code, regs, dl, base); if (unlikely(ret < 0 && arg->dynamic)) *dl = make_data_loc(0, dyndata - base); - else + else { dyndata += ret; + maxlen -= ret; + } } } -- 2.17.1