Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp709397ybk; Wed, 13 May 2020 11:00:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGyfe4GxIqJlE6+mC56YXvBjRLR5/djVmnt8DWs8cCttl8q6Gtkfmy9NYu9HqFVE37vZTM X-Received: by 2002:a50:d9cb:: with SMTP id x11mr817138edj.88.1589392859030; Wed, 13 May 2020 11:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392859; cv=none; d=google.com; s=arc-20160816; b=q9+YKp4Jda1aeLyFI7xVrx1aR9xMWCVhca8cTdtIuoIEXDoBP2ngNZnpYIYzRi+BUy XL3yE1RP5hDn4VlMku0VTA1hwMPcL09oEkVg48jSS2E+D0lHpo+Z8hAuoUcst/Bn5RiY ocCUEIvo2H+JAMbU7RxczQ33hTIE04GZWrlF//kjdmOR92QHXgI6t+ksGt1LMepsQluE fuaVFHqr04p2omqPcguvYrIu50rGfNtVKPrvTZYq4nRM4Ju1HURf1X1WKWN6GiwJ7cHq pzQUcNC9bluox7HC4Z3DfTrzrsav6u7tWyoKQ9DN/98yi0oo7N/Mvy5Epz9BCwweFoFV R2Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=F16QtRSzf878DRAHE3ucRhzTHi9PQVc2FyzR7+y/rko=; b=ZFUybnKb8E35RBI79mlWVGN+qoaG5ooxc9/Io7qg8EScdnN1ftxqx2EX8v5RFpJveA H0UjRQvwnw0a2cSVDaSSkHnkL/PIDdc47TVqvHz4mxqJqDkrmzaxv4ABZ/tOpbUeqGxj uIh4GI4C5N0evV/udLqWfEBBAFceftfpS9N7cZvhbduObn3IYxDh42xRap5qeMpAvRN2 1a3eF1F1nFZ7sD+piFmCBWMsmUH09U/lIqniUJftPAuzGeIN83yz1K7LxD19dL2RIrcK +A7kRmQUkv4pOlKs7W9EPYBSDVjTJ8LRzLa66mUlZwjKtzfBWnCee8X7IQ5eaUYXVUZb +H7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=gC6Ys2Z0; 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 a6si274244ejy.11.2020.05.13.11.00.35; Wed, 13 May 2020 11:00:59 -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=google header.b=gC6Ys2Z0; 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 S1733144AbgEMR4P (ORCPT + 99 others); Wed, 13 May 2020 13:56:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732986AbgEMR4O (ORCPT ); Wed, 13 May 2020 13:56:14 -0400 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4555C061A0E for ; Wed, 13 May 2020 10:56:14 -0700 (PDT) Received: by mail-il1-x141.google.com with SMTP id n11so565225ilj.4 for ; Wed, 13 May 2020 10:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=F16QtRSzf878DRAHE3ucRhzTHi9PQVc2FyzR7+y/rko=; b=gC6Ys2Z0X4VwL2tBzGS4x3OiTHrcdcOLARYEx4CguoyfFZEmU4tW2Ja48mydzgWx9B AS/BjGGUEfFjY2ALTRclJ/53GMtL/GU0s43O9XH4Hj+ik2iurcHuGpCjz+H302iTMblx EaeAJujlOc/UM+k5YOzD/iG25gUfMG5IiyWx4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=F16QtRSzf878DRAHE3ucRhzTHi9PQVc2FyzR7+y/rko=; b=dClh+vF4D3cSkj0bVeN84+Sc43zYzxw6NIMmHBljwh/CnkUoZcb/KYT+JRYnAqT+QV CaNrEVEkBssS00Lw2vqZSJkCBqNpTJEX4z41dbFdkMiBLw04/1NjCTz3u2bQnzdDL8s+ 1fESu/lGiFtW5NNK2FR7sJYfHO6AVbejUYsYky1eF56vFgkznZxfMG2nkZ8WkPrJfpAN akLzmUheQuRJKA0uLuS50Ngl3j1ldj2wp1hpBUGi6tvrogeMr7DXTd6FNXZocxyk1qvi v4w6oipX+s/+QHt9Q/tZ05BLMyOmFkcoNuPWXk5I3/MW2/QM9D8yPextWDArXdgiV1nR ZuHg== X-Gm-Message-State: AOAM533Qxs0Mb504ENsROUd3IoYrFBjRYBWCqJUhHekbk8eS+JaI4dnE dxW5W6o/uszZQ9tm4i19D8HeXA== X-Received: by 2002:a92:8144:: with SMTP id e65mr313116ild.242.1589392573981; Wed, 13 May 2020 10:56:13 -0700 (PDT) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id e13sm88045ils.27.2020.05.13.10.56.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 May 2020 10:56:13 -0700 (PDT) Subject: Re: [PATCH v2 2/2] fs: avoid fdput() after failed fdget() in kernel_read_file_from_fd() To: Al Viro 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, Shuah Khan References: <1159d74f88d100521c568037327ebc8ec7ffc6ef.1589311577.git.skhan@linuxfoundation.org> <20200513054950.GT23230@ZenIV.linux.org.uk> From: Shuah Khan Message-ID: <19709a34-68be-abb2-a8e1-f42e37a103ee@linuxfoundation.org> Date: Wed, 13 May 2020 11:56:11 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200513054950.GT23230@ZenIV.linux.org.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/12/20 11:49 PM, Al Viro wrote: > 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. > My reasoning is if this routine ends up growing it might be useful to handle the return this way. In any case, I will send v3 for both of these patches. thanks, -- Shuah