From patchwork Mon May 6 14:32:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 163416 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp75773ilm; Mon, 6 May 2019 07:58:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/s+ZXZsoG6cF++xriL9LpRyC8TaehRfCA44saqBN8EpYm4XjMiqblwnbDct7kherv2CjE X-Received: by 2002:a17:902:822:: with SMTP id 31mr32330279plk.41.1557154693884; Mon, 06 May 2019 07:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557154693; cv=none; d=google.com; s=arc-20160816; b=edosxHwFvvwUF+fHTyezH/LRV807o+5cnwWxTlxKajUk64HnmcfEY7zbj4O9k2gYS2 3Ja9oPUWHpYftvCLdXQYl2j+OTYdcWkcfScYAB8WAw2z7DEWI6Zd8oCgZiBnu1WjMxGn 4KVE4s9NT+YWVd+lDDkMcVWexgUmdcuk59sw/WvX1GXdysLPncLk2G9YQjSAVpGFl0lB gSLyuV+KzlioIOFcVM/oDq7gawedGHU37aBPbSbedx1tULLxk3cL38oqWzNbqA6s9DHZ fsBnbUDjF2uCpw9wcycl/5qky/qZKUJO+OnUnxU30XJLn3rLhsPhTtB4RXfB1eIsl4xo cZEg== 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=DnJxnBAtGfFmfgU+l2qvCVuuNX49S5PnJ0hA/MnBFCo=; b=ubfCJ1CkvB6LywBETlOWfrRHyhor3oJ9RvLQWsnXD4GWgF9AoxRKb0bR3W6vNMH6Zr tbaruNIZpWvpvrALsc7NuwJ8+qwZSwntc4Anip877PdcBlbFWX676V/8Pzup+nkH3bGw EZQS0TD8uhOphJb2FLdctRAUhl6QxXyHu6EzlFNNXKobRTKEaTjIg13uZaDEbQceXdG/ 1rkV706rhRJ6Z4FHZaxcQKYs03s4ei9pZBDQkY1jmZkuOBpAsJa1S+YbKBcy9z0w/nqm ubt8ekPaQt1s3+EOpL/8nGKtUP0XQ6o1VXgh88GJH19B+vPQR9cRBTrExTqc0MFk6Or5 mI/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LsHUEMNb; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 a1si14929993pff.258.2019.05.06.07.58.13; Mon, 06 May 2019 07:58:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=LsHUEMNb; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727487AbfEFO6M (ORCPT + 14 others); Mon, 6 May 2019 10:58:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:39912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728243AbfEFOn4 (ORCPT ); Mon, 6 May 2019 10:43:56 -0400 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 D818A20449; Mon, 6 May 2019 14:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153836; bh=BCJyrJQC8pq+NG1HUdcgLrXOxTCc40nsDQ/UkAV12WQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LsHUEMNb/LyOhV+nzrNVBm4TZhnaHzYl3lhUav/kUEuCV4edB0QixqVnXEFSjqye2 2c5C8KNM8m4dy5Up4bBMg/mYl8q/GiefjappX9QRx1pM7Cbx2mK4kUcOoSHA+5QlYt 9ESbv85Dgw7KGHFYzXNihBqCWyghDnTOOWq9wIZU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Andrey Konovalov , Catalin Marinas , Will Deacon Subject: [PATCH 4.14 15/75] arm64: only advance singlestep for user instruction traps Date: Mon, 6 May 2019 16:32:23 +0200 Message-Id: <20190506143054.566908300@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143053.287515952@linuxfoundation.org> References: <20190506143053.287515952@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Rutland commit 9478f1927e6ef9ef5e1ad761af1c98aa8e40b7f5 upstream. Our arm64_skip_faulting_instruction() helper advances the userspace singlestep state machine, but this is also called by the kernel BRK handler, as used for WARN*(). Thus, if we happen to hit a WARN*() while the user singlestep state machine is in the active-no-pending state, we'll advance to the active-pending state without having executed a user instruction, and will take a step exception earlier than expected when we return to userspace. Let's fix this by only advancing the state machine when skipping a user instruction. Signed-off-by: Mark Rutland Cc: Andrey Konovalov Cc: Catalin Marinas Cc: Will Deacon Signed-off-by: Will Deacon Signed-off-by: Andrey Konovalov Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/traps.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -304,7 +304,8 @@ void arm64_skip_faulting_instruction(str * If we were single stepping, we want to get the step exception after * we return from the trap. */ - user_fastforward_single_step(current); + if (user_mode(regs)) + user_fastforward_single_step(current); } static LIST_HEAD(undef_hook);