Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1109004ybj; Thu, 7 May 2020 15:11:07 -0700 (PDT) X-Google-Smtp-Source: APiQypLLxsQUOySWqAFil5VsQ9uoIEqD/wUY3SXPKknyhjJnfni4I2b86ICvMMUYEw5o1VW5JdDL X-Received: by 2002:a17:906:bfc9:: with SMTP id us9mr13264156ejb.84.1588889467482; Thu, 07 May 2020 15:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588889467; cv=none; d=google.com; s=arc-20160816; b=XYSD1Qhmw8eXAgJWPeDpgSkYt9C1MN+JhbkFotL0pAhMFRF1KRM6kZUGihyFw68feR bydsxholR+T/yJx6E4OlWIxEmbulZFYxy33K3egK1sRC5XK4PmCcInnhhIB/x9xfTiPc JyoRo2nk0mBurmfj8nvDF4jy5cTnURyP1tse5+XXVIiGXVvWBgJO9vP4cLViDxdazVX3 gpztVRNMOWe3zoLIIqEGU4+odlsfCvpRqjo/2+HTtd/Z9p62xP9YB38XdB2HvndSbTsI gtMjQm6se/FIinjYRPFvN/DKotahS3b71MxykoLle14JrztwPJkfuhqAjFTZhFl2cWKs LO0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qtZPIZNsbuUbD3RGBEjPJfYNwOa6dchp/AyaZeT2Fas=; b=EAkA/+Vf/t7LiuNf4x9g8Qi2qYjxTAfUJZ4QGwLEZC4cMf7APkMBYx+OMTByPWyZkR UIC8YjVHLhEleBUKYgNJ1/N08mBGyf/toovA6ynCPREZp/IOU0YgXHXwAhTveaiJ3hzD XdDzAMsnnrLM1btEE4Ru5jNqIGmJbJVdB4bKw9GRyFmUCJ6Kw9qIjjDu6Gf0GSBISUl3 VCy2usQZwB1vNGm87eh4M8EhM0O6lZfh8zMCYH//nAD+bWhBmNgbdfPYZioZ/4EjB4my +egVdliONjF+H9BP+1vFT4blA1bCmLoz5Pj90ujW9zIsTbtx0jMRFZvFT9PtNsjWyh4I NbDA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p90si3972491edd.215.2020.05.07.15.10.43; Thu, 07 May 2020 15:11: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbgEGWGn (ORCPT + 99 others); Thu, 7 May 2020 18:06:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726636AbgEGWGn (ORCPT ); Thu, 7 May 2020 18:06:43 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08152C05BD43; Thu, 7 May 2020 15:06:43 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jWof7-003GTu-PA; Thu, 07 May 2020 22:06:38 +0000 Date: Thu, 7 May 2020 23:06:37 +0100 From: Al Viro To: Jens Axboe Cc: Max Kellermann , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] fs/io_uring: fix O_PATH fds in openat, openat2, statx Message-ID: <20200507220637.GH23230@ZenIV.linux.org.uk> References: <20200507185725.15840-1-mk@cm4all.com> <20200507190131.GF23230@ZenIV.linux.org.uk> <4cac0e53-656c-50f0-3766-ae3cc6c0310a@kernel.dk> <20200507192903.GG23230@ZenIV.linux.org.uk> <8e3c88cc-027b-4f90-b4f8-a20d11d35c4b@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8e3c88cc-027b-4f90-b4f8-a20d11d35c4b@kernel.dk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 07, 2020 at 02:53:30PM -0600, Jens Axboe wrote: > I think the patch is correct as-is, I took a good look at how we're > currently handling it. None of those three ops should fiddle with > the fd at all, and all of them do forbid the use of fixed files (the > descriptor table look-alikes), so that part is fine, too. > > There's some low hanging fruit around optimizing and improving it, > I'm including an updated version below. Max, can you double check > with your testing? Could you explain WTF is io_issue_sqe() doing in case of IORING_OP_CLOSE? Specifically, what is the value of req->close.fd = READ_ONCE(sqe->fd); if (req->file->f_op == &io_uring_fops || req->close.fd == req->ctx->ring_fd) return -EBADF; in io_close_prep()? And what does happen if some joker does dup2() of something with io_uring_fops into our slot right after that check? Before the subsequent ret = __close_fd_get_file(req->close.fd, &req->close.put_file); that is.