Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3865920pxv; Mon, 19 Jul 2021 10:37:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1WIhTYnsgHRSyAF+ISYSmnwlQC6VVVPJuW9Zher9SELIx+pyh2aCmWDLaYZiRIhPLAix2 X-Received: by 2002:a05:6402:781:: with SMTP id d1mr36329272edy.32.1626716224805; Mon, 19 Jul 2021 10:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626716224; cv=none; d=google.com; s=arc-20160816; b=AFG/npOhAwJBUudp9zI/mHhzRvmGTRZRz043jE+SMA4dPYiH1axCNN3OvCROloxqv2 KeO4IqqPm8ob2ClCrOkSZ28V3G3niQPY9n0w+6li5ExnYgogHxAdpboLjYiK8fBQAGUm l3XzKY0ZJrDSoin6MdbZDeo97zD5r5vfOPk6OupMUah4h7YrIB0inK+a8WTkS5K3xbQE S3cD4oVkJYOaZqB+FwmFR1qYkXSH+2PskPduvMPcHyoCJ7keV3C2tEAIdgN16+WpEB90 jcqbSBw+vSt0zX/HzMvbT38tFSKn1k+aseBen6GqrCtHrjM5z6I38dpRPkDc8qUzfzAZ Hb1g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3H3Onm5Dg2/CAwGEzzez/veLaaeg7FiS/SMRderMrBA=; b=0HaqD9OGjhRSKjjuI6d57l1aScoyGT9uEjXMcmxtWbMRchfMqq6Fd2eXnokMX7pJH/ foH0qhCnRLrYDYjEjiB51wmgrrHH0+pH3mteY2TSsFIEjiLLuMKIVW5t2MesN1rcJS3U 3eOmwGx3GDUBBCGSWewZQm7r1Id8MVWwMO0Pz6elQhce8Kh9ibiciqqNc9RFwjISg/9X bj0uwQBekXabJB6EmP75Oa/UjBtzD8xeSwPd0iyVTNduvTNrUqct35xPrdngNh6Vgnht N/GFEQCNVablu3V+mgVLCiGXhX6fe/kkIrgDI9voP+3nr5BDHh5wnXzzviqYPtBpE1pG KLRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A+yM4kHU; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u13si12524098ejz.673.2021.07.19.10.36.41; Mon, 19 Jul 2021 10:37:04 -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=@linuxfoundation.org header.s=korg header.b=A+yM4kHU; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353242AbhGSQuY (ORCPT + 99 others); Mon, 19 Jul 2021 12:50:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:38168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348083AbhGSPYd (ORCPT ); Mon, 19 Jul 2021 11:24:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7531961421; Mon, 19 Jul 2021 16:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710491; bh=RU3k0Z0HBpTjvUzhHGjfHYIslttXtXdKwuqO741+84o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A+yM4kHUMdAM0wGB1rI7e9exR/FS4mEKVy9I/OVvgCOzJH5dSm9VMegXFaXKxyh5q 1SLnDLX8tcFXfz2ON9SbCauqzwDLUes6XqekhnxFrUX/wekCL/SEwbUzKHOhsgxxUF AoYalq0xiku5eDEsLsp9RiOz3Zd0AEKCw9hehOlQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Ingo Molnar , Masami Hiramatsu , Sasha Levin Subject: [PATCH 5.10 238/243] static_call: Fix static_call_text_reserved() vs __init Date: Mon, 19 Jul 2021 16:54:27 +0200 Message-Id: <20210719144948.607712484@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit 2bee6d16e4379326b1eea454e68c98b17456769e ] It turns out that static_call_text_reserved() was reporting __init text as being reserved past the time when the __init text was freed and re-used. This is mostly harmless and will at worst result in refusing a kprobe. Fixes: 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s") Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Reviewed-by: Masami Hiramatsu Link: https://lore.kernel.org/r/20210628113045.106211657@infradead.org Signed-off-by: Sasha Levin --- kernel/static_call.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kernel/static_call.c b/kernel/static_call.c index f59089a12231..b62a0c41c905 100644 --- a/kernel/static_call.c +++ b/kernel/static_call.c @@ -292,13 +292,15 @@ static int addr_conflict(struct static_call_site *site, void *start, void *end) static int __static_call_text_reserved(struct static_call_site *iter_start, struct static_call_site *iter_stop, - void *start, void *end) + void *start, void *end, bool init) { struct static_call_site *iter = iter_start; while (iter < iter_stop) { - if (addr_conflict(iter, start, end)) - return 1; + if (init || !static_call_is_init(iter)) { + if (addr_conflict(iter, start, end)) + return 1; + } iter++; } @@ -324,7 +326,7 @@ static int __static_call_mod_text_reserved(void *start, void *end) ret = __static_call_text_reserved(mod->static_call_sites, mod->static_call_sites + mod->num_static_call_sites, - start, end); + start, end, mod->state == MODULE_STATE_COMING); module_put(mod); @@ -459,8 +461,9 @@ static inline int __static_call_mod_text_reserved(void *start, void *end) int static_call_text_reserved(void *start, void *end) { + bool init = system_state < SYSTEM_RUNNING; int ret = __static_call_text_reserved(__start_static_call_sites, - __stop_static_call_sites, start, end); + __stop_static_call_sites, start, end, init); if (ret) return ret; -- 2.30.2