From patchwork Thu Oct 8 09:25:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 11822503 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 125F914D5 for ; Thu, 8 Oct 2020 09:26:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6D6DE21775 for ; Thu, 8 Oct 2020 09:26:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="OXf2kh89" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D6DE21775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 51CF56B005D; Thu, 8 Oct 2020 05:26:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4CCA36B0062; Thu, 8 Oct 2020 05:26:06 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BB056B0068; Thu, 8 Oct 2020 05:26:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 0CA716B005D for ; Thu, 8 Oct 2020 05:26:06 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A01B28249980 for ; Thu, 8 Oct 2020 09:26:05 +0000 (UTC) X-FDA: 77348226690.07.offer10_0d13e17271d6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 882461803F9A3 for ; Thu, 8 Oct 2020 09:26:05 +0000 (UTC) X-Spam-Summary: 1,0,0,83606ecd29e0bd17,d41d8cd98f00b204,aneesh.kumar@linux.ibm.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1311:1314:1345:1431:1437:1515:1535:1542:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2689:2904:3138:3139:3140:3141:3142:3353:3865:3867:3870:3871:4117:4321:5007:6238:6261:6653:6742:7875:8634:8660:9391:10004:11026:11658:11914:12043:12295:12296:12297:12438:12555:12679:12895:12986:13148:13230:13846:13870:13894:14096:14181:14394:14721:21080:21451:21627:21939:30054:30056:30064:30090,0,RBL:148.163.158.5:@linux.ibm.com:.lbl8.mailshell.net-64.201.201.201 62.14.0.100;04yftr64rfcsywrjgia9dnj1n1byjoc4gc6ue13yzy3ud1bcytxu3e1zh6eg7jz.8o7hh6pj476kgr4f75gjgj6op1tr6z7n1xifexgwfhy5fj3w56ehm97o8wuie5w.4-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: offer10_0d13e17271d6 X-Filterd-Recvd-Size: 6990 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 8 Oct 2020 09:26:04 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09892j6D133757; Thu, 8 Oct 2020 05:25:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=H5ujSFFLvFTfZOqN4N01nIzgOkdLLij7jTCD7y9DIFY=; b=OXf2kh89YB9KmwPNnbMxTQxptzhuio8QGyeMKMTd59gf4q9R6gQThZpt8ccjXWI2Oif4 9+O/NC7Qx0UZxwVFQBzyzfSvKUmbXiLxAKnjGgA0juOGEbqYCM5ccLAXedCUGZ0yK7Ak uOPWV4Aww9hXkSGZ/UkYHvv0y6lbOpytajKXuSnScGvmzvJW/36E5aFadLach6d6CA58 NY0a6eYbkbdKZ3mp1bTEadjrs4oiWaUernNGGzNLzrxUxLnWHMQP0xCypREGMPJ+jtKf ZJKfTa9bvE1cTFtVEaJA8P5wfZ/ExhmzjhSwX1gWoD2xd+vZJj00GwB2N70Cb/2BjGtZ oA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 341wwrcc9j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Oct 2020 05:25:59 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 098948Px139634; Thu, 8 Oct 2020 05:25:58 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 341wwrcc93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Oct 2020 05:25:58 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0989CLkx008572; Thu, 8 Oct 2020 09:25:57 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma03wdc.us.ibm.com with ESMTP id 33xgx95tu3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Oct 2020 09:25:57 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0989PuWt38076816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Oct 2020 09:25:56 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8946913604F; Thu, 8 Oct 2020 09:25:56 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B84913605D; Thu, 8 Oct 2020 09:25:51 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.85.112.45]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 8 Oct 2020 09:25:50 +0000 (GMT) From: "Aneesh Kumar K.V" To: linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au Cc: npiggin@gmail.com, "Aneesh Kumar K.V" , Peter Xu , Jason Gunthorpe , John Hubbard , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jan Kara , Michal Hocko , Kirill Shutemov , Hugh Dickins , Linus Torvalds Subject: [PATCH] mm: Avoid using set_pte_at when updating a present pte Date: Thu, 8 Oct 2020 14:55:41 +0530 Message-Id: <20201008092541.398079-1-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-10-08_04:2020-10-08,2020-10-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 clxscore=1011 mlxlogscore=735 priorityscore=1501 impostorscore=0 mlxscore=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2010080064 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This avoids the below warning WARNING: CPU: 0 PID: 30613 at arch/powerpc/mm/pgtable.c:185 set_pte_at+0x2a8/0x3a0 arch/powerpc/mm/pgtable.c:185 Kernel panic - not syncing: panic_on_warn set ... CPU: 0 PID: 30613 Comm: syz-executor.0 Not tainted 5.9.0-rc8-syzkaller-00156-gc85fb28b6f99 #0 Call Trace: [c0000000001cd1f0] panic+0x29c/0x75c kernel/panic.c:231 [c0000000001cce24] __warn+0x104/0x1b8 kernel/panic.c:600 [c000000000d829e4] report_bug+0x1d4/0x380 lib/bug.c:198 [c000000000036800] program_check_exception+0x4e0/0x750 arch/powerpc/kernel/traps.c:1508 [c0000000000098a8] program_check_common_virt+0x308/0x360 --- interrupt: 700 at set_pte_at+0x2a8/0x3a0 arch/powerpc/mm/pgtable.c:185 LR = set_pte_at+0x2a4/0x3a0 arch/powerpc/mm/pgtable.c:185 [c0000000005d2a7c] copy_present_page mm/memory.c:857 [inline] [c0000000005d2a7c] copy_present_pte mm/memory.c:899 [inline] [c0000000005d2a7c] copy_pte_range mm/memory.c:1014 [inline] [c0000000005d2a7c] copy_pmd_range mm/memory.c:1092 [inline] [c0000000005d2a7c] copy_pud_range mm/memory.c:1127 [inline] [c0000000005d2a7c] copy_p4d_range mm/memory.c:1150 [inline] [c0000000005d2a7c] copy_page_range+0x1f6c/0x2cc0 mm/memory.c:1212 [c0000000001c63cc] dup_mmap kernel/fork.c:592 [inline] [c0000000001c63cc] dup_mm+0x77c/0xab0 kernel/fork.c:1355 [c0000000001c8f70] copy_mm kernel/fork.c:1411 [inline] [c0000000001c8f70] copy_process+0x1f00/0x2740 kernel/fork.c:2070 [c0000000001c9b54] _do_fork+0xc4/0x10b0 kernel/fork.c:2429 [c0000000001caf54] __do_sys_clone3+0x1d4/0x2b0 kernel/fork.c:27 Architecture like ppc64 expects set_pte_at to be not used for updating a valid pte. This is further explained in commit 56eecdb912b5 ("mm: Use ptep/pmdp_set_numa() for updating _PAGE_NUMA bit") Cc: Peter Xu Cc: Jason Gunthorpe Cc: John Hubbard Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Cc: Andrew Morton Cc: Jan Kara Cc: Michal Hocko Cc: Kirill Shutemov Cc: Hugh Dickins Cc: Linus Torvalds Signed-off-by: Aneesh Kumar K.V --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index fcfc4ca36eba..bfe202ef6244 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -854,7 +854,7 @@ copy_present_page(struct mm_struct *dst_mm, struct mm_struct *src_mm, * source pte back to being writable. */ if (pte_write(pte)) - set_pte_at(src_mm, addr, src_pte, pte); + ptep_set_access_flags(vma, addr, src_pte, pte, 1); new_page = *prealloc; if (!new_page)