Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp812221ybz; Wed, 22 Apr 2020 08:25:35 -0700 (PDT) X-Google-Smtp-Source: APiQypI/BQOrC6PgDZvLGoXgFujdsxvaIAgMifww+/NM1evYdK2OrwKHiL0gEaNnOH1SisMZAivm X-Received: by 2002:a17:906:33d4:: with SMTP id w20mr26115704eja.284.1587569135767; Wed, 22 Apr 2020 08:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587569135; cv=none; d=google.com; s=arc-20160816; b=QaaJUfWHeLf7HoSBWV6QiebWT1kYKCvOwkrklZwXOtUOd4QRpPFEtt0DyESbaBhT3g E4NZ+F4ITFoyJ8YJdiqLS2ljwh0ZujamiEpIy/ED5v1CmXrSsJ3fDtf+iR4cK7A6B8e8 klQNm5foPz1w3Q3NLSExIpLBmEJX6AF4vF3/pmBw5pQN3SB4P2jFtS3qWOxmwhIwoFnt QBg10UQncdGeENdQ9rRFVMnnlwlLtDNamIYvPI86cG5LF8FCtaEYAX9UcqyYg0fhU2c4 ECg6mcwsKNHNveh5iR2kVJ1ISG7R6e/HqlTmUULu2lLDTjG/5gPlA0eDgcZXd/IhPU8z Ub5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:subject:cc:to:from:date; bh=UXP/RocoWyNsR7Hm4CqGdrY9JpRrorzoPBWoU8SWq1E=; b=vMKP80eeCaK/k0rjZkwSBgsjxxjLuF1Ma+7jP4uLFF/6tZEKQ9Sjr3sAMKcm+b2Edj hQ6Kyd4i2rn7FS6JLxZMHnN7FRHOk2+pOFI9oFpBain9EPQZ9BMHbJn4TUtOHda9Dgko ZsiQ6gyaUiXo3RTFFFN12UqYEVDYaHwNplpO6CuEFnzz+XFJPeEaPIVd+gZ8qIzKaFD6 iLvoSHHZEGiNtL16eJQVtDlA6b1opSBZyAlyaF0ujx6dtTISIibo04KGOevay4/nvK7U hyLNAEx03g0QDtgtjYgIfp8VwfckDCmfshvpWCmCzThKrUrohD42PKB09EnF2jSqsYt1 gV9A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si2736939edx.421.2020.04.22.08.25.09; Wed, 22 Apr 2020 08:25: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726403AbgDVPVf (ORCPT + 99 others); Wed, 22 Apr 2020 11:21:35 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:28082 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726361AbgDVPVf (ORCPT ); Wed, 22 Apr 2020 11:21:35 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03MFBjmh091861 for ; Wed, 22 Apr 2020 11:21:34 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 30gg2957ka-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Apr 2020 11:21:34 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 Apr 2020 16:20:56 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 22 Apr 2020 16:20:53 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 03MFLSJx1311004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Apr 2020 15:21:28 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FFC84203F; Wed, 22 Apr 2020 15:21:28 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 20CB042042; Wed, 22 Apr 2020 15:21:28 +0000 (GMT) Received: from thinkpad (unknown [9.145.91.245]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 22 Apr 2020 15:21:28 +0000 (GMT) Date: Wed, 22 Apr 2020 17:21:26 +0200 From: Gerald Schaefer To: Josh Poimboeuf Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Jessica Yu , linux-s390@vger.kernel.org, heiko.carstens@de.ibm.com, Vasily Gorbik , Gerald Schaefer Subject: Re: [PATCH v2 6/9] s390/module: Use s390_kernel_write() for late relocations In-Reply-To: <20200422164037.7edd21ea@thinkpad> References: <18266eb2c2c9a2ce0033426837d89dcb363a85d3.1587131959.git.jpoimboe@redhat.com> <20200422164037.7edd21ea@thinkpad> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 20042215-0008-0000-0000-00000375744E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20042215-0009-0000-0000-00004A973E22 Message-Id: <20200422172126.743908f5@thinkpad> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-22_06:2020-04-22,2020-04-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=0 spamscore=0 priorityscore=1501 clxscore=1015 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004220116 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 22 Apr 2020 16:40:37 +0200 Gerald Schaefer wrote: > On Fri, 17 Apr 2020 09:04:31 -0500 > Josh Poimboeuf wrote: > > > From: Peter Zijlstra > > > > Because of late module patching, a livepatch module needs to be able to > > apply some of its relocations well after it has been loaded. Instead of > > playing games with module_{dis,en}able_ro(), use existing text poking > > mechanisms to apply relocations after module loading. > > > > So far only x86, s390 and Power have HAVE_LIVEPATCH but only the first > > two also have STRICT_MODULE_RWX. > > > > This will allow removal of the last module_disable_ro() usage in > > livepatch. The ultimate goal is to completely disallow making > > executable mappings writable. > > > > Also, for the late patching case, use text_mutex, which is supposed to > > be held for all runtime text patching operations. > > > > [ jpoimboe: Split up patches. Use mod state to determine whether > > memcpy() can be used. Add text_mutex. Make it build. ] > > > > Cc: linux-s390@vger.kernel.org > > Cc: heiko.carstens@de.ibm.com > > Suggested-by: Josh Poimboeuf > > Signed-off-by: Peter Zijlstra (Intel) > > Signed-off-by: Josh Poimboeuf > > --- > > arch/s390/kernel/module.c | 125 ++++++++++++++++++++++++-------------- > > 1 file changed, 79 insertions(+), 46 deletions(-) > > Sorry, just noticed this. Heiko will return next month, and I'm not > really familiar with s390 livepatching. Adding Vasily, he might > have some more insight. > > So, I might be completely wrong here, but using s390_kernel_write() > for writing to anything other than 1:1 mapped kernel, should go > horribly wrong, as that runs w/o DAT. It would allow to bypass > DAT write protection, which I assume is why you want to use it, > but it should not work on module text section, as that would be > in vmalloc space and not 1:1 mapped kernel memory. > > Not quite sure how to test / trigger this, did this really work for > you on s390? OK, using s390_kernel_write() as default write function for module relocation seems to work fine for me, so apparently I am missing / mixing up something. Sorry for the noise, please ignore my concern.