From patchwork Wed Oct 19 08:21:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp202113wrs; Wed, 19 Oct 2022 01:39:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Si69RfgUvuo+Ask6FCkQ1TyNx/fLoZGKUT84nZLVubLn+IX7uuIhFk6R6k5gVQnUjWfAj X-Received: by 2002:a05:6402:1d4e:b0:45c:b459:25cb with SMTP id dz14-20020a0564021d4e00b0045cb45925cbmr6413271edb.170.1666168798237; Wed, 19 Oct 2022 01:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666168798; cv=none; d=google.com; s=arc-20160816; b=yOsFclrp4Y/lDtzaP5RgjhrOWVPth0/G+UrJXJAVqiHlEMr++GBp1z2MMv4usK12CD bOSrwTqGnzFAGR+41RroO9aKmCFgCvtOoimHmx8MLaQqA51shhzky6guV6kzhLSuLNe4 4KeGHhIIK78je7MZm+i+Pt/KuOxyDltjJllkYRcevWOH6ksJgbec3B73jLHTwI89BzBA 9xB65ZcIAzujLj3HYUCxCZ3dSb0J5odPzMRorF8JRsgErrsk/UgfUgYsq2n95dA78z0q ciytPHfv/Yl8+SYxHu54Hgsecc5G2yuc1AvWYh7bSNgHJohntXHxvnnzwu3LSPY3vbZ/ LW4Q== 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=UNTOP3a8ScbdLanu55IgUR0Wi2gtBF+VoxH8rPY6XMk=; b=rIr80dvSWH/NVBwARNScWnl4supiKI/0XjEcf8cdfZw0kkUArfH6NBN/oFy+FUgI5x 9uZgNf/nerbdAZAksB8yPItwo4RSXJeBsIvjtSWG8fMaygANBvIAhHgVDPiit1hoC5zs XncAikKYiU224JiJ+9AkcY7DRnl8BHI8yxDoaOeXZNCpjaOcrw7mixNWc8/UOHe964xh ItPS47xeRVKGUCwb1/DM50m8arVdiXMZsvPqwZm7DRavRXih7IVcjaWqLiv0xB+CcMTr WTqSFl/SiH1XiyZrdOI4douhHPNW7fRCFKDqFGPqXj30m6mEwmqWKzjBWynxx98Rn/0Z UhHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pE41ptUG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a056402190c00b0045d9a3adf48si8250137edz.591.2022.10.19.01.39.33; Wed, 19 Oct 2022 01:39:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pE41ptUG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230241AbiJSIjM (ORCPT + 99 others); Wed, 19 Oct 2022 04:39:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbiJSIii (ORCPT ); Wed, 19 Oct 2022 04:38:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6373981123; Wed, 19 Oct 2022 01:38:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2B4FAB822BE; Wed, 19 Oct 2022 08:37:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 828C4C433C1; Wed, 19 Oct 2022 08:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168672; bh=6AAYlz6WMbyiz2zlzUmiFzfmzMYzCpqeoaRixFgbwJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pE41ptUGKeM6c75YC0s9BvP+MKPFwWltgJuEAyu+SfzQ45F3X0pW9IZRoikK4pJuj iJ/EnMxbd58dUUudyEJKbmfs1o80zy1ppkPXgBBfSzx1ZCxSegqmNGr0yXKglkQy2T ldB/lMHuk0lQA3Tv+amJBmi0JKuHLkLb/oELkXgU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe Subject: [PATCH 6.0 017/862] io_uring: limit registration w/ SINGLE_ISSUER Date: Wed, 19 Oct 2022 10:21:44 +0200 Message-Id: <20221019083250.770950056@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747104614231870789?= X-GMAIL-MSGID: =?utf-8?q?1747104614231870789?= From: Pavel Begunkov commit d7cce96c449e35bbfd41e830b341b95973891eed upstream. IORING_SETUP_SINGLE_ISSUER restricts what tasks can submit requests. Extend it to registration as well, so non-owning task can't do registrations. It's not necessary at the moment but might be useful in the future. Cc: # 6.0 Fixes: 97bbdc06a444 ("io_uring: add IORING_SETUP_SINGLE_ISSUER") Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/f52a6a9c8a8990d4a831f73c0571e7406aac2bba.1664237592.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/io_uring.c | 3 +++ 1 file changed, 3 insertions(+) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3710,6 +3710,9 @@ static int __io_uring_register(struct io if (WARN_ON_ONCE(percpu_ref_is_dying(&ctx->refs))) return -ENXIO; + if (ctx->submitter_task && ctx->submitter_task != current) + return -EEXIST; + if (ctx->restricted) { if (opcode >= IORING_REGISTER_LAST) return -EINVAL;