From nobody Sun Sep 7 12:25:50 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3120ECAAD5 for ; Fri, 2 Sep 2022 12:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236975AbiIBMhN (ORCPT ); Fri, 2 Sep 2022 08:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237034AbiIBMgd (ORCPT ); Fri, 2 Sep 2022 08:36:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86259D5E90; Fri, 2 Sep 2022 05:29:07 -0700 (PDT) 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 DB13AB82A71; Fri, 2 Sep 2022 12:29:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37A54C433D6; Fri, 2 Sep 2022 12:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662121741; bh=8pl/xxUZx0RNJID+u/1oHv09CR39OevBrabcZIHbLFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AJiyt8Jwo5ZLS6UPftya8VAP69JmVU9c0mlTK2hkdyP+BWd6bBiI7ePp3cWFKli8v B0GZ0XttE2BJzmlEHdftNjrvsd2x2ITwVrB0H3P4usPsP4N3dCzzZf+AYA2TnFEq6W VqJP1BmBZHe3rMz0Rzq47/zYOghZkzzhNPPqNTL4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Hildenbrand , Heiko Carstens , Gerald Schaefer , Vasily Gorbik Subject: [PATCH 5.4 50/77] s390/mm: do not trigger write fault when vma does not allow VM_WRITE Date: Fri, 2 Sep 2022 14:18:59 +0200 Message-Id: <20220902121405.298833488@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121403.569927325@linuxfoundation.org> References: <20220902121403.569927325@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Gerald Schaefer commit 41ac42f137080bc230b5882e3c88c392ab7f2d32 upstream. For non-protection pXd_none() page faults in do_dat_exception(), we call do_exception() with access =3D=3D (VM_READ | VM_WRITE | VM_EXEC). In do_exception(), vma->vm_flags is checked against that before calling handle_mm_fault(). Since commit 92f842eac7ee3 ("[S390] store indication fault optimization"), we call handle_mm_fault() with FAULT_FLAG_WRITE, when recognizing that it was a write access. However, the vma flags check is still only checking against (VM_READ | VM_WRITE | VM_EXEC), and therefore also calling handle_mm_fault() with FAULT_FLAG_WRITE in cases where the vma does not allow VM_WRITE. Fix this by changing access check in do_exception() to VM_WRITE only, when recognizing write access. Link: https://lkml.kernel.org/r/20220811103435.188481-3-david@redhat.com Fixes: 92f842eac7ee3 ("[S390] store indication fault optimization") Cc: Reported-by: David Hildenbrand Reviewed-by: Heiko Carstens Signed-off-by: Gerald Schaefer Signed-off-by: Vasily Gorbik Signed-off-by: Gerald Schaefer Signed-off-by: Greg Kroah-Hartman --- arch/s390/mm/fault.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -432,7 +432,9 @@ static inline vm_fault_t do_exception(st flags =3D FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; if (user_mode(regs)) flags |=3D FAULT_FLAG_USER; - if (access =3D=3D VM_WRITE || (trans_exc_code & store_indication) =3D=3D = 0x400) + if ((trans_exc_code & store_indication) =3D=3D 0x400) + access =3D VM_WRITE; + if (access =3D=3D VM_WRITE) flags |=3D FAULT_FLAG_WRITE; down_read(&mm->mmap_sem);