Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp179305pxb; Mon, 13 Sep 2021 16:22:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySOC36nJRf868c5Bwrfoh3Y+NcGyAmB2amYI+ifYUNHqTQi4PAoAU1Df730w5vcZ305oZ1 X-Received: by 2002:a05:6638:329d:: with SMTP id f29mr11913185jav.61.1631575327876; Mon, 13 Sep 2021 16:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631575327; cv=none; d=google.com; s=arc-20160816; b=TIkrw+yAucqotRGrOxzmPFPE6a1RsaDLdzeetpjN1JWrSRDSfD6Tfx6FURxvdbTiho LOmAS9SI2QkYFKZVasiRHso6jO+o4u/d1FpRqBZW5beB6UIf+wYKvumQI+RfcrDJD47W d8pZOrVSrKGzp5BV6OV7oHj4ZsYaqLnvMpUcmX4deh0dMUUSSonKfZqr9V0TJiTgxJVW tdZhq+KKQd8eGpxTYcpoMLEcjvkveF8TtIY3GTkvhftt7N2YOv9sTegu7fODS8x8eQJe 2+tYbrmOUlCwRFT7mtsdelaTJ54NN8Ok+HqbdbXmWYx9saKEi39X8eQiskvWjLqmB1U2 EWFQ== 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=R0/JAU+6PeymjoTzwxc1rCNnzGnv++P2KLzCLb4Z0Dg=; b=lKKE3w+0SM9zT5chj1Fvtv/PFI0u/k+J+HVziCAy8kU0Wg1vlrMWV8HxkEo5XxNZDs u1N+2JIyBZ4yLAHmRKVQrJuQL1Y8jw/AY4Y7St4eo28JPSswCrNFverhZ8ROCNfQDw9z jYxmFKHWg8azEcrBJiV9gCZTCbRt4i8AIUb2iRP57ESpYTlEh1k9DS9IYSJjaYXDQ1S1 noQMh1N6lJsVEc66yvwFwP5GugjRIbNgyydgxzXnKbnqimL22aWEfRohk86kg7uF9E2s 2sdRLzbG1BqnvEl28GBA9rKNytaOXnecOeRjCdeLyd2OjeLcecwFsS+klswKUAANuxqG 9A3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pA4Szq1W; 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 l20si10262098jaj.132.2021.09.13.16.21.56; Mon, 13 Sep 2021 16:22: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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pA4Szq1W; 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 S1347192AbhIMOsg (ORCPT + 99 others); Mon, 13 Sep 2021 10:48:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:60464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345641AbhIMOoK (ORCPT ); Mon, 13 Sep 2021 10:44:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 941DA63212; Mon, 13 Sep 2021 13:57:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631541446; bh=9gf2gwK8tz+up98EQlGpMp4JIki2UzwEz2uUd0fADaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pA4Szq1WeNsQdG82YovL/Bt4NgkgCpv+1hkycU3HuAxSMaJP31jTGeqvMtL2TZzii e+SIHPblXhadkPwEYTCJ2WKoabl/IM0cTUFkprwCE0iNqFFfORx6jQwA0XOpwb75OW P/lm55SzWuOxwl91dOrR8+VI4F4v1R5KK7+6vILg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe , Pavel Begunkov Subject: [PATCH 5.14 300/334] io_uring: limit fixed table size by RLIMIT_NOFILE Date: Mon, 13 Sep 2021 15:15:54 +0200 Message-Id: <20210913131123.566192063@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131113.390368911@linuxfoundation.org> References: <20210913131113.390368911@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: Pavel Begunkov commit 3a1b8a4e843f96b636431450d8d79061605cf74b upstream. Limit the number of files in io_uring fixed tables by RLIMIT_NOFILE, that's the first and the simpliest restriction that we should impose. Cc: stable@vger.kernel.org Suggested-by: Jens Axboe Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/b2756c340aed7d6c0b302c26dab50c6c5907f4ce.1629451684.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7722,6 +7722,8 @@ static int io_sqe_files_register(struct return -EINVAL; if (nr_args > IORING_MAX_FIXED_FILES) return -EMFILE; + if (nr_args > rlimit(RLIMIT_NOFILE)) + return -EMFILE; ret = io_rsrc_node_switch_start(ctx); if (ret) return ret;