Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1500639pxb; Thu, 28 Jan 2021 19:41:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyx5gtwMNCsfV8XwytECPNqS9VWhAlpcDpiats/bCXKaJFN0M8g3iyw9NJM0gZeob+PjVbJ X-Received: by 2002:a17:906:a84d:: with SMTP id dx13mr2589959ejb.275.1611891669930; Thu, 28 Jan 2021 19:41:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611891669; cv=none; d=google.com; s=arc-20160816; b=lXNJ8jlcorIsfSskydBGzI3m9RRbB1sjF56heFaVi0QxX3oglP8lgBlXcOGVs78RPi qhbZuvx+vEFa2o0FNKTpn59RnmJrFNlL97i4uf1ULy7tVVEjuFJJWeByOO7WQ6NBrCy3 74PluD3duo/qCHdImQft3WUa/ICcWMcXBSHXarTxADzFlia66raDLPm+b37tuu27Ts4T Ly6JqUxx5UycXRS1ZIJ3dy/DwkK4rvqERVdlvgilAjT0wXzFTuUOs3Q/6iHxhGA6wekm l886+XmmW9iRlqWExcts2wH84blSBb7Rz0pBA8g+DovXK7LSvVQa25UKGSxaTIS7y4DN 1xXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=G38G4kGa/0gXeBa/+ri7OWTmGq3L46eE0tnr4T8mT20=; b=PpvdxgNfofyBoVytEM70vghvXyK6jnRc1Io4/QvpAs0hcifNztcWm0w6BXcEA49fr7 psC5GOkB3pxVr78DJfNV4y2bM2I5AJuriFuEtE6Ept4xRD6xC7JSKJDjQ/a1uTh1hve/ pz/kfIc3oZg0Gde9sG6shWdWL8hSc8h4PTQMO8g7xMJ36AEdwuR97dmyiPCIbx8Z8lDt UeHOEknXH7nKnLOb+Xk3xPiNo2azC4LDQ9GGlUB1gCwEM501JUM203TcOCoap5JFkG2b cMfUCZ0CK8smdO7XQ9klUAT9nuqVlWgb32bRN/jOvxTHHCBkT0udT4PPUJWLC8MaT7Kk hSfA== 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 m24si3795780ejg.728.2021.01.28.19.40.45; Thu, 28 Jan 2021 19:41:09 -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 S231783AbhA2Did (ORCPT + 99 others); Thu, 28 Jan 2021 22:38:33 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:11906 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231593AbhA2Di3 (ORCPT ); Thu, 28 Jan 2021 22:38:29 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DRjgf3NsYzjDdN; Fri, 29 Jan 2021 11:36:46 +0800 (CST) Received: from [10.174.178.52] (10.174.178.52) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.498.0; Fri, 29 Jan 2021 11:37:40 +0800 Subject: Re: [PATCH] kretprobe: avoid re-registration of the same kretprobe earlier To: Masami Hiramatsu CC: Steven Rostedt , , , , , , References: <20201124115719.11799-1-bobo.shaobowang@huawei.com> <20201130161850.34bcfc8a@gandalf.local.home> <20201202083253.9dbc76704149261e131345bf@kernel.org> <9dff21f8-4ab9-f9b2-64fd-cc8c5f731932@huawei.com> <20201215123119.35258dd5006942be247600db@kernel.org> <20201222200356.6910b42c165b8756878cc9b0@kernel.org> From: "Wangshaobo (bobo)" Message-ID: Date: Fri, 29 Jan 2021 11:37:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <20201222200356.6910b42c165b8756878cc9b0@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.52] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Masami and Steve, I have sent v2 but still have confusions: > OK, I think it is simpler to check the rp->kp.addr && rp->kp.symbol_name > because it is not allowed (it can lead inconsistent setting). > > How about this code? Is this work for you? > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index 41fdbb7953c6..73500be564be 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -2103,6 +2103,14 @@ int register_kretprobe(struct kretprobe *rp) > int i; > void *addr; > > + /* It is not allowed to specify addr and symbol_name at the same time */ > + if (rp->kp.addr && rp->kp.symbol_name) > + return -EINVAL; > + above sentence can be removed because of kprobe_on_func_entry() do it: kprobe_on_func_entry()      -=>_kprobe_addr() {if (rp->kp.addr && rp->kp.symbol_name) ...} > + /* If only rp->kp.addr is specified, check reregistering kprobes */ > + if (rp->kp.addr && check_kprobe_rereg(&rp->kp)) > + return -EINVAL; for arch arm64,x86_64, above sentence can be moved behind following sentence. kprobe_on_func_entry()     -=>arch_kprobe_on_func_entry() {kp->offset can not be 0 ; ...} So if offset of kprobe if not 0, do not waste time to excute above sentence. But for Arch ppc64,  I still not figure out better one solution. Thank you -- Wang ShaoBo > if (!kprobe_on_func_entry(rp->kp.addr, rp->kp.symbol_name, rp->kp.offset)) > return -EINVAL; > > > Thank you, >