Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1216491iol; Sun, 12 Jun 2022 09:15:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlTCKugJKVWFRfwfguLZzB0/+D/e2SlGHl1YcQ1ZeyG7U/UbYG8lFkAdyz0M8px40QQVuf X-Received: by 2002:a17:906:fb0f:b0:715:7e23:bbbc with SMTP id lz15-20020a170906fb0f00b007157e23bbbcmr3762107ejb.373.1655050542479; Sun, 12 Jun 2022 09:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655050542; cv=none; d=google.com; s=arc-20160816; b=DRF+p6Ti/+dCRWo+M8cFDP+JcRrlTltXlthPv+eISdl+sd2ucnSTVQyp402ZSVYcq+ L9Di+0G/g0vv7r6Rgc7eFKXJO/+u0EFMn15JAmsZ7nnz8Py1TvvqjarU4Sz8R9mTJq1r FVYiPXukZMIH78aKRWzkLolpHFt8BltMBI5l1K40m8n+ZHXQzC1aOHFOlvQYavrvV4XY /Ny3olBnsGB4i0kX+94MDHmOTVh4TlYt4Qca94pQebkxS7S/u7YMf8cSHhE5/XB6ePtu Dy9yQamlw066U/Sk87T1OYn6w7CzxvlLzECKFD3SmoHFh8Kfqbx2EO6iaYahO/zwMQX6 v/Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=NGrM8aOLW3P+D4Rx7zur1lNPPJiOVKsmRGPxJVvnPDs=; b=NfiVIQiwoEFVM+lznGLGb5TSCrFGjeiW7spJpgM65nThP+y41AD10m4p1Tug/hENtn /PulQYqheRauBw7qdlN4VEb2e6sCRvzOAZLKA4eduijndpncSsShgWJK/KZ9wGYmvXiZ PcID4F73Y35jby24wzndl2AIreu3dwKM7kgcCaulhQsUItyqrXsnuoQU3riVj2jScPi9 xGRQhTMQK8HOUAbMxrHUSLEfQ0DQDr4v4szmkF0riDnQoQexdGcuZrZYiUJccDim/37Q leYB6y7C5yVma3IOM+fpJ/38wUfH5T0vol2J5bc4jySsnuVRRSaoqysRWAK3yafAGs3G W2YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=oKvYGL0B; dkim=pass header.i=@codewreck.org header.s=2 header.b=I8JxRLMQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he15-20020a1709073d8f00b0070b2e7a7c7csi6508848ejc.426.2022.06.12.09.15.16; Sun, 12 Jun 2022 09:15:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=oKvYGL0B; dkim=pass header.i=@codewreck.org header.s=2 header.b=I8JxRLMQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234975AbiFLIyT (ORCPT + 99 others); Sun, 12 Jun 2022 04:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234993AbiFLIyR (ORCPT ); Sun, 12 Jun 2022 04:54:17 -0400 Received: from nautica.notk.org (nautica.notk.org [91.121.71.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAEA5517C3 for ; Sun, 12 Jun 2022 01:54:16 -0700 (PDT) Received: by nautica.notk.org (Postfix, from userid 108) id 588EEC022; Sun, 12 Jun 2022 10:54:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1655024055; bh=NGrM8aOLW3P+D4Rx7zur1lNPPJiOVKsmRGPxJVvnPDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oKvYGL0B9tcmmAYPevuw7CIc9o+pAtZr6haB5YQiuGao/Alip1H1REebw+hGJpFUB jMMRfYcP72Fx5gR8FoFC/Zp7BUuxsaELWTG+Tb8mjbxQHxA7V9SQf/UToasJr9LWaX EQC91qVZtNkDh8Mr6zNBt/89VcQg2/P+j+VKv38XZ5lvU1CQTlARjFDP7ZMcXv7zrZ YVoLifracoufWYgUPjxoyCb+6fwqauLOdLNVpOfM86XK35la4JpbFEeP9nnglEcHGz yCfiJ5cL5AkIaRgQiPbF4as24QyRobtOCaceF79fZk/l5Q4ra6+EycUHyWhPUNAQyB ey8VNNC2Vji5w== X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Received: from odin.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id 626F2C01C; Sun, 12 Jun 2022 10:54:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1655024054; bh=NGrM8aOLW3P+D4Rx7zur1lNPPJiOVKsmRGPxJVvnPDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I8JxRLMQM5jMQ6KIrOGYGqQ2cTmfPMaiDXcawSxqCTrcOe9i7TXA1CdG6yvXQvFF1 P+hMvGTH7qo4uK5y4HYLxqlMdIsqhpiL6/IBHfibkpMMVQEnlyz0qKoXVj6UMN1idn VnoSI0xhPBkzFp+PzsHljfmsQTzDGpPV5F7ot/rgvom9PbQzNM/BT5Tz6S1fx5t0yz 6J558nM8AteTMbpWweNCRspQgPB8K/pMWqyEM5c1nS2NaJspr2kppuFK+a7lHIe/+K 1D2f7tfU2UFzhQVXknU3b/A8P4/4Scq+Y1kbWyPHAAaHBQUevvgOONEyT+nOZFFSGE ISxArtJEqAsRA== Received: from localhost (odin.codewreck.org [local]) by odin.codewreck.org (OpenSMTPD) with ESMTPA id afea8486; Sun, 12 Jun 2022 08:54:08 +0000 (UTC) From: Dominique Martinet To: Christian Schoenebeck , Tyler Hicks , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Jianyong Wu Cc: v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 02/06] 9p: fix fid refcount leak in v9fs_vfs_get_link Date: Sun, 12 Jun 2022 17:53:25 +0900 Message-Id: <20220612085330.1451496-3-asmadeus@codewreck.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220612085330.1451496-1-asmadeus@codewreck.org> References: <20220612085330.1451496-1-asmadeus@codewreck.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org we check for protocol version later than required, after a fid has been obtained. Just move the version check earlier. Fixes: 6636b6dcc3db ("9p: add refcount to p9_fid struct") Cc: stable@vger.kernel.org Signed-off-by: Dominique Martinet --- fs/9p/vfs_inode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 55367ecb9442..18c780ffd4b5 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -1250,15 +1250,15 @@ static const char *v9fs_vfs_get_link(struct dentry *dentry, return ERR_PTR(-ECHILD); v9ses = v9fs_dentry2v9ses(dentry); - fid = v9fs_fid_lookup(dentry); + if (!v9fs_proto_dotu(v9ses)) + return ERR_PTR(-EBADF); + p9_debug(P9_DEBUG_VFS, "%pd\n", dentry); + fid = v9fs_fid_lookup(dentry); if (IS_ERR(fid)) return ERR_CAST(fid); - if (!v9fs_proto_dotu(v9ses)) - return ERR_PTR(-EBADF); - st = p9_client_stat(fid); p9_client_clunk(fid); if (IS_ERR(st)) -- 2.35.1