Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4491697ybx; Mon, 4 Nov 2019 14:18:28 -0800 (PST) X-Google-Smtp-Source: APXvYqx1nXxf+DwNTQdFjXBI9I/EvR762OhiGGZv5JQNBbjOUGVx3xYR+vrB0M5scW2JFN27YFOx X-Received: by 2002:a17:906:684a:: with SMTP id a10mr2254344ejs.160.1572905908689; Mon, 04 Nov 2019 14:18:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905908; cv=none; d=google.com; s=arc-20160816; b=LzEDxRplk95nFEq9x8vS38ebgFPsj5zy8GsNuOCfZ31uXNc/EFYZV51VBtQFFuYf/a 1PPcyTZx3bTH4Gr1jrfkQ0OnIX4K6ssNs0bikVqFpUHG+9aYjpqQgeSlBRn0B7oH2IIg jImHfdYeVQCkwfltEzHaKVVD+jBzFgdxsXxdiCqmr29E6VI7+Yrb0L3/hX3UIkQ9WWBO k4LIuWibwaQ88/+HDQ7DCTEt4cBg1u1emkuk8lPYgMKc/oYN0RtIKT2Cztj066wz0Ym4 vwpSOynkWemOZ8lQNQnuKgc146KnF4uLapAzEPw3tZo+6XMtjQpUsEGCEL5emQuXEzbr sDSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=S+Hmi5h+PbcqXnY+gfhoXYT83KYj259KeOG2o7aH+4U=; b=1JWxAHav/sgciya22l/pUo+WWpzDWpcAHwnpqEGAwixKSWpAZ+u8MQlc/wVQGm/Kju +rzy9dTo6FHNt8q3ZmcfqH1iPkjRxBBTwH4ouXShlFDP5K482WQfvrBh8kSaQOExpIra wVn5damBnLmzGuiUeQYaWODsjl4d+Yf0GHKuUUqhS34YfCGd9egik1LLPIcy5vNprwgB gxQ9Y+maB8S1WYRPPs47lqAvR75f6+gs6WcPc7iZaRbolqLzl5AU3FEu6Wqvtb+yeZu3 rlSGzXU3sW0BIbtaNpzksCIy0WwRuKkG5WyF5EkzF9IjjY3xcsgMyxpngMRITOi2k5C2 Kiyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wLW8TSf+; 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 bi17si9512626edb.430.2019.11.04.14.18.03; Mon, 04 Nov 2019 14:18:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=wLW8TSf+; 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 S2390141AbfKDWPh (ORCPT + 99 others); Mon, 4 Nov 2019 17:15:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:37450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387876AbfKDWFw (ORCPT ); Mon, 4 Nov 2019 17:05:52 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (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 3C50D2084D; Mon, 4 Nov 2019 22:05:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905152; bh=sn9PuHWrsSWJy+qnRz1rl2QGZbrjTOyXUksthEqa3vc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wLW8TSf+uAZEjqvklYSIGKsb/U2KOqvGO4pBcGj6GSgbK9zkySExP0fi52t13mJgC wT5FRoYHLQUiBMGl/qvX7iAeVW+GTeyQ5ABYNneDNsqDDoDLwGtVcoPQorwFMy4Xd3 C7TT6zns1U8drKgKYpiiy280MUuh4G3Fcsk5fSb4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Rogers , Arnaldo Carvalho de Melo , Alexander Shishkin , Andi Kleen , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Stephane Eranian , Wang Nan , Sasha Levin Subject: [PATCH 5.3 009/163] perf tests: Avoid raising SEGV using an obvious NULL dereference Date: Mon, 4 Nov 2019 22:43:19 +0100 Message-Id: <20191104212141.185441579@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ian Rogers [ Upstream commit e3e2cf3d5b1fe800b032e14c0fdcd9a6fb20cf3b ] An optimized build such as: make -C tools/perf CLANG=1 CC=clang EXTRA_CFLAGS="-O3 will turn the dereference operation into a ud2 instruction, raising a SIGILL rather than a SIGSEGV. Use raise(..) for correctness and clarity. Similar issues were addressed in Numfor Mbiziwo-Tiapo's patch: https://lkml.org/lkml/2019/7/8/1234 Committer testing: Before: [root@quaco ~]# perf test hooks 55: perf hooks : Ok [root@quaco ~]# perf test -v hooks 55: perf hooks : --- start --- test child forked, pid 17092 SIGSEGV is observed as expected, try to recover. Fatal error (SEGFAULT) in perf hook 'test' test child finished with 0 ---- end ---- perf hooks: Ok [root@quaco ~]# After: [root@quaco ~]# perf test hooks 55: perf hooks : Ok [root@quaco ~]# perf test -v hooks 55: perf hooks : --- start --- test child forked, pid 17909 SIGSEGV is observed as expected, try to recover. Fatal error (SEGFAULT) in perf hook 'test' test child finished with 0 ---- end ---- perf hooks: Ok [root@quaco ~]# Fixes: a074865e60ed ("perf tools: Introduce perf hooks") Signed-off-by: Ian Rogers Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Wang Nan Link: http://lore.kernel.org/lkml/20190925195924.152834-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/tests/perf-hooks.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/perf/tests/perf-hooks.c b/tools/perf/tests/perf-hooks.c index a693bcf017ea2..44c16fd11bf6e 100644 --- a/tools/perf/tests/perf-hooks.c +++ b/tools/perf/tests/perf-hooks.c @@ -20,12 +20,11 @@ static void sigsegv_handler(int sig __maybe_unused) static void the_hook(void *_hook_flags) { int *hook_flags = _hook_flags; - int *p = NULL; *hook_flags = 1234; /* Generate a segfault, test perf_hooks__recover */ - *p = 0; + raise(SIGSEGV); } int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unused) -- 2.20.1