Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp867764pxb; Tue, 1 Feb 2022 12:04:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+BZ6LcMyabSTFizC7PQrCxaaS1nQKIw2pge+ju91/7JXUgYYStXo8Jcvlz4syZWxTIEeN X-Received: by 2002:a17:907:7ba9:: with SMTP id ne41mr22732985ejc.4.1643745894715; Tue, 01 Feb 2022 12:04:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745894; cv=none; d=google.com; s=arc-20160816; b=h/ppjarVy6cHk0Rhi3RW/d1taEgbbaiMHQz9lVtO5j4T2Ye3NfWOptHyGRC1kqIIqV 82RcJRWrt/W/PM8k9x848PerEfFsTpyhzWyXzX8BK1odQx5MnKnqm+Qxkw2UPvmiX0I8 X1EhWmaQmKwchgv5bN7jSiYMgtn3PlVEuy4+hiCne2FlbzzfOd45hL2toJAIWvO81q9U E92Utk/pY7w7x3/frcRzh3qVkzQNtAOt/5po1vpqIoNkWq6zpfjx5KWjW3W6yLym8hQ4 zPKdorPEoOj9Bn59LG8Bx3t59YfwEqbtXhmxob91RbK/Yadphx+XiuWcoSw93YU9bRbH wv1w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=quRUxcN5lPptOhHQcZx7IcQAXeDXEWTBGhl43ZKmZ8k=; b=dcpIIrSToZ0ZAGNSZ04i+6agz2wtmIAaTN4HuwerbezObb1PgY4f9GmnAca9qsOzVz MDaAqvak6Z4BSGl5Z6c9mEFqUAWRO/WwqgQYWz3INYLvaDPse4V8C6ZxP2FVrmzDGEDJ QsTepSLHbf0OYGi3ZmtXQpd0UX2RDAwmrPQ+Zr3zlQYzxEr2fLNz04MsUJPIGLOZoRXJ LlPerUW2THfZ5UIJN7VfkDfOLrh6dg1eoRqsWWwqFZAplD2UVmOcyD1fDP0a5JUNM38N wmvLnfzkigvxz5t+S5e/AAoySHWUewivJQWOs1aUk/ZO3XH9J/LWxD84zR4Ni4TSPyi7 l3gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VFhqGm5E; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f15si9557531ejl.448.2022.02.01.12.04.29; Tue, 01 Feb 2022 12:04:54 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VFhqGm5E; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376268AbiAaLPM (ORCPT + 99 others); Mon, 31 Jan 2022 06:15:12 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:53778 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359765AbiAaLHx (ORCPT ); Mon, 31 Jan 2022 06:07:53 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9F529B82A60; Mon, 31 Jan 2022 11:07:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA0E8C340EE; Mon, 31 Jan 2022 11:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643627271; bh=myLVBl6zHmcFTp0kc54ysSdXxGjwoDp+p7iGxE8p230=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VFhqGm5ErRN59GH57fLLUbJHN+nhj9u+RrooUO6xVSdfp2K42ES3Gb+Bm4JPUMjVp GAPdC2aXZ40UuUZ2FxR21RFVX/SEIuQ3hK1d7wVqtMpkChGsspCFsbGkeXzXZzA0D8 eu/qL63/DtH+CPhBofITLrcKfDFWaz2Uq1M6dVMQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrea Righi , Ilya Leoshkevich , Heiko Carstens , Vasily Gorbik , Christian Borntraeger Subject: [PATCH 5.15 008/171] s390/module: fix loading modules with a lot of relocations Date: Mon, 31 Jan 2022 11:54:33 +0100 Message-Id: <20220131105230.263525150@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105229.959216821@linuxfoundation.org> References: <20220131105229.959216821@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilya Leoshkevich commit f3b7e73b2c6619884351a3a0a7468642f852b8a2 upstream. If the size of the PLT entries generated by apply_rela() exceeds 64KiB, the first ones can no longer reach __jump_r1 with brc. Fix by using brcl. An alternative solution is to add a __jump_r1 copy after every 64KiB, however, the space savings are quite small and do not justify the additional complexity. Fixes: f19fbd5ed642 ("s390: introduce execute-trampolines for branches") Cc: stable@vger.kernel.org Reported-by: Andrea Righi Signed-off-by: Ilya Leoshkevich Reviewed-by: Heiko Carstens Cc: Vasily Gorbik Cc: Christian Borntraeger Signed-off-by: Heiko Carstens Signed-off-by: Greg Kroah-Hartman --- arch/s390/kernel/module.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) --- a/arch/s390/kernel/module.c +++ b/arch/s390/kernel/module.c @@ -33,7 +33,7 @@ #define DEBUGP(fmt , ...) #endif -#define PLT_ENTRY_SIZE 20 +#define PLT_ENTRY_SIZE 22 void *module_alloc(unsigned long size) { @@ -340,27 +340,26 @@ static int apply_rela(Elf_Rela *rela, El case R_390_PLTOFF32: /* 32 bit offset from GOT to PLT. */ case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */ if (info->plt_initialized == 0) { - unsigned int insn[5]; - unsigned int *ip = me->core_layout.base + - me->arch.plt_offset + - info->plt_offset; - - insn[0] = 0x0d10e310; /* basr 1,0 */ - insn[1] = 0x100a0004; /* lg 1,10(1) */ + unsigned char insn[PLT_ENTRY_SIZE]; + char *plt_base; + char *ip; + + plt_base = me->core_layout.base + me->arch.plt_offset; + ip = plt_base + info->plt_offset; + *(int *)insn = 0x0d10e310; /* basr 1,0 */ + *(int *)&insn[4] = 0x100c0004; /* lg 1,12(1) */ if (IS_ENABLED(CONFIG_EXPOLINE) && !nospec_disable) { - unsigned int *ij; - ij = me->core_layout.base + - me->arch.plt_offset + - me->arch.plt_size - PLT_ENTRY_SIZE; - insn[2] = 0xa7f40000 + /* j __jump_r1 */ - (unsigned int)(u16) - (((unsigned long) ij - 8 - - (unsigned long) ip) / 2); + char *jump_r1; + + jump_r1 = plt_base + me->arch.plt_size - + PLT_ENTRY_SIZE; + /* brcl 0xf,__jump_r1 */ + *(short *)&insn[8] = 0xc0f4; + *(int *)&insn[10] = (jump_r1 - (ip + 8)) / 2; } else { - insn[2] = 0x07f10000; /* br %r1 */ + *(int *)&insn[8] = 0x07f10000; /* br %r1 */ } - insn[3] = (unsigned int) (val >> 32); - insn[4] = (unsigned int) val; + *(long *)&insn[14] = val; write(ip, insn, sizeof(insn)); info->plt_initialized = 1;