Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2512688imm; Mon, 28 May 2018 09:29:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrECp4EZsLr8fSnD7tKjRc+SjCGon5ZJ34x7j/VGAGmGi5hf7zjota3SltZIM2dL3r0dU9l X-Received: by 2002:a17:902:7598:: with SMTP id j24-v6mr14352217pll.160.1527524963738; Mon, 28 May 2018 09:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527524963; cv=none; d=google.com; s=arc-20160816; b=u9RCojbabpH3PuBEDEcCfCqzdCTVPj1S3p8L+3+yA7iN1g8sf0Nvw/UGdhNNueQm6w DCJrKk2osf8y45tBBuf56lDTmC0SPrpuXcmeFtt1BO6kPKfN7/cdZhhKTqzH2IZcXB1T wNWx9BFq5XOAkMHG2GNV5qfF9Tk4htY5K++IGIkuq9wJO2MWv1hn6jyl5j3uppNQYs5/ 8MBD6M5J+pmbCap3W5/0PljDnJS4kJ5mIGNDxnoH8w7w+5LzHN1aA2nsIyCkc02KKz/k hIo9AUWbWzZ8Aa1LEvj4MkTqMLlQlZuHgGYkv+SwgXUCBzjw8dPouy43NnzbaO0u4uYc 9tFg== 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:dkim-signature :arc-authentication-results; bh=Hl03uqX30LYPgnuydq7hTIiCEXPXy99PqtTt5s4CGY4=; b=dRYCGrb/t9cOHyFt8WeYfteTOYIUzFVgQQaTMgUIVxv4DDjw7zCh5T6vUyHUa/zoDP I6gL82m5TZ7R4BiFW+tsyYTGwAwvugsqXEzA3NRYEsJNeign41Q2bFWAdGxFnsH1kOVk QGnPw6mUUVn0EwY/1ad15EBw2e7ch+d5LT7M1CqmanCHvoaS4EAtiWhZzReBve292hBD pJW4i5CCARql8zMqTsADNlqL/wJEBPWIX8Jq3r0zy9VXYKtw/8NDSlCRUQWTX0hzSU0v Vn/4BLxYi43mkfDMvIedZOkh6m5b9ImgsZ93TKfWOgpLA9Q+tApWqzh21PvNHLViqxA/ EtSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nOJbnHJr; 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 70-v6si32003180pfu.274.2018.05.28.09.29.09; Mon, 28 May 2018 09:29:23 -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; dkim=pass header.i=@kernel.org header.s=default header.b=nOJbnHJr; 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 S1425364AbeE1Q2i (ORCPT + 99 others); Mon, 28 May 2018 12:28:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:58238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936433AbeE1KKF (ORCPT ); Mon, 28 May 2018 06:10:05 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE0EF2086D; Mon, 28 May 2018 10:10:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502204; bh=/tpmcDq6fhSJZ5dpkH3rvhnIC8rcnI7xk1LlEleBsuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nOJbnHJrSPgSFoGByItmkBPsgadpgKzbr57XwB8S3aEWVUYdDVbT8gWXosemYTOjv sBxHNKVprIOfy1hMMnwVqBOw0lhd76lBj+519s6uR7r8QNCTC3JL4n5wECJmCm+rSR /SSoQbXcxvHFN4BbOngeanv0ght/nnHZVSmRZxto= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , "Steven Rostedt (VMware)" , Sasha Levin Subject: [PATCH 3.18 099/185] selftests: ftrace: Add probe event argument syntax testcase Date: Mon, 28 May 2018 12:02:20 +0200 Message-Id: <20180528100059.486444445@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Masami Hiramatsu [ Upstream commit 871bef2000968c312a4000b2f56d370dcedbc93c ] Add a testcase for probe event argument syntax which ensures the kprobe_events interface correctly parses given event arguments. Link: http://lkml.kernel.org/r/152129033679.31874.12705519603869152799.stgit@devbox Signed-off-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc | 97 ++++++++++ 1 file changed, 97 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc @@ -0,0 +1,97 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe event argument syntax + +[ -f kprobe_events ] || exit_unsupported # this is configurable + +grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue + +echo 0 > events/enable +echo > kprobe_events + +PROBEFUNC="vfs_read" +GOODREG= +BADREG= +GOODSYM="_sdata" +if ! grep -qw ${GOODSYM} /proc/kallsyms ; then + GOODSYM=$PROBEFUNC +fi +BADSYM="deaqswdefr" +SYMADDR=0x`grep -w ${GOODSYM} /proc/kallsyms | cut -f 1 -d " "` +GOODTYPE="x16" +BADTYPE="y16" + +case `uname -m` in +x86_64|i[3456]86) + GOODREG=%ax + BADREG=%ex +;; +aarch64) + GOODREG=%x0 + BADREG=%ax +;; +arm*) + GOODREG=%r0 + BADREG=%ax +;; +esac + +test_goodarg() # Good-args +{ + while [ "$1" ]; do + echo "p ${PROBEFUNC} $1" > kprobe_events + shift 1 + done; +} + +test_badarg() # Bad-args +{ + while [ "$1" ]; do + ! echo "p ${PROBEFUNC} $1" > kprobe_events + shift 1 + done; +} + +echo > kprobe_events + +: "Register access" +test_goodarg ${GOODREG} +test_badarg ${BADREG} + +: "Symbol access" +test_goodarg "@${GOODSYM}" "@${SYMADDR}" "@${GOODSYM}+10" "@${GOODSYM}-10" +test_badarg "@" "@${BADSYM}" "@${GOODSYM}*10" "@${GOODSYM}/10" \ + "@${GOODSYM}%10" "@${GOODSYM}&10" "@${GOODSYM}|10" + +: "Stack access" +test_goodarg "\$stack" "\$stack0" "\$stack1" +test_badarg "\$stackp" "\$stack0+10" "\$stack1-10" + +: "Retval access" +echo "r ${PROBEFUNC} \$retval" > kprobe_events +! echo "p ${PROBEFUNC} \$retval" > kprobe_events + +: "Comm access" +test_goodarg "\$comm" + +: "Indirect memory access" +test_goodarg "+0(${GOODREG})" "-0(${GOODREG})" "+10(\$stack)" \ + "+0(\$stack1)" "+10(@${GOODSYM}-10)" "+0(+10(+20(\$stack)))" +test_badarg "+(${GOODREG})" "(${GOODREG}+10)" "-(${GOODREG})" "(${GOODREG})" \ + "+10(\$comm)" "+0(${GOODREG})+10" + +: "Name assignment" +test_goodarg "varname=${GOODREG}" +test_badarg "varname=varname2=${GOODREG}" + +: "Type syntax" +test_goodarg "${GOODREG}:${GOODTYPE}" +test_badarg "${GOODREG}::${GOODTYPE}" "${GOODREG}:${BADTYPE}" \ + "${GOODTYPE}:${GOODREG}" + +: "Combination check" + +test_goodarg "\$comm:string" "+0(\$stack):string" +test_badarg "\$comm:x64" "\$stack:string" "${GOODREG}:string" + +echo > kprobe_events