Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13474641ybl; Sun, 29 Dec 2019 12:47:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzSbOx2rHyucUKcEUBmMqE7njGL8ooYe3HYLz6mqeZYRr++fr88CXLni/P8ScpQZx7U6UAJ X-Received: by 2002:a9d:4706:: with SMTP id a6mr65341397otf.331.1577652451794; Sun, 29 Dec 2019 12:47:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652451; cv=none; d=google.com; s=arc-20160816; b=fBGgy0BKtmFvHq+cZNOnHPSmG4eR8so39lMm5FMTHj8993+zWG9G5VVxqQadl5OvaQ fmnRoVRK2++9wldZnxswZahkI9PHF0JEHkIMpzjizI28OKd1MaGzrxHsKAsfeYHiDTcB L2MrtcKDbtYz/5/1Fu+aAw9uzqF79RbIHI75Bf0u/ZKWaj0OAHJ+pbBNKSpFmONUETwV TTC0wf1bDjlsr3HCiEtF1R1CHfjaUGqpFzJ4DXwvUs0R9jBBILSddgzEKciVQ6O9VcMm TJm5jzbfDJVLV3vSiHdqF84QsImD+IMNhdPv9MnZnr5NOq91RXKNjdmZ1Mc3t2tz+NQx pyLw== 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=+W/oQn1n/l06yKkfwn2undMLxewszmDFmLpTMpPebnI=; b=TViav2ufoLBZ8kaMfhfTj3V0j3lZ8KBVvURAJAOWuYhgyxegzVj6PR4O5X90w7JB0s VxyZW30f9VWc6sPU6pbtksyQFDVZqctE5kJdnxwvK07jN9QQ8RtUCJfSu5qDde7cM5EV vWmBauOFUR84VRFnHNpF+0cHB1jTTaK8Fz6sQsioT6fJi/AZ+CwF0nDHSt2gwcxox05B nu3bYbRess4MFPpxy+AN+2GFUE4nQoiDgVkfys1go3fXgKj1NfKyerdiIZ13zaProKOE QZSSUjd7DO5vNbMhqWiqIaEVkqFvOqhHUC6PaEgO1ZnM5eP/IZzboWEPYHkCuysoheDB YhDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Bgnyl2Qi; 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 n14si22947754otk.179.2019.12.29.12.47.21; Sun, 29 Dec 2019 12:47:31 -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=Bgnyl2Qi; 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 S1731713AbfL2Rts (ORCPT + 99 others); Sun, 29 Dec 2019 12:49:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:33726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731699AbfL2Rtp (ORCPT ); Sun, 29 Dec 2019 12:49:45 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 926F1206A4; Sun, 29 Dec 2019 17:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641785; bh=pY5RMKT8cgvlRPtL4xg+luLIwlAVdWKVgAjk5DNaUYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bgnyl2QiF72bnma+jwfGkhU3JZQsx4A3vVoN6hI2XncgXwcUeYmd7urIPGP4ehIN9 cPZp/ta5jiLQVo+qgAvV7+By58cT+e8azpNNdATi+TmdLfTv79mxH3t5tm7ZIqz8DH cO5polCKxFQDniAfPyk6aDLPlvgI1+pvaWeVXBQo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Leoshkevich , Vasily Gorbik , Sasha Levin Subject: [PATCH 5.4 210/434] s390: add error handling to perf_callchain_kernel Date: Sun, 29 Dec 2019 18:24:23 +0100 Message-Id: <20191229172715.778459235@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@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: Ilya Leoshkevich [ Upstream commit effb83ccc83a97dbbe5214f4c443522719f05f3a ] perf_callchain_kernel stops neither when it encounters a garbage address, nor when it runs out of space. Fix both issues using x86 version as an inspiration. Signed-off-by: Ilya Leoshkevich Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/kernel/perf_event.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c index fcb6c2e92b07..1e75cc983546 100644 --- a/arch/s390/kernel/perf_event.c +++ b/arch/s390/kernel/perf_event.c @@ -224,9 +224,13 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs) { struct unwind_state state; + unsigned long addr; - unwind_for_each_frame(&state, current, regs, 0) - perf_callchain_store(entry, state.ip); + unwind_for_each_frame(&state, current, regs, 0) { + addr = unwind_get_return_address(&state); + if (!addr || perf_callchain_store(entry, addr)) + return; + } } /* Perf definitions for PMU event attributes in sysfs */ -- 2.20.1