From patchwork Wed Jul 5 18:12:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 116296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2066665vqx; Wed, 5 Jul 2023 11:46:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6VYSLdC0nMkZtLidJlH+MqOH2lRdWnwEOi9RlyOC3lO0NK+PMHqztoy5T5+WgIHLOieSVh X-Received: by 2002:a05:6a20:1b24:b0:104:35ec:c25c with SMTP id ch36-20020a056a201b2400b0010435ecc25cmr12507108pzb.41.1688582760181; Wed, 05 Jul 2023 11:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688582760; cv=none; d=google.com; s=arc-20160816; b=p5OTDucrEj/k4epJieDDEf9VrVZEef4VvHzJIUhvLRr7Ne/3CYq23H4B4522UIaEMr dwyFEfWpyIdu+ah95wt/bDHHJ6YI0dQj9U0lvfo3h1cB2eeKF/rSteVNwBC4F6NImZus TPSs57r6XDFrJuRfYJ5Y+HLINUsxdX2KNi14a6Rj9qX+x/NrSR+6txkW3cqfaIvFGwO9 6zU8iOQygt2g3ouhqHFxWvEiQzW1UUF7iop46C40OU06lUyoBY78nZJo8YUseTddnSAz D+OJKMLdGyqZAhARHhBV4LfZFZyhGriICOJLmBR7yYaNffG32DNq8jn39meqzbrJ3Tp8 2jKQ== 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:date:subject:cc:to:from :dkim-signature; bh=Rmsxmag8ZkUExVz48NdRE4bjGysGk4VVErYcJqwPIM4=; fh=dVCMRuKhK2aqTEuWethYlqkP4G2sINJQEE+rq5xoO1c=; b=SxZ9Rd5o31FfP6tf7MbYp9pWXsA4N4Gj8o6pMqFrL8j3gbA5tgvQZDJp0xRkfBChaU p/S9LYc++1+Xxu0mu+DKSWoUZWX3XRUkIC1HIpkpVW/iGLYEhs49+LuqBFIu2Td+fmz2 BMGq/ANpn1syL421gbeAOn4lUadMCv1U55iaAeiMRcuV5rrhO15WdWvZFAl7LK+1AjfF 7yUc6js7M/vJzWWSWygh8sa7e0/9Geti1Nws59UxlrfDbBOx5Poa35foqWkBXYV1nI1i /itr1x6/aePQWekyxOrEMUSHE7+QMVRA9o6KzHItehqKW49y4RrmnEIDO45HQTKQqN9F zhew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jVug4lix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a170902e88400b001b89b7ce902si7137760plg.305.2023.07.05.11.45.43; Wed, 05 Jul 2023 11:46:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jVug4lix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233438AbjGESSE (ORCPT + 99 others); Wed, 5 Jul 2023 14:18:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231799AbjGESRr (ORCPT ); Wed, 5 Jul 2023 14:17:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EAEB19B9 for ; Wed, 5 Jul 2023 11:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688581010; 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=Rmsxmag8ZkUExVz48NdRE4bjGysGk4VVErYcJqwPIM4=; b=jVug4lixrd8sNTBzab87XhRmBUWCeutjFXjzcwdzf4m5Zw9+HX4i39LypG1+d2tmkks3cr 6diKooABmh6I+YRJpH/d8tRWQ/6HMD8lYeDrdsi2CkPTDFnQy8i3QWu8PJt4CAoK3Gvy/m f15sVMxI63qVqzBRCG0PGRjHoCIbOJY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-534-K-_lME6ZNbOFxO4KCoVoVw-1; Wed, 05 Jul 2023 14:16:49 -0400 X-MC-Unique: K-_lME6ZNbOFxO4KCoVoVw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 980F53815EF4; Wed, 5 Jul 2023 18:16:46 +0000 (UTC) Received: from vschneid.remote.csb (unknown [10.42.28.164]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D5B65F5CFA; Wed, 5 Jul 2023 18:16:41 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, x86@kernel.org Cc: Steven Rostedt , Masami Hiramatsu , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Andy Lutomirski , Peter Zijlstra , Frederic Weisbecker , "Paul E. McKenney" , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Josh Poimboeuf , Kees Cook , Sami Tolvanen , Ard Biesheuvel , Nicholas Piggin , Juerg Haefliger , Nicolas Saenz Julienne , "Kirill A. Shutemov" , Nadav Amit , Dan Carpenter , Chuang Wang , Yang Jihong , Petr Mladek , "Jason A. Donenfeld" , Song Liu , Julian Pidancet , Tom Lendacky , Dionna Glaze , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Yair Podemsky Subject: [RFC PATCH 08/14] BROKEN: context_tracking: Make context_tracking_key __ro_after_init Date: Wed, 5 Jul 2023 19:12:50 +0100 Message-Id: <20230705181256.3539027-9-vschneid@redhat.com> In-Reply-To: <20230705181256.3539027-1-vschneid@redhat.com> References: <20230705181256.3539027-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770607356334719411?= X-GMAIL-MSGID: =?utf-8?q?1770607356334719411?= objtool now warns about it: vmlinux.o: warning: objtool: enter_from_user_mode+0x4e: Non __ro_after_init static key "context_tracking_key" in .noinstr section vmlinux.o: warning: objtool: enter_from_user_mode+0x50: Non __ro_after_init static key "context_tracking_key" in .noinstr section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x60: Non __ro_after_init static key "context_tracking_key" in .noinstr section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x62: Non __ro_after_init static key "context_tracking_key" in .noinstr section [...] The key can only be enabled (and not disabled) in the __init function ct_cpu_tracker_user(), so mark it as __ro_after_init. BROKEN: the struct static_key lives in a read-only mapping after mark_rodata_ro(), which falls apart when the KVM module is loaded after init and a write to the struct happens due to e.g. guest_state_exit_irqoff() relying on the static key: jump_label_add_module() `\ static_key_set_mod() static_key_set_linked() Signed-off-by: Valentin Schneider --- kernel/context_tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index a09f1c19336ae..4e6cb14272fcb 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c @@ -432,7 +432,7 @@ static __always_inline void ct_kernel_enter(bool user, int offset) { } #define CREATE_TRACE_POINTS #include -DEFINE_STATIC_KEY_FALSE(context_tracking_key); +DEFINE_STATIC_KEY_FALSE_RO(context_tracking_key); EXPORT_SYMBOL_GPL(context_tracking_key); static noinstr bool context_tracking_recursion_enter(void)