From patchwork Tue Sep 24 20:10:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13811140 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 999E8CF9C69 for ; Tue, 24 Sep 2024 20:10:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 273B56B00A7; Tue, 24 Sep 2024 16:10:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 223EB6B00AA; Tue, 24 Sep 2024 16:10:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04FCA6B00AB; Tue, 24 Sep 2024 16:10:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D79616B00A7 for ; Tue, 24 Sep 2024 16:10:50 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 48AC51202E1 for ; Tue, 24 Sep 2024 20:10:50 +0000 (UTC) X-FDA: 82600725060.30.178AF46 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf17.hostedemail.com (Postfix) with ESMTP id ECA2440004 for ; Tue, 24 Sep 2024 20:10:46 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=EJOWnu8x; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=PZi2mIAm; spf=pass (imf17.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727208611; 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: references:dkim-signature; bh=dgK3c4prp5J4ovvA6MC6NRiXlJaXBNcHXz5s9K5M7qU=; b=FFmlOJ5PdFud0cWibbVfq3JorvO2J+WaLL6Oy7c/iu3P9FhRAg0K6iUQW6MxvgjKEWwjPI pNXClXi7Ml7WCdxApbT8ulWljwudsEDYMwStyImQ6riskspK7LcVDTcDJ6v5NY4I2dzx47 C6/RqnsSrmVtK6EThs1E55N1+jiqOfU= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=EJOWnu8x; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=PZi2mIAm; spf=pass (imf17.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1727208611; a=rsa-sha256; cv=pass; b=4IRa0x53MMhlSKVTaXPZwiaJ16bdh8dBfRHABfCrGCgrL/DMqeR2A3ZXMS+jL550oChuM2 OAVMcs48P1Ta7XUguTXx617qlpXxuQ64AtJIAH2e6O7Rka3n8a+rp+afrWmK3yVVQgEaTI Kv5aW61shOcWcrJdtHU+4Yk8Mz8FgGE= Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48OHMag4006458; Tue, 24 Sep 2024 20:10:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:content-transfer-encoding :content-type:mime-version; s=corp-2023-11-20; bh=dgK3c4prp5J4ov vA6MC6NRiXlJaXBNcHXz5s9K5M7qU=; b=EJOWnu8x9AhTNQRhCmTMiJMn4TySKO d+G2JBq0YMbCLUj80JblaYV4gKCrUha6hr0dTj0kuWE0o/H7Z9naudTgTCP0wqrh 0x+tiaB446drXKWIqxAJdgL03U9TSRJS2XnCHwS1j5Dmoyqr6dcId12kDi2WQfC6 CK63Xo2iG+mOBp3eF995I0Eq1lQwUc6ru1Q5hXYohuhKwEX5gYWuDkTVm/8WCU8B bLsN8DPBZMitf4hRVf6Izh3gyBWg8JvByWF4XoGwPVpA+HnwB+0y3Qa3f52Ffy80 cSEtp6N2StRv28PH2wILns0D1+mtHCydm3abJVX8tzbReXvpgltLtRzA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41sp1age4s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Sep 2024 20:10:43 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48OImBEF030480; Tue, 24 Sep 2024 20:10:42 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2047.outbound.protection.outlook.com [104.47.70.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41smk9snu8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Sep 2024 20:10:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NgKdEe2rV5BRH/7W4RsLpfQfOZSdePS8LxtMzSKj1SmkcvGUUo38NlMsj3I3E2YPNcMtaCUYlr1deRjimHa0b+zYB2GUJf44bDf+lirTZgP4yEyIGiVkjPCsZZRsZ2if69iWHqEMBhKyYm1iS4kLbKIbDzInzIc6P4paXG1ohIv0pzmfSOGeaZNGj1TkCCFtl8Av8joD1/ZVNK2UYCrk1sgoe3PJbMwAXgqIBTQHuGrQK54zw+bhQMSUjsxbZQwcEIFl3ul1O9+7S0jyIanvasO45xb16DzVi8XpMaVcmq4nGcPkie0SgtMWkR4BFB7Ehf3NTEZ9uw4aw02s7Dir8g== 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=dgK3c4prp5J4ovvA6MC6NRiXlJaXBNcHXz5s9K5M7qU=; b=XV/cwdngBF7VEFkcz4XPWDc+Oarv6PDA3FYkwySUDeAk0BxZnyILrAB6CZsuGYTzBpiouKr+pae6xVio0o803CeTpPSPMriswVv7u61DWrBn8LAGaSz6Rvh3a1PrDUvmzqYcyHuVPYimlFZLDmJu3aYHhDTKp1U/VklHJkJfmi21dqfeMG8GT0HTO5jbOsZnjzjOsEd/aqbUvm0IksDSBLPdMm/XIF04Jr2NT45gWUqF8YVmgeTSyVUB9j/r0jdwDUUwPn9e+b+5FsWEtL972ANVrLZ36AfDC/XjpvNEv+I6z3+54qKenZ68jhj3OTVOHpd/9lRjdtWkrx4uFmLKxQ== 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=dgK3c4prp5J4ovvA6MC6NRiXlJaXBNcHXz5s9K5M7qU=; b=PZi2mIAmK0aG3+uS4c8d838ovj9cKn7ZQPA7LMuCQbND1X1dLDJSd5hKyEAGfsH51s0slply4tiyuxxECP11bYi/4qh9YLQnMnc0MLhwqSrV8VC/THdBd23ZYxDrl6HB5xT3AoE9CRnlUC4DA+6m5Ob0p9i/Q7ALTOOcCYd3Zps= Received: from SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) by BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.13; Tue, 24 Sep 2024 20:10:39 +0000 Received: from SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e]) by SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e%5]) with mapi id 15.20.8005.010; Tue, 24 Sep 2024 20:10:39 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH] mm: refactor mm_access() to not return NULL Date: Tue, 24 Sep 2024 21:10:23 +0100 Message-ID: <20240924201023.193135-1-lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.46.0 X-ClientProxiedBy: LO0P123CA0006.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:354::8) To SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR10MB5613:EE_|BY5PR10MB4162:EE_ X-MS-Office365-Filtering-Correlation-Id: fbc8d1c5-b0fe-42c5-5b76-08dcdcd4f5cf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NUE98ywA2HA35Z4gZFTy42yc7TPrOtjnB/k5spJ2w15OqdLEm69jVUnEy7yeRIslkiVQzbJHYlj9q7kx3CXcwQjCSdZR6ciyclYdqa5VJEzp+VF19ZPWTnkC9ZRe1nDpDKY8c4o1gugRjKiVrrCBlkzdHH5Yb7yCaYrt0wbCpr3B30mlmZ0S1YiaTMfYy4pfCZ9XF+mg9fue/AyJX0inlXIkn2mBpUeL4LO3jLS/6lZrrnPuivPBAD5EtO8j/rJwtT+qVuwvplLGUqgzaDNEVs+p94OgsrNW1xFC/JSvAVN2Ifeh+mPN1K7ZcRns9cH4+ozw/vHuyy0iKe8Qu7ZB1aXjTIZ/+9Y2glfGKU1dTgHTOTNApCquXWQZkvKkSvAkIJG3vPa4bYG6A+LHoX1ep2m892A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB5613.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lntkrLwhJE0d1YZpmYEmyIj9fxKgOPmF54kaoULv4zvhdhyIJGcoNqieM3CAV/iVnZcTgUey+5BWgAez3wqTq7jNqD6H6GEoxnep7b6LR+6KqOAtLhEwJHHCAhAR3bBX7m++PI01CDU8kvIXrQIc8ZH9lIppdQxY0Zdoovh7SiQ7teHBD1g7ylfL4NERCRB0wFNLUyfNN6AHwrV1rMHlm0MVwNox8rVYxmpIYCcJiVphHHDIwt9iNLcaxYenQFOizkC7O73HT9AEZ/7OGHDhOExHGIwGGCIDPER/ZFoGN8A/3YfyH6Lz3bl034HaYcXLCgpK84RzNa8r4Jv7cbS1OF1BUcMKFTSFhx8K6Tb7zKkZmiQdvuffAjZSVbdwF4IMORCrEiEeGrvu22rdflLX+LlWiDE0HB8CAc87+3im4Xpswc7zdpjD9ZN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L3VVwYB5S/FP+JKlwxhTsMsXo6JmHR/jIIG6pA+NLmf5XfAdWSeF7uw/uzkUlRytFzCB5nuz4JWP6AUMfKtOHT4Es9pkff11rAbYhw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2cylNRpPMgFkZ9pO5BF/+5q/9uZgjF4Iknbh4GpXo4U0VjFOgsa0G7jqfDI9ZcdQPq7f9t9HaXxApDYjAXdFAlS6b764XNIAGCLtOvFf95ww0alxhVO8YGszH6EdG0p/2ZaPVm7FshmB5kzwCF3veYCzIyKH2jsGy+KMab013ZnZFD+cdS8yLG9Lw5B5TVLm+fM/YQAomKezBC0E95oPa9fxpTGz/aI4jpjOUuElZn2JFeM1v5uW/T0oyo1CVEgjKe216YBi1Q1N8UyKKqjv3y7FMVQVE2jtSs1HpMFGl2LIT8SjG38GVbOSOpgvNznnmtIMS0s9jC3DPxvET6PzUVF1Ff05cYnZqad1EBBTOgjOQ48opg/6Mhu6Bs9lbzeLGzdSAhKd5Q60lAOFX2WDn6YlrKsuyQuZs+TSarmVYxXm9WOMaaxkirC53K83+hFpGWdF/Tuuu4T83xOMrVa9RCXMjmXtxkvHVL8x4s3h0qNvXzY34uNtp0X7SFMAZ5atJgJGL2aty9B7SBbT5S4kpw3+Hfv0Nlo6ul1aPHQv6d5B7biykH3oT5I5PbkyvmL4rcaJVwlUfjE/RZHdrokSOImghfTrzA5In/BpnERYXJ4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbc8d1c5-b0fe-42c5-5b76-08dcdcd4f5cf X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB5613.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2024 20:10:39.5655 (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: 2eR2kEDG87z7YpxgSsWt00laNhEUpILKyp4pWDWP73yNjTshX5aWdj4G/dxHS6+flqru5UolLq7RQMYiFi0x5QrnSRR4f4dmUgCWNJnr8io= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-24_02,2024-09-24_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409240142 X-Proofpoint-ORIG-GUID: 57bMz3Radvx3qw8shJg7ZNDBmC-n1IKl X-Proofpoint-GUID: 57bMz3Radvx3qw8shJg7ZNDBmC-n1IKl X-Rspam-User: X-Stat-Signature: 6ioc77k6r5kczu7ra3tzdixz8dqqrjiw X-Rspamd-Queue-Id: ECA2440004 X-Rspamd-Server: rspam11 X-HE-Tag: 1727208646-775594 X-HE-Meta: U2FsdGVkX1+XZZ165Hjbt5/LSPh4AdUwthWGuqcUznXQF/gxCOtERCcS+Vp4Q3URriIW5HEkZYJi85ySau8Ah1axD/NwJrTAXIHMh9yWtvGb7cLNWX53XdinDBcH/BBA9oYmyT98msq+nd2qYON7Pqru+fqkwXSESeTAuOmZs42KAZVthJZkAwZBYhtCcheobbVuDYxjAl1tqQl5xgylKN6sUItAkm4pe8wO9RN9lU0Cy1koeWGCNGIFt1AUs91OWG7UczGeFKSqvBrOOuh4NnJfOv/JFD7vVtSqT6F68WZ3fRplsmYTEOMVzRYKb6hW5fXaws9Q4AjG+UV+7SINU8Cf62ZZwO/qoU/gj6tCdI8m0epR7sFkf2MO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ryMU+Kf6uRp6MWrCjcuA6d8jaujChWyHvGvHRBZZB85Wad6ziunt0M1KiqpY173h/JuwGnb3mIjdf3x3wzK7gY7qadjzpNx9+ybsamvP1iXYad6N46Z7TGEzR 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: The mm_access() function can return NULL if the mm is not found, but this is handled the same as an error in all callers, with some translating this into an -ESRCH error. Only proc_mem_open() returns NULL if no mm is found, however in this case it is clearer and makes more sense to explicitly handle the error. Additionally we take the opportunity to refactor the function to eliminate unnecessary nesting. Simplify things by simply returning -ESRCH if no mm is found - this both eliminates confusing use of the IS_ERR_OR_NULL() macro, and simplifies callers which would return -ESRCH by returning this error directly. Suggested-by: Arnd Bergmann Signed-off-by: Lorenzo Stoakes Signed-off-by: Lorenzo Stoakes --- fs/proc/base.c | 26 ++++++++++++++------------ kernel/fork.c | 5 +++-- mm/madvise.c | 4 ++-- mm/process_vm_access.c | 4 ++-- 4 files changed, 21 insertions(+), 18 deletions(-) -- 2.46.0 diff --git a/fs/proc/base.c b/fs/proc/base.c index b31283d81c52..fe31decc12b5 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -832,19 +832,21 @@ static const struct file_operations proc_single_file_operations = { struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode) { struct task_struct *task = get_proc_task(inode); - struct mm_struct *mm = ERR_PTR(-ESRCH); + struct mm_struct *mm; - if (task) { - mm = mm_access(task, mode | PTRACE_MODE_FSCREDS); - put_task_struct(task); + if (!task) + return ERR_PTR(-ESRCH); - if (!IS_ERR_OR_NULL(mm)) { - /* ensure this mm_struct can't be freed */ - mmgrab(mm); - /* but do not pin its memory */ - mmput(mm); - } - } + mm = mm_access(task, mode | PTRACE_MODE_FSCREDS); + put_task_struct(task); + + if (IS_ERR(mm)) + return PTR_ERR(mm) == -ESRCH ? NULL : mm; + + /* ensure this mm_struct can't be freed */ + mmgrab(mm); + /* but do not pin its memory */ + mmput(mm); return mm; } @@ -2208,7 +2210,7 @@ static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags) goto out_notask; mm = mm_access(task, PTRACE_MODE_READ_FSCREDS); - if (IS_ERR_OR_NULL(mm)) + if (IS_ERR(mm)) goto out; if (!dname_to_vma_addr(dentry, &vm_start, &vm_end)) { diff --git a/kernel/fork.c b/kernel/fork.c index cbdaca45d0c1..841f60630c58 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1545,8 +1545,9 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode) return ERR_PTR(err); mm = get_task_mm(task); - if (mm && mm != current->mm && - !ptrace_may_access(task, mode)) { + if (!mm) { + mm = ERR_PTR(-ESRCH); + } else if (mm != current->mm && !ptrace_may_access(task, mode)) { mmput(mm); mm = ERR_PTR(-EACCES); } diff --git a/mm/madvise.c b/mm/madvise.c index ff139e57cca2..50d223ab3894 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -1511,8 +1511,8 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, /* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */ mm = mm_access(task, PTRACE_MODE_READ_FSCREDS); - if (IS_ERR_OR_NULL(mm)) { - ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH; + if (IS_ERR(mm)) { + ret = PTR_ERR(mm); goto release_task; } diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c index b308e96cd05a..656d3e88755b 100644 --- a/mm/process_vm_access.c +++ b/mm/process_vm_access.c @@ -201,8 +201,8 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter, } mm = mm_access(task, PTRACE_MODE_ATTACH_REALCREDS); - if (!mm || IS_ERR(mm)) { - rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH; + if (IS_ERR(mm)) { + rc = PTR_ERR(mm); /* * Explicitly map EACCES to EPERM as EPERM is a more * appropriate error code for process_vw_readv/writev