From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09C04C2BB86 for ; Tue, 14 Apr 2020 12:20:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D637A20732 for ; Tue, 14 Apr 2020 12:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586866847; bh=heXSDPjGezH1vO/ctG3ngrZJIpf5e5+LKt4qpi9qD18=; h=Subject:To:Cc:From:Date:List-ID:From; b=JXMb8oXIThVRBlkT8wy+2qFp7GZu2ywy5rIcLz0h9QX9ez6vkl8kTQb2lWl6CQM2N CAVGK5bdYFzPctFy/c7N3hZDTBIDgMrmPSqzQ3GNHWcOBujYVPIu5mGr2zOZKuB5fW BqTmoieGII4ONmRCaOZySdA031e+S31zlvYkS27E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440014AbgDNMUo (ORCPT ); Tue, 14 Apr 2020 08:20:44 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:48987 "EHLO wout1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440034AbgDNMUm (ORCPT ); Tue, 14 Apr 2020 08:20:42 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 892A08A3; Tue, 14 Apr 2020 08:20:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 14 Apr 2020 08:20:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=u+q7Xa lXg0fL8PMJ7Bs0wnn4tpMaTbJcnmpHKQ9JY9o=; b=MEfQAATimxXA4+/JVHEkMc eMTgiAchARNeW1V5Ls98j3ebUzw4W7XawICwtJ2UBNn32wqUDw+PZX8H6F5REroX aT7iuKyVQvhlgPIc5N+p5SSa0DtbvEDEgO2nZtEe5Uav86u+n7peN1APfbKJY8HX FwG8D36ySORicngKk3zsE7N+bcQAWmbbfV7REyl+TiB/qMy9WMitck2NvGDVKIr4 y2BqH/X39mAKSVYji6DJGcNWusx4EhrWXfqDj8Y3Yh8lj1Jq03WJ24VOr5NevJ4C +pVcynnAhm6P9pLdmioblDKywa4OanRFnwVIMhL7smK5VguFX/8Gg1y4M7MgEjOQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrfedugdehtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvhfffkfggtgfgsehtkeertddttd flnecuhfhrohhmpeeoghhrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhg qeenucfkphepkeefrdekiedrkeelrddutdejnecuvehluhhsthgvrhfuihiivgepvdenuc frrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhm X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id C33B3306005F; Tue, 14 Apr 2020 08:20:40 -0400 (EDT) Subject: FAILED: patch "[PATCH] io_uring: honor original task RLIMIT_FSIZE" failed to apply to 5.5-stable tree To: axboe@kernel.dk Cc: From: Date: Tue, 14 Apr 2020 14:20:30 +0200 Message-ID: <158686683043191@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.5-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 4ed734b0d0913e566a9d871e15d24eb240f269f7 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 20 Mar 2020 11:23:41 -0600 Subject: [PATCH] io_uring: honor original task RLIMIT_FSIZE With the previous fixes for number of files open checking, I added some debug code to see if we had other spots where we're checking rlimit() against the async io-wq workers. The only one I found was file size checking, which we should also honor. During write and fallocate prep, store the max file size and override that for the current ask if we're in io-wq worker context. Cc: stable@vger.kernel.org # 5.1+ Signed-off-by: Jens Axboe diff --git a/fs/io_uring.c b/fs/io_uring.c index dfe40bf80adc..05260ed485ad 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -604,7 +604,10 @@ struct io_kiocb { struct list_head list; unsigned int flags; refcount_t refs; - struct task_struct *task; + union { + struct task_struct *task; + unsigned long fsize; + }; u64 user_data; u32 result; u32 sequence; @@ -2593,6 +2596,8 @@ static int io_write_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe, if (unlikely(!(req->file->f_mode & FMODE_WRITE))) return -EBADF; + req->fsize = rlimit(RLIMIT_FSIZE); + /* either don't need iovec imported or already have it */ if (!req->io || req->flags & REQ_F_NEED_CLEANUP) return 0; @@ -2662,10 +2667,17 @@ static int io_write(struct io_kiocb *req, bool force_nonblock) } kiocb->ki_flags |= IOCB_WRITE; + if (!force_nonblock) + current->signal->rlim[RLIMIT_FSIZE].rlim_cur = req->fsize; + if (req->file->f_op->write_iter) ret2 = call_write_iter(req->file, kiocb, &iter); else ret2 = loop_rw_iter(WRITE, req->file, kiocb, &iter); + + if (!force_nonblock) + current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; + /* * Raw bdev writes will -EOPNOTSUPP for IOCB_NOWAIT. Just * retry them without IOCB_NOWAIT. @@ -2848,8 +2860,10 @@ static void __io_fallocate(struct io_kiocb *req) { int ret; + current->signal->rlim[RLIMIT_FSIZE].rlim_cur = req->fsize; ret = vfs_fallocate(req->file, req->sync.mode, req->sync.off, req->sync.len); + current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; if (ret < 0) req_set_fail_links(req); io_cqring_add_event(req, ret); @@ -2875,6 +2889,7 @@ static int io_fallocate_prep(struct io_kiocb *req, req->sync.off = READ_ONCE(sqe->off); req->sync.len = READ_ONCE(sqe->addr); req->sync.mode = READ_ONCE(sqe->len); + req->fsize = rlimit(RLIMIT_FSIZE); return 0; }