Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp764453rwb; Thu, 4 Aug 2022 10:27:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR66fqxh8f7AvDBgbGO3gIrUxOKReNmZWvE3x4CmLrBI2/r0ZfD1do6aFQJmE/6Wii2W911d X-Received: by 2002:a17:903:124f:b0:16b:8167:e34e with SMTP id u15-20020a170903124f00b0016b8167e34emr2837541plh.52.1659634045601; Thu, 04 Aug 2022 10:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659634045; cv=none; d=google.com; s=arc-20160816; b=uQgbaVwbvtzOVPzacVwrz1uChChTRk0UXuJcOSf4jg8ocEzZTski3Ed/aNwjD10pOo FrP0mdvB/dm1RPZn/DoTHIuTlbx3cw6oPryIscvQdgX5SgzAIo7/5xXGsZQMqCMqIHuT s0keP2Hbgo/WkxGjDuXfp6wF6knavhPEjDQv9n/etC4jirF4qQ91/HMJVyEbs1W6/iOd 0wZqlz9/hetK8n5Oes4oD8kEwOXBhL78L1sOibWqZHneZkAO89yev/F/S/VYsmmxEgZe f9aooyghzWwBVFf02Jf/A+y45eQ96qoEwgzxbR1JuHxUtZGgXzLNb9B587GNJYqK0eIA 9W+g== 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 :message-id:date:subject:cc:to:from; bh=KdoYfvBOZwWW6VbV3PtgkbgDOYCvoZntaV/PVWEiyFQ=; b=C1Z0ywAwqhoBNwNTS6/Q4UPEevubn9FCtfhbredFQGZhWR1zyJL3i2DliNfsxketvI Wb8YTh0RpZvzJj2NqklGvpRi/4JtKiV7oCkyDcnlG/YrRxMYI9BzX42R+6sAdTZd0Qw+ mBTbAOR7kG473elj3G8zHXMgielVl9ZZuWpqi9H+DYnXmOscRouKzPNp7UUKeigvfKYE lSFnsLwMtdmLrrvXxZ+81rOwmn9+Qm7034o6cQtwRHrZjGbQZ4OHo4VfBnOUOJ7EBO/x 9afRTE0+QaMzxNg0A4G8TKL2yUrz5BP6LlS3YP006ZbrUsc98hlZcNlWs6TykJh+bmII nuBg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a170902ef4300b0016ec7395a85si1441009plx.524.2022.08.04.10.27.09; Thu, 04 Aug 2022 10:27:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237680AbiHDRPR (ORCPT + 99 others); Thu, 4 Aug 2022 13:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236308AbiHDRPO (ORCPT ); Thu, 4 Aug 2022 13:15:14 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 159CC278; Thu, 4 Aug 2022 10:15:11 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.0.0) id 77c46452effa720a; Thu, 4 Aug 2022 19:15:09 +0200 Received: from kreacher.localnet (unknown [213.134.181.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id D586166CDB6; Thu, 4 Aug 2022 19:15:08 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Kees Cook , Greg Kroah-Hartman Subject: [PATCH] PM: core: Do not randomize struct dev_pm_ops layout Date: Thu, 04 Aug 2022 19:15:08 +0200 Message-ID: <2643836.mvXUDI8C0e@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.181.60 X-CLIENT-HOSTNAME: 213.134.181.60 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrvddvledgudduudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeffffffkefgheehffelteeiveeffeevhfelteejvddvieejjeelvdeiheeuveeuffenucfkphepvddufedrudefgedrudekuddriedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekuddriedtpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeegpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepkhgvvghstghoohhksegthhhrohhmihhumhdrohhrghdprhgtphhtthhopehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=4 Fuz1=4 Fuz2=4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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 From: Rafael J. Wysocki Because __rpm_get_callback() uses offsetof() to compute the address of the callback in question in struct dev_pm_ops, randomizing the layout of the latter leads to interesting, but unfortunately also undesirable results in some cases. Prevent that from happening by using the __no_randomize_layout annotation on struct dev_pm_ops. Signed-off-by: Rafael J. Wysocki --- include/linux/pm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-pm/include/linux/pm.h =================================================================== --- linux-pm.orig/include/linux/pm.h +++ linux-pm/include/linux/pm.h @@ -307,7 +307,7 @@ struct dev_pm_ops { int (*runtime_suspend)(struct device *dev); int (*runtime_resume)(struct device *dev); int (*runtime_idle)(struct device *dev); -}; +} __no_randomize_layout; #define SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ .suspend = pm_sleep_ptr(suspend_fn), \