Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1876060pxb; Mon, 13 Sep 2021 07:22:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMQQMjQ0RZtbmxLmL9TbEoHlnBlUUyyz0BqjDQQTfohz61hkkX1rBDLVFA4G+ldsDKT4Zv X-Received: by 2002:a5e:d80a:: with SMTP id l10mr9031405iok.36.1631542924998; Mon, 13 Sep 2021 07:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631542924; cv=none; d=google.com; s=arc-20160816; b=ykoa5As0i/tBAQzpW/OtseeSlTBOwp2eEMIXfOBialwsYltAXTUmcPCB1ZF45aU9Lc 3v0r/BdGWd4UmqsyerldUGsFHMs1xi0DJNhH3RphnhedlJuM8VbjACk19H0p3cKMkHIp pXwojvofsfZnMx9MjIIClXuwxX6dRgT+ZN7+jCuOMIUP+1Fnj2//4RZHxX5eAA4Bdf8l xiCxbpNodORXrDDftwOc0kdmV106Sru//uflXtFHYmMMXIfYAUEGkZg70lgcp70LTHLA QAYBsbkgLpQjdl1F5ymrdR+aTlXJffSHe5HBq1dLQMlRk11Klzg2/1lLZ0U8UduxdmG3 RL7Q== 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=Swc9+C/x8depzCikLBUnYLaCaLPXeEKpNqYnpZregRU=; b=zUL1H7KefK2GMOO0xoxMpSUu0XSrw6X7pJkGLI7zkbFUUERuCo+dkddO2CSkMpkkm9 wfy1taBkp+tUaTlp3Q/3Tw81yMMam4wXpzYHbpdJfbs8mWYdyBbXiOS9J8zuz2BqjkIS ZzI8SMdrX1vNJYM0YZLre1fjxpZqb25Tf24ZyWOycH/aU3E4UtXyXNt9gRcb9C1RE5F6 Djw70rMwAw+/hJLz9KXUTrxSemmR6z60OB4PbbI1KzqG1aUFFNrhjkmMbMzGHB+jGhAu PdfmZpGvV9V8FWx/y8MyJIKjAxQGJaXl1IqD0u10++kmG/HNfpiuOfdw9GOBmWyz6G2a mI4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sLCdx90Y; 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 l5si6623915ioa.54.2021.09.13.07.21.50; Mon, 13 Sep 2021 07:22:04 -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=sLCdx90Y; 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 S1346195AbhIMOVR (ORCPT + 99 others); Mon, 13 Sep 2021 10:21:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:37132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344328AbhIMORN (ORCPT ); Mon, 13 Sep 2021 10:17:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A14261B00; Mon, 13 Sep 2021 13:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540703; bh=bmPJBKw+Wtb+O4NmkL6qHAe26ifXnHe5UboCJlAslCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sLCdx90YK2OfdCjTAtsqW7gAgBatwblgNQ6cXNAk4Xzw0HZ5ne3/mP1doZVRLdlF/ Mq/aYPHd9ckh0VxSFRB9vt3BANiw2R+GrlH6OiIKBydlrSqBfUKUi3nsOFQxbd5ZCz beRCAMdw5rhD4D63qZCRXf9irAnbG9spmIdfpkGE= 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.13 269/300] io_uring: limit fixed table size by RLIMIT_NOFILE Date: Mon, 13 Sep 2021 15:15:30 +0200 Message-Id: <20210913131118.429088901@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@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 @@ -7669,6 +7669,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;