From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C54B0CDD0F4 for ; Tue, 22 Oct 2024 20:46:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A1286B00BF; Tue, 22 Oct 2024 16:46:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 529816B00C0; Tue, 22 Oct 2024 16:46:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DF5A6B00C1; Tue, 22 Oct 2024 16:46:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0405F6B00BF for ; Tue, 22 Oct 2024 16:46:22 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 43F22804FF for ; Tue, 22 Oct 2024 20:46:08 +0000 (UTC) X-FDA: 82702420626.15.A30843F Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf29.hostedemail.com (Postfix) with ESMTP id 3BF6A120010 for ; Tue, 22 Oct 2024 20:45:57 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=jxlyGc8H; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=eXV6ivvW; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf29.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1729629856; a=rsa-sha256; cv=pass; b=i83SM2ZyZo2qNWmKef4f6I3N7GfT9Zv82c6lKzmiim30usOBWQrQbVYeiPqHuo6AVR9H7H 6KAKUP2K1+oet1NGf3WxpVHC9tseNs6gFldqI7U1vSjWC9ObivV+fCrv/5IPiIQUJt6IkE 0FxNIDMlTzoBxKgU5xG1CVUYrCflbYE= ARC-Authentication-Results: i=2; imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=jxlyGc8H; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=eXV6ivvW; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf29.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729629856; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+nus8Xrp8j5XotQ3pGgSzwK1AZHKD0WT78VBFXRPAX4=; b=pL3NbTcRUDThz1NVjv1vFlSd7lIEVNPh9v+ayNntA+L++xyIYqtHltkM+MDKqn6S2+ARRC 8nmDTK++LhxfkYS3fqAgpmzboVcvweza3Tv4Q8aSzcYagKoXMXMNTn5Ud94sFvXOsIbjWC Ua9bsE1spDeRjcEHe78U7wTILEmONFg= Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49MK3YO6004902; Tue, 22 Oct 2024 20:45:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=+nus8Xrp8j5XotQ3pGgSzwK1AZHKD0WT78VBFXRPAX4=; b= jxlyGc8H2PLGg1ndFR4+Qa1gFv17jumkX4SyE7c+xhdYbYmCdbpMk7T8DtIWSICS q+H+pG0gcNFw3tllblV4KFGozV/s7AQuIsqibyCe4rIlM64LmkRKPEukiIVy31Db S+WQWEUaADi0L89S/zcKjH9KcdS+zkn4Reu5kZfhtU+/nUFZZhxYPVZza7BqvRrr 1NBcHwjEjEWAbD5siWVtK/lzMSOtWaWveCy7ZNVKNwEJ/Db2Wz2rFXwyeheNoX/o eP66h4Zz6IapCJrfvGZ5Z2Z1o84dZZDK+dU6S/LDPBiHsVfdhJk1o4vnjZPhf8GG hKbP7Vx2n8PnGhHNsBZkUw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c55uxn9g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 20:45:42 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49MK8tcI023392; Tue, 22 Oct 2024 20:45:38 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2040.outbound.protection.outlook.com [104.47.57.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42c8ew38w0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 20:45:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Brb9HOSnuH/OyhvZxyc/wXpXUzsuKy6VedD7BR3pPYli0xIsFjMG2Cd2OfjLwlGvse01lcZe+fvBTIqUYiFpSQNLDEicZsPIjViERsbIXZkxtol/U7zJjIjqsQTuvbBemdFe+3lLld8MMR/w8lRsOX2+8xLbzJy5stcvMDph5z3DJzhHeeW8ZSFUk3wa87NdqdBFj2dPFyRlY5fjeKNiPY51+8B88oV9hZSBSl7n4QYtfjjm82HVQU3tSrkI9yn82r2YhBftXXN2FboLfFVJGDWFwUZPmTv9qsYYy+1voIr47Oezb4Y8/Px09ItHYgyMEvW+FkPlaTrJLZ1xLDAykw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+nus8Xrp8j5XotQ3pGgSzwK1AZHKD0WT78VBFXRPAX4=; b=Ux50Nm7Bv1TKBLqFSurA+HJ2xVP/ff5W8b3gRbxMesKyRsWuAat3PeTkvSvnPSSdH3bs4kzwY5zXlWrsp1Npy9duaFPIyBOs30Hc2UpGtP+VI/jIE9LqRyHSjNyyjEuaw0flpY35g/1lB+0WSglKBQn3mO36bFxg417ryeMZpWrQ5kkHrrE/WbAZ+o1wBDLvG1+sv7L+r9VeDeQUIu/MBNwB1LCRUm/+UD0f0ASyAxUMmsgGRE0DsCGJ9HrVRoAvAREk/4m9x1d03YcZqYEKfRD0SoOarPtgcndNSr6YTas6L+shVW52DQt6aYROiQDl0PIZ5/cE9FiAFURyEGkhnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+nus8Xrp8j5XotQ3pGgSzwK1AZHKD0WT78VBFXRPAX4=; b=eXV6ivvW9pfnkb79IuKqQLW9w65dXu0Ph3WFFw1DQ+vtVDV/rYFUbEK3fFbOIYokn5Maw+sLPQOqfhYGXSkc+Wt0xBVzNd1J1PjCL5JfSz7ghW80NuYUh8MpC9mSxqdwYgnouEDJwVXmO39H+gmna+xYqcbhS9lk3Y6FmiVmOJo= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by DS0PR10MB6054.namprd10.prod.outlook.com (2603:10b6:8:cd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Tue, 22 Oct 2024 20:45:33 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8069.024; Tue, 22 Oct 2024 20:45:33 +0000 Date: Tue, 22 Oct 2024 21:45:30 +0100 From: Lorenzo Stoakes To: Jann Horn Cc: Vlastimil Babka , Andrew Morton , Suren Baghdasaryan , "Liam R . Howlett" , Matthew Wilcox , "Paul E . McKenney" , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E . J . Bottomley" , Helge Deller , Chris Zankel , Max Filippov , Arnd Bergmann , linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-arch@vger.kernel.org, Shuah Khan , Christian Brauner , linux-kselftest@vger.kernel.org, Sidhartha Kumar , Jeff Xu , Christoph Hellwig , linux-api@vger.kernel.org, John Hubbard Subject: Re: [PATCH v2 3/5] mm: madvise: implement lightweight guard page mechanism Message-ID: <5afafb29-85d8-4d51-8a7f-be2186224e7d@lucifer.local> References: <393b0932-1c52-4d59-9466-e5e6184a7daf@lucifer.local> <2647d37b-3482-4fc9-8da2-1158ebdc919e@lucifer.local> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: LO4P123CA0234.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a6::23) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|DS0PR10MB6054:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e4aa590-4612-49d0-bf26-08dcf2da7964 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|10070799003|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?NVRLVWJRMWdHWFZRL3VDOTdLaElNZWYrQXc0dWFQVGV2Nk84Tk14N3lTbU1l?= =?utf-8?B?WUxMWFhVSFkrMVZ6ZTVPTmRZV1JoTFpKQXdFTlZldHJaRWxPbURucWFFaE5C?= =?utf-8?B?UG90aFhsRlB6OUgvaHk2dlo1WlFHYjI5WDZKd2pXMVZlemNWdWxRZXl4MzJ5?= =?utf-8?B?cjlJVmZrZkhvYVlFYUhHejdDZU56L3MrWE1TNzVtd002Qm5qcWxBVE5LTmF3?= =?utf-8?B?ZFg5N2lIN1NpQUlOZWpMdWc1RHU4ZlFnSHVZRnoxa3BvdFJneXBVbzJhOUE5?= =?utf-8?B?YVYyM2NuaFdWVVBCQnQ0VHpoaVhLRkVOMm9JQWk4VG1reGF5ZnR4b2hhUGFI?= =?utf-8?B?ZmNGY2hxODd5YUZVSEdIUUhrb1JiWVEyQkVKZkVJYlIwYlZZUFFSVGx1WWRY?= =?utf-8?B?cWZlTjRRMWY1NENmNXNZbURJSFlGUkxTZVEyd0x3R2VhY2V3c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ViNUJzSE1M?= =?utf-8?B?dy82WTlTRE5jY3VoTFJBUjZxbXFkUkY1bHlqYjBGSDY1NE85THhzUFlheUZS?= =?utf-8?B?U2ZpdUZ4eExiam9qdE80MmRWWlpWaU95VFcrdklBemczSDVZV3ZyRkdqdXJm?= =?utf-8?B?dEI3OXdiRE9XNjZzT0FMQ2tORERNMlZDelJjMEwyaHY3VS9TNHhyZjlJTDFO?= =?utf-8?B?RERtY1RCVUYzR0UwL2JLMkVRczNLcllQdnFvUS9EcHRBcjl1eE42TmdMZ1ND?= =?utf-8?B?TG96M1N3OE9ER2sxRmsrSTZha1piVE1oeWc3OWMrWmQ3UnFHVmhYYVBPRE5C?= =?utf-8?B?aklxRmRaMUgzZW1kK0YxS0kyMWVLSTQwcjBORHE0Y1JMVmtlZXRjRmNwWDNl?= =?utf-8?Q?FvL5dmVXsAPukxQ9vtCSJnV5R9K9z1QC6OiCCOd?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(10070799003)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aDBhb2FlRXdVTnZpemRESVdqMjU0QVpIWnpMK1RvWW0xKzBhQUlTU0xMMFo4?= =?utf-8?B?LzR6SkhOSkZ4bTBCd1ljOStPUlVSMFJuU0RTaEVzdDlkdVN2S1lJZ3R1Mzdv?= =?utf-8?B?Wk1WZm1lWmdEZmFHYk15Q3NONENpc01sWERhWUQ4aGQzWkc3K1Z5dHNWU1B4?= =?utf-8?B?dGoyMFdmeXg3aDQ5d3lUb00zNkR1dzc2SXdwWlg1OWdVTjJ5UlV6alErbmRI?= =?utf-8?B?bGFNdFU0T2RvVXFLQkhDVjZWRUhCeWFHc2JIY1Fza1FEZWNn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?azljQk5aRUpOSEVaQ3AyS2VhM0xXS05kaHR2NnJKRnppRjAwejZmOEplcEZR?= =?utf-8?B?TDRUcEtVaXJWR0RuTThoUVNDaDltaWdPRW9JU3ZkZFMvOFZERlRjWUdERUVv?= =?utf-8?B?bjFTeWsvRGdPd2pLWURiT0lTRldYdEsvMStVSi9DOWdRZThYa1RmWFlsdXRF?= =?utf-8?B?WDFlczNrcUVQM2dta2hjZWU2a25BPT0=?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ymNqwnu0nNwbBJtWh/HQSR+w4ZVY5pUA2Hc+5rUPhLj21cKLgNS9BLTB5v/w2I/6DIDaoKnJADyFP0TshspzdxQvVDQDjNf5jMGRMoB2kjkNZ42MU/uRWNnh5qUsnx2stDG/rIQrUjJqsUXJQ9x018gSna82XE029m+sgSjUc/PZ26Vvv/G00qjCuQHEKTJZrTo5b7wkSSxw2eiDFe2n4Kbnn+868CcwPY4zMZCGNd+KPNlNqA6wjiLWbMWl0IYwtXmchxXcoGn7QNRaCHlKIrMVN+9C5oIae/4u6f4nbEHc5KnwaycerKoINDcEc3eguSJy6qweVpS+UTcmeG1nKQl5JYrzlEGy1ONqvMv9CO3HQILdp3WdS0dYUJOMxktPUF742fjpSMqYBi5HyVwykx32Wzjpejf4xuoNJ5m2TzUQbRP6j9fnVOb+mcinScLvx0L2bNa4HBZ9P1VtCWI3Ys/OT4V+fOvd4bxKwDNAUgYXuC4A7Swesgb7/r7HBsNBXit63/K5w8QLDX0gQCsBi9qqZsFSkd8WxWzUpegme3G/2pvTV+J2d/S89r/HXz37VsoAQUWAtFQ0SAOfQCNZmer2gbFnP16sGd2Mf47LEmU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e4aa590-4612-49d0-bf26-08dcf2da7964 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 20:45:33.6058 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qhwCx/lInlPWUkxni1Q3FAfBnmEfByt2rpqzCMRSr6+gM8SAwE9Au0uCgrsoCUqmPx7eBNARtkKm6fhh07inCypS82ZMODwqqKCaAz+rrw8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6054 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-22_21,2024-10-22_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=851 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410220135 X-Proofpoint-GUID: 499eZyXLxVLNYra2VEX3SMLxpoO10bzC X-Proofpoint-ORIG-GUID: 499eZyXLxVLNYra2VEX3SMLxpoO10bzC X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3BF6A120010 X-Stat-Signature: qo77hnmqpi3gtiauwtf9cue9ds9m7hq7 X-Rspam-User: X-HE-Tag: 1729629957-206386 X-HE-Meta: U2FsdGVkX18M9E6cDRnlGKmglIrAXDFrk4t/1i5c7UE1dCxH98JfSmZLk5n+kFo6A5cbqotTHVEJmDOCwBB4NXDIz5SgO6eb8zLzLqFQtxbHRYOC4Hph78YngyjjREMnYZZF/EMOXJOYolPbjgl4TNd/xg8PAvIVMQZRuc9arcfGCQqUfjsJwkvkTj/yvlOY34S0phDR0DtXZTXVphjCjoYjUcdXbVWsZD4uM3qI1KrRKOMKeBEldW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9rs6g8ZAab9KXRu7+x248JjKeUQjjll7vnlmFF2h2YRSdr8nqTmEC8jYTpsfKuLK11HvZ8htLEld9v2vvW5dSpVs2BBdJbRCeLmG3LkrGIWgiBpE5ZkUgoYmW8NZD29EQCDV+rcwiEutUJ4ktCU0vs3KQVJDmzwUf8oKQA/OdVFOh/DPORU/uOA/pSpW54gbdbxbj4N+2AhcKs2Cj6xzVNoBnHSU= 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: List-Subscribe: List-Unsubscribe: On Tue, Oct 22, 2024 at 09:57:39PM +0200, Jann Horn wrote: > On Tue, Oct 22, 2024 at 9:35 PM Lorenzo Stoakes > wrote: > > On Tue, Oct 22, 2024 at 09:08:53PM +0200, Jann Horn wrote: > > > On Mon, Oct 21, 2024 at 10:46 PM Vlastimil Babka wrote: > > > > On 10/21/24 22:27, Lorenzo Stoakes wrote: > > > > > On Mon, Oct 21, 2024 at 10:11:29PM +0200, Vlastimil Babka wrote: > > > > >> On 10/20/24 18:20, Lorenzo Stoakes wrote: > > > > >> > + while (true) { > > > > >> > + /* Returns < 0 on error, == 0 if success, > 0 if zap needed. */ > > > > >> > + err = walk_page_range_mm(vma->vm_mm, start, end, > > > > >> > + &guard_poison_walk_ops, NULL); > > > > >> > + if (err <= 0) > > > > >> > + return err; > > > > >> > + > > > > >> > + /* > > > > >> > + * OK some of the range have non-guard pages mapped, zap > > > > >> > + * them. This leaves existing guard pages in place. > > > > >> > + */ > > > > >> > + zap_page_range_single(vma, start, end - start, NULL); > > > > >> > > > > >> ... however the potentially endless loop doesn't seem great. Could a > > > > >> malicious program keep refaulting the range (ignoring any segfaults if it > > > > >> loses a race) with one thread while failing to make progress here with > > > > >> another thread? Is that ok because it would only punish itself? > > > > > > > > > > Sigh. Again, I don't think you've read the previous series have you? Or > > > > > even the changelog... I added this as Jann asked for it. Originally we'd > > > > > -EAGAIN if we got raced. See the discussion over in v1 for details. > > > > > > > > > > I did it that way specifically to avoid such things, but Jann didn't appear > > > > > to think it was a problem. > > > > > > > > If Jann is fine with this then it must be secure enough. > > > > > > My thinking there was: > > > > > > We can legitimately race with adjacent faults populating the area > > > we're operating on with THP pages; as long as the zapping and > > > poison-marker-setting are separate, *someone* will have to do the > > > retry. Either we do it in the kernel, or we tell userspace to handle > > > it, but having the kernel take care of it is preferable because it > > > makes the stable UAPI less messy. > > > > > > One easy way to do it in the kernel would be to return -ERESTARTNOINTR > > > after the zap_page_range_single() instead of jumping back up, which in > > > terms of locking and signal handling and such would be equivalent to > > > looping in userspace (because really that's what -ERESTARTNOINTR does > > > - it returns out to userspace and moves the instruction pointer back > > > to restart the syscall). Though if we do that immediately, it might > > > make MADV_POISON unnecessarily slow, so we should probably retry once > > > before doing that. The other easy way is to just loop here. > > > > Yes we should definitely retry probably a few times to cover the rare > > situation of a THP race as you describe under non-abusive circumstances. > > > > > > > > The cond_resched() and pending fatal signal check mean that (except on > > > CONFIG_PREEMPT_NONE) the only differences between the current > > > implementation and looping in userspace are that we don't handle > > > non-fatal signals in between iterations and that we keep hogging the > > > mmap_lock in read mode. We do already have a bunch of codepaths that > > > retry on concurrent page table changes, like when zap_pte_range() > > > encounters a pte_offset_map_lock() failure; though I guess the > > > difference is that the retry on those is just a couple instructions, > > > which would be harder to race consistently, while here we redo walks > > > across the entire range, which should be fairly easy to race > > > repeatedly. > > > > > > So I guess you have a point that this might be the easiest way to > > > stall other tasks that are trying to take mmap_lock for an extended > > > amount of time, I did not fully consider that... and then I guess you > > > could use that to slow down usercopy fault handling (once the lock > > > switches to handoff mode because of a stalled writer?) or slow down > > > other processes trying to read /proc/$pid/cmdline? > > > > Hm does that need a write lock? > > No, but if you have one reader that is hogging the rwsem, and then a > writer is queued up on the rwsem afterwards, I think new readers will > sometimes be queued up behind the writer. So even though the rwsem is > only actually held by a reader, new readers can't immediately take the > rwsem because the rwsem code thinks that would be unfair to a pending > writer who just wants to make some quick change. I'm not super > familiar with this code, but basically I think it works roughly like > this: > > If the rwsem code notices that a bunch of readers are preventing a > writer from taking the lock, the rwsem code will start queuing new > readers behind the queued writer. You can see in rwsem_read_trylock() > that the trylock fastpath is skipped if anyone is waiting on the rwsem > or the handoff flag is set, and in rwsem_down_read_slowpath() the > "reader optimistic lock stealing" path is skipped if the lock is > currently held by multiple readers or if the handoff bit is set. > > The handoff bit can be set in rwsem_try_write_lock() by a writer "if > it is an RT task or wait in the wait queue for too long". Basically I > think it means something like "I think other users of the lock are > hogging it more than they should, stop stealing the lock from me". > And the RWSEM_WAIT_TIMEOUT for triggering handoff mode is pretty > short, RWSEM_WAIT_TIMEOUT is defined to something like 4ms, so I think > that's how long writers tolerate the lock being hogged by readers > before they prevent new readers from stealing the lock. Ack makes sense! -ERESTARTNOINTR should help resolve this so definitely unless anybody has any objection to that I'll go ahead and do a respin taking that approach (+ all otehr fixes) for v2. Thanks for your input!