Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp268029ybk; Tue, 12 May 2020 22:52:41 -0700 (PDT) X-Google-Smtp-Source: APiQypIYXiNZx+qJDLnFx+8S8tIGeVcoGp31Ys26HXyk1T24TAwL8s1SVPO3951cIyN7atygwFE7 X-Received: by 2002:a05:6402:28e:: with SMTP id l14mr20204751edv.184.1589349161176; Tue, 12 May 2020 22:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589349161; cv=none; d=google.com; s=arc-20160816; b=nCtMm/5o980DeoDMVjwOEZemQVzhG7x8aNZHtzOvm/WcyFdgFeoX21888iUNeGJyde BwjK+LDr8+AseKb+/eLuM0QsxhO2upTsgD/bERtRn1HWa4oTcu9NIuTR80T9yqNQMwPR pPXBAi+Rbvo9sB1cY3Ci0MZ4r8UzAoHFJckiJtYJh1YQMzBwk8qaxeJqzDvGsSiLoXh2 NXZva+jqpvWIiW7PhR+rWUW/Rt8FDaoGyTQowhPDaeFIUa27a4dRTobONV7O7QnujmRS bqJHkKITVC1PQj9UH7Y1tQkV1meQ599NKK0SLezQE4xlYpU6krtt/64NWZz5Ts0J+KIg 5wNQ== 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=Xk3Q2rYmaoxQ1cmjT0sFzy0LAS0Ypd+T1yQBIUVI/ps=; b=ZW4uXdXeypnLylivjjsWM4aPTHfoW69dlL2TqRzyzYf1x2DLWcQHG2kG/qfHbYat5k bkwstaBJs9KqLRDA+L6Rmi5bttv/SB5zWiZsTJjREVL9HbOVpfHdTAA+zvQffKm9lxJ7 FASejZfSBC8UHRF+nLJhO7uezPrNO+1dcyUiN49I2G0D24Q2cix1Osjl2Wj/Ux14Ul9J AtzbzfzIY3R23eM1uFrAeXEQq3HFa2ewPT4T2IMdZhN7FjnJwe5RjZOJNdej4k5TmaET 2TsRqNoMUyfV5FE0HlJinoKB4zqEhxS5RhFIRABDRpFmBuu0xC5lUjWAdVpXtXEDnEEq E8Qg== 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 d19si8260062ejc.396.2020.05.12.22.52.18; Tue, 12 May 2020 22:52:41 -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 S1728962AbgEMFtz (ORCPT + 99 others); Wed, 13 May 2020 01:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728680AbgEMFtz (ORCPT ); Wed, 13 May 2020 01:49:55 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 389B9C061A0C; Tue, 12 May 2020 22:49:55 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jYkH8-007EUK-Qh; Wed, 13 May 2020 05:49:51 +0000 Date: Wed, 13 May 2020 06:49:50 +0100 From: Al Viro To: Shuah Khan Cc: axboe@kernel.dk, zohar@linux.vnet.ibm.com, mcgrof@kernel.org, keescook@chromium.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] fs: avoid fdput() after failed fdget() in kernel_read_file_from_fd() Message-ID: <20200513054950.GT23230@ZenIV.linux.org.uk> References: <1159d74f88d100521c568037327ebc8ec7ffc6ef.1589311577.git.skhan@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1159d74f88d100521c568037327ebc8ec7ffc6ef.1589311577.git.skhan@linuxfoundation.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 12, 2020 at 01:43:05PM -0600, Shuah Khan wrote: > Fix kernel_read_file_from_fd() to avoid fdput() after a failed fdget(). > fdput() doesn't do fput() on this file since FDPUT_FPUT isn't set > in fd.flags. Fix it anyway since failed fdget() doesn't require > a fdput(). > > This was introduced in a commit that added kernel_read_file_from_fd() as > a wrapper for the VFS common kernel_read_file(). > > Fixes: b844f0ecbc56 ("vfs: define kernel_copy_file_from_fd()") > Signed-off-by: Shuah Khan > --- > fs/exec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/exec.c b/fs/exec.c > index 06b4c550af5d..ea24bdce939d 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -1021,8 +1021,8 @@ int kernel_read_file_from_fd(int fd, void **buf, loff_t *size, loff_t max_size, > goto out; > > ret = kernel_read_file(f.file, buf, size, max_size, id); > -out: > fdput(f); > +out: > return ret; Again, that goto is a pointless obfuscation; just return -EBADF and be done with that. Incidentally, why is that thing exported?