From patchwork Wed Sep 8 00:04:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Brennan X-Patchwork-Id: 12479607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30388C433FE for ; Wed, 8 Sep 2021 00:04:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 160AD61102 for ; Wed, 8 Sep 2021 00:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347218AbhIHAFa (ORCPT ); Tue, 7 Sep 2021 20:05:30 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:30574 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347185AbhIHAF3 (ORCPT ); Tue, 7 Sep 2021 20:05:29 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 187LTUC1018860; Wed, 8 Sep 2021 00:04:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=WpJDEHRKCZUIj9sBlrG8dZl8Er9MMawNvkT262xqaLM=; b=OuMsGh6RZdMoBAL/c6bhKUIUCpDmdUiWLCae2cbwNT9SGFaJrTIkoGHlXnwwOFKt79uo XBzFHTVIh2q93KqYgsM2GZnxVzXw95iU6I/toq6fpcbfwjDS02RUUfcwdlxDGm5p7cSz xZlIjYTfEcwIgWWQ94sxmUrV2EeU2R/3HPZgcidKDCIKqJHnD+t97ePYzJIZfgWDRRBL Y3gLHOSvE+/VWsdPVJWcf0UfsTAbgKASFrm/9YDZsRc+Vv2Dv4khNhifDvrLeJxM9Gts /Zs3GydAgaL+pET3cyCro3E9HbTIMuQzPittQ3rqNRUcDfI729m+GSPFnBv2orWh84OW KA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=WpJDEHRKCZUIj9sBlrG8dZl8Er9MMawNvkT262xqaLM=; b=TcHbOXfVF3n0TqdqxCiFXANXUvWgD2yayYsj9DRRoAZm1XBD7P/2UBDGZxGBV+cqAvgk rrbiwjmxKookD4fPGFd7VQOtVbA2CErJQn0EMT7aRuzHq2VnCPD1qgU73ZPtvCkU5HTB +9tEwSUWD42PtQCtLUemrNH4vtXmSwLBvumZZTEFsArlt0Led+4cTNBJYuTcPjvLQD0H KvaG2zPiKcTP0tY6kKb803RRj8ytYlYjVb9BeH+3UH2HFuxkCo0LjuxcMcA3nDJ3JRXZ 3O5awGFMAXJew2DukCPhpujMSJYCZ8PIeiAB/nSF2QPqAshByW5GII+2occcIph0tkfw nQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3axd7t8rf2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 08 Sep 2021 00:04:17 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18800FJ8006507; Wed, 8 Sep 2021 00:04:16 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by userp3020.oracle.com with ESMTP id 3axcppraa8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 08 Sep 2021 00:04:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SsjpRMu4FmW3accLV6TJwVGyzZx4fWrEYytDj+IM79cW2zU1GYwvJzdppYgaxigmWh0SHi7yZak9Ig6NVbKwQyhP5kMG6k6t+AFZ3m0fvAS/KHlzqmVBlFCRz8CBOtx/aTdoJnsiey9+gh7pibXrKwIuUTx8KiGdRAXZkT8ICyh3Gv0r7dW1r6GZ7uTl9Ts9Gx3Khn6X7Y7M5SjWsxHazhq8HaEeUDyskgTPTwl3LDmPIfAESkmwI63NIP+krj5zio4jKFrlFq7dII5lu/YNvSjizbTou/TTVkHhKuUBMQdjBB/wXtp78iLP45Ex57SViM0BwVjqlCMTK5cYTYSi6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=WpJDEHRKCZUIj9sBlrG8dZl8Er9MMawNvkT262xqaLM=; b=dCgN+0WvwUzEJsR9yk/GDArjo1AfjuR/RozkH7hsJAZV8hGm/OpxaEgrtFC0vbrEgRL+U5Rn/unW+MPtTOuhApjXtt974fcaOmGQBBUnumM7izA4shzb2kMbgQUqse1wSTfP9mVnx48Q074AYeECIN6kIrREnEILegXpuf2nW0q7cKHZu8MaHkMvAvh5QWAuXhhf9XHA2rVGaYEJ19CrsVL8Oxi/d0o2qgQu8qeOxL12nzHGWbwFPNkiageLPGxmpCp6DRMTnFlCmamVVAb6krg6dJ1yezJXjokB6RcaHE3ESgKJYUcnpMcz/NVqzPOPk67PIQj1ibp+0ykqj49HAw== 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=WpJDEHRKCZUIj9sBlrG8dZl8Er9MMawNvkT262xqaLM=; b=Y7zzMHPv2DDMu6c3RgLpdGQX4BXzYoQrb3Xc/NhBvhhpLtavwScPZRQiwL6HsjMxp7YNr2uzRo2BN7QVqcUDmsTlZdkVcD1lYhAEyzG3LrwInG+aBBLicoWUWGZvfj1riwwP8CZLZQMfkHXwK5x+gZviujBMDSG2wr4i0mW79ME= Authentication-Results: zeniv.linux.org.uk; dkim=none (message not signed) header.d=none;zeniv.linux.org.uk; dmarc=none action=none header.from=oracle.com; Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by CH0PR10MB5147.namprd10.prod.outlook.com (2603:10b6:610:c2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Wed, 8 Sep 2021 00:04:14 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027%9]) with mapi id 15.20.4478.026; Wed, 8 Sep 2021 00:04:14 +0000 From: Stephen Brennan To: Alexander Viro , Jens Axboe , Dmitry Kadashev Cc: Stephen Brennan , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/4] namei: Fix use after free in kern_path_locked Date: Tue, 7 Sep 2021 17:04:10 -0700 Message-Id: <20210908000413.42264-2-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210908000413.42264-1-stephen.s.brennan@oracle.com> References: <20210908000413.42264-1-stephen.s.brennan@oracle.com> X-ClientProxiedBy: SN4PR0501CA0090.namprd05.prod.outlook.com (2603:10b6:803:22::28) To CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) MIME-Version: 1.0 Received: from localhost (148.87.23.7) by SN4PR0501CA0090.namprd05.prod.outlook.com (2603:10b6:803:22::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.4 via Frontend Transport; Wed, 8 Sep 2021 00:04:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 20e113d2-a03d-4e5c-2db6-08d9725c314b X-MS-TrafficTypeDiagnostic: CH0PR10MB5147: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bIlgYGAy+Niaf9LHEqIcocMYgFUn7leO6MtLW9Vkz1pp8m4hagZisvAghArC2oxYmg2qvNNX02YsRUQypPbTkOlZViiNdFYyidEVNajOY4vRBZmbyAUOKd0tRQ4u/TN6R2SRdjuFGcK6zH6N/fqAQLcoBL8Q8lFJK2YGcoUM5Ddaqs7B9rDc19DUCXpRZrT+kNJjn0J3EufAEqDoLsdOV5fi7NxcuM1Yp3bjDOerWChjqDeKuCNKUuupkSHBfjiXAHskmY6yUw3TTVhfkAqtSNkp66vM1ZtHI/p/pOTn3x1C1Jnc0Xq2Iem9k67W4GAatOJCXDND4vinhQm+vwlfuEczm2groHFANDrqxky9L0mn+0qeY/3v9hvsOZVq7N093Vmit5wsh01y0nwn/HCr+Ygck14lUpn99jBO6LaqJQeR4r8Sq60SUmFPCJ1EPL21H4GOhSNRGz8lqhlRrPsGHJ3cQOy0wEDOGo2hCEAA1C7X46EEvZ6M2KCCQta/NnCDG/IhcH2/GoijnbwgrNiGSnyi5FUGma1H9yV0qC9mFKNcy3WwtSpv+Xp+DEgIWHJWivU8T98zA1gvVYCJd2Ie+4pCcD7GuiFk2R2RvhF7EKiAmpf7/aJ4vi85D+nmfCzA3Zy41wqKOxDPT5Lb+Bh3yc0wb6WDwEQdnQMtMY9XsnM/p6OM116/CqTbyRBiqfc8es3nGiYhK/TOZVhmRFpR8gBPpjgut67wGNKF4DOiZe82lZk0H47mpU66dUoHKxvzI7s9KC0bGw9c8U5AoVSzDemnVwu/Mlcr1nXsl1nycUpYMDYG1QwmahCemPaRJYow3fL2KJFRi6Um28aFIb8gIstA1qbrQ82g0R3I96hxSAvFF7B8j5BwRP433e4phWCAxsnjKqr6dExj90InieL/NSls97apOVtgkGUJi48k4RrSjpfnY2SMaFtkhV90s/6G7lgbnNILbdHidyJG08Y3wkj4Y5qxh4qd6J4rT3XKE5Y59T8Z8iYC1cnb5hPI6jwWq4dtvLb/zXPwQtgSSRSdYkf6xofco/hLo9bh1NfphdNrzvu/zlbOUyF3e9HbibvFbCyPbuA/sjhS13APAXcjAWzxGJgyaydUzQK3AzAomsk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:5;SRV:;IPV:NLI;SFV:SPM;H:CH2PR10MB4166.namprd10.prod.outlook.com;PTR:;CAT:OSPM;SFS:(136003)(396003)(346002)(376002)(366004)(39860400002)(8676002)(2906002)(8936002)(110136005)(103116003)(478600001)(66476007)(52116002)(956004)(316002)(66556008)(38350700002)(38100700002)(36756003)(6486002)(6496006)(966005)(86362001)(2616005)(1076003)(26005)(4326008)(186003)(83380400001)(5660300002)(66946007)(23200700001);DIR:OUT;SFP:1501; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XonR0pnmO98HA2yIdG0AbI0WoXim6MeP9PSXB4x5cCV0xTp7EkQ+0To4HfOnmBDrQK37caxJ6icKe0wJEpHAnOGyfPnIjh/nxk2hstsFEthFI655ZB8CH+JaGJKERrvUmmRHp+0aeZFo9YsGTRYZXRalZbCzAJwfpdti7p61AhKCgRRUe0Ict18drc+0b89ZWdDte+7WP5hMxacnbGjgmxA5+FA3YVGHUZ969lODhIV+jMPELt2oJ6bxOF2VXe34KxpSaaIRwtxwe8rwKbk4Ds7F7K709q98k4JI28w7hfqnvjU7Qmdms9yq3TBGbgQD5s6hEK8BxImf+1N9wz0F/FyxPvRioS+Eo9c6dv2Aqb+v8PsSstjQfMq5wsr6FxwIhaeCs3cjIXyhpJ/JALLbsyVAmvQTYD5uxhL7tSNztj+Y6Yj7WyCa0MLP+LrsTU8DBNg1CibYgxbl/V4iE4MCPHJewgX542e0tHBtX+N9CwGUrqhvYHpaxW3IiiBhDpEl71RusnbYiA0TLEApO3r2sKUjm3ukbCqWkXEa6DRoxIbqDl4wOg9zKkASSusSFqJ8NQFIyoRKnEZZekCk8s9z73HGskVXo6HTF3g1zq5kFGaXW8x+yZma6/nn9mUjKqrtbLt5Qm8djtr9bvJPI5udLIcTaw3mo+IBDCk7ta4twmuEZGNrIFq3YnIKKDOOLaFuZzI9g+blX/7TakBih6Yy8x1Ict0baCojdexirGZpc9e+zo/Vzud0QloQ19F+6/pPJHKKmA+xoFdJ+G6LGpyO3zCBT8FKRLBVfePo1wd5Y7jUjopwUW/wGsNwwVu5u28Fk9sFDSkhC0ImZ1c9WipNxQ80yRXipBbe1XqRRx7Z6p3eINLDqtswGKTQNNr/eERdhE741sIbbKnaAV7BqtE/g86PYF9qA/iPmmKvNJ3b+2/24KPrnbcy4nmHiGTACJkPl0+mJ6MLNwyI3ludUyccCRhZW1uceif8dRqxihyMoh/pW2TUUq6ASsBuPHKf4W2Q6Eo6GqfZDYeWW0RS+i0T6RgbzcZYZuY+N80Fl6LorNZ3BasvAXPBpA6c5bDhhEl4vvDRVjgatfx6Bz7biEuBxhcXbYFFKt/tKG7h3Q5PT6pIj1EWeJcefLFg0oLPneAD9HV+V8P5FvS/SJUn3vcF+fjh7RrRolTsVBIBW1r6GGk1+kCVj/edxgs7JKLf5pzF7Qj/Gq+zMm5aOlKweomrUnAiAQoIy7RCYqcIkdahqdtOjm3iBj0S7N68dO/0W3hKQslFYgQERY1d/0se/BQcPSMe0i5xolya0/5ba32uGrLHjweCrMvJM+CiVKN3DoS3 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20e113d2-a03d-4e5c-2db6-08d9725c314b X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 00:04:14.0563 (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: uOoMYkJCCeJ5Ej04VCaQPfnAg6qEbYHOEjgXnyoxx0WvQZBlfDd1259umZfY6pj1nbx+xhTOvSRmUr1hthKmDtlYGQ0Lm8DAIMiQVwx5+Ag= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5147 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10100 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109070152 X-Proofpoint-GUID: OE6hsEy7A-tx8C6hGXUS0ud739v0Zk5k X-Proofpoint-ORIG-GUID: OE6hsEy7A-tx8C6hGXUS0ud739v0Zk5k Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In 0ee50b47532a ("namei: change filename_parentat() calling conventions"), filename_parentat() was made to always call putname() on the filename before returning, and kern_path_locked() was migrated to this calling convention. However, kern_path_locked() uses the "last" parameter to lookup and potentially create a new dentry. The last parameter contains the last component of the path and points within the filename, which was recently freed at the end of filename_parentat(). Thus, when kern_path_locked() calls __lookup_hash(), it is using the filename after it has already been freed. Switch to using __filename_parentat() to avoid freeing the filename, and wrap the function with a getname and putname instead. Remove filename_parentat() as it is now unused, and it is inherently broken. Fixes: 0ee50b47532a ("namei: change filename_parentat() calling conventions") Link: https://lore.kernel.org/linux-fsdevel/YTfVE7IbbTV71Own@zeniv-ca.linux.org.uk/ Cc: Christoph Hellwig Cc: Al Viro Reported-by: syzbot+fb0d60a179096e8c2731@syzkaller.appspotmail.com Signed-off-by: Stephen Brennan --- fs/namei.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index d049d3972695..d6340fabaab4 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2538,25 +2538,15 @@ static int __filename_parentat(int dfd, struct filename *name, return retval; } -static int filename_parentat(int dfd, struct filename *name, - unsigned int flags, struct path *parent, - struct qstr *last, int *type) -{ - int retval = __filename_parentat(dfd, name, flags, parent, last, type); - - putname(name); - return retval; -} - /* does lookup, returns the object with parent locked */ -struct dentry *kern_path_locked(const char *name, struct path *path) +static struct dentry *__kern_path_locked(struct filename *name, + struct path *path) { struct dentry *d; struct qstr last; int type, error; - error = filename_parentat(AT_FDCWD, getname_kernel(name), 0, path, - &last, &type); + error = __filename_parentat(AT_FDCWD, name, 0, path, &last, &type); if (error) return ERR_PTR(error); if (unlikely(type != LAST_NORM)) { @@ -2572,6 +2562,15 @@ struct dentry *kern_path_locked(const char *name, struct path *path) return d; } +struct dentry *kern_path_locked(const char *name, struct path *path) +{ + struct filename *filename = getname_kernel(name); + struct dentry *res = __kern_path_locked(filename, path); + + putname(filename); + return res; +} + int kern_path(const char *name, unsigned int flags, struct path *path) { return filename_lookup(AT_FDCWD, getname_kernel(name), From patchwork Wed Sep 8 00:04:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Brennan X-Patchwork-Id: 12479605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E53CDC433F5 for ; Wed, 8 Sep 2021 00:04:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C14F760E97 for ; Wed, 8 Sep 2021 00:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347188AbhIHAF3 (ORCPT ); Tue, 7 Sep 2021 20:05:29 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:57702 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347152AbhIHAF2 (ORCPT ); Tue, 7 Sep 2021 20:05:28 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 187LTZC7015703; Wed, 8 Sep 2021 00:04:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=QlSui7A98vbmXzPptJLKqYxYJOsWjBk9Se11S+phqq0=; b=JVvx9pHWAymTGgEyQE7eo1EISL2d5SqOA32pCu8A/EJdr1qvjB0WApVGzj6iwRvhKK2q 1RARR2MpOnRmD4rWuzdRLDQhh1izwOoEiYxpR2LNcwTnc7LlTJULVfBjMTEAPhqSbvUa 4L9x8AizmUTEXiSsNDQLo70KTimQZgwWuXkMGoGhnoV829FmC961oVQ311mKLLtlThMa Y0jKCQch4EkXosPz4GnqaNKpwVllqYxJ+HWLutYGccO1bRMAwIGXMybzNuUMwhbeCwQY ffOBAojxfkfm+hue4e1XpJZ2FglyJ/3Stjg78Wi0uKj9itGgnnJ3GCGXM9NSlQ3P5NfP mA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=QlSui7A98vbmXzPptJLKqYxYJOsWjBk9Se11S+phqq0=; b=l0tfOSKwjpBvbBPIXZDBitzaCsHDMly7+p2SAB2slC+ZK0AX0Jb+txJ6Vp+WqtNfRB9x Y2xB3TxAR7CE4aL67fcs8mJ10zNTKAHgPXbtG6wnH60ZeqeKXvHfYZH3OahVfiAvQ7fI GKDILSxmxhKA2ACNM6K8NbCeZDDvs60z1mxSmyZPZxGPYpyqRr9EhEkM4KovQCasceSU 5ghZCE+mBRQVjK6n4J1UyHiRCvsv63FxdVCgO2CDEEAzXOvMurrXeoaiLWQBfk7PtIUe BgDCEPoytD8qjHxf9r7TZnSmA0R6SupHf8Rup3CPk1Cq8W3pEXs1aB9oS8LB5Na9X4gE cA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3axcuq8t6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 08 Sep 2021 00:04:20 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18800ngE029240; Wed, 8 Sep 2021 00:04:19 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by userp3030.oracle.com with ESMTP id 3axcq0g29u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 08 Sep 2021 00:04:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZdOk8Zr2TpGuUV2a/HJR3YGJ/fdROrrdaBoSlhG+DXHNTIGtbfmM+z0I9r47SbK3lC97fqeFKuhoK+RbRDfK1+fIUD+djBRL/PjgO+skFmvPfdQs5KKl5hdakJr+IvHvcGIEUvsWKVVZBei1cnjuoWqLFAgkW/WmnyoJKFRisZ9fXfH4jfSMAgb+RCf+t75GymNTBcUAIyr42U79fC8Sj2vzVEFHT/aMOzAh/yxf/8RwePTfUEwD76mleyF/pKd2rJUW/+uUM1Jw+f8Snfba8o1a95AWEli7jPLOLdCveaaYVGGM6Ian/fkSUdaAwRyfi2Tu9/JPAUVGEt8vLY1XzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=QlSui7A98vbmXzPptJLKqYxYJOsWjBk9Se11S+phqq0=; b=HA8rUtJwprOrA2HiMnu3ongvFy7SFz1E0i2PP0vsua/sI8k+L2oSIFmThbVt5ymY8jLvP6rfeRdIi6XCuR4ikZzl+9HONxaUKbcKorL2GIpWt5x2d0vFTm5D75IP8gLDIRU7eWPw2e+Rz+heI0g9xbLiDJsR1rj4x+L9lGOxx5U09XQsPcwodC6AnvXTFA/LCnq36UTMLwhRHcR6CzzYkHyJgkto6MewFVYC/TOENzpNLnHpV2c4XhlSH4EX9V9cZKBiPHIGbraiYTpUkHuC3siSSjkQ3aOrQ+tsEpwm0DCUPCV96hjMqjZew5hGihDSBncMujzi4KGt0sbUlV+mUg== 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=QlSui7A98vbmXzPptJLKqYxYJOsWjBk9Se11S+phqq0=; b=e67JUlIKsPa7uGoICft6D5/sznD1IyQcOUFDT4MgrtYyl9PFMTHl02moOwoFzsjQaOA1LgHQWReI2P76J/8LJa78n7GcVH5mbmf/Uok4b4etQgTabL4ekzemR3hVqN8MHuD10AUWNGpRH0+WgEAkNNqsk2rCsvFaE+jimiXEJsQ= Authentication-Results: zeniv.linux.org.uk; dkim=none (message not signed) header.d=none;zeniv.linux.org.uk; dmarc=none action=none header.from=oracle.com; Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by CH0PR10MB5147.namprd10.prod.outlook.com (2603:10b6:610:c2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Wed, 8 Sep 2021 00:04:16 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027%9]) with mapi id 15.20.4478.026; Wed, 8 Sep 2021 00:04:16 +0000 From: Stephen Brennan To: Alexander Viro Cc: Stephen Brennan , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/4] namei: Rename __filename_parentat() Date: Tue, 7 Sep 2021 17:04:11 -0700 Message-Id: <20210908000413.42264-3-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210908000413.42264-1-stephen.s.brennan@oracle.com> References: <20210908000413.42264-1-stephen.s.brennan@oracle.com> X-ClientProxiedBy: SN4PR0501CA0080.namprd05.prod.outlook.com (2603:10b6:803:22::18) To CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) MIME-Version: 1.0 Received: from localhost (148.87.23.7) by SN4PR0501CA0080.namprd05.prod.outlook.com (2603:10b6:803:22::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.6 via Frontend Transport; Wed, 8 Sep 2021 00:04:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b622c60-7013-47ee-b849-08d9725c32e1 X-MS-TrafficTypeDiagnostic: CH0PR10MB5147: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 80MAvXkgNnWC7yvjXzAzkWuWTRHkCfMRF/0PCLLJNwr72LWg0Kz6HQqScdvU4+kt9vhNLDYdrChIxEx91Ac7WVKxHBghBfEI4D3b9CPHtAp/FJroS0uZVPRkPrMP4Awev9hY1j35VG0IZ/e/Kyza2X6qv0TpDJCumXsJZVVmHQi1TOLRYhf05NYhZDelHRKZLvxNuqljcNpwoTSSVbPZ6P5qZ1si8jvRLf2xmJ3t/Kp9t0hnUPkSVfB7Fbma0HBB5CPJQjHOE1T5c+q+LmDXnAEGRbrNHp2hk1SubEjK+jsn1szgSfyD+I6snM0m6O/Dbvr2olm9t7tG0xhugmavKBvrt5KuTEYd+85/u8fDgbDfNCAkLwUDStQ2dacNpNahpt5lfyI8Yr6xVqOzrZChg+ZbB4flDv5rgGLT6phewox4gDL4fhp0vQ/MetK1FO9vr/d6aDSmwKxeK9ixABhUqzgI+lvTjnJYGZWWjrWnXgsdEoYKpyryD8XANXf4BEjOOJyl4a4V23IQNaVda0808GL8YxUwRuihTDa6wDBUi4Wn/SU2vQmySH51hWtGLuG+QUwkzXJmI9tXhN5gCwvAfDJlGD87u9MUKhbq3TycnGUQckbJ6OOf/m7iN8m01MaqLvrHvQ5n3qiwHXxfWh2Nt64utnutg1kgvEBosBkpT12qPdOutupKb28TIx5FgF85hlxD50MguWG/jdZu5/Hfbmg3D7o3xn+ufauwm1T/4fJupEo2431tbTDIg7Pq92UxGF88SQishgynV06jLScj+7GhVqpiS3PGKJDzTgcPr6rYlik64dVCVCsfL3daUIhxy+znNo2cw9yVpMhH+p2kNZ+9UZ9WsqHwH3yrO+9h2JAWnIU6tg00JETADBZFRCEUVUz2HKuV/NByEwlihm9yyUpfBrh67nCGQWzB/eiTaRPFsokp2TLBn0xEKvSGCOSRk3TYa7ci3gScTc67ntTC5WFcllTrr8SHyAmCCkAgPK//2R/44eG1SdvP3JWTGMXG6oDVXAfPCr8LVidti4Q6LtTmiFw4Rhd3+u8OSnchDIu2RJKBuhq76FIqQlX3YDU3tW1vGe40fFiuXrGPAjsTSoSTzzALM1VJC/K4Czsr5O4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:5;SRV:;IPV:NLI;SFV:SPM;H:CH2PR10MB4166.namprd10.prod.outlook.com;PTR:;CAT:OSPM;SFS:(136003)(396003)(346002)(376002)(366004)(39860400002)(8676002)(2906002)(6666004)(8936002)(103116003)(478600001)(66476007)(52116002)(956004)(316002)(66556008)(38350700002)(38100700002)(36756003)(6486002)(6496006)(966005)(86362001)(2616005)(1076003)(26005)(4326008)(6916009)(186003)(83380400001)(5660300002)(66946007)(23200700001);DIR:OUT;SFP:1501; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X8Yb6VL7b18VpYb8TwIhvpRwrh8/uZWXws3P2XQZV+5sFUzZ1tOnXaywWfrH4qxX2D262g3uLaFPC+okX//OdUQ63IdINzC5l6rLu8d8fMhIYOKFOBvi9w/6IwT8A6zxALoGgexxuYB60aaBWWsUGUvvMWpz0/ZzHMgzbsa70fr86B6Uso8Xzq1gp6xS5midSXIkgsY9k+Fb+NPKnGS6g++YMXIYUfTtsk+OC0S+EokCwvuTMAz069fZdPI3jP6ymD+Jmdo+E0sAqhSAo1EDTKcy5ujUuDbsyuecKA4IS08SfeJ3yjiKKBnz/wvk+VEIt7fmbNKub8Y87vmXdZdWWTv1wSaD5bgKNLEljKl1y7TSiJPdY/zDL3dY6yPZLmG0WILvBPdK/l4m/6lbR5qyAKkcNiPw+mRAxvPKYq1p69/j4LPue6tM5Gsf7vtambM5+/UhjI8+vz4eOeEbsxXvdtaCGJsZSezDwRV9XcsL/JHx82/KwBfqJSWrdK55nrQ/tmR5WJhtV05/k1TVFaPL6T3PoP4mipLWhmAgQb4sYf4oMBWMPTBU7H5UulDJDAeujcF5Hn+uE6xVluO1F8JsLcWkbWiJXzl6xiVnpZAvT/ARAjZ5b/uk12/XBSGheXMZQMkFQTtNE9knntOabY3M0/RUEf4LnH2bia+nauCNvOoFG846gZ0do+RQatdrahwU2uwFSRzHF/LDkTGJkt6s2VtcM2VsbhjoJxX60E6PH92+cF/euvBVhTcZmT8xVriFY77keJl9UD0pxFj33Th9NKp1DHWRhjz0vmdFKrZpfyqwqp5NBB4uLP1RfspcnmkgXkMh5N21j47+iCG+6SZIlDTTkGFYjZegH5NJAMFICwAJJbEr5miOPhzgbkrbkN8ZnbvE8K2cinac5b+AtAEYcuCQalAzMgWKCS29HI8JrYtq8Cxs1OwGOm3bPFWWtFoJyXCh0jUoZ33RyJmOidB4AqGIu1gmdPZXPtU6Srm+3Sb6YfHa8ftByAmA/pa7o/a8Y1lCp2h+zBUN0zWeSaqGzDzpGn19zpLrwh4EZtxFjL/fh4KuciQEsOb/1RFN35BQvX6mFyu0+wAurNkam3Ori9BBDHBxRAAPlUw2vRlWmf++QCE2/SMd3qVFGBKbHut9ZHisvc68J+CWmijMNT7k3Fn8PXWeG4vSlBZplJNedzlBWdNbBcou/vEprHDVr8ykfmlHCYeO7NUm5RiAJdHUPj+8FLKTpo+x6dOcacmJY79nYebCu4IIdF+XLFyPisS0ceUkrA0TYQGNwFnktdMdTNjonS7eU7GxvJpZCxwzBy/nrEe8O+n552UM5yZ4yZKx X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b622c60-7013-47ee-b849-08d9725c32e1 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 00:04:16.8072 (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: 1Fz2meAkNTZXIZrzNbB+956cqSmojw3CYERHCZsG+g7hwULwzgzoGBJfYi1mZOu8pwYWVZmMOYJH7A1En3dYDCcH4bLO1dDkvDo2iCRKGDk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5147 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10100 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109070152 X-Proofpoint-ORIG-GUID: -tKpG_WRIqzSxBr1nIvx4_MK0yYGqUuC X-Proofpoint-GUID: -tKpG_WRIqzSxBr1nIvx4_MK0yYGqUuC Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Now that filename_parentat() is gone, rename __filename_parentat() to the original name. Link: https://lore.kernel.org/linux-fsdevel/YS9D4AlEsaCxLFV0@infradead.org/ Cc: Christoph Hellwig Cc: Al Viro Signed-off-by: Stephen Brennan Co-authored-by: Dmitry Kadashev --- fs/namei.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index d6340fabaab4..33f60d1b3a87 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2514,9 +2514,10 @@ static int path_parentat(struct nameidata *nd, unsigned flags, return err; } -static int __filename_parentat(int dfd, struct filename *name, - unsigned int flags, struct path *parent, - struct qstr *last, int *type) +/* Note: this does not consume "name" */ +static int filename_parentat(int dfd, struct filename *name, + unsigned int flags, struct path *parent, + struct qstr *last, int *type) { int retval; struct nameidata nd; @@ -2546,7 +2547,7 @@ static struct dentry *__kern_path_locked(struct filename *name, struct qstr last; int type, error; - error = __filename_parentat(AT_FDCWD, name, 0, path, &last, &type); + error = filename_parentat(AT_FDCWD, name, 0, path, &last, &type); if (error) return ERR_PTR(error); if (unlikely(type != LAST_NORM)) { @@ -3633,7 +3634,7 @@ static struct dentry *__filename_create(int dfd, struct filename *name, */ lookup_flags &= LOOKUP_REVAL; - error = __filename_parentat(dfd, name, lookup_flags, path, &last, &type); + error = filename_parentat(dfd, name, lookup_flags, path, &last, &type); if (error) return ERR_PTR(error); @@ -3995,7 +3996,7 @@ int do_rmdir(int dfd, struct filename *name) int type; unsigned int lookup_flags = 0; retry: - error = __filename_parentat(dfd, name, lookup_flags, &path, &last, &type); + error = filename_parentat(dfd, name, lookup_flags, &path, &last, &type); if (error) goto exit1; @@ -4134,7 +4135,7 @@ int do_unlinkat(int dfd, struct filename *name) struct inode *delegated_inode = NULL; unsigned int lookup_flags = 0; retry: - error = __filename_parentat(dfd, name, lookup_flags, &path, &last, &type); + error = filename_parentat(dfd, name, lookup_flags, &path, &last, &type); if (error) goto exit1; @@ -4682,13 +4683,13 @@ int do_renameat2(int olddfd, struct filename *from, int newdfd, target_flags = 0; retry: - error = __filename_parentat(olddfd, from, lookup_flags, &old_path, - &old_last, &old_type); + error = filename_parentat(olddfd, from, lookup_flags, &old_path, + &old_last, &old_type); if (error) goto put_names; - error = __filename_parentat(newdfd, to, lookup_flags, &new_path, &new_last, - &new_type); + error = filename_parentat(newdfd, to, lookup_flags, &new_path, &new_last, + &new_type); if (error) goto exit1; From patchwork Wed Sep 8 00:04:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Brennan X-Patchwork-Id: 12479609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E655FC433EF for ; Wed, 8 Sep 2021 00:04:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8F9860E97 for ; Wed, 8 Sep 2021 00:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347223AbhIHAFb (ORCPT ); Tue, 7 Sep 2021 20:05:31 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:59518 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347211AbhIHAF3 (ORCPT ); Tue, 7 Sep 2021 20:05:29 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 187LTZC8015703; Wed, 8 Sep 2021 00:04:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=eXe1cDPrmwEam8jFfF07xwr+AbpqC3g7UhIrlqDWgq8=; b=CCRdabzhV7VES499ACtmGBD3QXNNHlWDiWI+8skcdLR1YDUQAQCVNvBvrc8FjV8totVf 09ddrdm9uWcImIHYGtYfWW2W5ElJnRglGm1VR22GJu9OfoxMiS+VWnYzljQgMFTceM0l KvIjpZgSmpv3bbbBrOdbNdQpgT1Sg3B8LUhEYdNuW0ubxBpLks7D4msmw7snABzekXYU lHkegqEwBOAdYwIBogEdjj6Q6FJHwW4vqWxyD/bI2zYeXxKxM3dOPKExFHnbxg3Npvbe 64jpQlex47QFywiMB0SomLUr5sW7KjYeqCAh9Fy7RF1Ro3lCwEeZFoSyUHB1nAeeeHEv rw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=eXe1cDPrmwEam8jFfF07xwr+AbpqC3g7UhIrlqDWgq8=; b=K5yJMMgaZ52anyI2ASoSriKFuYjxCVfgjOvw4DqHET9fcoOLXnU7HtqUIB3eGGuq93x3 Eos0Q9TILXT698csDVi7k2pE2govvw5BwrQWFrq/5i2wsxmMvepvFaHKD//FIVoAGZPt UT3d4KwEHdMmCuyLf4w1CC5vAi0ciIOyejoMdwN2UVFD3dBqidoxVwzKP5gWVfuR6yI9 FkqKZ/BG4nKEwcA4rTkfeUPQXZ3+jt4o3347pdmY7Dy9eXDZNUWjPdE+dLTO9R4jRYRk F9OOAP22c0UXukCuP02yJl4TqCsq/emEPhq/HRL06ecmDIiPhmgpDieRrl4JtUQeGQ5c yQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3axcuq8t6k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 08 Sep 2021 00:04:22 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 188001NE017221; Wed, 8 Sep 2021 00:04:21 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3020.oracle.com with ESMTP id 3axcpkebt3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 08 Sep 2021 00:04:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KFVLFz3goRJYrf6+tLkVy2agJy8lr5J2rDjfm/8LLt+Y5U9Hm5+KMSOQuJJv2oTFGq3ESdRwYW+V7SJ6twomZ2/tpklq1QNQuXogK/c6ZKXfCmD295yGrl5E4eFAlRrLO7ATXIYeTu7l/c0DmV0BkZLBPlh7QXtT3ChQvuMMqOHd1NPGvNPkj+ngKBvqi4a2Zsa82S9Khf4rXRuYaQkC82M7tRJfCsYLOW1roFuw7XtgezKT1O5nLrymp5JaI3IN1c/G5NeoFqShL4g+x75+BpEa0K8sA+N1urO7t6seQMOxYU+LZbOBZFWb2iQN5c0xqVetcaydj8NY3awXgtSCGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=eXe1cDPrmwEam8jFfF07xwr+AbpqC3g7UhIrlqDWgq8=; b=ApeQiM7x+jYHMp3OsBkhZK1DwTgLLOEtB09H9SzlQpNTDW1sAXOmtMQXunW/DZpZRHlEdS33DeLlx64ijeDnI1sjYt32yRzYeZq5UH2detOLI79Tdlp7H2M5p2RkG7Mw/kopZHDOk+fQZMCRyAcDGmcjYKkwzGSXNPgre7zyQ2MFz2uYWWIVD+hVYp4vP9HBnYwaJ5Sri9I4TWhMZyGx0+Pp00hnNoXPBMlzJX2ibRT+V8Gb1O7AtEDueDgCwnW8+pEXU5k3xVW+K4LtG5F4ATAcC6dC1a+kA052kWZCsS8XZgUPUlz0FV1qnuhGyfuCLGebLvofUf6fkg+E+PVd3A== 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=eXe1cDPrmwEam8jFfF07xwr+AbpqC3g7UhIrlqDWgq8=; b=LB6mTlmUwjAWoxwKbqpguerQSZh/yiE4WRQtzUc7zwZC8IbJ9hbOwSUZuqWyn9/3yd2yjGTHbwe9/4Rmj5016QrwNP1jt+Kbr4GYj8DTXWFM0a2scn51aCmbzL7YT6SoFTEH1mOhCEpk9jkO2KlE9t1/GuVSz7qqe3Gxio2O//g= Authentication-Results: zeniv.linux.org.uk; dkim=none (message not signed) header.d=none;zeniv.linux.org.uk; dmarc=none action=none header.from=oracle.com; Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by CH0PR10MB5147.namprd10.prod.outlook.com (2603:10b6:610:c2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Wed, 8 Sep 2021 00:04:19 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027%9]) with mapi id 15.20.4478.026; Wed, 8 Sep 2021 00:04:19 +0000 From: Stephen Brennan To: Alexander Viro Cc: Stephen Brennan , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/4] namei: Standardize callers of filename_lookup() Date: Tue, 7 Sep 2021 17:04:12 -0700 Message-Id: <20210908000413.42264-4-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210908000413.42264-1-stephen.s.brennan@oracle.com> References: <20210908000413.42264-1-stephen.s.brennan@oracle.com> X-ClientProxiedBy: SN4PR0501CA0046.namprd05.prod.outlook.com (2603:10b6:803:41::23) To CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) MIME-Version: 1.0 Received: from localhost (148.87.23.7) by SN4PR0501CA0046.namprd05.prod.outlook.com (2603:10b6:803:41::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.6 via Frontend Transport; Wed, 8 Sep 2021 00:04:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 851969b6-f0ff-44de-6bd4-08d9725c34ae X-MS-TrafficTypeDiagnostic: CH0PR10MB5147: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a2Qg+YuooEjGpKL2fd7QHEgLPpYJdHqtTE3t5F8L7LmCy0Wv7eyW6QjA4YJDPuFjqyo9/CHbXFmZUu/BCbSLhRL0q+w9UqEkIr26THddUU0cI0PzljXHW8gzTFOp5y1uFUUVnbpO3GS9FlZ+mblFj3ZOuXTs31MJYZSnCydsjIv0+29FSSLfj0i5x4Nba024giH6xiZyhjfqtJggqSufO/eAp/bCZH0+RcnSnbwnxgFoNNYkaj1gJ5Wx5hQf1DNhDpNnQQRXMNKJ8nzj0y0t1Q101Rd2MlD+wg4aWdYzPd+L5v5RB7B0RA211JRDeo1/R2iVZSjE+ebpyGjpZztiKOMXSLpsYOpY0njHQeoK5lf0d1kyL03aTP1CmtZjTZtRYUxovTfhxT9h++1rXMq0cd5bIbal5UALNrukmQ2qlvPmjoBNtfx8gCOeULEmK8yd8GyDfkHTgO3NNeszQH/Jm1mSrAl888OvcwiaOXNThCG9fJC6koTNMYO/bFwfo753oOA8aLsRFWhnG450Qky4ugs2JaJwVODuFdL+xyR51yqRQQ66G/p+ew+qtaZ6wp9GkQaHkc46vh/QX5vY8Hu5WsYEgJ/A77m8kh5Lbrdj6DKSvr256gXbfeXxVd0NCNLoFwTi5zIUEcum5d/DNC0hsgCrOjlLLGhReIJ5Ff42KszEnmXqY/Ay7Wmwh6Dx7Aa3OyK8b7Q1L80YQf0bQz6zX+l6aM3eUHEnInky9ATt+INDpGOymDR9gc4jdPK8cp5xbMe8FpzMkZkGUPfc3fGP/teavaHp7GgfFq6ALNSFTjAvhfP8qwPRxK+k1GdaMI9EBl6DcJW1u8rn7X+HIDy9xmt/6O4ldk4SQ1MojQd0WoalLeqtju/VJp4hzWNBIJ4a4p/c/U5E7Yv1KqgY3gegHdHFYqBlbw1i2H9k1vuYn/mB1b2xwnng/3aYGpiSKSdrU+4HoGOxRSvSXkXCTntUHu+xQajWhMKcXq+CgHyS6zW9PW5zWZ0+9IAsPn9DQCLSO1L6zERNcAFknQNIGiczQTomMcmgGo9t08XTCpSAJkMBLBLcTvL3uvAD4XwDAIy/FfZpOnUVuJIIU2OU24qgfqvHXPbDGRO74eTJS8bXizA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:5;SRV:;IPV:NLI;SFV:SPM;H:CH2PR10MB4166.namprd10.prod.outlook.com;PTR:;CAT:OSPM;SFS:(136003)(396003)(346002)(376002)(366004)(39860400002)(8676002)(2906002)(6666004)(8936002)(103116003)(478600001)(66476007)(52116002)(956004)(316002)(66556008)(38350700002)(38100700002)(36756003)(6486002)(6496006)(966005)(86362001)(2616005)(1076003)(26005)(4326008)(6916009)(186003)(83380400001)(5660300002)(66946007)(23200700001);DIR:OUT;SFP:1501; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qlriMw9RwPZnto7A9cHXnFROrz9EA/UU3UHvJjj2UChhuLqIrWj/kCKNEM+hb1rNRilj5GhV+dO+w0CTLYPsud3ixdCqJ+76Mn43HJqrQaWeXW5VsC05G6yhtxJhbWFi8SuSx4B5pWSTVcpZF2Wq9mBxu8VPr1s28+F+lopk7APXsM/HcLIPFYYKMkLTfVaQmLzRlQVFhSFf3pMopDv3hfBo/5qlmcc+JN6zFcIKbr7kibQgN3V12HPCnD920y9hv7sYt8og3RsU6AElAz4ge4usnOS68sNfZs06+wZrV6Ub6332Adn1SGJEJ98scSM+am7gWv0ef8VWTat/U8sd4xSOTRd6Sr6jUqrBgXC+CDcxriXbJJHdZjyroH5909Y0dNsAkGB+oq+OXSUGp+1S+LkGzQNFwCU5reTHuGvIWQeSRh+FRWGOReAmBSNdNuXiAc+gHZncrrxpNg1ssBYdbc+fBTwtvDB9RDqxA+JRo4Dqxpselo1hnjLzhnKf5iSbnkr0g4BaTPNUisohJNh+Aov2YBWqIZehT+LfhaHnoZ7G9w38aUkcT0KAiFcr6mH5to5TAeZNSb2YkzBGUou3hGXmbBgx3wvJ3oA1sNZ0wyHCQhwli7Ldqu+ySzLWLDX9vS5EB9o020Of/X02EwjnEJOmuXJ8U6kj6kZHC2gxIJ9v7eURF0FY4jlDw9Y23VXsfjilKdoxgkvuVWPhuGkfjBQnbzmOrVWu3nXfyaqrm9/n5BALYi91zwulOWlXqsTACwF9wHSOCje3TgQDejEXir5eqkptiClvKzU+9YIt/YZM+aD8UCQ1wuUSOkgFuQOZcsoLYvZvB9qPiW4j2utjUj2WZW2rZ2m47puMohtmw1tbLoel8tcH+RAOIbTyw3EsvD9PnXTS/BEt09Wmuc7VFdCDHRV9paampxXxtqryKoDr6IiMYizDw2rUSqBSGi5RLE0w2ApBWAzlm8s+OMo1ZA0L2UR8pajhOIKqpXG9h64uc0jy9lrhuQ8ESDGiccMKezxUN9PSbS2XPkQrIKWHGpm5FkQEPr9CjYeYgxOb7cZACVpBaT+6Fy2C/MBLnuKa9tW+g0bi7iAR2UzNq0oCJwd4Vf1KJVJANKU+vz3uBJGy0yB/0LuaLs331Fu26r2553uo3BJpSfux9SLLLb9QEYkLhpgH5zUKo9NluUk8h+PylwT43acUnfOq+udifGy0L+Aoceh1tL4nfPT0VrIPUtwo5vLOPFUAPk3pSAvZtYxamqKWkf5indE16sDYkYyUUQNK1zNL9eWs82dqvx9zBa937B+pq3fN/oJM1m5iEpXktfCiZEnvEdumjEkGan1W X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 851969b6-f0ff-44de-6bd4-08d9725c34ae X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 00:04:19.7159 (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: fzRZAINVD8+vn5BguxpfDIhlTENPWkjAjOqcIinSJxGjozSdn1vuso4pfV7+6SHCJo7eF8zyR5Yjyn576nJ2ik3iDtK7TqPJk6dIKEXgCkk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5147 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10100 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109070152 X-Proofpoint-ORIG-GUID: DZsvoV4iGOGFvKaQlvpH8R4K9Xl7ud_r X-Proofpoint-GUID: DZsvoV4iGOGFvKaQlvpH8R4K9Xl7ud_r Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org filename_lookup() has two variants, one which drops the caller's reference to filename (filename_lookup), and one which does not (__filename_lookup). This can be confusing as it's unusual to drop a caller's reference. Remove filename_lookup, rename __filename_lookup to filename_lookup, and convert all callers. The cost is a few slightly longer functions, but the clarity is greater. Link: https://lore.kernel.org/linux-fsdevel/YS+dstZ3xfcLxhoB@zeniv-ca.linux.org.uk/ Cc: Christoph Hellwig Cc: Al Viro Signed-off-by: Stephen Brennan --- fs/fs_parser.c | 1 - fs/namei.c | 41 ++++++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/fs/fs_parser.c b/fs/fs_parser.c index 980d44fd3a36..3df07c0e32b3 100644 --- a/fs/fs_parser.c +++ b/fs/fs_parser.c @@ -165,7 +165,6 @@ int fs_lookup_param(struct fs_context *fc, return invalf(fc, "%s: not usable as path", param->key); } - f->refcnt++; /* filename_lookup() drops our ref. */ ret = filename_lookup(param->dirfd, f, flags, _path, NULL); if (ret < 0) { errorf(fc, "%s: Lookup failure for '%s'", param->key, f->name); diff --git a/fs/namei.c b/fs/namei.c index 33f60d1b3a87..7bd3d1c90e52 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2467,7 +2467,7 @@ static int path_lookupat(struct nameidata *nd, unsigned flags, struct path *path return err; } -static int __filename_lookup(int dfd, struct filename *name, unsigned flags, +int filename_lookup(int dfd, struct filename *name, unsigned flags, struct path *path, struct path *root) { int retval; @@ -2488,15 +2488,6 @@ static int __filename_lookup(int dfd, struct filename *name, unsigned flags, return retval; } -int filename_lookup(int dfd, struct filename *name, unsigned flags, - struct path *path, struct path *root) -{ - int retval = __filename_lookup(dfd, name, flags, path, root); - - putname(name); - return retval; -} - /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ static int path_parentat(struct nameidata *nd, unsigned flags, struct path *parent) @@ -2574,8 +2565,14 @@ struct dentry *kern_path_locked(const char *name, struct path *path) int kern_path(const char *name, unsigned int flags, struct path *path) { - return filename_lookup(AT_FDCWD, getname_kernel(name), - flags, path, NULL); + struct filename *filename; + int ret; + + filename = getname_kernel(name); + ret = filename_lookup(AT_FDCWD, filename, flags, path, NULL); + putname(filename); + return ret; + } EXPORT_SYMBOL(kern_path); @@ -2591,10 +2588,15 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt, const char *name, unsigned int flags, struct path *path) { + struct filename *filename; struct path root = {.mnt = mnt, .dentry = dentry}; + int ret; + + filename = getname_kernel(name); /* the first argument of filename_lookup() is ignored with root */ - return filename_lookup(AT_FDCWD, getname_kernel(name), - flags , path, &root); + ret = filename_lookup(AT_FDCWD, filename, flags, path, &root); + putname(filename); + return ret; } EXPORT_SYMBOL(vfs_path_lookup); @@ -2798,8 +2800,13 @@ int path_pts(struct path *path) int user_path_at_empty(int dfd, const char __user *name, unsigned flags, struct path *path, int *empty) { - return filename_lookup(dfd, getname_flags(name, flags, empty), - flags, path, NULL); + struct filename *filename; + int ret; + + filename = getname_flags(name, flags, empty); + ret = filename_lookup(dfd, filename, flags, path, NULL); + putname(filename); + return ret; } EXPORT_SYMBOL(user_path_at_empty); @@ -4424,7 +4431,7 @@ int do_linkat(int olddfd, struct filename *old, int newdfd, if (flags & AT_SYMLINK_FOLLOW) how |= LOOKUP_FOLLOW; retry: - error = __filename_lookup(olddfd, old, how, &old_path, NULL); + error = filename_lookup(olddfd, old, how, &old_path, NULL); if (error) goto out_putnames; From patchwork Wed Sep 8 00:04:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Brennan X-Patchwork-Id: 12479611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12C6BC433F5 for ; Wed, 8 Sep 2021 00:04:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED6666113C for ; Wed, 8 Sep 2021 00:04:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347233AbhIHAFi (ORCPT ); Tue, 7 Sep 2021 20:05:38 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:64642 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347250AbhIHAFd (ORCPT ); Tue, 7 Sep 2021 20:05:33 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 187LTME0028195; Wed, 8 Sep 2021 00:04:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=gpWYEQKiL77b6Ey3rqWOqOghf509PhteOC7e97is3WE=; b=zfn/CQPCCIr4CiIjmg514KrfrGNPtwvEKxKlCF08dLRCfomQe9RbeVcxgP/ejLJExsfg koadz3G5u2njd4n5gTYBHYETVp1pjy4HV5KZQr8Mn8ZYsmyZsk47ZN199cezI5vqKybH Za0G5ubt6wgXPh0IzZ+izPJIRfBn7UHDeMgBV/CTvniTsscerSLV+AW+KFiczxbyb0h2 xHFQj6WCY7KBuVT8XnfEauW0HLuzrTDrZO8jLVIYGc8LhU9vuGHbntpO8M1R8rKmQ21H AuUZ/2R5MDV97d+bLvR/0gBU/zBuV/is88QeQ76Y0w72vb5ljiCQAne9BrYjn0F6DZAt kg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=gpWYEQKiL77b6Ey3rqWOqOghf509PhteOC7e97is3WE=; b=tC16jgkzTdgZvLVQib8LqBZ2NNhEtAszMzucc+1oVT7GpYbBbR1DKBOgkqf796l0vaCv VxTmK3qy/VwD1cgTTt5Y+ivY6cK1O2NjBFLUlkFFRYvbjRGKDXyI1wzoVsiTbOlo/ZQS etkq4SvJhWbvPUb7slDPRRrE2Ev/OUnt2LccaRK9oL2WDIw8sHEYZAWigHxY/VxaBU8J 8+nyiVnPrbjC7pHKNEOBgfOakdxabxykslCS+QI+/mf99MlDj+2waVQIc38UGyBAJZoE sdi4cORL7WurF8erhrmxqxNMIIDhlxgKvE1QUvuHNMN+PaFnGg0AKkB4rctg4c4TuHKc MQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3axcw68tqs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 08 Sep 2021 00:04:25 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18800mJi029133; Wed, 8 Sep 2021 00:04:24 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by userp3030.oracle.com with ESMTP id 3axcq0g2cf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 08 Sep 2021 00:04:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oZY/Tnwv9LKy+ZmBmXdQiuxiwKPr7arigZONBE4rwpxQrx9qlPHuDsa7cb3ct6EBBsdX3RlaAQFlhzgWoDudpSiIv5cpPv0SehsSrkCn7VV14gkde14uztui3QFYGzqwFbX4fa0ABxHrHgussRKiZg6VJRsFO+SHA+vdCBIFf2Lax3czMmmHMt+PwSrqYwXh90Yi2V5XpVR8xo7VOiiDQPSlC+m/6zDBO4gY0HAgjxuu42pdh0bxlSXN59z4mbYfBTNVTWW+95dZ7AB+lUDo6RcZpL0WD4HBLCwl6kJQExVmDws/00/E+mPmM8fjZiFUWbNfmPl6LoFCTQcberk89A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=gpWYEQKiL77b6Ey3rqWOqOghf509PhteOC7e97is3WE=; b=CcWlMLtYqbByG88T36AP+T7qfCmBnw2qd2kcdCdZ7XAT/QlrDzyVv6zrgszQYS/F42MCqD6liQEEYuIROuVo8fENCsrZxLI/NrlgxaXUUd+CzswD+degsil9rwyCinXWFmas7sVn/zRIG46OWK2yEflk74+4bYPk6SotfdaoSErcdf7TLm9D7pYmMRCz8dx81MAFy6RhRd7yi7WlDukLN4B6dcsLpxA2OaSgQZcWB47Wak27WW1AEJ1AQCQ94sjkTfcUTUdCL/ZVUlQt3FDg+5alcAG1T5SAdbuervigncwrpXmUU6gGgCuJy4+v7mOdeYYUU0SJkxIiCFURAM1AYA== 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=gpWYEQKiL77b6Ey3rqWOqOghf509PhteOC7e97is3WE=; b=tIE+3tL5Rqth3RVPEjmSKIpM7NHKdrEHEqxH3GOLIZWnoXln27pnOKLxTldqwdG8GQCWRWJlViF86pA3PAiS8CYKNZEBrIT6vopWndZ2ZaPLvuwcK6v/aPTaUjsr4X3Pr2M9qEczP0wdzPSuSAWBP4/yC2FrSXvO0EHpCQxrCAI= Authentication-Results: zeniv.linux.org.uk; dkim=none (message not signed) header.d=none;zeniv.linux.org.uk; dmarc=none action=none header.from=oracle.com; Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by CH0PR10MB5147.namprd10.prod.outlook.com (2603:10b6:610:c2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Wed, 8 Sep 2021 00:04:22 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027%9]) with mapi id 15.20.4478.026; Wed, 8 Sep 2021 00:04:22 +0000 From: Stephen Brennan To: Alexander Viro Cc: Stephen Brennan , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/4] namei: Standardize callers of filename_create() Date: Tue, 7 Sep 2021 17:04:13 -0700 Message-Id: <20210908000413.42264-5-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210908000413.42264-1-stephen.s.brennan@oracle.com> References: <20210908000413.42264-1-stephen.s.brennan@oracle.com> X-ClientProxiedBy: SN6PR04CA0105.namprd04.prod.outlook.com (2603:10b6:805:f2::46) To CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) MIME-Version: 1.0 Received: from localhost (148.87.23.7) by SN6PR04CA0105.namprd04.prod.outlook.com (2603:10b6:805:f2::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 00:04:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3773015b-1abb-4127-b063-08d9725c3666 X-MS-TrafficTypeDiagnostic: CH0PR10MB5147: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b14HRE8WcVbVEb/m81xcWflIK4E6+f8/4YbqIxAq5Lul5U85iHGJfe+zD7zMxp/j0v5dHDBPrd9m6535VWWGZwhqiqXUdwmqgtK2EqwHPNPo/19jZF4Mj4RX5GSvK/qsrD/6PBmc0XoBnVNjtF94pCVkBpZHXkj/6o4fEGiUM2kHC9XZ2Xk50rzcBUfIFACsOaztkHh7iDmB7cuhBgY7OsfeWwoEeCo6a69h9dFKqFGdXStsOwTrtGdxpe7ss6YPfjK27WPQpHnKg7Uqf+riyeXP6VcP7Dp7FE0Cy8dos48emtTZDstPnVlzQsaiOU67z0zAYvKWjSb3clYTYUZEp19lelWoKUZR6LzQjoI5iPtdybHwqV/kMxKdhPIBbpfB7BgmaVat0ZjRj+5PW3mYFexcC0qzVlOMYkjR5mR5InXA6o22kNlibP+HiNavALbcicdW5H167aYMTbRbVRjRSg24Mt8HTDuMVtST14H1E/Utl4KDWPo292s2Wb9MFoWXOCw2bpO1DGm94fxcdF7mKivpK0Eyl5Dv9ZCW9CZOqmUmDhcFTjufu7xvGSSlJZ3nbOegOKTnhTq3n/q1ZZqT0T8hZIilpMQf7jZhM5lBqQi9DOZdN8gZC1/Uh/HNaHEdJmbvLhVUsKk9a3uD4W64b4o6lptSeBv7XG8UGxP/Hv+4f9Bcxsou3puJJE06+AYDNkQBu5lA/hxJl3sL8fvSpZlGSxavetoqg7AfYNq6cLP1ziXvKQqkjlkc4GIuj0VfhMEySGdYrNOMgcPF0Aw3NglrTxyHWKn5YfFIAmxvDzs4ruf6WL/anMApn7scqrOp1FkL2xUmf2dyyI0/mI2fgLyYpJNlYoZrtuGHyHhiPyuD7Mw6CkT9U5kkuzH2I3rTXu+i25TLRy1FK/8+jZlh8SFT468t+H6rt3NzdKhZPNcKT3o1sO7LAVv03GcSt7qQs09ckt06Ao0iAhlJkwnHwd4Csqve/luCGnUw09VwlXORCYk70B3ykiv4N5aniqcAlvvRL6NiEPHbbGCz6N6UbOuKCGcALwBOsIycKdXkUdzIoH/bvm4+S4SEeLaaaxK2h8tLdeyHWxhTOW0hwmeVFLPNZ1G5VXxZ56wvLbFjiDo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:5;SRV:;IPV:NLI;SFV:SPM;H:CH2PR10MB4166.namprd10.prod.outlook.com;PTR:;CAT:OSPM;SFS:(136003)(396003)(346002)(376002)(366004)(39860400002)(8676002)(2906002)(6666004)(8936002)(103116003)(478600001)(66476007)(52116002)(956004)(316002)(66556008)(38350700002)(38100700002)(36756003)(6486002)(6496006)(966005)(86362001)(2616005)(1076003)(26005)(4326008)(6916009)(186003)(83380400001)(5660300002)(66946007)(23200700001);DIR:OUT;SFP:1501; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WopiRuJqYRpu+c09h8SG+jobvKCF6DrtOqnDcmFUCx0Y8YGkXYshNek4qA9OvHUshcorF64Ln95tOSlyp3ll/M62EyPq+sRAtjEVqwwvsVyoISnO+psl7l/u5RiR+03LRSzftYn5a/AKhkjDVxAkPdh7jNckv1+rtMAI+vamM2UsczmmmAAGGcW/1duxVIJN+T2/7VuaVdHmIscnFdy9JhtlWs1t86TZEhjYpmZw733zZsoLLCiOZMc6W2cHcgb5ILp508QktaoqCLXJnKhcrxb8w5RNzSU4kvxlaV2tN0dDNQCBGtC1aGGVgl7azt8Kamqr8X0UzTMDYIcA58Z6nBjgeOwGKnavMXVU8EmJEshv9fooDblWXMRo+qhfhb7WtImX7u3JQTR6fiiEHjjo+ohO1lr88DQPBS0L73ZN9+cF6bJsKSX76gPdLrrEpK5rroRntHBZtSHONpbNWjbSH8uBevU3WNnrOXyH8/2Eb8yYaLeK0TW9W4N5xMPreH9ttstbQtOJOJmiDQh0GLsLjOq47wWFHtP01VZCqlIIHsWb6kldg+j0tyDtXkoxylv6qDG0y33xmQM5E/zefw/A10xoxPKw5sWIitpxik0hSacHhhch5upjOviRUcAuTkL8ZivIWuF5HWwHNy/ngXOwn5eWD+yF+VNCV+eEu3hJgoPJQsQy+mG8irJvJuNO8/Pkp0HKvU8wV5zwKSAnGJKP+urcX7D3H+TVxRzM/4t0gfn9DupWOHc+T6O5XouDEtmDUgKQTc4FzOJx7QYDJNg78JmJIxco12DbKI0iREGlZgQ9eqM1Y8DbIpfvlG9yxz+xWgcqsGcjCFw+vumLA3+3EoTgQwZmoMfCKql6AkIigzBYfQpfW7cucEq5JqC5qnxBpzluMF1pGuZkLR7NbIPTdQ8eiG8zZSon88fkH0oKa4dgwnLtReGh8NVzdEV1HcxhdpqE0YtLqH+5qh8f5FSB1PuYdg2wDYPKS7kbWZQoOiK6g4PZfIVgbIlO8pSmfppgS8VoN8gCUXSwFfE7PXwJ6lF7iKAkfMfDc9It1YGeZ3LJGkxxfuFvo0aUP3zDwA02l15hobgpjPkaMbX4wbwT/HeuzdZsqIFrd5UDjVcRRlfIxkG7E4SEuQ7fwT2n5Xoej5bfvlwHILWvtdxSTuJTGaYDJtXCdeVqaqp3phNEkl4CDGstBzKr89Fs9LaxD5Spd1J+Uds9aBz5AItAjllKRHIGUWLxnZyaC34Q5wFgLxdtKqCChuR9CbzwtPq30IOmuUXQx5i24kUA+5uael0tSjDrQ8hDfEuEKcJisS2MMn1PTInvTvOfdPYNkmHof+l5 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3773015b-1abb-4127-b063-08d9725c3666 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 00:04:22.6481 (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: gSXBrKgtXATm9lVGwsDxXHJpDF1Y8vYqcG2DW/XdwPVzVMkmvxIrg615MNaOhatIaoHoTpMs24yMYHKcxMPJAtu3sWDnWIeDzOYDVf6GUk0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5147 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10100 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109070152 X-Proofpoint-GUID: Gs1ztt_lbBd99-qzfoM_fXS9AXPUN1Hq X-Proofpoint-ORIG-GUID: Gs1ztt_lbBd99-qzfoM_fXS9AXPUN1Hq Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org filename_create() has two variants, one which drops the caller's reference to filename (filename_create) and one which does not (__filename_create). This can be confusing as it's unusual to drop a caller's reference. Remove filename_create, rename __filename_create to filename_create, and convert all callers. Link: https://lore.kernel.org/linux-fsdevel/f6238254-35bd-7e97-5b27-21050c745874@oracle.com/ Cc: Christoph Hellwig Cc: Al Viro Signed-off-by: Stephen Brennan --- fs/namei.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 7bd3d1c90e52..88cdc379255c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3625,8 +3625,8 @@ struct file *do_file_open_root(const struct path *root, return file; } -static struct dentry *__filename_create(int dfd, struct filename *name, - struct path *path, unsigned int lookup_flags) +static struct dentry *filename_create(int dfd, struct filename *name, + struct path *path, unsigned int lookup_flags) { struct dentry *dentry = ERR_PTR(-EEXIST); struct qstr last; @@ -3694,20 +3694,16 @@ static struct dentry *__filename_create(int dfd, struct filename *name, return dentry; } -static inline struct dentry *filename_create(int dfd, struct filename *name, - struct path *path, unsigned int lookup_flags) -{ - struct dentry *res = __filename_create(dfd, name, path, lookup_flags); - - putname(name); - return res; -} - struct dentry *kern_path_create(int dfd, const char *pathname, struct path *path, unsigned int lookup_flags) { - return filename_create(dfd, getname_kernel(pathname), - path, lookup_flags); + struct filename *filename; + struct dentry *dentry; + + filename = getname_kernel(pathname); + dentry = filename_create(dfd, filename, path, lookup_flags); + putname(filename); + return dentry; } EXPORT_SYMBOL(kern_path_create); @@ -3723,7 +3719,13 @@ EXPORT_SYMBOL(done_path_create); inline struct dentry *user_path_create(int dfd, const char __user *pathname, struct path *path, unsigned int lookup_flags) { - return filename_create(dfd, getname(pathname), path, lookup_flags); + struct filename *filename; + struct dentry *dentry; + + filename = getname(pathname); + dentry = filename_create(dfd, filename, path, lookup_flags); + putname(filename); + return dentry; } EXPORT_SYMBOL(user_path_create); @@ -3804,7 +3806,7 @@ static int do_mknodat(int dfd, struct filename *name, umode_t mode, if (error) goto out1; retry: - dentry = __filename_create(dfd, name, &path, lookup_flags); + dentry = filename_create(dfd, name, &path, lookup_flags); error = PTR_ERR(dentry); if (IS_ERR(dentry)) goto out1; @@ -3904,7 +3906,7 @@ int do_mkdirat(int dfd, struct filename *name, umode_t mode) unsigned int lookup_flags = LOOKUP_DIRECTORY; retry: - dentry = __filename_create(dfd, name, &path, lookup_flags); + dentry = filename_create(dfd, name, &path, lookup_flags); error = PTR_ERR(dentry); if (IS_ERR(dentry)) goto out_putname; @@ -4271,7 +4273,7 @@ int do_symlinkat(struct filename *from, int newdfd, struct filename *to) goto out_putnames; } retry: - dentry = __filename_create(newdfd, to, &path, lookup_flags); + dentry = filename_create(newdfd, to, &path, lookup_flags); error = PTR_ERR(dentry); if (IS_ERR(dentry)) goto out_putnames; @@ -4435,7 +4437,7 @@ int do_linkat(int olddfd, struct filename *old, int newdfd, if (error) goto out_putnames; - new_dentry = __filename_create(newdfd, new, &new_path, + new_dentry = filename_create(newdfd, new, &new_path, (how & LOOKUP_REVAL)); error = PTR_ERR(new_dentry); if (IS_ERR(new_dentry))