Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3421371pxf; Mon, 29 Mar 2021 01:34:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfYx3R61y58XYPGQgibh8rhYWdf8sPz4KzNgHy/qaT/BnXaw7sHfnQYuy0wBW8gdqjMhJR X-Received: by 2002:a05:6402:68e:: with SMTP id f14mr27235208edy.169.1617006871785; Mon, 29 Mar 2021 01:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006871; cv=none; d=google.com; s=arc-20160816; b=VCblECWw50P/YzSFwwzm0cxgYIv3JME9MiZV4un8mWME1oilLlW8CVjgz+Ds5whRun tR240jN/jQef7YVy7HYSyrYQoNsjE5Kr7bNOTjBAkV0/zNQXbpFEALL7MhYAoe9uJWtR 8U321d+gdVvisN+RPnYza78KA/rKyeTpbrkCRDuw0fwTzl1Ze4Qnm3xeKmnSI4BPNsk2 n9qk9a0nzFApxTh/zaxfeRZ1i0q8AZJ1TTrRd7wRYJ7g/w0/Y3XlK+wDrgT1FmguBHsC 6qJpGI2BTK7SNAgIehc14CMB+GfC4s8ewwQ2Zk9fxpqDZ9d8q0WeB4O4pCkmTbANI5vb Oe4Q== 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=q1oAoF7bScuuIF7gAoN+i7x270Z9b1YXt7vC8I9hFc4=; b=vAHCCOCme2ZRtZuO1Qhv/nk5fTplNTKm8Vkot0OlAdbPpBBaeli6mZ4J5KJKD+K/3u 7oUENpt71n5vsAMI5+tJYAsujGqiiLAr8ZK9HlP1hPGpJAnRSlCYd568+1TNtLtqHUy2 E4Y+RRWnj+ooqwMi9OEOmMhiKY281yqoH3fZxBFgDr/g2LpL6aV5WMxl/zwuspfNvOd2 UCFT+vbPz18k2+GCbg1y1tcEq8ZQRQ8cIqAc5KtdAjcnRrwVkmco+VGfFRFAmdBvge6G aVyl1cMXFn15NbnuiTBgznTVUpmql69lGamT7VHwayhwikVbqBQ0OX5fBcid0kWjNWUC BATg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NCAyQgTK; 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 de11si12372947edb.15.2021.03.29.01.34.08; Mon, 29 Mar 2021 01:34:31 -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=NCAyQgTK; 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 S232829AbhC2I3w (ORCPT + 99 others); Mon, 29 Mar 2021 04:29:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:35846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232939AbhC2ITD (ORCPT ); Mon, 29 Mar 2021 04:19:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7492261580; Mon, 29 Mar 2021 08:19:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005942; bh=0m4JfSlrMTrCVvzYnSKX7M8SxB0GrqoW95y4dwsWLus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NCAyQgTKQtxB5C9cMwL1HSNeFvzmyEwP2Qh+8VcYQDQ6KG4m/5Pq++ALhQEYjbJD2 RKF8IDHBQ7Dbx2c9FSviJOV4RgzaCRfIMZvOBejkeA12aD0V5rz8FBCmMcWqHYfP3V v+UNDre3gnt/+eYTAFZs5d4EP4j0TA4dInpfzg+U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steven Rostedt , "Peter Zijlstra (Intel)" , Ingo Molnar , Sasha Levin Subject: [PATCH 5.10 059/221] static_call: Fix the module key fixup Date: Mon, 29 Mar 2021 09:56:30 +0200 Message-Id: <20210329075631.160677004@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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 50bf8080a94d171e843fc013abec19d8ab9f50ae ] Provided the target address of a R_X86_64_PC32 relocation is aligned, the low two bits should be invariant between the relative and absolute value. Turns out the address is not aligned and things go sideways, ensure we transfer the bits in the absolute form when fixing up the key address. Fixes: 73f44fe19d35 ("static_call: Allow module use without exposing static_call_key") Reported-by: Steven Rostedt Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Tested-by: Steven Rostedt (VMware) Link: https://lkml.kernel.org/r/20210225220351.GE4746@worktop.programming.kicks-ass.net Signed-off-by: Sasha Levin --- kernel/static_call.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/static_call.c b/kernel/static_call.c index db64c2331a32..5d53c354fbe7 100644 --- a/kernel/static_call.c +++ b/kernel/static_call.c @@ -358,7 +358,8 @@ static int static_call_add_module(struct module *mod) struct static_call_site *site; for (site = start; site != stop; site++) { - unsigned long addr = (unsigned long)static_call_key(site); + unsigned long s_key = (long)site->key + (long)&site->key; + unsigned long addr = s_key & ~STATIC_CALL_SITE_FLAGS; unsigned long key; /* @@ -382,8 +383,8 @@ static int static_call_add_module(struct module *mod) return -EINVAL; } - site->key = (key - (long)&site->key) | - (site->key & STATIC_CALL_SITE_FLAGS); + key |= s_key & STATIC_CALL_SITE_FLAGS; + site->key = key - (long)&site->key; } return __static_call_init(mod, start, stop); -- 2.30.1