Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp401562pxu; Tue, 1 Dec 2020 14:19:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMpIf+WN3kX1O3JhpfCfdQqK5xsG6X1xEVWrNKo1rX5kvwy7FznDaoQcdD2RViVvNYA8aO X-Received: by 2002:aa7:d545:: with SMTP id u5mr5246027edr.113.1606861196916; Tue, 01 Dec 2020 14:19:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861196; cv=none; d=google.com; s=arc-20160816; b=RWE/3lEPWq7E6EvI6T1BgxvG9Q/WO/NdMvXAmFGkhSu/ib/cyXC5USJqTunh6Zp9BB 7JJNJVzL4383rNT0/4uxqAh/3BVLddeqEgLFjmtB6+t/CZfkJdiqiH1V3TrNHWrwU1iE t8zEppg/v+N97u9ODJa6BRly5CZ0YsnadoJG7DzICCz0RXitVIoRYyBguqbibpnQWQpe 3X0IMwiDL4A9hgKAVn1jme8wfPQRMXv044qjDzgvM9RxcftjYyRmspSqNeuLnYQgKw9u 8KHJsjb6/eLxrXZBHY7waEZ2oxHK6duV6EY607HxHeaN6evoF2afQNkXwrutAg+0A//7 0hSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kknBzrTtF36RyqbLPSv5jOILL6Jtil93OwiSb4tG5XI=; b=CrGLr6dIN743gs+/2RA+JcLjj2JOkEAadiEjUzfaPhhI0B9uZ4e8RxadmEuUF7g52/ CMQhajRqL02UsPPsrlDWO38JBVHDWlsTAbVsThhFHWfd70aKGxSNFMbFjnBjdUUM48Ww XC7zNF1xYgTTX6hDILtqsbREwwBjOFNK9bFIIqQ5h4mlrYVVv6QTmgvqZzWtXgtlAedw zrfFBXlSx/0COas1wcR3UT5LcnYKOMdXIZD+7EPo8JQ3zGg6M4BWz39gUpl0wi1PeJ7E sAux/Aw02Nr/Ny0+l0vWLtNKq6nWiuACmqvZDWjs7dAPW6QboH+3ngbKLTFmgjrXqh5V ky+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1kHocxZ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si777746edx.431.2020.12.01.14.19.34; Tue, 01 Dec 2020 14:19:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1kHocxZ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387806AbgLAI51 (ORCPT + 99 others); Tue, 1 Dec 2020 03:57:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:60596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729251AbgLAI5Z (ORCPT ); Tue, 1 Dec 2020 03:57:25 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 CE763217A0; Tue, 1 Dec 2020 08:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813029; bh=h1W4HaVghn4s9MK9eosH2RNEJR7M4Y5nEnsp+sYZ9XQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1kHocxZ5BVtLUeNPbmDzlHwi7OTzerLbkHV0cspItzph2pusnJI+2qhz/f6dVbc2W +R+I/XUvxHaXGDQ2y+KZixQ1n84t2E7FVi+2b78wB219ah8k7WkaFXdLWQJianCVcR 3XqlMOjGawe71QcFC4RWK+VpWAKn1+xDi7Z6O8FM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathieu Poirier , Igor Lubashev , Alexander Shishkin , Alexey Budankov , James Morris , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Suzuki Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo , Alexander Dahl Subject: [PATCH 4.14 01/50] perf event: Check ref_reloc_sym before using it Date: Tue, 1 Dec 2020 09:53:00 +0100 Message-Id: <20201201084644.950526926@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084644.803812112@linuxfoundation.org> References: <20201201084644.803812112@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Igor Lubashev commit e9a6882f267a8105461066e3ea6b4b6b9be1b807 upstream. Check for ref_reloc_sym before using it instead of checking symbol_conf.kptr_restrict and relying solely on that check. Reported-by: Mathieu Poirier Signed-off-by: Igor Lubashev Tested-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Alexey Budankov Cc: James Morris Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1566869956-7154-2-git-send-email-ilubashe@akamai.com Signed-off-by: Arnaldo Carvalho de Melo Cc: Alexander Dahl Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/event.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -794,11 +794,13 @@ int perf_event__synthesize_kernel_mmap(s int err; union perf_event *event; - if (symbol_conf.kptr_restrict) - return -1; if (map == NULL) return -1; + kmap = map__kmap(map); + if (!kmap->ref_reloc_sym) + return -1; + /* * We should get this from /sys/kernel/sections/.text, but till that is * available use this, and after it is use this as a fallback for older @@ -822,7 +824,6 @@ int perf_event__synthesize_kernel_mmap(s event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL; } - kmap = map__kmap(map); size = snprintf(event->mmap.filename, sizeof(event->mmap.filename), "%s%s", mmap_name, kmap->ref_reloc_sym->name) + 1; size = PERF_ALIGN(size, sizeof(u64));