Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2772980rdb; Mon, 12 Feb 2024 16:50:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWSpj+bvZwMdp6hdTHiuvRcMYOc5Umud9fzrKhQZMbYz6rxy5Uw76Utyjc/lDs9sg6sQCs7MkPgX+5vDIm6Ode80PH4iQPkJutdy6GwPw== X-Google-Smtp-Source: AGHT+IEwKtWOj3B/2GV0TqAddpkNYPXrFLkZ2u0RJfg7vkhnPZhnY1AelzEEwr8cOoW+JY5RaHpP X-Received: by 2002:a05:6a00:1494:b0:6e0:d4c8:28e with SMTP id v20-20020a056a00149400b006e0d4c8028emr6140259pfu.29.1707785422117; Mon, 12 Feb 2024 16:50:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707785422; cv=pass; d=google.com; s=arc-20160816; b=fAy3+rWYTh+5n51uCW2I55dhUE7o/ugggA5bYpUcHlGHcNczvF7g28lO1AmHZWXpyj MvLor8sUhrm6tHTeDZiwXQi2OsyAopYeHHqlH9DDZFbM6zUam4GdtF4RJ6SXEp8itUfq NEvUJVUZqt4ggUcmHCCP2ijfLJddrbhHzblQLbCgr2BkK0DsVxEHfZQSCdcydG3t9xpO yQwCuSTTv6kErfrcFjW33HqI2XZ74u2hHcCnAONTXyUKVmPwLVcvapdPiPBRpzKAyfG8 Z/A5WSSmYmdKrUq7/ciEnXQZrePG4enyo3bK0nCDgE4QSqnqP41g7jpKprv4I+BEPoyv eXsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nmgCccft2bgweqaXlqRICr7j014WAF5Qu1yIQuC7kCM=; fh=F9t1Q1Zr2jSoeB5AX1JKve7lrpuDEB6TceJ4N/X73L0=; b=UiaCzupcDUu/hPZJPunBUsN7IG2DuAzDifYa4W2KTSJ4g9+ZbsU98anQYqoemH+X1e dfUBEPze4Yd0rdI2ji+2cUFI3qUscVvUM5fokPTSi7ebPTNQnMM3sqOjTq3bXQkDR0qC ndMlk4djxFoOfKp8nWji5y/rCa3l88pCnOlS6+pULIoqSWipVK2tBgc1JFqD2jk2DzHO ufyQ+2KYHfijba2/ms/lqEZRhGV0NjALWlIJFItLpI0kVqDgbAdHaLITgNDG5vXxk/FI CrH+tedgLcXqGSJI5zaDKGt69FxN/wxyGAUOPEcUgCmXPHYai1sr+a/sFpQvhTCDQOuZ +Qqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="GxEp/MX4"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-62686-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62686-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUl5R08guPKDBgdFBsqAUZUIVVqC+Bje9EraFlAFrAeTERMhtCBBfxYvK4dwarn1ny0vARSXAeUYQw6UEl05XpHjpik8JcK1nH6oSSUng== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g15-20020a63374f000000b005d8b5979996si1070459pgn.492.2024.02.12.16.50.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 16:50:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62686-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="GxEp/MX4"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-62686-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62686-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BBF2328272A for ; Tue, 13 Feb 2024 00:50:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9205E74E33; Tue, 13 Feb 2024 00:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GxEp/MX4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAEEB71B38; Tue, 13 Feb 2024 00:22:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707783760; cv=none; b=Wo6BySIFeqmBjZ17X0s/BvdCyBFTouf9SXq3PWjT2PqECLiNRr1/81xoYf1+oTZ0bY/CnKMd8ddGDYiotJaew3BcuE7WXpE3XGBKkNk5Hlh6XWJ44+iBeUiQyvSeJUCk5EyWHnPCfXjwk4lCh1jwfdGlcX6NVuoK8oyHio43UFk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707783760; c=relaxed/simple; bh=8ihEVflOv1jQ6OzK869Yv1uPRUtmxtAHHdIRmcDNL+8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S5W3D5S2MUzTcLzgf25ZT49RRw6Sk3M8MIqBMlEkACunb9rw0I5qIDtglWTYAzJ9V/hFwNcODdTUi7wy8Btda4gu8kjl+DdQEm7PEBfLXJHKN+LnjupJ8I8cSSYVjaVoolPwd6RKaJ9jgR4E1RB9qCuNSIU7Ivq9PoYUm+cWVKc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GxEp/MX4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84BA0C433A6; Tue, 13 Feb 2024 00:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707783760; bh=8ihEVflOv1jQ6OzK869Yv1uPRUtmxtAHHdIRmcDNL+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxEp/MX4NWoAfI1DXTW+AyHrFV4+IydiHXah8yaR2TA7VQze1oHfuMpIJF6mwSqUJ UmemWQWSlvb/xVwh/ZNw3q2S2ma9Fa66hBJdTFkomopxAY/gLoj9oVJpjzwSbnkBsT vtSE9iPimIqnsetSm2KvM8GMxCgr/bPgauqmDeUbiHzFJOcD2gmWF29xpfAJCdnO4W zupXEv8bTcjIgan2TgI4qa3gmahQSPXv3qJSfBwAzf+cRa2ma1ek58ljAmF7s2Ps8T AU8u46QMO+34TSDEOLUvKPsOQcH1S4YxzDBK/9gksVTnHTiPW6GlqAiD7T84G8WowD 8fMTzuTje5UMg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Konstantin Komarov , Sasha Levin , ntfs3@lists.linux.dev Subject: [PATCH AUTOSEL 6.1 03/28] fs/ntfs3: Correct hard links updating when dealing with DOS names Date: Mon, 12 Feb 2024 19:22:01 -0500 Message-ID: <20240213002235.671934-3-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213002235.671934-1-sashal@kernel.org> References: <20240213002235.671934-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.77 Content-Transfer-Encoding: 8bit From: Konstantin Komarov [ Upstream commit 1918c10e137eae266b8eb0ab1cc14421dcb0e3e2 ] Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/record.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index ba336c7280b8..ab03c373cec6 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -491,8 +491,20 @@ bool mi_remove_attr(struct ntfs_inode *ni, struct mft_inode *mi, return false; if (ni && is_attr_indexed(attr)) { - le16_add_cpu(&ni->mi.mrec->hard_links, -1); - ni->mi.dirty = true; + u16 links = le16_to_cpu(ni->mi.mrec->hard_links); + struct ATTR_FILE_NAME *fname = + attr->type != ATTR_NAME ? + NULL : + resident_data_ex(attr, + SIZEOF_ATTRIBUTE_FILENAME); + if (fname && fname->type == FILE_NAME_DOS) { + /* Do not decrease links count deleting DOS name. */ + } else if (!links) { + /* minor error. Not critical. */ + } else { + ni->mi.mrec->hard_links = cpu_to_le16(links - 1); + ni->mi.dirty = true; + } } used -= asize; -- 2.43.0