Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1130453ybj; Thu, 7 May 2020 15:47:01 -0700 (PDT) X-Google-Smtp-Source: APiQypIB1LfIW3epV9W77tAOIMCE1n9ZNvf1FlROK8HOEkyU3t+7FF3k+PmrmaLFnmR2Aqsc9ZsV X-Received: by 2002:aa7:dd95:: with SMTP id g21mr13960072edv.148.1588891621054; Thu, 07 May 2020 15:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588891621; cv=none; d=google.com; s=arc-20160816; b=ZAUAJe1omaE5fZB8ULoMc8iUpxt3BVdncDdNvMaJ2WdIDO9IlA+Z2SJkKVOFnCEm11 HQ9cTv69J3yQMMvm07zv0tr0fpRSyqk6sxqzJD3AjTmbzGa4Hop4mQo43omHV3ya9AN8 H71VoEM0fBmu+mbCt4mMCgZvOzq6JHcQ1sbek/ZG3hITgpl3GgKpb0HJctx7IwPpAL9s NX6BEAOs9yjsSTrXvoO28qj/Bcet6AtE5X4eMMCh0qfUF4COe+BZ9uB94M6kL0l3r/NA pb1WxU3dXKOX5hxy/em7CRV+7myk2p87rbYGuIfFWMV1osVdyYb9blUKsV5ENEOpCSM9 iVdw== 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=xCTtWxB4C67vnTgOLVlfXQdoHzo3K/iF5OfOpuqhn0E=; b=RI0vGR2TbtO+uoauGdkjeChBdOhTINRMLp26wPf6dAQJct2M0oBsAV5OCwXnS8tLrz UXTLKS0kFf0lGbBy6i9kK1DHuLZ06vX0yBVJwczGWuHepoUACRT8SQSstCaQVY8VdMoq HoWGw6oW69zYyjMtRjSv8Sf9TO1+AeH6l9JlDAm6VNwTIVLFSLLdEVIZHQ+yywMZ2iCu 2XIUekKQJwxwqke4RmqdXGGRCVsKU72Fki+oD6/25DDA4MPit9gG/jbwi89Kns2Z3gbW zCAZ3oZd4jXu8IDPnkwhkIpTcSQ+81h5xa7CVgdL4rl9IM2Nk6zGjZ8MMxGfxGsYwGNB RKXA== 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 f11si3924681ejb.492.2020.05.07.15.46.37; Thu, 07 May 2020 15:47:01 -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 S1726598AbgEGWow (ORCPT + 99 others); Thu, 7 May 2020 18:44:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbgEGWow (ORCPT ); Thu, 7 May 2020 18:44:52 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13D6CC05BD43; Thu, 7 May 2020 15:44:52 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jWpG3-003HUj-EA; Thu, 07 May 2020 22:44:47 +0000 Date: Thu, 7 May 2020 23:44:47 +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: <20200507224447.GI23230@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> <20200507220637.GH23230@ZenIV.linux.org.uk> <283c8edb-fea2-5192-f1d6-3cc57815b1e2@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <283c8edb-fea2-5192-f1d6-3cc57815b1e2@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 04:25:24PM -0600, Jens Axboe wrote: > static int io_close(struct io_kiocb *req, bool force_nonblock) > { > + struct files_struct *files = current->files; > int ret; > > req->close.put_file = NULL; > - ret = __close_fd_get_file(req->close.fd, &req->close.put_file); > + spin_lock(&files->file_lock); > + if (req->file->f_op == &io_uring_fops || > + req->close.fd == req->ctx->ring_fd) { > + spin_unlock(&files->file_lock); > + return -EBADF; > + } > + > + ret = __close_fd_get_file_locked(files, req->close.fd, > + &req->close.put_file); Pointless. By that point req->file might have nothing in common with anything in any descriptor table. Al, carefully _not_ saying anything about the taste and style of the entire thing...