Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp409178pxu; Tue, 1 Dec 2020 14:32:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxSwYE8nYyPMlbB/zWnsGfFaDCv9eRutCyM6WYwfSDM4qgUR4UBQHZ9TzDEqNNOQFvxMq4j X-Received: by 2002:a50:e786:: with SMTP id b6mr5197580edn.242.1606861970305; Tue, 01 Dec 2020 14:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861970; cv=none; d=google.com; s=arc-20160816; b=hhFF65e83oEaIaRPw7gaDn/PNgk8OiHIW3Rnsv2SBh4p/RF4Lu1ph1T19gPXockNTq 2WyuUDip8k93JkQBJ7hBLSVjt+dKJGJpwzRSDhho8ZfYYNDpyadiscrV/wS3XRU0OHgJ NGc/VKiUdlSoIRRTqtjC8uCqYpoUfOx9/8+OvgQPCeVIwVpfH0J/ZGW6IT1wo/SPqrxd J+XPJDOHu3ODIsgW3uCIH9LtGGedkOtLyZQI38c/VXUtsEbnlUkC5xKhT7e1NQurDiAb YzF5JZQFRqYEd+jJaFzgp7iIXiW4wRTZfdksvchyPKMqBEwBIk2w/RkyITKfwan4aJ18 JxMQ== 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=W5M3oy0hVwZBjAsNWZ8NycpSyUozD1V17z6fDmRYOpA=; b=zA9kFq8Vpj6DLOO77cuh/DBHIDRymGxhqhYkprURdy5SzXJ5RrzBmtxmmj4AbcBqwQ AXpWO4WZhE23YmzWDygCv3wVpGaOcnfpvudoOK/9IxAsH8FDyrbeueDuHsOVXSsS7C/s tbXLDuzDLVedTFee2XDv+EhoXN0+G5igl0bVOC50176aHf8IuLIgtaOe0dU9e6XCxBGp Q6BkOEFjorEZrE6w5qSEE17TfQs23Z9kua4YWxlfOlZwPi9jcZ/YG7tLX/r115jaVC6P P3CW/RO1gri2WOJDO3zwvF0BwiJKte/kia4Pq8dzVycpS9/Q74jVYvQwm3gi2G+ZgIu9 wiTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bwIRIvpp; 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 h24si961943ejt.452.2020.12.01.14.32.27; Tue, 01 Dec 2020 14:32:50 -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=bwIRIvpp; 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 S2391229AbgLAJaz (ORCPT + 99 others); Tue, 1 Dec 2020 04:30:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:57748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729092AbgLAIzV (ORCPT ); Tue, 1 Dec 2020 03:55:21 -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 056B32224B; Tue, 1 Dec 2020 08:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606812883; bh=j8jIezXE1iVzqmmri5lVcq0mQjhgAkZGwGITFThS85Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bwIRIvppxCs6KL2BKgTL+65xHinmgkzgQYzlmRb+gYj+nFsl5sDXDcW0tBoSi1JDe w5t/iQ9FLWi9pdTbiNtV+HtG8IL9boXCoTdpHMhl2+fAdvRjQv5T65il9KTbT2d3ul IiP02VH87f7YWcBMeWG8ycDYH/PnYUMuz6QkDpNM= 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.9 01/42] perf event: Check ref_reloc_sym before using it Date: Tue, 1 Dec 2020 09:52:59 +0100 Message-Id: <20201201084642.245523020@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084642.194933793@linuxfoundation.org> References: <20201201084642.194933793@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 @@ -682,11 +682,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 @@ -710,7 +712,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));