Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3737174pxv; Tue, 13 Jul 2021 02:32:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIEYyX/iJSklxNQcInvhhPgNEb+66lLz75IOdxWS6ntqk3PAVXDqY/xMiPEJjsMt/pAPn+ X-Received: by 2002:a05:6402:48f:: with SMTP id k15mr4482793edv.262.1626168727415; Tue, 13 Jul 2021 02:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626168727; cv=none; d=google.com; s=arc-20160816; b=L+/0/W+LSWmz90aKUyuPzNRMYbp9QSWL/f4bKsiOMDjrCbnttdl3tQz/Ow/HEIwIzW F/UXKDcK3mluy+6JI0uNaIMWPMAda+iLao0j4h4GXg+wo6DJkCwHq7hK8pPfjYa9EwWg EAsSxgZmY5trH6Bs4eNVQK2dhJrsDLsElaKbJjhezbznjTGeDDOH6rzRUgUdvNPoLcta bhN7PvWLudCBHITwbyHSFovfcS8mN3rYqIOkf+F3P61VnSNbAloB+p5JtjuJ/MQ3WEC+ zE9gZxmA0jeppDU72R7ezphQ9WBWRO2qwFu6ZcIottawIoPWCfyNqfIVWkOMkLdNIYWv oRoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ag3fGmfwSwSIemI9qNSXAlFxXQP7l2D6i0cHT/maPeg=; b=MFzaxRVmHZWLLgJDpYXvbxktYEej6s5C45rsaUIDIQm2k5V5hHCppaICd3Z75RdhMP kB/LS+Dn5JlOCkflIIX18GqHuGi6wZYlDodRq/KBOLGIzgo8mfF1j2v9bWZo4n84SGX/ azFJOaRbjJMHtm8YJYmF4r/SnZwTLFaHRv2Sp/uiCNQQDxGnI9v+haXFj8efP15z61gH KNVn+4OGOxvj6YDA0b/PZqSybXGUqxxaM2uwyqhjpQkETILMbqsu19a3iniFkgHUOUZG wCUtKo+/3OxscdxRDI8Zxlx2Q0QxMg8WrEhgrch0N4HpUfXnn68Ej+Ldfv51px7XgVWN FfKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ho35si12406017ejc.607.2021.07.13.02.31.43; Tue, 13 Jul 2021 02:32:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235262AbhGMJcx (ORCPT + 99 others); Tue, 13 Jul 2021 05:32:53 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:10476 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235252AbhGMJcv (ORCPT ); Tue, 13 Jul 2021 05:32:51 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GPFdH1w88zccym; Tue, 13 Jul 2021 17:26:43 +0800 (CST) Received: from dggpemm500002.china.huawei.com (7.185.36.229) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 13 Jul 2021 17:29:51 +0800 Received: from linux-ibm.site (10.175.102.37) by dggpemm500002.china.huawei.com (7.185.36.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 13 Jul 2021 17:29:50 +0800 From: Hanjun Guo To: CC: , Greg Kroah-Hartman , Sasha Levin , Yejune Deng , Jens Axboe , Hanjun Guo Subject: [Backport for 5.10.y PATCH 3/7] io_uring: simplify io_remove_personalities() Date: Tue, 13 Jul 2021 17:18:33 +0800 Message-ID: <1626167917-11972-4-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1626167917-11972-1-git-send-email-guohanjun@huawei.com> References: <1626167917-11972-1-git-send-email-guohanjun@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500002.china.huawei.com (7.185.36.229) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yejune Deng commit 0bead8cd39b9c9c7c4e902018ccf129107ac50ef upstream. The function io_remove_personalities() is very similar to io_unregister_personality(),so implement io_remove_personalities() calling io_unregister_personality(). Signed-off-by: Yejune Deng Reviewed-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Hanjun Guo --- fs/io_uring.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 0138aa7..0cbf2a0 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -8505,9 +8505,8 @@ static int io_uring_fasync(int fd, struct file *file, int on) return fasync_helper(fd, file, on, &ctx->cq_fasync); } -static int io_remove_personalities(int id, void *p, void *data) +static int io_unregister_personality(struct io_ring_ctx *ctx, unsigned id) { - struct io_ring_ctx *ctx = data; struct io_identity *iod; iod = idr_remove(&ctx->personality_idr, id); @@ -8515,7 +8514,17 @@ static int io_remove_personalities(int id, void *p, void *data) put_cred(iod->creds); if (refcount_dec_and_test(&iod->count)) kfree(iod); + return 0; } + + return -EINVAL; +} + +static int io_remove_personalities(int id, void *p, void *data) +{ + struct io_ring_ctx *ctx = data; + + io_unregister_personality(ctx, id); return 0; } @@ -9606,21 +9615,6 @@ static int io_register_personality(struct io_ring_ctx *ctx) return ret; } -static int io_unregister_personality(struct io_ring_ctx *ctx, unsigned id) -{ - struct io_identity *iod; - - iod = idr_remove(&ctx->personality_idr, id); - if (iod) { - put_cred(iod->creds); - if (refcount_dec_and_test(&iod->count)) - kfree(iod); - return 0; - } - - return -EINVAL; -} - static int io_register_restrictions(struct io_ring_ctx *ctx, void __user *arg, unsigned int nr_args) { -- 1.7.12.4