Message ID | 20200810151813.876491816@linuxfoundation.org |
---|---|
State | Superseded |
Headers | show
Return-Path: <SRS0=uOiG=BU=vger.kernel.org=stable-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC62EC433DF for <stable@archiver.kernel.org>; Mon, 10 Aug 2020 15:41:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD99E20825 for <stable@archiver.kernel.org>; Mon, 10 Aug 2020 15:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597074074; bh=1fgeCoTwmpji+1gz0ECi45OvDJ5prtYx5oK3gPIZZ2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=glFX1kFLGKrSttWno7zfkdSLolGtbx9hVSYq0Lpb9CABqBtls3U6kNis1BMFiIWWm nQ6C6Ob0uzoH6M2JTNCEc2uIey+bc6Uyo4PUusFD51dRge2Hh8Bmc7sMlc8BZaabLT 92U03NAAuw2ISVSNoFHT1dtG9NSYnYS67iJibsTE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728314AbgHJPX1 (ORCPT <rfc822;stable@archiver.kernel.org>); Mon, 10 Aug 2020 11:23:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:54790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728309AbgHJPXZ (ORCPT <rfc822;stable@vger.kernel.org>); Mon, 10 Aug 2020 11:23:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F4B9214F1; Mon, 10 Aug 2020 15:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073005; bh=1fgeCoTwmpji+1gz0ECi45OvDJ5prtYx5oK3gPIZZ2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N43ckUzR9RtZXISUfPXfP8SEbpo2dd5BrrEB+L8M27zheL/nlCSKF8O7gecO7A258 P6PQ/0ierQNGL+Q6cu55t96F64sjV8ugg1HqdhbX8yytuFbBF5CQtUkcUy4eKIg2T7 3a23p3wqXdJpzBRb3hg3t0Qxfa5m1PfLZv1EMxWQ= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, syzbot+e6f77e16ff68b2434a2c@syzkaller.appspotmail.com, Christoph Hellwig <hch@lst.de>, Dominique Martinet <asmadeus@codewreck.org>, Sasha Levin <sashal@kernel.org> Subject: [PATCH 5.7 32/79] net/9p: validate fds in p9_fd_open Date: Mon, 10 Aug 2020 17:20:51 +0200 Message-Id: <20200810151813.876491816@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151812.114485777@linuxfoundation.org> References: <20200810151812.114485777@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: <stable.vger.kernel.org> X-Mailing-List: stable@vger.kernel.org |
Series |
None
|
expand
|
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 3f67803123be2..12ecacf0c55fb 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c @@ -816,20 +816,28 @@ static int p9_fd_open(struct p9_client *client, int rfd, int wfd) return -ENOMEM; ts->rd = fget(rfd); + if (!ts->rd) + goto out_free_ts; + if (!(ts->rd->f_mode & FMODE_READ)) + goto out_put_rd; ts->wr = fget(wfd); - if (!ts->rd || !ts->wr) { - if (ts->rd) - fput(ts->rd); - if (ts->wr) - fput(ts->wr); - kfree(ts); - return -EIO; - } + if (!ts->wr) + goto out_put_rd; + if (!(ts->wr->f_mode & FMODE_WRITE)) + goto out_put_wr; client->trans = ts; client->status = Connected; return 0; + +out_put_wr: + fput(ts->wr); +out_put_rd: + fput(ts->rd); +out_free_ts: + kfree(ts); + return -EIO; } static int p9_socket_open(struct p9_client *client, struct socket *csocket)