Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3525248pxb; Wed, 13 Oct 2021 07:45:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxs3JK7Zb5Q2OwJnLZcBEiM026MJJZjMf8GuYPfQhVKuSylO1q6FkH/xblOuvhRS1YQU62B X-Received: by 2002:a17:902:e5cb:b0:13f:25b7:4d50 with SMTP id u11-20020a170902e5cb00b0013f25b74d50mr23540942plf.38.1634136335799; Wed, 13 Oct 2021 07:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634136335; cv=none; d=google.com; s=arc-20160816; b=jNTBh2j7fTthUWCPoUegYdWxR7UX9eNdRT34zgXfgxm8jKmN+qAN/fUeRNJ49A/UR6 5D0RzXpvrK1mnTZQHVdqfIbSsLumjAuGcJLP+7Yc3tMj+MRJlJtwZ9zWW/pRmlLItxGi d097lRKRjpJPNoz/gcB5F0bx1X9pdHZM+nnU5sKh49mnjgROjaFNfQ/yebD+ure1Uze0 pVofz6YgmdjKaZPD54pz8ZuDGKnTq9ze4YDIiJZAYk9JXRXpIfuxPIWyB/XZ/VJsXO1I riNFaTXxlX3IlTlRtbGbW3WPJLanJwwHp7UJQjAWVoWTDgRm816zBNrxlom79Jde7yVK RUCg== 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=9t69+Zfsp/Oxp4dunf+ndhlSiQIUs6ovGVLwHRL91m0=; b=kqjc1qI4B91qlPsQN50XkWKdoSrz4OR8nlzr04gR0hlXSGiPYBGX07ZtIDiWOzsBbk 9hrLw2cuqAlHsOa9wRGN9DdSbfXBmMZ0S61tIfZDOJeT3b/i64hLfuevPrzi92e1xpW/ njnRjw17Q63JzHkACFgbnNddaB8SuLsOGovWWeDt+ZuefjopGZKTEC1diXN2H1RS1n87 E8RosfxwXAai5Q+eAG5jR8n4TFvfYghKtHiij+0cJcWg350SFi1v28aj+2hTrwWF31gX E4Zj0gXCDxrFOBiifLdnlA079g9ptRGhyJCda73OGEbx1V38wsCwCuT+Sl78b61wx9Dn SOxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t8si12104125pgu.259.2021.10.13.07.45.23; Wed, 13 Oct 2021 07:45:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237528AbhJMOqN (ORCPT + 99 others); Wed, 13 Oct 2021 10:46:13 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:52627 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233744AbhJMOqN (ORCPT ); Wed, 13 Oct 2021 10:46:13 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4HTwK46BYsz9sS3; Wed, 13 Oct 2021 16:44:08 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TpKPfGchi9lR; Wed, 13 Oct 2021 16:44:08 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4HTwK45NbRz9sS0; Wed, 13 Oct 2021 16:44:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A2C028B786; Wed, 13 Oct 2021 16:44:08 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id EnVTRYWogTQZ; Wed, 13 Oct 2021 16:44:08 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [172.25.230.103]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 818138B763; Wed, 13 Oct 2021 16:44:08 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.16.1/8.16.1) with ESMTPS id 19DEhwZg2125395 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 13 Oct 2021 16:43:58 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.16.1/8.16.1/Submit) id 19DEhw8q2125394; Wed, 13 Oct 2021 16:43:58 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH] powerpc: Mark .opd section read-only Date: Wed, 13 Oct 2021 16:43:54 +0200 Message-Id: <3cd40b682fb6f75bb40947b55ca0bac20cb3f995.1634136222.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1634136233; l=1235; s=20211009; h=from:subject:message-id; bh=lpaC6Oi5RiGO/pS0hBKg1xO31nCFLyBbA6zQNLxTo/Y=; b=0J8NsJzOJ6is94Yh3RvTBReeZ+Y5seuf/gHQnsqrhpHtHzIGk/GIXipWo+MpOXe216JuUMF64FNH cQffp7I+C27voKsh2wKovwoHlQ2ewpK5EPp+y6k0fjXrRn9cnuQU X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org .opd section contains function descriptors used to locate functions in the kernel. If someone is able to modify a function descriptor he will be able to run arbitrary kernel function instead of another. To avoid that, move .opd section inside read-only memory. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/vmlinux.lds.S | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S index 40bdefe9caa7..18e42c74abdd 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S +++ b/arch/powerpc/kernel/vmlinux.lds.S @@ -143,6 +143,12 @@ SECTIONS SOFT_MASK_TABLE(8) RESTART_TABLE(8) + .opd : AT(ADDR(.opd) - LOAD_OFFSET) { + __start_opd = .; + KEEP(*(.opd)) + __end_opd = .; + } + . = ALIGN(8); __stf_entry_barrier_fixup : AT(ADDR(__stf_entry_barrier_fixup) - LOAD_OFFSET) { __start___stf_entry_barrier_fixup = .; @@ -339,12 +345,6 @@ SECTIONS *(.branch_lt) } - .opd : AT(ADDR(.opd) - LOAD_OFFSET) { - __start_opd = .; - KEEP(*(.opd)) - __end_opd = .; - } - . = ALIGN(256); .got : AT(ADDR(.got) - LOAD_OFFSET) { __toc_start = .; -- 2.31.1