From patchwork Fri Dec 20 17:41:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13917197 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E76A421CA00; Fri, 20 Dec 2024 17:47:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734716861; cv=none; b=ksZdic3SIl5Q7a1kw/Erx4Ug1nu0t+1c3mGnWWyNHLh9uRH84YLmw6QGbtwY2hHSUGdMX2IRe/iN6P78TblRpSqbqnitqjTA91YoO6HaOhQPEI7qEZdD+9buDOFGgaRCw1mqpz3+wu2Zreo/EhcU3akbXTLmgUvN88vQWxKE2u4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734716861; c=relaxed/simple; bh=+tMmuDHymxm4vFnd5USrEbmUauXQHlCNL/qrRG/E+z0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TU57FbGQbGr3xwggUoQmIEU17prK1Tm4MIqORFs6QrpWnN39c2ij30zeXyf2Wj51FJWTX12cgzDOpRvCGbBMmm7t1zerqXtmcmv4BQaxXeYakEGlVWmF6G+w5Kk87806BZCpOzrZOrdT0pwSoad3P/vLFCtUsD1OqQbSc8H9zpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zJHZQy7a; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cRWwGbMS; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zJHZQy7a"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cRWwGbMS" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1734716858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TBQkgNJsnyD1dMyjjHJldsklJJimcQF6KjLARswWJz4=; b=zJHZQy7a2uxj6v/PogTSedLmCA9KIMQaNtY/vslFIBa+tVxuLKZH/7rlUpUJ/TtCxXy9of vt7ThkYxZ/ot7OZGorEGdIMf3pqlqEHw/0HxTsGNehIcZ9gk/XUjEGWBmEU0L/2C03VHII QtLEsocJcf87pjKOhjp1PG2bAkDailB57EkAlhW/Ppo4VpOfcwzkzUW7qM7XPqYAgIZkAT lWeaqGKGd3gnMciQMPtc/FaTsVixpxkLxR/caFeO2OZmhIlm0qLVqdXC2rdB2KsGq2rb3j 12M1vfB9P8jQq05H86jOIMxT1mkvGllb0Ht8prdCydFAv/0I/3DmQSShP80Evg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1734716858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TBQkgNJsnyD1dMyjjHJldsklJJimcQF6KjLARswWJz4=; b=cRWwGbMS9RG2bIk6NZ/gAcSUj4/H+CPt62mvwZUUuvTEdBZKQM1W8LTeDPSZnI/OWcjDGU 04Vrc824M86AH1Dg== To: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Gomez , Luis Chamberlain , "Paul E . McKenney" , Peter Zijlstra , Petr Pavlu , Sami Tolvanen , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH v2 04/28] module: Use RCU in find_kallsyms_symbol(). Date: Fri, 20 Dec 2024 18:41:18 +0100 Message-ID: <20241220174731.514432-5-bigeasy@linutronix.de> In-Reply-To: <20241220174731.514432-1-bigeasy@linutronix.de> References: <20241220174731.514432-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-modules@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The modules list and module::kallsyms can be accessed under RCU assumption. Use rcu_dereference() to reference the kallsyms pointer in find_kallsyms_symbol(). Use a RCU section instead of preempt_disable in callers of find_kallsyms_symbol(). Keep the preempt-disable in module_address_lookup() due to __module_address(). Signed-off-by: Sebastian Andrzej Siewior --- kernel/module/kallsyms.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index 45846ae4042d1..3f59d04795572 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -257,7 +257,7 @@ static const char *find_kallsyms_symbol(struct module *mod, { unsigned int i, best = 0; unsigned long nextval, bestval; - struct mod_kallsyms *kallsyms = rcu_dereference_sched(mod->kallsyms); + struct mod_kallsyms *kallsyms = rcu_dereference(mod->kallsyms); struct module_memory *mod_mem; /* At worse, next value is at end of module */ @@ -329,6 +329,7 @@ int module_address_lookup(unsigned long addr, int ret = 0; struct module *mod; + guard(rcu)(); preempt_disable(); mod = __module_address(addr); if (mod) { @@ -356,7 +357,7 @@ int lookup_module_symbol_name(unsigned long addr, char *symname) { struct module *mod; - preempt_disable(); + guard(rcu)(); list_for_each_entry_rcu(mod, &modules, list) { if (mod->state == MODULE_STATE_UNFORMED) continue; @@ -368,12 +369,10 @@ int lookup_module_symbol_name(unsigned long addr, char *symname) goto out; strscpy(symname, sym, KSYM_NAME_LEN); - preempt_enable(); return 0; } } out: - preempt_enable(); return -ERANGE; }