Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2422220rdh; Sun, 29 Oct 2023 15:55:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwSf+ftLyjtjGw4jLnBtoIoVj29Jwe+27Tjnt/8W4sUqZ8s0cMCaoYwhmN9QD+sQaWO4JX X-Received: by 2002:a05:6a00:10d4:b0:690:1857:3349 with SMTP id d20-20020a056a0010d400b0069018573349mr10668951pfu.25.1698620146678; Sun, 29 Oct 2023 15:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698620146; cv=none; d=google.com; s=arc-20160816; b=pNcV8YPSAJ0d8BxivNoHkl3plLHQAEpiq9xzbQIyz/fgs0wXRK+EIYOZqXr0NG4dlP jhNGSai+YC3iTUAhbweRvQiRjAdjA4/EQ0oh+22A8SztaLZs9um9Ysl2ZSH4dU03Ilah D6ifRhh6HlkSYRePACdjjtzpBQNl7Bp0v4cpK6OHXGINZaE55+IQeDCnZkrqXkUyJrPQ R4HzxgV867qP3qNYgF4oUgPpPCs6QnEgU3cN86HodU2gxrSpE6Js1JbmSTupwXdMPR5x PfLIisPs/W4y31micM06lh9ogC9TInth7biJQ76iO1PeE0xgVR1nd8EdVRIaP24Ylve0 n1ew== 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; bh=Q0EOPwGCg8OUKlj2KEzJ2Ur+tEG/umNiuwamSvFmOgc=; fh=SEzFK85430dX+ott6en0tViRmcXR7P6suF8CPSQfwtY=; b=sMaD1YxIV5H+lxbvKfUcGJC429y4JFcwlUWURROzFTYiq/FYbaRTRKT2CbcXDIR/Ov XCEJ/+FJwAliX9fWixUyfjsljkZJacEFg6Byt8CMm74lvXPUf11d3vsUBuecttWbJ2m3 7dZb24SkS7UT73GKtJTAixkLNE70tcUlkr5IiJfKpeQX5Ei0bt/BvWJlzcExaEHbN3wr 2U0+BAY9wFwRhIwgbNYGQbn7GX0HA8sz/nATvBmsuKlKgzmp9jnsE7O5WmkgOrZd/WTJ fZ9phT1hDZS/9Uabd7s9Dzj2pYqI+HMG9e7nAOaDKenCc909s4lvMJF77tyDhM/DU4GB 2ong== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Hro/1mUo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h17-20020a056a00219100b006be08015248si4083984pfi.294.2023.10.29.15.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 15:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Hro/1mUo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 425A3804C494; Sun, 29 Oct 2023 15:55:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231217AbjJ2Wzi (ORCPT + 99 others); Sun, 29 Oct 2023 18:55:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbjJ2WzO (ORCPT ); Sun, 29 Oct 2023 18:55:14 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D184B1BB; Sun, 29 Oct 2023 15:55:04 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C39AC433C8; Sun, 29 Oct 2023 22:55:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698620103; bh=E7esBqLyr0+1UTE13D8ejR5e9vkrfaQoW0PQHcPr7CY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hro/1mUoXWTdkLjZarRvCSA3XkZoUQ+mGhgkQ22HUboKPiRTCRZ73W77rNscTA0vS c51R1qWhAZVDrFp31hJYE9sQdivTpoX03hDMHWK4PHK8mVRcQwhFYFdaXrgqV33y+M XNRt3AEgZoTY6izMowAlzGSyTcsWi0Sgs+CRXOUfIO3s4u5Tl+B10N2CmZAMFHfQQ4 yfGnpVfvudTzJnug52CaUQCCNqIN8HqddWMFtNl9YH23k7X5Mfw4q7GsQ14CFJfS5/ q+9LWowC+gFPwNjtd8hkkOEXTx2OnzgazwWL1cl6fR3Ya4RtRbW9lFy0VtW8iWNCD7 H1S2ecgnwSV6Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gabriel Marcano , Konstantin Komarov , Sasha Levin , ntfs3@lists.linux.dev Subject: [PATCH AUTOSEL 6.5 14/52] fs/ntfs3: Fix directory element type detection Date: Sun, 29 Oct 2023 18:53:01 -0400 Message-ID: <20231029225441.789781-14-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231029225441.789781-1-sashal@kernel.org> References: <20231029225441.789781-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.9 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 29 Oct 2023 15:55:45 -0700 (PDT) From: Gabriel Marcano [ Upstream commit 85a4780dc96ed9dd643bbadf236552b3320fae26 ] Calling stat() from userspace correctly identified junctions in an NTFS partition as symlinks, but using readdir() and iterating through the directory containing the same junction did not identify the junction as a symlink. When emitting directory contents, check FILE_ATTRIBUTE_REPARSE_POINT attribute to detect junctions and report them as links. Signed-off-by: Gabriel Marcano Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index 063a6654199bc..ec0566b322d5d 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -309,7 +309,11 @@ static inline int ntfs_filldir(struct ntfs_sb_info *sbi, struct ntfs_inode *ni, return 0; } - dt_type = (fname->dup.fa & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG; + /* NTFS: symlinks are "dir + reparse" or "file + reparse" */ + if (fname->dup.fa & FILE_ATTRIBUTE_REPARSE_POINT) + dt_type = DT_LNK; + else + dt_type = (fname->dup.fa & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG; return !dir_emit(ctx, (s8 *)name, name_len, ino, dt_type); } -- 2.42.0