Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2976433ybk; Tue, 12 May 2020 12:48:11 -0700 (PDT) X-Google-Smtp-Source: APiQypKEI3rVKNprJBDfdIkfq6q38cYO5vcx7W88Vqln66zpvBD68dEsqBkYOgvpiJnUezUdQxGt X-Received: by 2002:aa7:c3d3:: with SMTP id l19mr19075720edr.14.1589312890940; Tue, 12 May 2020 12:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589312890; cv=none; d=google.com; s=arc-20160816; b=ffjukgVt/F5gWoQ15RaxCzkDn4nTjN5qC28FyOPTleWZKegobgv1vTarkyAaJWN0lG 4XIgdaqG+gNZ3IV5nOXoUaMQAxvHjrTdBXJtUijJ7OORgEtsAo2WH0OEWfLZ97ZjC2Qc ssoI58se4WQ+g8w2gB3cFA5/d63udVj0dJ63yAqwqQeH8aiy0k7/MPAbFNVJzhxMeHUp MyRUjdijG0QD8nPEWyxME3fRXP05y0TWTVjhL4vrETcNeV1BsJIb5pUoQRSa4I+/2n8r jmTn84Qv8ePDegCnhAfGRWZYB1B9BsegQJeRnKZwVzpv9VBN9O7YQw/PKNIT914yCgHf crEA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5f4RJYDHuVh6PmC6voPvbMaVVDseoYYhjdA/uiY/cuE=; b=Z72yAdfMziLapu3HA9Z36L5+JXJhP/KxXRTVtrNlYtQ1I7HlU4QwSRsWrftKuUDWmV r0WsctdI/2LqtbsSRw0FZbeOigyS2kAjAk8Y2CnA/2DB8iOBDBlmg5dQU9NOsPYcQw/l zDuyHisku1LF7NTSu/cKfqugNZdkXJgopWSu5vdKgbK1GbdDgNlTWdpDlF6OcfOZcOnX AImZF9/s6xSlEa7gRtnSnSlO1l7hE6F1/+n1mJjqpjr2yCbA8/ai8niAMunMQkJ2YHnx nfUeJdGAdRL7zJYwJkhkvPZZXJS0uDeZ7gF8X3hPTOfXJj8AQKDXi6+PjFKdi2UTx0kn lkoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=dDiHF6Qc; 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 r9si617057eji.262.2020.05.12.12.47.37; Tue, 12 May 2020 12:48:10 -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=dDiHF6Qc; 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 S1731045AbgELTnP (ORCPT + 99 others); Tue, 12 May 2020 15:43:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731047AbgELTnL (ORCPT ); Tue, 12 May 2020 15:43:11 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A652CC061A0F for ; Tue, 12 May 2020 12:43:11 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id w6so13655727ilg.1 for ; Tue, 12 May 2020 12:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5f4RJYDHuVh6PmC6voPvbMaVVDseoYYhjdA/uiY/cuE=; b=dDiHF6QcMxQj56/4jqPt4rp/TqSru+DYb5YBX3ju2WcjAsD10UHXWv9eb12IepmgEW HSipt/qwzbvnX8XXGO4VQkcFHihJfgqksvGWHtpRW7GbV7Y96UrZ/KWBoGTMTyx51U7S HfvA/sHFw2IKN+p76Lc+RXjMrhy5RLIJulFb4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5f4RJYDHuVh6PmC6voPvbMaVVDseoYYhjdA/uiY/cuE=; b=V0JEkekaXDEt9tpdZncbGlzeIFWtvtg/0zr894zRNbIZ9gUtmKKcscAov3O1sdmgIn QvQpBYC3qI34Z4A+DUcRNU1B4f16ykA8IVE8ceJykmqGYAzmRtozLq4DhI8C889P/ghB h1WwlFUKOgdMG9yhJlf8MbMESjIy2Y3+wiNj3Kw3NE29enNfWgMGxIcnii/zQsJ1zcF7 N2Aivxwb97UVFowZIzPGmMXc76KGVlmt+CXq38UKe1QXPrPDYDNIpqq8IC5tAZ/SSbqg Pa2mwRLA72XaMvxOQ5Z2cyk8xuf+hKMQVs1WVUpi/9Qqy63I076Pn/JcKWQlQSHJccOP 7law== X-Gm-Message-State: AGi0PubkhAGE0y7dulmu8E60I21veyxjJU+5MHUudEXLhCGtSs0WZ1M2 wmPS3kScDaSLjryGbJVwrOt03g== X-Received: by 2002:a05:6e02:c74:: with SMTP id f20mr23535878ilj.86.1589312590842; Tue, 12 May 2020 12:43:10 -0700 (PDT) Received: from shuah-t480s.internal (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id f5sm6177781iok.4.2020.05.12.12.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2020 12:43:10 -0700 (PDT) From: Shuah Khan To: viro@zeniv.linux.org.uk, axboe@kernel.dk, zohar@linux.vnet.ibm.com, mcgrof@kernel.org, keescook@chromium.org Cc: Shuah Khan , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] fs: avoid fdput() after failed fdget() in kernel_read_file_from_fd() Date: Tue, 12 May 2020 13:43:05 -0600 Message-Id: <1159d74f88d100521c568037327ebc8ec7ffc6ef.1589311577.git.skhan@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } EXPORT_SYMBOL_GPL(kernel_read_file_from_fd); -- 2.25.1