Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1829623pxb; Sat, 27 Feb 2021 01:21:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxRy96qQwppNNEJnGMecDox4+jNhJ4snZjCFELCwkVTa/YqoH3rCo2VvDZ6y4ruuwDcrin X-Received: by 2002:a05:6402:1118:: with SMTP id u24mr7417359edv.386.1614417673601; Sat, 27 Feb 2021 01:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614417673; cv=none; d=google.com; s=arc-20160816; b=UajnhbLlR7LyxbEVnmBaNZw1OdCbDHt65aux9y5PJA1N+0YsGXBHA7X5F/ci8SvxcP Q0HdYrM8EyIV90TbU0ze/iTI528is9bQ8myfFu/au+JlJBh3oR4JhAe6PF4CHYM5lU31 L049wG7GgOc5JqfXBPnvpJKjlQPi2ylScRChxbw8qOUyk8hxH7BGUDs2vIynRzvecyIz PIQriTCi/O4EAAD1gkmUDYA1ipvrBZxfrrhpHrYr/YpAWiFy4gR/02HyFC+SUIOXcoxh ISticG5xip59dDi43h4v5Levj9yQqLIhLj8TzzZSbyx1/BAaiC3nw68f1qaK1yBaTx2G bkgA== 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 :message-id:date:subject:cc:to:from; bh=fJhxIWZK34X35CsCHY0uPzSIIBgOIug+VnqoD1nyLPY=; b=MX9tQfwtcgSSj5Ex9vF6nVETf54MvcSbuSQ4cDABmZVRDZbK7tp7RCC/Zc3p+ghh0l yT6rzGjx1lxj9I/t9vJr9VPwD+sb7Qy6QyNvpUazxE1+W65E7bRrItiDAJ6l8cUH6zXK 9dNHghyi3HYtJaEqu6JmAD2lulrADdD4nFAFMId84qL1DVTn/fEARPIVcu/Rl8186zCk DTHfpxlcsO9jxOBVxgaSkZrTXSdSkni1KdPp5ZbyWva+SKKg7eMiZYxdDjW+lQ2/ZYfl X5Yr2QB6dlVQXz9wofwkFr5MEL+5366F0qRV18C3APtFA7qUZv1LOH2xyjS8VsU3pMD1 LH0w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g16si8543679ejf.30.2021.02.27.01.20.47; Sat, 27 Feb 2021 01:21:13 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbhB0JSM (ORCPT + 99 others); Sat, 27 Feb 2021 04:18:12 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:12654 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbhB0JSL (ORCPT ); Sat, 27 Feb 2021 04:18:11 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Dngpv2RCFzlPmM; Sat, 27 Feb 2021 17:15:19 +0800 (CST) Received: from DESKTOP-E0KHRBE.china.huawei.com (10.67.103.82) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Sat, 27 Feb 2021 17:17:17 +0800 From: huangshaobo To: , , , , , , CC: , , , , , , Subject: [PATCH 4.4.y] arm: kprobes: Allow to handle reentered kprobe on single-stepping Date: Sat, 27 Feb 2021 17:17:01 +0800 Message-ID: <20210227091701.23944-1-huangshaobo6@huawei.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.103.82] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu commit f3fbd7ec62dec1528fb8044034e2885f2b257941 upstream This is arm port of commit 6a5022a56ac3 ("kprobes/x86: Allow to handle reentered kprobe on single-stepping") Since the FIQ handlers can interrupt in the single stepping (or preparing the single stepping, do_debug etc.), we should consider a kprobe is hit in the NMI handler. Even in that case, the kprobe is allowed to be reentered as same as the kprobes hit in kprobe handlers (KPROBE_HIT_ACTIVE or KPROBE_HIT_SSDONE). The real issue will happen when a kprobe hit while another reentered kprobe is processing (KPROBE_REENTER), because we already consumed a saved-area for the previous kprobe. Signed-off-by: Masami Hiramatsu Signed-off-by: Jon Medhurst Fixes: 24ba613c9d6c ("ARM kprobes: core code") Cc: stable@vger.kernel.org #v2.6.25~v4.11 Signed-off-by: huangshaobo --- arch/arm/probes/kprobes/core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/probes/kprobes/core.c b/arch/arm/probes/kprobes/core.c index 3eb018fa1a1f..c3362ddd6c4c 100644 --- a/arch/arm/probes/kprobes/core.c +++ b/arch/arm/probes/kprobes/core.c @@ -270,6 +270,7 @@ void __kprobes kprobe_handler(struct pt_regs *regs) switch (kcb->kprobe_status) { case KPROBE_HIT_ACTIVE: case KPROBE_HIT_SSDONE: + case KPROBE_HIT_SS: /* A pre- or post-handler probe got us here. */ kprobes_inc_nmissed_count(p); save_previous_kprobe(kcb); @@ -278,6 +279,11 @@ void __kprobes kprobe_handler(struct pt_regs *regs) singlestep(p, regs, kcb); restore_previous_kprobe(kcb); break; + case KPROBE_REENTER: + /* A nested probe was hit in FIQ, it is a BUG */ + pr_warn("Unrecoverable kprobe detected at %p.\n", + p->addr); + /* fall through */ default: /* impossible cases */ BUG(); -- 2.12.3