Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp800849ybe; Fri, 13 Sep 2019 06:35:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+GqP1VP/Gq2KPl+3wAfjkOq3nDEtnux4FdZjhKIn3DJV55m8YQdm2jFyf51iIr63he7bq X-Received: by 2002:a17:906:2619:: with SMTP id h25mr39270816ejc.283.1568381740255; Fri, 13 Sep 2019 06:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568381740; cv=none; d=google.com; s=arc-20160816; b=jO3vbsnPKFKfMapCXOdAfNahMpeCgCwRXP0DRy/ns6IM9i75QgsHvrOq/id+OMm4ta 3Q9QtA12kyzVIK4qTtpbaKpMRe9ZBD55XyhaWMyQYa3BFruquaqeCSy0N00XV0oOwXE1 rrUHGB6zDixoXOjmrvwANGdS3BX4exkcHbkpXDUGG3Hwp/z44GvBbWsibLnhxbCCh+IU Zh2/DaujeA8Mb9RF+elCSRXuGm1JmBwTe+lcIsbfLCWiBMtG3K9uAOuPpQbypp3UcRoe YS7Nwpgsf1fxmuW661DoVTLggTdFQFNCTyeIysde5fuA8NER8eQSiDY8UKt9jsFnu5E4 ipPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=95lzUjKIrz6FY18CWy6baZwsFxJOL5sQF5s88rSY8Ww=; b=i3ffqopIXXzABIJwdOAyK7IqVvJ9gBq92FF7YXocGC9pShL0zdR2FfVAV7vK2OC6cl 3ckOGYHWRGWncTgeuVdb2QnNuStwH4dPhH0X2OVfpMu2ZWCOA80eIA4PvpfTVPBT/GRR SZ6aoiagEH5OU0X3kuIPty/gRum9QcSYfdslYFAAHlN25xehCOYXBkvINli0xO+Imj8W hTgkIStzgqXp8FdrQYAc6mHcyGi8dVWY64RE9tu5VIgjEMpQKrxHl1aXD+D+qoLNSsP5 kJ8EB0IzAkqt0f4zVRyyjBpHLkDgv1r8QxO/2xWeJWBKR6+6fIKi5BV1VTDigPXi7C/J nL0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EttRl2jh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c23si10873818edt.376.2019.09.13.06.35.16; Fri, 13 Sep 2019 06:35:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EttRl2jh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388219AbfIMNND (ORCPT + 99 others); Fri, 13 Sep 2019 09:13:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:38592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387856AbfIMNNB (ORCPT ); Fri, 13 Sep 2019 09:13:01 -0400 Received: from localhost (unknown [104.132.45.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0AE09206BB; Fri, 13 Sep 2019 13:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568380380; bh=/aEczhmxV0vNgZu3Sc/REWLdkz8GghfVEszL5Jkcgu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EttRl2jhTVy32IwqvN0iZeAj6VsIzGNeq2TLuSuwJ/jz1yUinlII3El6IoE5hg6LQ R9KmjimHPUqt3N/e/Kjf9qhQBuuGNNqDDgh8L9qtCGAzRxbzOikV6Bkgw1FTzk0w7m g0Nf7TZ39R1KqihR45fiKVoRpGGyW3sDRR7zCVxI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Kaiser , Bartosz Golaszewski , David Lechner , Martin Kaiser , Bartosz Golaszewski , Jessica Yu , Sasha Levin Subject: [PATCH 4.19 028/190] modules: always page-align module section allocations Date: Fri, 13 Sep 2019 14:04:43 +0100 Message-Id: <20190913130601.887343656@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913130559.669563815@linuxfoundation.org> References: <20190913130559.669563815@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 38f054d549a869f22a02224cd276a27bf14b6171 ] Some arches (e.g., arm64, x86) have moved towards non-executable module_alloc() allocations for security hardening reasons. That means that the module loader will need to set the text section of a module to executable, regardless of whether or not CONFIG_STRICT_MODULE_RWX is set. When CONFIG_STRICT_MODULE_RWX=y, module section allocations are always page-aligned to handle memory rwx permissions. On some arches with CONFIG_STRICT_MODULE_RWX=n however, when setting the module text to executable, the BUG_ON() in frob_text() gets triggered since module section allocations are not page-aligned when CONFIG_STRICT_MODULE_RWX=n. Since the set_memory_* API works with pages, and since we need to call set_memory_x() regardless of whether CONFIG_STRICT_MODULE_RWX is set, we might as well page-align all module section allocations for ease of managing rwx permissions of module sections (text, rodata, etc). Fixes: 2eef1399a866 ("modules: fix BUG when load module with rodata=n") Reported-by: Martin Kaiser Reported-by: Bartosz Golaszewski Tested-by: David Lechner Tested-by: Martin Kaiser Tested-by: Bartosz Golaszewski Signed-off-by: Jessica Yu Signed-off-by: Sasha Levin --- kernel/module.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 3fda10c549a25..2dec3d4a9b627 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -76,14 +76,9 @@ /* * Modules' sections will be aligned on page boundaries - * to ensure complete separation of code and data, but - * only when CONFIG_STRICT_MODULE_RWX=y + * to ensure complete separation of code and data */ -#ifdef CONFIG_STRICT_MODULE_RWX # define debug_align(X) ALIGN(X, PAGE_SIZE) -#else -# define debug_align(X) (X) -#endif /* If this is set, the section belongs in the init part of the module */ #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) -- 2.20.1