Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp905259pxx; Tue, 27 Oct 2020 03:36:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMB9SQkuQPvjPAnNcag67gduG/JDSRpG25r9TElNQvt+eQMSsEzDsM6HhjT1M/ktQZo5hU X-Received: by 2002:a17:906:c149:: with SMTP id dp9mr1821459ejc.88.1603794982772; Tue, 27 Oct 2020 03:36:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603794982; cv=none; d=google.com; s=arc-20160816; b=fqxP+ijEOnSadUkB7hMJ+bFRxebJJ3aLW4Rt5v99NzMh37ToAJp/a7Kh1b22hVEyt5 VUPKrp9HdgNWRRgpUTxPjVSh8MHUYVsT7PDr9z95pMb85AcA7aL+fAiA9y+GWFeUMpJg f2CnucGWA1VB3M4ACPYSeFtOa4a84IIfL/b3WSA9l8SoFIfVHF+ylp4k5LBGvlNasKj6 9WS3w12yEvho5bDlhTu2PYO3AfJ8T/otNJK7OqC1CQZuMpQdrzE0gxZyhi+qG9QuZCab 20kZZM7UFv8sNWx705KDG0ylV7Jb93yjZvfn7zkJsjrAowhAf8XZeezLGiK51B5vtLt+ 369A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ObGJBJeqSJ2I7LqRVcRhEWTeuQki4K9X7DSYCTo2yJw=; b=EOXv3Vx5wsMbjHWXt+auBY8G9JLl5VFRsOoiMnFEvZlQGQ/Jqpwmbifv2671Tr9bCw TjqxbTH2iWZyaSyz8rkjjh7O22E+4ki1KvVCeu7jzwn3ezEKFmhC0lqxQf/EbGXDxuLj 1BY1eYzyCFMxlS4EapFbqYx3sM5B7PpZp0uBx4IuNwOILpE3PAZwdnq0lgSR0kB0F3uh t82hv8cFcpUm4Z02ObXSWWAK4qXKYVMEVG43yd4AlMd1gGoXYegM0elErZWsXdVXEKUC KvZJfmRvjB2kWAwrkdrWPieVf7jMe+7Dv6b3SYeGom09DtyF6QsvhS1DtufIyoK6p+O4 9LGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OFSngjRA; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t13si714511ejr.92.2020.10.27.03.36.00; Tue, 27 Oct 2020 03:36:22 -0700 (PDT) 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=@kernel.org header.s=default header.b=OFSngjRA; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436977AbgJZX6M (ORCPT + 99 others); Mon, 26 Oct 2020 19:58:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:34892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404516AbgJZXzy (ORCPT ); Mon, 26 Oct 2020 19:55:54 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2F11321D7B; Mon, 26 Oct 2020 23:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756553; bh=b0aSR3s+f7POOM80evIJLhUdfl2lkDPiYgyYitdmhcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OFSngjRALLWk81PIWJ8e/AKQTpxI2CsFm7VrCuHg8Vc9jLABsSb6eToNg6WzcPQ26 gXlj0pEyHSBUrP64zV1ygIxfW7Xs63w1LFAAacPeEgNxXK1e++NovMdVy958f1AUHN 5Fga8XJEKOKAUjzgHqEZGxP3H2RwrQA1hw8vz7r8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Masami Hiramatsu , Ingo Molnar , Sasha Levin , linux-ia64@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 30/80] ia64: kprobes: Use generic kretprobe trampoline handler Date: Mon, 26 Oct 2020 19:54:26 -0400 Message-Id: <20201026235516.1025100-30-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu [ Upstream commit e792ff804f49720ce003b3e4c618b5d996256a18 ] Use the generic kretprobe trampoline handler. Don't use framepointer verification. Signed-off-by: Masami Hiramatsu Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/159870606883.1229682.12331813108378725668.stgit@devnote2 Signed-off-by: Sasha Levin --- arch/ia64/kernel/kprobes.c | 77 +------------------------------------- 1 file changed, 2 insertions(+), 75 deletions(-) diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c index b8356edbde659..b3dc39050c1ad 100644 --- a/arch/ia64/kernel/kprobes.c +++ b/arch/ia64/kernel/kprobes.c @@ -396,83 +396,9 @@ static void kretprobe_trampoline(void) { } -/* - * At this point the target function has been tricked into - * returning into our trampoline. Lookup the associated instance - * and then: - * - call the handler function - * - cleanup by marking the instance as unused - * - long jump back to the original return address - */ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) { - struct kretprobe_instance *ri = NULL; - struct hlist_head *head, empty_rp; - struct hlist_node *tmp; - unsigned long flags, orig_ret_address = 0; - unsigned long trampoline_address = - ((struct fnptr *)kretprobe_trampoline)->ip; - - INIT_HLIST_HEAD(&empty_rp); - kretprobe_hash_lock(current, &head, &flags); - - /* - * It is possible to have multiple instances associated with a given - * task either because an multiple functions in the call path - * have a return probe installed on them, and/or more than one return - * return probe was registered for a target function. - * - * We can handle this because: - * - instances are always inserted at the head of the list - * - when multiple return probes are registered for the same - * function, the first instance's ret_addr will point to the - * real return address, and all the rest will point to - * kretprobe_trampoline - */ - hlist_for_each_entry_safe(ri, tmp, head, hlist) { - if (ri->task != current) - /* another task is sharing our hash bucket */ - continue; - - orig_ret_address = (unsigned long)ri->ret_addr; - if (orig_ret_address != trampoline_address) - /* - * This is the real return address. Any other - * instances associated with this task are for - * other calls deeper on the call stack - */ - break; - } - - regs->cr_iip = orig_ret_address; - - hlist_for_each_entry_safe(ri, tmp, head, hlist) { - if (ri->task != current) - /* another task is sharing our hash bucket */ - continue; - - if (ri->rp && ri->rp->handler) - ri->rp->handler(ri, regs); - - orig_ret_address = (unsigned long)ri->ret_addr; - recycle_rp_inst(ri, &empty_rp); - - if (orig_ret_address != trampoline_address) - /* - * This is the real return address. Any other - * instances associated with this task are for - * other calls deeper on the call stack - */ - break; - } - kretprobe_assert(ri, orig_ret_address, trampoline_address); - - kretprobe_hash_unlock(current, &flags); - - hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) { - hlist_del(&ri->hlist); - kfree(ri); - } + regs->cr_iip = __kretprobe_trampoline_handler(regs, kretprobe_trampoline, NULL); /* * By returning a non-zero value, we are telling * kprobe_handler() that we don't want the post_handler @@ -485,6 +411,7 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs *regs) { ri->ret_addr = (kprobe_opcode_t *)regs->b0; + ri->fp = NULL; /* Replace the return addr with trampoline addr */ regs->b0 = ((struct fnptr *)kretprobe_trampoline)->ip; -- 2.25.1