Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6237617ybe; Tue, 17 Sep 2019 23:33:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMS87KVoGO67PvSaBMnH6cN2zbtt9UpbBE97ZZOR8NE9ulUB28soCtDS3cE836VGLfgCBw X-Received: by 2002:a05:6402:1251:: with SMTP id l17mr138028edw.270.1568788426507; Tue, 17 Sep 2019 23:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568788426; cv=none; d=google.com; s=arc-20160816; b=IQukgMkFtsjm/bnu6NvqVMlkSw3FmCao/jPQdEldqm5Luj0x7SXXbMDA7p0fxnYTMv cJRaJ5Uevzs3y5qjYn9Ln8hInZuSrgYHzZYWoI2eItNhgCvQuTxdV8XlsesK7F5gr2UH rLmmt1KRk8MK5A/kpVfpTe4iRQxEXFmZSiXlxSvb3ujDFIglGi1aMVewYzace9qQLeCD 66qVs41BLl/Q6n7mF/59KjcWckW6CPk5OSi2LHEkgGDVjnY9CtJO7IFXxfCwaR+EeXrL VUkdWDErxLdqGqrfH4kUNru3Xm6mHvnFEWNclonvjsGtJw6GgY/DKEN5dfmvc9qcCYUH 0Vog== 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=XtiPtHJi//US5Yis0oOrhLEIv8/7FGFjG4WcqjZRRU8=; b=g1r7Scq/MmjKzKR2IRw4721xA2SoNbjbjl+ylCqoUW0fIGpcQIOBYkp5y3rjuwvfhR k6uPuXY3NUoDpW9rD5bxUYAIiz0lOD7131bf5T9JHmz3QjK1FCl8pXD0EOubrkrzHtK/ Bz7RBoL+nqI+k2qPJFzM4k8Zvb5yxH5ti8uB5w4db55mAF6zO+9t/4U00iSRgT/HqxWx E3DQT5aP+u9b4nMUo8MALQTG6j1BjNBPj7QP3dlB7X99kUuLmtJ7d/NeWz0X/V4DLTaw 7P3JqPFeqyp1KdfamFM1NSh2Kj/oifg+vXAnRkS0aF38t/gd4HNpbZYAXsQVkVF3vK0w s3ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NpXsaALk; 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 c30si2464495ejj.214.2019.09.17.23.33.23; Tue, 17 Sep 2019 23:33:46 -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=NpXsaALk; 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 S1729183AbfIRG2d (ORCPT + 99 others); Wed, 18 Sep 2019 02:28:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:49386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729393AbfIRG13 (ORCPT ); Wed, 18 Sep 2019 02:27:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 706E2218AF; Wed, 18 Sep 2019 06:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568788048; bh=Amq+M4DiCO97PAdKdNZc8x7IibU++eD91G9+f3YTBCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NpXsaALkJxpQDLCHZ88wNytMkrTbJWXDSImplLJ2yHcjMtrWgYhLJX3i8ryFiEchA cq1/1BpzjGiCOgKSIjo19XR3nmXngn0bf9jTdgkogRFgIzHncXMBOb4j9NrNxv0V+5 +lV+M0HStNUGUQAo9NCFi/1wkzK/y08jnpk2CdCA= 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 Subject: [PATCH 5.2 79/85] modules: always page-align module section allocations Date: Wed, 18 Sep 2019 08:19:37 +0200 Message-Id: <20190918061237.881859124@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190918061234.107708857@linuxfoundation.org> References: <20190918061234.107708857@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 From: Jessica Yu commit 38f054d549a869f22a02224cd276a27bf14b6171 upstream. 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: Greg Kroah-Hartman --- kernel/module.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) --- a/kernel/module.c +++ b/kernel/module.c @@ -64,14 +64,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))