Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp631872pxv; Thu, 15 Jul 2021 12:01:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiydIQYuZwbFcNvlwXwcVvOe7BsuGNaB/fIMS0WkfK9+qDyZmWoWp+BsNTaJ48eQGKVm1b X-Received: by 2002:a6b:b883:: with SMTP id i125mr4376776iof.104.1626375684418; Thu, 15 Jul 2021 12:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375684; cv=none; d=google.com; s=arc-20160816; b=bclx4nGIDewcimLPwvis8bXLZ68j/CHilk8tpAYxiq2Xy9VIXSrBSAPKTRoMJO1lLx 2H3JC2NAOwAIMcfogSL17EpbrtNcmBHPMxWmQoXeB7PLTfCYIn7Fv1tYS0Kg+NFhIejd zlKkphft+XwiNlJOy1ZKoSmPzrWH+coGYRNaa+aFSmG24M+LjMAboO+jA2nws3ieBAus pZYeuZq4DZkkKOJPutieeZvVlMkvedAv5zSMK8eWKuwIHLQXPG1ywpMd8Z/fadZFs5X1 SmJe6qfkD8XDOghzmlpDNryWTLVx2s9d2GmAinXlsbzVvJfGKO/vKEvVtepLNvE3AhRT aU2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B1YERJvWZHkEt7A5c1wcdbhQMSb3emAZ4KChBokn3dg=; b=ggViAwMZ2y2t9JRqfR2TH2BCJjW5rpw5UOnF5orVSbJRu8jqVeNlmZ2bT8Krgxg+ZS nWy3PhSP7p4oScSmqWqtxpmEmrkjvhbArtK6U9R8Sj1rhupavyhZFHc+KNtHG/a/9M1Z 7Cvbu9lCBGlBQ0FIkGVIEeP/AMUKD4UODC5XeBAGp4Ae+zKqLm7xnUhQqnu/8IAvwgRH lW52vFE07xGR1yYExKmsWFDNJOk/Pu2XmcBAZ+kenVlI9ZyMEVTbG99VdddcKEqQExFW a5X+PUkpR/FP56POz2eAHmEVR7zCWHZ718vckmJME4V56INkcwY4K8uPdMFZsoyUKvm+ vYLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0Uf8J9jJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h16si7616755ilc.129.2021.07.15.12.01.11; Thu, 15 Jul 2021 12:01:24 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0Uf8J9jJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241508AbhGOTBT (ORCPT + 99 others); Thu, 15 Jul 2021 15:01:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:58514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240342AbhGOSx6 (ORCPT ); Thu, 15 Jul 2021 14:53:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1BCF6613CC; Thu, 15 Jul 2021 18:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375062; bh=ntoSeY1may51ety/atua3izw2+UANxCK4CoOIwGTNRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Uf8J9jJpxQ9ICepmaznyxkVeTiDaXFhHrvTca+S2jySp04WuAbhlvZ/NJOZXWI0J 4I8RQjYcMkFxP49+GN8MJL86bqZXY19CNeHC9E+ONGHT1Nzo4A01pZW/V8O+suHj6w WU8coyBWNFaOAPfp8STAxOp9JapkfcdO0ILo7HPc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Yejune Deng , Pavel Begunkov , Jens Axboe , Hanjun Guo Subject: [PATCH 5.10 141/215] io_uring: simplify io_remove_personalities() Date: Thu, 15 Jul 2021 20:38:33 +0200 Message-Id: <20210715182624.489114043@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -8505,9 +8505,8 @@ static int io_uring_fasync(int fd, struc 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 i 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(struc 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) {