From patchwork Mon Oct 2 02:31:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13405509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 440D0E784A7 for ; Mon, 2 Oct 2023 02:31:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235342AbjJBCb4 (ORCPT ); Sun, 1 Oct 2023 22:31:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235137AbjJBCbz (ORCPT ); Sun, 1 Oct 2023 22:31:55 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE40399 for ; Sun, 1 Oct 2023 19:31:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=4AnR85rsjiuD1oFzzScjoOARp5ltt5SGcQanpgN2lOg=; b=LKSK1Ymt22gwkXB6byW2clLd2F daEwEw1Cc7cTEiCbbAxlVOR0g4/+Edvl12K8peZmTppyQHalYwAuAzfVR6j+k45RiRvIfwja8xL6L NJRTfD2Cmq9ygJucZ0kgtvbrUHv2Ro61SA6Nw6fDP1NHQFDYXYKBRLbUxyCyOYDIqiszorbohAcSz mSUmyfIksV64LEOlOJHI76i3fmhWyOVcD73sBG4uph56yp5y0kernPtTpQJOCjbPzlXFRe7ixgN7X 8LYHrLLXuh+eMM00m/ukVYs/1OIHYHuGEr0X2uJ5VV97NTqg3IrLqmGg19FZ/HCxQ12Tz5iXvgMN0 GcqMT9WQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1qn8is-00EDsP-1a; Mon, 02 Oct 2023 02:31:50 +0000 Date: Mon, 2 Oct 2023 03:31:50 +0100 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Christian Brauner , Christoph Hellwig , Linus Torvalds , Namjae Jeon , David Sterba , David Howells , Miklos Szeredi , Amir Goldstein , Trond Myklebust , Bob Peterson , Steve French , Luis Chamberlain Subject: [PATCH 05/15] cifs_get_link(): bail out in unsafe case Message-ID: <20231002023150.GF3389589@ZenIV> References: <20231002022815.GQ800259@ZenIV> <20231002022846.GA3389589@ZenIV> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231002022846.GA3389589@ZenIV> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org ->d_revalidate() bails out there, anyway. It's not enough to prevent getting into ->get_link() in RCU mode, but that could happen only in a very contrieved setup. Not worth trying to do anything fancy here unless ->d_revalidate() stops kicking out of RCU mode at least in some cases. Signed-off-by: Al Viro --- fs/smb/client/cifsfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index 22869cda1356..2b044e47a3a6 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1170,6 +1170,9 @@ const char *cifs_get_link(struct dentry *dentry, struct inode *inode, { char *target_path; + if (!dentry) + return ERR_PTR(-ECHILD); + target_path = kmalloc(PATH_MAX, GFP_KERNEL); if (!target_path) return ERR_PTR(-ENOMEM);