Message ID | 20230423091235.968980-1-ruanjinjie@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2112994vqo; Sun, 23 Apr 2023 02:56:59 -0700 (PDT) X-Google-Smtp-Source: AKy350bELckdQk0q6MttDgRYFIsIq7jcGVCy6HnUhatqODmzxzWRyB9f/gd2MIR7HJH43NsJ3iUk X-Received: by 2002:a05:6a20:4296:b0:ef:1457:6cdf with SMTP id o22-20020a056a20429600b000ef14576cdfmr13340403pzj.19.1682243819617; Sun, 23 Apr 2023 02:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682243819; cv=none; d=google.com; s=arc-20160816; b=BHBS0NFBi6ZY5oQViRQHT/9An8a4b9/4g7g9OL3Wx03Nc5FtJaHp/CLRxnW+KKFmhM lTKc//czCW+d5O8Y3Y74jt6fJd0jqgrT3HCu1BoR2FLRwCze63SVdXnJku5EHDZBCZi+ Ss7vLpbM6FqcMFXBM8KSmHxQznqfVD9l61VdQ8Ffz0LXCE5RWRaCnGWabUcEWG+IVOgG j0ThKLGXQfULlbOGoQA7wW6aOEqtskB70faZ8XJKf3Iah3UHxRvzNjwLhPFOKmpb7PtG R6G2JFIvD23s406hV+Lbykk8rVZEaREn7aRdjKFDrk2N+VqQE7IJExQVgWhhYPJ4r0VS vQJQ== 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=b/z/pPWDp3rI14053+E146h+I5Qv3sFdpN95mK5G90k=; b=kWL74gVqggLJnBy8o0kS5a4jeuQjRRNwaonIpcKVdnnjP78PN52nuIIRqN5dZSmYwI naYRUe4NZDoweqfMHEKv1SrMxeq6+cIRTJsHyZqyMka+RhrURHAYgO+EaWTbE+4qm60l 7yz0uCBuNOjCa3WWKJHzQeQe5lIAfumqV2yFngBSWah//fpy6D0I4cVSh4NePf2uhTXr UsihwRTNSgjDiOXgGRaRCy/srQg0C/D7pkh9uVa2YcXVFNXeVl8VM9KaxVUpXhMQXjHX spkm2TvpjFJegcfhMUuxlDQ6hcj6NEneIfyyRLHOWXdwTmZvj8D+WnXaZiKC8Wgb6mSs JSBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a6567c3000000b0050bf0c6b2f4si8796492pgs.379.2023.04.23.02.56.47; Sun, 23 Apr 2023 02:56:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229976AbjDWJOR (ORCPT <rfc822;fengqi706@gmail.com> + 99 others); Sun, 23 Apr 2023 05:14:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjDWJOQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 23 Apr 2023 05:14:16 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 673881727 for <linux-kernel@vger.kernel.org>; Sun, 23 Apr 2023 02:14:15 -0700 (PDT) Received: from kwepemi500008.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Q42Z84gYczL0YL; Sun, 23 Apr 2023 17:11:28 +0800 (CST) Received: from huawei.com (10.67.175.83) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Sun, 23 Apr 2023 17:14:11 +0800 From: ruanjinjie <ruanjinjie@huawei.com> To: <paul.walmsley@sifive.com>, <palmer@dabbelt.com>, <aou@eecs.berkeley.edu>, <linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org> CC: <ruanjinjie@huawei.com> Subject: [PATCH v2] riscv: fix kprobe __user string arg print fault issue Date: Sun, 23 Apr 2023 17:12:35 +0800 Message-ID: <20230423091235.968980-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.175.83] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500008.china.huawei.com (7.221.188.139) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763928486262618757?= X-GMAIL-MSGID: =?utf-8?q?1763960495571926111?= |
Series |
[v2] riscv: fix kprobe __user string arg print fault issue
|
|
Commit Message
Jinjie Ruan
April 23, 2023, 9:12 a.m. UTC
On riscv qemu platform, when add kprobe event on do_sys_open() to show
filename string arg, it just print fault as follow:
echo 'p:myprobe do_sys_open dfd=$arg1 filename=+0($arg2):string flags=$arg3
mode=$arg4' > kprobe_events
bash-166 [000] ...1. 360.195367: myprobe: (do_sys_open+0x0/0x84)
dfd=0xffffffffffffff9c filename=(fault) flags=0x8241 mode=0x1b6
bash-166 [000] ...1. 360.219369: myprobe: (do_sys_open+0x0/0x84)
dfd=0xffffffffffffff9c filename=(fault) flags=0x8241 mode=0x1b6
bash-191 [000] ...1. 360.378827: myprobe: (do_sys_open+0x0/0x84)
dfd=0xffffffffffffff9c filename=(fault) flags=0x98800 mode=0x0
As riscv do not select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE,
the +0($arg2) addr is processed as a kernel address though it is a
userspace address, cause the above filename=(fault) print. So select
ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE to avoid the issue, after that the
kprobe trace is ok as below:
bash-166 [000] ...1. 96.767641: myprobe: (do_sys_open+0x0/0x84)
dfd=0xffffffffffffff9c filename="/dev/null" flags=0x8241 mode=0x1b6
bash-166 [000] ...1. 96.793751: myprobe: (do_sys_open+0x0/0x84)
dfd=0xffffffffffffff9c filename="/dev/null" flags=0x8241 mode=0x1b6
bash-177 [000] ...1. 96.962354: myprobe: (do_sys_open+0x0/0x84)
dfd=0xffffffffffffff9c filename="/sys/kernel/debug/tracing/events/kprobes/"
flags=0x98800 mode=0x0
Signed-off-by: ruanjinjie <ruanjinjie@huawei.com>
---
v2:
- add the config in alphabetical order
---
arch/riscv/Kconfig | 1 +
1 file changed, 1 insertion(+)
Comments
Ping. On 2023/4/23 17:12, ruanjinjie wrote: > On riscv qemu platform, when add kprobe event on do_sys_open() to show > filename string arg, it just print fault as follow: > > echo 'p:myprobe do_sys_open dfd=$arg1 filename=+0($arg2):string flags=$arg3 > mode=$arg4' > kprobe_events > > bash-166 [000] ...1. 360.195367: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename=(fault) flags=0x8241 mode=0x1b6 > > bash-166 [000] ...1. 360.219369: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename=(fault) flags=0x8241 mode=0x1b6 > > bash-191 [000] ...1. 360.378827: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename=(fault) flags=0x98800 mode=0x0 > > As riscv do not select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE, > the +0($arg2) addr is processed as a kernel address though it is a > userspace address, cause the above filename=(fault) print. So select > ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE to avoid the issue, after that the > kprobe trace is ok as below: > > bash-166 [000] ...1. 96.767641: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename="/dev/null" flags=0x8241 mode=0x1b6 > > bash-166 [000] ...1. 96.793751: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename="/dev/null" flags=0x8241 mode=0x1b6 > > bash-177 [000] ...1. 96.962354: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename="/sys/kernel/debug/tracing/events/kprobes/" > flags=0x98800 mode=0x0 > > Signed-off-by: ruanjinjie <ruanjinjie@huawei.com> > --- > v2: > - add the config in alphabetical order > --- > arch/riscv/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index eb7f29a412f8..b462ed7d41fe 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -25,6 +25,7 @@ config RISCV > select ARCH_HAS_GIGANTIC_PAGE > select ARCH_HAS_KCOV > select ARCH_HAS_MMIOWB > + select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE > select ARCH_HAS_PMEM_API > select ARCH_HAS_PTE_SPECIAL > select ARCH_HAS_SET_DIRECT_MAP if MMU
ruanjinjie <ruanjinjie@huawei.com> writes: > On riscv qemu platform, when add kprobe event on do_sys_open() to show > filename string arg, it just print fault as follow: > > echo 'p:myprobe do_sys_open dfd=$arg1 filename=+0($arg2):string flags=$arg3 > mode=$arg4' > kprobe_events > > bash-166 [000] ...1. 360.195367: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename=(fault) flags=0x8241 mode=0x1b6 > > bash-166 [000] ...1. 360.219369: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename=(fault) flags=0x8241 mode=0x1b6 > > bash-191 [000] ...1. 360.378827: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename=(fault) flags=0x98800 mode=0x0 > > As riscv do not select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE, > the +0($arg2) addr is processed as a kernel address though it is a > userspace address, cause the above filename=(fault) print. So select > ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE to avoid the issue, after that the > kprobe trace is ok as below: > > bash-166 [000] ...1. 96.767641: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename="/dev/null" flags=0x8241 mode=0x1b6 > > bash-166 [000] ...1. 96.793751: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename="/dev/null" flags=0x8241 mode=0x1b6 > > bash-177 [000] ...1. 96.962354: myprobe: (do_sys_open+0x0/0x84) > dfd=0xffffffffffffff9c filename="/sys/kernel/debug/tracing/events/kprobes/" > flags=0x98800 mode=0x0 > > Signed-off-by: ruanjinjie <ruanjinjie@huawei.com> Please use your full name. > --- > v2: > - add the config in alphabetical order > --- > arch/riscv/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index eb7f29a412f8..b462ed7d41fe 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -25,6 +25,7 @@ config RISCV > select ARCH_HAS_GIGANTIC_PAGE > select ARCH_HAS_KCOV > select ARCH_HAS_MMIOWB > + select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE After adding proper name in SoB, feel free to add: Acked-by: Björn Töpel <bjorn@rivosinc.com> > select ARCH_HAS_PMEM_API > select ARCH_HAS_PTE_SPECIAL > select ARCH_HAS_SET_DIRECT_MAP if MMU > -- > 2.25.1
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index eb7f29a412f8..b462ed7d41fe 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -25,6 +25,7 @@ config RISCV select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV select ARCH_HAS_MMIOWB + select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PMEM_API select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SET_DIRECT_MAP if MMU