Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2556472yba; Mon, 6 May 2019 07:59:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDP9DeSfYCEFBnO51IZs9A/SdA01aJicekCbQwYyw01vfq6zts3nlhgHH9i5fqqUQ4duiK X-Received: by 2002:a63:1d4f:: with SMTP id d15mr31514045pgm.347.1557154761222; Mon, 06 May 2019 07:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557154761; cv=none; d=google.com; s=arc-20160816; b=fMPO8t7j1E3b7T01xZgFcq7fb3eeGUFlA1z2Yp2YYajWbfOxGjU1WNp/vf5s/WVf7v dN2SLQp+buhWympvub1njo5igFKd9Fz39nqRTQEjO4CcPnh6DS6CH+ZQ3hhTN2a3TAIU nKa2+egujr/LEMUqTGIiKwySM6pYpMOvqHFbrOVtU0Z+qUgWlg5RQD6qaU0Jh5+mqIhN fo7AlFhMj8iXfaHtT+EtPfRLb3CVZIkAPkDqKcTmc5xlJZTuCefPjy04O8hd5SOTCvrP K692K1ZqRGWpDBKzcSayZcVFSS8FM3y8aRuHdIHZUiIr+Q9dREChsbxgT4rzvP8C40U/ ZhOw== 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=nV+moVGaZIL67fN5XW+OQY1ALwdtoid+LUIAYeS4pv9yBWrsa8M+qmd6tx8iXhpenc nVEQhheHSXMRNL44/8Xo5T0/6XNnySk059StwBVr9UnmWw1FNf5lFiG/yXCsxRq5c9V7 gusFNZHsnBoW7x8Cv6FRKD48l/zJ+rZpwwu+A33gX4bTpjOOx655VIquKrJJ6A41GVjX UF2akevpb+masenJaO2aQtTmIgHnixg3EpF5JWn+QBAMFgqI3OIYJGd6Biun9WLDgMPr O1EDWpkoUpQPYZrqGKnkbGEx0LADa3k02t4+XS5sOc2Jk1LOV5WcSHsLwIvIS587va0B WYbw== 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 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 gn13si14117609plb.377.2019.05.06.07.59.05; Mon, 06 May 2019 07:59:21 -0700 (PDT) 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=LsHUEMNb; 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 S1727545AbfEFO6O (ORCPT + 99 others); Mon, 6 May 2019 10:58:14 -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 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: 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);