Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp458015pxb; Wed, 27 Jan 2021 11:57:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJx53/b+PtMGW8JrJfY9VuI9DWDt/30dUEFuE7V4ef6VuCwM1hJXxsE9LuDjsHVDA2YQ5fUc X-Received: by 2002:a17:906:5857:: with SMTP id h23mr7644534ejs.465.1611777429405; Wed, 27 Jan 2021 11:57:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611777429; cv=none; d=google.com; s=arc-20160816; b=jXUv9z/AqORGEJoGFE3oiuat+CHAfMBjRSYruFI4PovmT9t65cJt7kpJ12DLbH6UWs j1GRH4sUmMBpvtShObUPSR9shnmrgnDnMFGiVbF7uFkJG62QsZY8Y9oXX0RCIi12E8/X d/RJ9mNooE4csHdih5QONnWWsurKBy96WjSWDCXDStCxw72quPw4K1RQJRt1D7gkAt8u 3tRfXF7xceuNZgVjHInp3mzHczy2cnw7mCjw4gOxq+z08Vb5XIkpYTdXDVabi4M78lpd uA5GXa26MUGDzlcIMpsr6kGGXE3XqS9ayaD/Bn/SKo8K9L8ch0e7JjYQsmQ84dZ4mPB1 I66w== 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:subject:cc:to:from:date; bh=mcUJFidfFZlhbfkserJNSjdd1EFe5N58gvOdMO7T6RU=; b=NSNM5V5EDPUCdB1b0O70Q1TkPmg6h0Mx7dM8PO/ex9OYp0N+gv1zfjROdK1Vzw1cv7 QdT/cOHNGWaFC+dNP0cHogROvzgH1zm83sFuQEYxtuoUFIrVVlTMHEvQW+I10fg9rHEl WTpuVHAquoheuOXlzheFVhwk936gzZOS9QhmCIuqbfT6IlJD582pp1KUXd8bI/ffzE4j u7m2mTlxzJhogDFuEgItAgTRFpQkZQfauJBX7N+QU6xjd13kZDT9UNY/pILhJuLJzNwy liczUEOynwX4crHghQdr+uAgOCvFbe/a2i81LIxz84RdvN3GBDHbemVFq0egwK2Pxnhm QBLg== 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 y12si1470832edv.604.2021.01.27.11.56.44; Wed, 27 Jan 2021 11:57: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 S236498AbhA0Dew (ORCPT + 99 others); Tue, 26 Jan 2021 22:34:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:48258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727688AbhAZVlV (ORCPT ); Tue, 26 Jan 2021 16:41:21 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 59B6620449; Tue, 26 Jan 2021 21:40:40 +0000 (UTC) Date: Tue, 26 Jan 2021 16:40:38 -0500 From: Steven Rostedt To: Oleg Nesterov Cc: Masami Hiramatsu , Jianlin Lv , mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] tracing: precise log info for kretprobe addr err Message-ID: <20210126164038.566ef8c2@gandalf.local.home> In-Reply-To: <20210126211722.GA23645@redhat.com> References: <20210125160108.2147511-1-Jianlin.Lv@arm.com> <20210125181926.GA10248@redhat.com> <20210125133840.511b1496@gandalf.local.home> <20210126131536.f6e3a737a7b948799084fa7a@kernel.org> <20210126202058.GC12469@redhat.com> <20210126154302.302a3bb0@gandalf.local.home> <20210126211722.GA23645@redhat.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Jan 2021 22:17:23 +0100 Oleg Nesterov wrote: > On 01/26, Steven Rostedt wrote: > > > > On Tue, 26 Jan 2021 21:20:59 +0100 > > Oleg Nesterov wrote: > > > > > > No, not wrong. Even offset != 0, if the symbol exists in the kernel, > > > > kprobe_on_func_entry() will check it. > > > > > > Yes, but unless I am totally confused... if kprobe_on_func_entry() returns false, > > > then trace_kprobe_create() should fail with BAD_RETPROBE even if offset == 0 ? > > > > From what I understand. kprobe_on_func_entry() can return false if you pass > > in: "MOD:not_yet_loaded_module_func", but this is OK, because when the > > module is loaded, and the "not_yet_loaded_module_func" exists, the > > kretprobe will then be added. > > > > The strchr(symbol,":") check is to see if "MOD:" (or some other ":" command) > > is in the name, and we don't want it to fail if it is. Which is why we > > should have that commented. > > Agreed, this matches my understanding. > > But just in case... not sure I read this code correctly, but I think that > module_kallsyms_lookup_name("not_yet_loaded_module_func") should work even > without the "MOD:" prefix. > > IOW, kprobe_on_func_entry("not_yet_loaded_module_func") can fail, and then > later succeed if you load the module which provides this symbol. > > But even if I am right, I agree with the strchr(symbol,":") check. I see what you are saying. If "MOD" is not loaded yet, the kprobe_on_func_entry() should succeed. kprobe_on_func_entry(name) { _kprobe_addr(name) { _kprobe_lookup_name(name) { kallsyms_lookup_name(name) { module_kallsyms_lookup_name(name) { Which is: unsigned long module_kallsyms_lookup_name(const char *name) { struct module *mod; char *colon; unsigned long ret = 0; /* Don't lock: we're in enough trouble already. */ preempt_disable(); if ((colon = strnchr(name, MODULE_NAME_LEN, ':')) != NULL) { if ((mod = find_module_all(name, colon - name, false)) != NULL) ret = find_kallsyms_symbol_value(mod, colon+1); } else { list_for_each_entry_rcu(mod, &modules, list) { if (mod->state == MODULE_STATE_UNFORMED) continue; if ((ret = find_kallsyms_symbol_value(mod, name)) != 0) break; } } preempt_enable(); return ret; } And if find_module_all() fails, ret isn't updated, and "return ret" will return zero. That is, the ":" check may not be needed, but its at least good to have? -- Steve