Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11031293ybi; Thu, 25 Jul 2019 08:48:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzh9X6MHaYipeFUMFUQK3/bIxCKe2hWDz4ekDjXmrMd6Nh1w5UAJeqYSLbjT4JBVPRpcWt2 X-Received: by 2002:a17:902:f204:: with SMTP id gn4mr92483181plb.3.1564069727467; Thu, 25 Jul 2019 08:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564069727; cv=none; d=google.com; s=arc-20160816; b=WdL28MvS2S1zHJVl+YDacfv17GXAWTayVkK2U3ejzpR/9mmT7PVhL79CPSF7bi+wjt irKGr4XHv1JIOiPcvulvaqfbxaXI+HRBbzBLbOKlFYjs1fNiNwpvqYbvAx7jcMELmzYI M4/KtAci3UgxPFM2Ch8Wolue8jka4Dyu+sKqtbZxo7V2OAVqUgwTBuIVW1iOyS5NN9Ac GhMkgkZ24adegTUIpUOyVnq9J+T+1mp8awhYVMcK2aLoj7NnofRd5j/pgem7Ma2dr88i PRRghyY1VejhTW4owweveAucM+qSNCmv+tlwnSVZctEzUrcZ1CgPnNOV31oFZBjgDiO7 BnEg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/NsOOSmmzO3ouZR79VA2X4x5+ipc/g1qgS9k4/NHDuE=; b=MDXud/Y1n63WWMLhH/a9JFpLsSkeqSbKjsFPiUKYWxDcU3zpbioMFK7zrPdHQHqxrT Qe+vHweBkXU4wvX/uZB0AUYHPrzfTY3oko8tpydsOhQnT5fNR1yBDKqAYFv7h06kAetC Tt9bVhZ535Nbwn2qEt8TyTrwQffJbhDZmYZVzO0oT/OIHhOYZITCRe802D8KbrA2j8pI Qj4jWFolcuaMyK+8ybw/HdbhyVV84HFVT6dRG+7TbuX2Y3AY8rne/o91uRa2Cpcz8eoS mvBGubud6u1F8Our33lom5QSIt7bpfZ+kQkTR6BWn/hZSaI/8C3DCmS7vhH84MfHmDzf K8bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=sgmvkbQd; 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 t16si15340409ply.133.2019.07.25.08.48.21; Thu, 25 Jul 2019 08:48:47 -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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=sgmvkbQd; 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 S1728969AbfGYHIo (ORCPT + 99 others); Thu, 25 Jul 2019 03:08:44 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:32890 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728097AbfGYHIo (ORCPT ); Thu, 25 Jul 2019 03:08:44 -0400 Received: by mail-io1-f68.google.com with SMTP id z3so95140710iog.0 for ; Thu, 25 Jul 2019 00:08:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/NsOOSmmzO3ouZR79VA2X4x5+ipc/g1qgS9k4/NHDuE=; b=sgmvkbQdmyOibpBn40shEi7rJ8z75kD/TJw4J/zmBkLGQbBcumdRr/jw7AU4Qe1HdE VxOSYas/ddnTitzw7CuPr475G3Iv/U5FkwnNQN0mgC2724Hh4sPiBirLhkRFo3GYU/Ui 3TYE6l/tPmTYI5DEr22ddxutNfXGWrH90oltRH9pPpJoJ1Rp3LkCgkzjCdNMu+O833sN 4diqCBqPvG5lAOxqYhneGAN1Ygcm3O1G43SPbl/rjyBgoPpqqe8945BMFpQXZTeKXzJA A6wH8/B6SZLbzgdTBFeIu6a6kRvNHBxvvzbp+N/ha+CYO6sT+btaSMT3vMeYhjA9O0eu P+fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/NsOOSmmzO3ouZR79VA2X4x5+ipc/g1qgS9k4/NHDuE=; b=YHwSp4qQQ7OLK/If8jWJBs2x7zLsFAzxrLm20ZOPSyOem2Xo4jmUbMn+pzzvJgVrRp rwXaZGERG0H2RLP2G4FE7lDyDc0+wZgN35e28AodskwsVvJkSYMgFwyqxgWE9D1zH+RB Z6ZyRBuE55vNYf2PXzXFKCu62GU+JWVwQlyKY+6fWbI+HsnG1HsR6DH5S/LRLCF+EdSa 2F6Uj5EbWQ3el0OEhHwrzW4CkXE4NeDi5wNfKSm3vGSkYZh3FlETJjlOU6EiIrEHO/zL KdvuKS/rXzdpiofypp9CFlhDtPOWZNgPzDEckyMNi41zFNZelEf0LFDtDp34otfjn5NN M6qw== X-Gm-Message-State: APjAAAXHdFeiNLEBKsEuiZxjHP6FEr64rkp2kOeB1tpvTADT3zA74miQ sBG173YyvU5IB1+mbSZU9K1WgI8LdBPrMcrRAIA= X-Received: by 2002:a5e:8b43:: with SMTP id z3mr78655086iom.287.1564038523269; Thu, 25 Jul 2019 00:08:43 -0700 (PDT) MIME-Version: 1.0 References: <20190724150156.28526-1-jeyu@kernel.org> In-Reply-To: <20190724150156.28526-1-jeyu@kernel.org> From: Bartosz Golaszewski Date: Thu, 25 Jul 2019 09:08:32 +0200 Message-ID: Subject: Re: [PATCH] modules: always page-align module section allocations To: Jessica Yu Cc: Linux Kernel Mailing List , Yang Yingliang , Jian Cheng , Nadav Amit , Sekhar Nori , Kevin Hilman , David Lechner , Adam Ford , Martin Kaiser Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =C5=9Br., 24 lip 2019 o 17:02 Jessica Yu napisa=C5=82(a): > > 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=3Dy, module section allocations are always > page-aligned to handle memory rwx permissions. On some arches with > CONFIG_STRICT_MODULE_RWX=3Dn 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=3D= 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=3Dn") > Reported-by: Martin Kaiser > Reported-by: Bartosz Golaszewski > Tested-by: David Lechner > Tested-by: Martin Kaiser > Signed-off-by: Jessica Yu > --- > kernel/module.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/kernel/module.c b/kernel/module.c > index 5933395af9a0..cd8df516666d 100644 > --- 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=3Dy > + * 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.16.4 > Tested-by: Bartosz Golaszewski