From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 2191A13D602; Wed, 17 Apr 2024 13:04:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359065; cv=none; b=SIBbXvRKXe6ogABbMHKZM5FQSufeVTuJ47juENVNPgRHL1bi933nMAexR4MNFD3t40RhIeyzM35owkcDmY8h1A0VPD3NekOIbwcRnPFI5T/A1XWMLRrZNK6uHeJlzy7tWxSQn3pqrHXGI6P80yXVNrZ+Y8HxE8ew3mYD4HGYgOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359065; c=relaxed/simple; bh=kN4Zh8uJjfNwUm/W7UF88zGWnSaHMwjVtETPiu+d704=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=e58L94f7XdH5wcH+10JvNDzuPsoJWdK6yYZLU6xEJQ/4X1KKL0uEOYWUmGlRNuqqgAa2+TWezzhAmztFa2WfjrrPwz/5LOrK07w08rQXqcOFrrR9imvPOWd4FA0QsEbqB6H65ndq0aOsaCOVyJUD+tH1uIBH+D5T7dyCFuYifQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=j6Uo9ToS; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=Gr9gds8m; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="j6Uo9ToS"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="Gr9gds8m" Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 3EF292126; Wed, 17 Apr 2024 12:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358610; bh=hOaXPBoDYaEEFQtxf9hg6OHtyzUndpHUFWq8x7yxmik=; h=Date:Subject:From:To:References:In-Reply-To; b=j6Uo9ToSctgbzS1+5bkR8GwAIKA5+0PYEtGUDf/lLsVx7QQJopqIGYCCNnFOGM4I3 w/f8ppQxiYc4pNoKFDfi802v6aGbFlSYhq4dilgsa49Hwoz1omf5zGLhuGIzMH98mp Kv1V5y2AV9Tq/Ym41MyUzx2MFApMlw+Z4fQXAfgk= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 3034A35D; Wed, 17 Apr 2024 13:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713359059; bh=hOaXPBoDYaEEFQtxf9hg6OHtyzUndpHUFWq8x7yxmik=; h=Date:Subject:From:To:References:In-Reply-To; b=Gr9gds8m2hKXjUXveXB9FoBTe9yCkG6hiB04RXWx8Pku0hVV1YzsPfob1UMPuQXt7 SwHB2UG9ITBX0U9xftutnogKa/py2CEeIGL9q68U3Y9UX0Yfx/pqnqTlfHj/FHnYFk gvEpMqM/QDc6NeGjv6yxV6G2iTp8j8Zhu2GU9TQQ= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:04:18 +0300 Message-ID: <8c102e86-466d-4c6c-897a-f2d42c15a204@paragon-software.com> Date: Wed, 17 Apr 2024 16:04:18 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 01/11] fs/ntfs3: Remove max link count info display during driver init From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/super.c | 2 -- =C2=A01 file changed, 2 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 9df7c20d066f..ac4722011140 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1804,8 +1804,6 @@ static int __init init_ntfs_fs(void) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0int err; -=C2=A0=C2=A0 =C2=A0pr_info("ntfs3: Max link count %u\n", NTFS_LINK_MAX); - =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ENABLED(CONFIG_NTFS3_FS_POSIX_ACL)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0pr_info("ntfs3: Enabled Linux = POSIX ACLs support\n"); =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ENABLED(CONFIG_NTFS3_64BIT_CLUSTER)) --=20 2.34.1 From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 9130D13D527; Wed, 17 Apr 2024 13:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359098; cv=none; b=crwCTETI4rG9IRMGOjpeakcs8I0O238aIN/v6KNc+WgYT8DBNC9vXxrk+pIJh6mAQ4ugDuQAXZOcj+H1lQZ2dqDMvKfVksDW8oQhDGodj5YbqdWLXYug5vkz6iNu7VtPbzxtVsTyxGvhWqFcWm5I0hu/iuDjU5X7TIFidJeER/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359098; c=relaxed/simple; bh=nHiJJBnDAQh8XXjJSwshq7E/3U50CC4VOVeAqV3KbtU=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=aXw0xnOwinBuZyF0jecCP+wTJ9a7+/ZmdrWlBuiVmTys15Q1e1SEyarQpva+wgQTDTlpQilFsH2MFtrBxVVO9su6XQYXy8lihBirgmnOeI39J/TvGyJMOr38o+pBaMFWVl6zHmUR9+RSr2Ea30hOsb3knC0/7WJaPJ3/bTv79C8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=WlW0rVrg; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=icV/Ihcy; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="WlW0rVrg"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="icV/Ihcy" Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id B08182126; Wed, 17 Apr 2024 12:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358642; bh=BrCZcm5Cajkf+pB8Wxb1+H+kYQ+CtM5WRPNP2QBYrWk=; h=Date:Subject:From:To:References:In-Reply-To; b=WlW0rVrg97I3/mFt/HdsMnEJVjChVc1DurOPVFCFE9Dz/0sruBBZIQtXKgofFe2R/ 4Oau6CCebmd8vYgqCYRsCNbrMr9GbCiz4lxjTCqvJEdY6W7QH6jdW6rdJKYvtzm7Z0 KpTWwL5VRvIeveDRaVxOM3CkqQYUkUZfL7K6T9To= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id A196035D; Wed, 17 Apr 2024 13:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713359091; bh=BrCZcm5Cajkf+pB8Wxb1+H+kYQ+CtM5WRPNP2QBYrWk=; h=Date:Subject:From:To:References:In-Reply-To; b=icV/IhcysPooiB40Kq1jxZ1t4y7DPQn6K/cs6rIDEJeXNwPCvxxWrbC1CWSu+US6Q jJXHJIAeQeHdTRQhd5kZRJ4YIi3m1BGXJoIunKSW7HW3wKVy6V/OTDi7eBWq4CANCH ZLcKKG9eZlCP+fgRCHdudvmsE8UK55WwVx1CwCnU= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:04:51 +0300 Message-ID: <45365ee4-44da-46a7-9edb-a641f0900076@paragon-software.com> Date: Wed, 17 Apr 2024 16:04:50 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 02/11] fs/ntfs3: Missed le32_to_cpu conversion From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/fslog.c | 2 +- =C2=A01 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index 855519713bf7..d9d08823de62 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -517,7 +517,7 @@ static inline bool is_rst_area_valid(const struct=20 RESTART_HDR *rhdr) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_bits -=3D 1; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0if (seq_bits !=3D ra->seq_num_bits) +=C2=A0=C2=A0 =C2=A0if (seq_bits !=3D le32_to_cpu(ra->seq_num_bits)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return false; =C2=A0=C2=A0=C2=A0 =C2=A0/* The log page data offset and record header len= gth must be=20 quad-aligned. */ --=20 2.34.1 From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 271DC13D265; Wed, 17 Apr 2024 13:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359169; cv=none; b=ftJyV8faNFrwahK2FLp+RqUISs65CsOgqORoBc5wcH5ZfzYQU4QQecFZHNHdOAd3qjfddzagD0uA0ecDjNjyfadcBUvABbk+NFzNPd0quk4WlNWZqxPkwwaef7WYtreoM5KUUWpQY7Ibf3Im3A8Lkz0R4Kwf+sbvepcsr1ilsKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359169; c=relaxed/simple; bh=9Ie/YLM/joywAkgY5c4+CnSqKB8Gr3vixzyksohbcTw=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=h7sXqRBU0fKt7sycjP3M7B8HPgFaZNhb5TBcVX+sfi+PL3nO1XViLC/vjJ6N8/j9Sp/0QEjF0sW+s6lsFxcOMkZFZy7iEBajb9Y24HJJ1VubTXYzXJH36U+WvGNP7Lj8TsBhFpaFuo156VuWZlvKgxUd/QX4Ja2yeh5KrU29cQQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=NVHiYSx9; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="NVHiYSx9" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 213B32126; Wed, 17 Apr 2024 12:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358713; bh=sstzwDA7HJF1SbYTI7fJ3qkhbZk4t2Sju46k98cE9Mk=; h=Date:Subject:From:To:References:In-Reply-To; b=NVHiYSx9A3Qy8ga9U6cPD4ucTqsztbDPJ3G1vOyNDXOz4qvhmIox/kSwJLwFDFEOt L83ygnznR6U2/UJcQVTvOOlXrMcPoTcFpTwHCHf+G5qoUYWKD0VZkBTOwObmRfBjRg pAhiJejHIrPpDsVwzcRb+XZDWj1UXcYwewVnNQUM= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:06:01 +0300 Message-ID: Date: Wed, 17 Apr 2024 16:06:01 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 03/11] fs/ntfs3: Mark volume as dirty if xattr is broken From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/xattr.c | 17 +++++++++++------ =C2=A01 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 53e7d1fa036a..872df2197202 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -200,6 +200,7 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni,=20 char *buffer, =C2=A0=C2=A0=C2=A0 =C2=A0int err; =C2=A0=C2=A0=C2=A0 =C2=A0int ea_size; =C2=A0=C2=A0=C2=A0 =C2=A0size_t ret; +=C2=A0=C2=A0 =C2=A0u8 name_len; =C2=A0=C2=A0=C2=A0 =C2=A0err =3D ntfs_read_ea(ni, &ea_all, 0, &info); =C2=A0=C2=A0=C2=A0 =C2=A0if (err) @@ -215,28 +216,32 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni,=20 char *buffer, =C2=A0=C2=A0=C2=A0 =C2=A0for (off =3D 0; off + sizeof(struct EA_FULL) < si= ze; off +=3D ea_size) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ea =3D Add2Ptr(ea_all, off); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ea_size =3D unpacked_ea_size(e= a); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0name_len =3D ea->name_len; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!ea->name_len) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!name_len) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (ea->name_len > ea_size) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (name_len > ea_size) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_set_state(ni= ->mi.sbi, NTFS_DIRTY_ERROR); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; = /* corrupted fs. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (buffer) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Check if= we can use field ea->name */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (off + e= a_size > size) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0break; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (ret + ea->nam= e_len + 1 > bytes_per_buffer) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (ret + name_le= n + 1 > bytes_per_buffer) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0err =3D -ERANGE; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(buffer + r= et, ea->name, ea->name_len); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0buffer[ret + ea->= name_len] =3D 0; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(buffer + r= et, ea->name, name_len); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0buffer[ret + name= _len] =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ret +=3D ea->name_len + 1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ret +=3D name_len + 1; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0out: --=20 2.34.1 From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 06326EDC; Wed, 17 Apr 2024 13:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359186; cv=none; b=In7WFWU6reNV07kC/sz88/QRBhPnpT/VMziMKnK1xYXaQDMLZdGDdTBt/kfZrbQDXQDoB7AXn8698R/CjhD5F5lu7MFPkvMFE0CZjjDh6h6yk84e+jprC1Yvyvfw1wi69l2W1uZRENozvH8XT3v8hnYYOlJHNvNeOISlenKms20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359186; c=relaxed/simple; bh=o2Pgs/OHVyxb8mEbOBd0XpJqiR9GMrCKt0nOnueqKXY=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=cd1HiOs155vADynqvAs2kakMUWZ2b6BI6d1fotdaJHhq/SjvGiNgo24AHxicUyRaUG0kgz2x1aiP9Q0CrNzQOSOXpxX9wGAX2VN1KARMcIKDQKLz+2DKBAMnKqLexCErGMncVRbqZWvF1AscXnrbcEHE71+m0UxJ8SmVmtaeDFY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=LuZVpP1n; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=giFrNiZh; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="LuZVpP1n"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="giFrNiZh" Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 4BA492126; Wed, 17 Apr 2024 12:58:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358732; bh=x+Bby5lC0g9OLE4iwMauFcXl4HfEIHzHrb5HCchtf4s=; h=Date:Subject:From:To:References:In-Reply-To; b=LuZVpP1nFq0Qm4yxVRUAhTHFcbjiLRXLtlC8bp3Dk6Tvhl1ArB/wR7hYOET2lw47d LinyybqqDtpdqro4a6OXnGw6vpNpay44Cs6cHkNFfsyjFOL19SGChueGG2YulRrM2f RPIIv/xe/lA/Fr19x12JdeXWPRgULHfSAfT0GdQE= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 3B76035D; Wed, 17 Apr 2024 13:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713359181; bh=x+Bby5lC0g9OLE4iwMauFcXl4HfEIHzHrb5HCchtf4s=; h=Date:Subject:From:To:References:In-Reply-To; b=giFrNiZhMuFUBviOnDgmEsuzFBpvUkRfrCC0Kb13mvyjf8Nn5S1vhgrWJBwoPEumw ofiFcl9/9HfJY1OQwhUAWbj6iLkyrvrJb7ZZb+AfPQUnGuxok4quC1v6EiGnIDq9uS dtOZuyKSOHX7Veu/4BvbbU5LifUVjUx1Jwsi756s= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:06:20 +0300 Message-ID: <02e53c60-92f6-4d43-a9a1-bf4c17ec021e@paragon-software.com> Date: Wed, 17 Apr 2024 16:06:20 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 04/11] fs/ntfs3: Use variable length array instead of fixed size From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/ntfs.h | 2 +- =C2=A01 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index 9c7478150a03..3d6143c7abc0 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -59,7 +59,7 @@ struct GUID { =C2=A0struct cpu_str { =C2=A0=C2=A0=C2=A0 =C2=A0u8 len; =C2=A0=C2=A0=C2=A0 =C2=A0u8 unused; -=C2=A0=C2=A0 =C2=A0u16 name[10]; +=C2=A0=C2=A0 =C2=A0u16 name[]; =C2=A0}; =C2=A0struct le_str { --=20 2.34.1 From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 39B8213D535; Wed, 17 Apr 2024 13:06:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359207; cv=none; b=W8Lk39MPaxY5rx7n11w40zJgEWezSjrHvKg0ZyYN6F9IKZOj5npP86JSUyRm9Eu5BDF8DnlxFgi36YRihgHDH4c8Y0/wewq/+vazsT3eI3S36VXowpuVwf6dTJTjlnHrh5bDhPCxCCpW0+7/YvyolozfhqREEDkWqRRzkS4pc9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359207; c=relaxed/simple; bh=moeDjildggmPtbyTfn+Q7Du1kw3N5TGihlzFDNAJ9g0=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=TdDxKDbHhSewM+IxTgQSH1Ove9k3JS9ksJJpqr46CWiFHXNH4Vp+4IQYFDV8wKHaM+6VbKl1QaksfYMOydQJk4LDs2FCyhKxGJD3SO8IjrCEYVTHDEJGy+7WxzIruQBkoUAdyzJR0RXv/nAEpAAFXyAxMW1DG9k7QS7P8JKCq4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=MOUjvk3f; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="MOUjvk3f" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 4D9D92126; Wed, 17 Apr 2024 12:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358752; bh=ztdNdcA2+6+PqSRE5LqvWFbFaw0Bru7dBXFKo7QG3k4=; h=Date:Subject:From:To:References:In-Reply-To; b=MOUjvk3fwEdepmtANtqrXePrW6As6j09nx3ChkKCcs/Cgx3a+7hDqCMd6Lm9KQENj UlToG/RMWmlMnvgEEh0S6xn0RzLSCl1U1bXa24jc/spzy5zkmwUq1hj4EpXoroJzPq s9dyDFhZP5VFsoGDchI91Qmg9tp9V+6xQsUgeHQM= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:06:40 +0300 Message-ID: <4e9cb4a5-202d-45db-846f-17ef74bd2a5b@paragon-software.com> Date: Wed, 17 Apr 2024 16:06:40 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 05/11] fs/ntfs3: Use 64 bit variable to avoid 32 bit overflow From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/fslog.c | 3 ++- =C2=A01 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index d9d08823de62..d7807d255dfe 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -1184,7 +1184,8 @@ static int read_log_page(struct ntfs_log *log, u32=20 vbo, =C2=A0static int log_read_rst(struct ntfs_log *log, bool first, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct rest= art_info *info) =C2=A0{ -=C2=A0=C2=A0 =C2=A0u32 skip, vbo; +=C2=A0=C2=A0 =C2=A0u32 skip; +=C2=A0=C2=A0 =C2=A0u64 vbo; =C2=A0=C2=A0=C2=A0 =C2=A0struct RESTART_HDR *r_page =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0/* Determine which restart area we are looking fo= r. */ --=20 2.34.1 From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 935C47D071; Wed, 17 Apr 2024 13:07:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359244; cv=none; b=o6GrxWJ4eLsCbEEp9TGuNcH5mx00h6RbTzTU7gq6SOlkO4pII/qU3Z/oZfFfBnOYbqeErunvJ/aUJv/FY2gu8o4TDnIa/ApjJMWc/j0HJJ0lFZSdOSM+T4SD1BxmZyYDYEB2y8XqZAiZ0eD/VuIFr2OwGYeoK4FntxBc/I1I88k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359244; c=relaxed/simple; bh=z0IW3/Brxpfkh18MS9+cTaxXo9NVdBoBJ3n5eEgmBjM=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=VV8aDs4vSZdCVDZP7HRaTWHtXQsQn0wQ8Sz0eLtLDZarG+XzkSiwIFCMjD/GT3S7UBwSrdoX7SnyiGzg6PC0s750Ys8cl8Umq2KE3OLA1QjXlKxkE/swOnO3aCacz+4GW1OwTiRsCkRJQmsmG5TWRXeuZOLchyDc6hQUIEZZ6n0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=dQxfV0hr; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="dQxfV0hr" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id CEC6E2126; Wed, 17 Apr 2024 12:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358790; bh=+s6MrL/MryqHMryIwr1o1fGOI0TS7160OkRPd7Inyqg=; h=Date:Subject:From:To:References:In-Reply-To; b=dQxfV0hr+dNtRjMRJ3grudsr3sK5G3NrH0Fv0CHTXEs5+wsSk/7rco53658zI44gb TPUz6tMEnL44M6kzO6jp8l3WMOGsnvrBO0zbR5rwDOEks5xLr/EOA69zoYWO682EOy Q0pvareU23Hr6O6ycMeuQT/WQxAB3JPGEYdpZwBE= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:07:19 +0300 Message-ID: Date: Wed, 17 Apr 2024 16:07:18 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 06/11] fs/ntfs3: Redesign ntfs_create_inode to return error code instead of inode From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/inode.c=C2=A0=C2=A0 | 22 +++++++++++----------- =C2=A0fs/ntfs3/namei.c=C2=A0=C2=A0 | 31 ++++++++----------------------- =C2=A0fs/ntfs3/ntfs_fs.h |=C2=A0 9 ++++----- =C2=A03 files changed, 23 insertions(+), 39 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index eb7a8c9fba01..85a10d4a74c4 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -1210,11 +1210,10 @@ ntfs_create_reparse_buffer(struct ntfs_sb_info=20 *sbi, const char *symname, =C2=A0 * =C2=A0 * NOTE: if fnd !=3D NULL (ntfs_atomic_open) then @dir is locked =C2=A0 */ -struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct dentry *dentry, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0const struct cpu_str *uni, umode_t mode, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0dev_t dev, const char *symname, u32 size, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct ntfs_fnd *fnd) +int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struc= t dentry *dentry, const struct cpu_str *uni, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 umode= _t mode, dev_t dev, const char *symname, u32 size, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struc= t ntfs_fnd *fnd) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0int err; =C2=A0=C2=A0=C2=A0 =C2=A0struct super_block *sb =3D dir->i_sb; @@ -1239,6 +1238,9 @@ struct inode *ntfs_create_inode(struct mnt_idmap=20 *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0struct REPARSE_DATA_BUFFER *rp =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0bool rp_inserted =3D false; +=C2=A0=C2=A0 =C2=A0/* New file will be resident or non resident. */ +=C2=A0=C2=A0 =C2=A0const bool new_file_resident =3D 1; + =C2=A0=C2=A0=C2=A0 =C2=A0if (!fnd) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_lock_dir(dir_ni); @@ -1478,7 +1480,7 @@ struct inode *ntfs_create_inode(struct mnt_idmap=20 *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->size =3D cpu_to_le32(SIZ= EOF_RESIDENT); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->name_off =3D SIZEOF_RESI= DENT_LE; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->res.data_off =3D SIZEOF_= RESIDENT_LE; -=C2=A0=C2=A0 =C2=A0} else if (S_ISREG(mode)) { +=C2=A0=C2=A0 =C2=A0} else if (!new_file_resident && S_ISREG(mode)) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 * Regular file. Create empty = non resident data attribute. =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 */ @@ -1715,12 +1717,10 @@ struct inode *ntfs_create_inode(struct mnt_idmap=20 *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0if (!fnd) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_unlock(dir_ni); -=C2=A0=C2=A0 =C2=A0if (err) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return ERR_PTR(err); - -=C2=A0=C2=A0 =C2=A0unlock_new_inode(inode); +=C2=A0=C2=A0 =C2=A0if (!err) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unlock_new_inode(inode); -=C2=A0=C2=A0 =C2=A0return inode; +=C2=A0=C2=A0 =C2=A0return err; =C2=A0} =C2=A0int ntfs_link_inode(struct inode *inode, struct dentry *dentry) diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index edb6a7141246..71498421ce60 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -107,12 +107,8 @@ static struct dentry *ntfs_lookup(struct inode=20 *dir, struct dentry *dentry, =C2=A0static int ntfs_create(struct mnt_idmap *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 struct dentry *dentry, umode_t mode, bool excl) =C2=A0{ -=C2=A0=C2=A0 =C2=A0struct inode *inode; - -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFREG | mode, 0, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL, 0, NULL); - -=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; +=C2=A0=C2=A0 =C2=A0return ntfs_create_inode(idmap, dir, dentry, NULL, S_IF= REG | mode, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 NULL, 0, NULL); =C2=A0} =C2=A0/* @@ -123,12 +119,8 @@ static int ntfs_create(struct mnt_idmap *idmap,=20 struct inode *dir, =C2=A0static int ntfs_mknod(struct mnt_idmap *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= struct dentry *dentry, umode_t mode, dev_t rdev) =C2=A0{ -=C2=A0=C2=A0 =C2=A0struct inode *inode; - -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, m= ode, rdev,=20 NULL, 0, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL); - -=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; +=C2=A0=C2=A0 =C2=A0return ntfs_create_inode(idmap, dir, dentry, NULL, mode= , rdev, NULL, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 NULL); =C2=A0} =C2=A0/* @@ -200,15 +192,12 @@ static int ntfs_symlink(struct mnt_idmap *idmap,=20 struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct dent= ry *dentry, const char *symname) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0u32 size =3D strlen(symname); -=C2=A0=C2=A0 =C2=A0struct inode *inode; =C2=A0=C2=A0=C2=A0 =C2=A0if (unlikely(ntfs3_forced_shutdown(dir->i_sb))) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EIO; -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFLNK | 0777, 0, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 symname, size, NULL); - -=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; +=C2=A0=C2=A0 =C2=A0return ntfs_create_inode(idmap, dir, dentry, NULL, S_IF= LNK | 0777, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 symname, size, NULL); =C2=A0} =C2=A0/* @@ -217,12 +206,8 @@ static int ntfs_symlink(struct mnt_idmap *idmap,=20 struct inode *dir, =C2=A0static int ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= struct dentry *dentry, umode_t mode) =C2=A0{ -=C2=A0=C2=A0 =C2=A0struct inode *inode; - -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFDIR | mode, 0, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL, 0, NULL); - -=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; +=C2=A0=C2=A0 =C2=A0return ntfs_create_inode(idmap, dir, dentry, NULL, S_IF= DIR | mode, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 NULL, 0, NULL); =C2=A0} =C2=A0/* diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 79356fd29a14..3db6a61f61dc 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -714,11 +714,10 @@ int ntfs_sync_inode(struct inode *inode); =C2=A0int ntfs_flush_inodes(struct super_block *sb, struct inode *i1, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= struct inode *i2); =C2=A0int inode_write_data(struct inode *inode, const void *data, size_t b= ytes); -struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct dentry *dentry, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0const struct cpu_str *uni, umode_t mode, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0dev_t dev, const char *symname, u32 size, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct ntfs_fnd *fnd); +int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struc= t dentry *dentry, const struct cpu_str *uni, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 umode= _t mode, dev_t dev, const char *symname, u32 size, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struc= t ntfs_fnd *fnd); =C2=A0int ntfs_link_inode(struct inode *inode, struct dentry *dentry); =C2=A0int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry= ); =C2=A0void ntfs_evict_inode(struct inode *inode); --=20 2.34.1 From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 BBC6F139F; Wed, 17 Apr 2024 13:07:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359271; cv=none; b=koYPONM9QLrSlnoWrWRet5ckquYlE6M2adXEAHQx5mskY8qOyIU5H66B2F57MRuGgQnuvKmabWa1dEvz3dkNST+3wZNah1oqpHFKjpFtR//Fcsr9KgSHA/puT5JkmGDZplzHmwzgTxPyEY1ck2jjjdQBG6z/LDmDZbQlddFYfhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359271; c=relaxed/simple; bh=lmasahfYKfVOBZlqGI9lYCBg9fkni9arTHpxK4mtGXw=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=tIBnZuhAASw4+uwKHYJVdrktd5Qibrg0k1bmZLG7p+1iSTnb2P6nszuHph1LYRL+GTHlnPKKCOpr2Ldh2T2Q3ULSPZLhrwuE1UIsmoGLpUtGf1HB/zXnvWzOYF3gEyuJFq1XRpXJOue1LqSsBPU/duxEs9kMz2ZbFw0Rzy+0MTM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=KH9DerAQ; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=dysMG+oi; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="KH9DerAQ"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="dysMG+oi" Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 11E1D2126; Wed, 17 Apr 2024 13:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358818; bh=IMyO98h2ap+R+a4RgdmKeCsdfzkIWjUB3lBQadUdqOQ=; h=Date:Subject:From:To:References:In-Reply-To; b=KH9DerAQZXwiD/zM3X17AjS+GPdu7Y8kHwmMAh+GcEHp4ZY0SEEASN6tO7nzyq/Pm Euii0gQAmT5qhLo1c2Au0ZDHC9XeX2HRqcZZGdcunaaabLLX2VDJwnPnBPTn4+rgud gUA7cYpt3szPv5RM9aryTpBeIBUeRoZRMik1GXNE= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 03BC935D; Wed, 17 Apr 2024 13:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713359267; bh=IMyO98h2ap+R+a4RgdmKeCsdfzkIWjUB3lBQadUdqOQ=; h=Date:Subject:From:To:References:In-Reply-To; b=dysMG+oiiCetBRdhchoD5f2jOZhun7Gi7zy8ArGOJj2n+ANbkjGNM1RtT4qfqx2dE lw0XLZ2zALJKturXwTgTVunvLxkCSlItw4fktGKVC+Jji+E1LHBtJAZon5L+k7I0tl fyl736oKMIz7femYL5+WKArSkhvChHl3jxUuVuN4= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:07:46 +0300 Message-ID: Date: Wed, 17 Apr 2024 16:07:46 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 07/11] fs/ntfs3: Check 'folio' pointer for NULL From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) It can be NULL if bmap is called. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/inode.c | 17 +++++++++++------ =C2=A01 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 85a10d4a74c4..94177c1dd818 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -570,13 +570,18 @@ static noinline int ntfs_get_block_vbo(struct=20 inode *inode, u64 vbo, =C2=A0=C2=A0=C2=A0 =C2=A0clear_buffer_uptodate(bh); =C2=A0=C2=A0=C2=A0 =C2=A0if (is_resident(ni)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_lock(ni); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D attr_data_read_resident(ni, = &folio->page); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_unlock(ni); - -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!err) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0set_buffer_uptoda= te(bh); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0bh->b_blocknr =3D RESIDENT_LCN; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0bh->b_size =3D block_size; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!folio) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D 0; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} else { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_lock(ni); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D attr_data= _read_resident(ni, &folio->page); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_unlock(ni); + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!err) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0set_buffer_uptodate(bh); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return err; =C2=A0=C2=A0=C2=A0 =C2=A0} --=20 2.34.1 From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 26D1EEDC; Wed, 17 Apr 2024 13:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359293; cv=none; b=nWcdrdkeBgn1XIzt86i0+WHjjzKv8KRpOylO6yA0QkxdXSxt1Gj9+jnHmSPkdBB0l9hJOfSA6UJ+9IMFJFn9vC5vsg3KQyG4ae1G1zqAYfinr6Q/rwam9JGncBn6CHpGxFX/GV9tcwnQf/pHijWnNFC1vKLslsqqyUd3Q3yK/14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359293; c=relaxed/simple; bh=zB4pDB+1MwPVDU5eslMh2SAruBxdLfRVPm21RrqBJOk=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=VOi9wwHYYbTm+bby6glEE//tOM60y0NHXsggJpbMMKeyCDmksXTvmxgLMAGPsF2Q6PM5IQvLuug23U36BweciRSqGUeUr0vr6hxLsgZPIyDLD8RydIaz+vllX9wKrvSfJRRObAsdnwxmxHArmMgIvceljT3zoR9BVXo6nt6csGc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=ZSxgI9cI; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="ZSxgI9cI" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 5F0522126; Wed, 17 Apr 2024 13:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358839; bh=faaEBEoPf/qjweIscSis0xJmfoKEHMCDLYFkHEvEXk4=; h=Date:Subject:From:To:References:In-Reply-To; b=ZSxgI9cIaMLzufguDdMhDaTI3J8+HnDoz4+5IjcR3oUp9M5HhLKFny1SPVrrgY70A oSVN3Y35fsiaKKwq0I5inOGCPBuwWF8M5dpypn05UDn0Kyz006FzeeaV9ONqdU2jdp AMEJOf/gkEJEBdF+DsuvEGpGetrLxfKsuXZj8gm8= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:08:08 +0300 Message-ID: Date: Wed, 17 Apr 2024 16:08:07 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 08/11] fs/ntfs3: Always make file nonresident if fallocate (xfstest 438) From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/attrib.c=C2=A0 | 32 ++++++++++++++++++++++++++++++++ =C2=A0fs/ntfs3/file.c=C2=A0=C2=A0=C2=A0 |=C2=A0 9 +++++++++ =C2=A0fs/ntfs3/ntfs_fs.h |=C2=A0 1 + =C2=A03 files changed, 42 insertions(+) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 7aadf5010999..aedae36b91d0 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -2558,3 +2558,35 @@ int attr_insert_range(struct ntfs_inode *ni, u64=20 vbo, u64 bytes) =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0} + +/* + * attr_force_nonresident + * + * Convert default data attribute into non resident form. + */ +int attr_force_nonresident(struct ntfs_inode *ni) +{ +=C2=A0=C2=A0 =C2=A0int err; +=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr; +=C2=A0=C2=A0 =C2=A0struct ATTR_LIST_ENTRY *le =3D NULL; +=C2=A0=C2=A0 =C2=A0struct mft_inode *mi; + +=C2=A0=C2=A0 =C2=A0attr =3D ni_find_attr(ni, NULL, &le, ATTR_DATA, NULL, 0= , NULL, &mi); +=C2=A0=C2=A0 =C2=A0if (!attr) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_bad_inode(&ni->vfs_inode, "no d= ata attribute"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOENT; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0if (attr->non_res) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Already non resident. */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return 0; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0down_write(&ni->file.run_lock); +=C2=A0=C2=A0 =C2=A0err =3D attr_make_nonresident(ni, attr, le, mi, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0 le32_to_cpu(attr->res.data_size), +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0 &ni->file.run, &attr, NULL); +=C2=A0=C2=A0 =C2=A0up_write(&ni->file.run_lock); + +=C2=A0=C2=A0 =C2=A0return err; +} \ No newline at end of file diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 5418662c80d8..fce8ea098d60 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -578,6 +578,15 @@ static long ntfs_fallocate(struct file *file, int=20 mode, loff_t vbo, loff_t len) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Check new size. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u8 cluster_bits =3D sbi->clust= er_bits; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Be sure file is non resident. */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (is_resident(ni)) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_lock(ni); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D attr_forc= e_nonresident(ni); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_unlock(ni); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (err) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0goto out; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* generic/213: expected -ENOS= PC instead of -EFBIG. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!is_supported_holes) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0loff_t to_a= lloc =3D new_size - inode_get_bytes(inode); diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 3db6a61f61dc..00dec0ec5648 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -452,6 +452,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST=20 frame, size_t compr_size, =C2=A0int attr_collapse_range(struct ntfs_inode *ni, u64 vbo, u64 bytes); =C2=A0int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes); =C2=A0int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32=20 *frame_size); +int attr_force_nonresident(struct ntfs_inode *ni); =C2=A0/* Functions from attrlist.c */ =C2=A0void al_destroy(struct ntfs_inode *ni); --=20 2.34.1 From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 08D7613C9BF; Wed, 17 Apr 2024 13:08:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359311; cv=none; b=FFd5dmusEBexO7jQG64/AY4wd8botLR/P7cVSb5b6Oruy0GXyzthrVKuVrLjQYu6Y3pqsU76PCno8wGBh0E4tfVjudehxYD9OP27Ky8j+sKa57PQJGyznvt7GCGpCJs1VtUZe1EJ7g5JkX7VWK+qP0jIXLXYMWQv/IdOj1oPMh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359311; c=relaxed/simple; bh=8lhml+YZgdjn8NhCBVBuvir1Lph3FMmzF6dbSgoTgss=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=BK5cnDEdMebMqkCxt1hi8b7zv4EuTlbm9lx3oc2mgNAp1kD/3YVSvofRQmZg19yKtonvkC37vtuB1HfbrEa5ipEvdooYw4tUGoDbWI24cMuiXbQUfPIQz5r3wDVYvjQxgpxr1Yr1JO0cUxEmQ0/hh4pblQAAt3/ui6tc7GTjoo8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=c9rld15O; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=ajzIORTs; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="c9rld15O"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="ajzIORTs" Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 219912126; Wed, 17 Apr 2024 13:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358857; bh=prgkscqEDLQIeu/yy6QwD13KMz4blk3DXnk7Gem4noY=; h=Date:Subject:From:To:References:In-Reply-To; b=c9rld15O0zHZUUGxuKxM0t1kmvjmqY4rRlwvalNxKTGbsow0UKEtLGmm2sfudolIs HFu5G+h7qRIi/cDx2+24gAz+uGWq2ng3O4kYcO8FjrKA0SKnx19EeYYq2jBjScBIBn oEXHiqfbklD32UDiGOau6WM26LzYQXDQSHNxbpL0= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 138AB35D; Wed, 17 Apr 2024 13:08:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713359306; bh=prgkscqEDLQIeu/yy6QwD13KMz4blk3DXnk7Gem4noY=; h=Date:Subject:From:To:References:In-Reply-To; b=ajzIORTsFNjLVBZjpm9z0L7PWxTDZFVnIkONSEV13XxtlnyMT2DdFCeZJUdOcGFe3 7LNXEEszrbs5pdseE/pHmJJXViqJ8bFzqRVKNLQIUBGMnCiFkKl4ZVrRsP6wEhVBXS GoLX9PUSfPx4GpUKo0TmiPSFAO/Pp6AERY4t41VM= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:08:25 +0300 Message-ID: Date: Wed, 17 Apr 2024 16:08:25 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 09/11] fs/ntfs3: Optimize to store sorted attribute definition table From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) 0x18 bytes instead of 0xa0 Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/fsntfs.c=C2=A0 | 60 ++++++++++++++++++++++++++++- =C2=A0fs/ntfs3/inode.c=C2=A0=C2=A0 | 30 +++++++-------- =C2=A0fs/ntfs3/ntfs.h=C2=A0=C2=A0=C2=A0 |=C2=A0 4 -- =C2=A0fs/ntfs3/ntfs_fs.h | 40 ++++++++++--------- =C2=A0fs/ntfs3/super.c=C2=A0=C2=A0 | 95 +++++++++++++++-------------------= ------------ =C2=A0fs/ntfs3/xattr.c=C2=A0=C2=A0 |=C2=A0 6 +-- =C2=A06 files changed, 126 insertions(+), 109 deletions(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index ae2ef5c11868..f9c60f3cadaf 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -2698,4 +2698,62 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8=20 *label, int len) =C2=A0out: =C2=A0=C2=A0=C2=A0 =C2=A0__putname(uni); =C2=A0=C2=A0=C2=A0 =C2=A0return err; -} \ No newline at end of file +} + +/* + * Check $AttrDef content and store sorted small $AttrDef entries + */ +int ntfs_check_attr_def(struct ntfs_sb_info *sbi, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0const struct ATTR= _DEF_ENTRY *raw, u32 bytes) +{ +=C2=A0=C2=A0 =C2=A0const struct ATTR_DEF_ENTRY *de_s; +=C2=A0=C2=A0 =C2=A0struct ATTR_DEF_ENTRY_SMALL *de_d; +=C2=A0=C2=A0 =C2=A0u32 i, j; +=C2=A0=C2=A0 =C2=A0u32 max_attr_type; +=C2=A0=C2=A0 =C2=A0u32 n =3D (bytes / sizeof(*raw)) * sizeof(*raw); + +=C2=A0=C2=A0 =C2=A0for (i =3D 0, max_attr_type =3D 0, de_s =3D raw; i < n;= i++, de_s++) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u64 sz; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u32 attr_type =3D le32_to_cpu(de_s->= type); + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!attr_type) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if ((attr_type & 0xf) || (!i && ATTR= _STD !=3D de_s->type) || +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (i && le32_to_cpu= (de_s[-1].type) >=3D attr_type)) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EINVAL; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0max_attr_type =3D attr_type; + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sz =3D le64_to_cpu(de_s->max_sz); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (de_s->type =3D=3D ATTR_REPARSE) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->attrdef.rp_m= ax_size =3D sz; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0else if (de_s->type =3D=3D ATTR_EA) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->attrdef.ea_m= ax_size =3D sz; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0else if (de_s->type =3D=3D ATTR_LABE= L) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->attrdef.labe= l_max_size =3D sz; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0/* Last known attribute type is 0x100. */ +=C2=A0=C2=A0 =C2=A0if (!max_attr_type || max_attr_type > 0x200) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EINVAL; + +=C2=A0=C2=A0 =C2=A0n =3D max_attr_type >> 4; +=C2=A0=C2=A0 =C2=A0sbi->attrdef.table =3D kcalloc(n, sizeof(*de_d), GFP_KE= RNEL); +=C2=A0=C2=A0 =C2=A0if (!sbi->attrdef.table) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOMEM; + +=C2=A0=C2=A0 =C2=A0for (j =3D 0, de_s =3D raw; j < i; j++, de_s++) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u32 idx =3D (le32_to_cpu(de_s->type)= >> 4) - 1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0de_d =3D sbi->attrdef.table + idx; + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0de_d->type =3D de_s->type; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0de_d->flags =3D de_s->flags; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0de_d->min_sz =3D le64_to_cpu(de_s->m= in_sz); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0de_d->max_sz =3D le64_to_cpu(de_s->m= ax_sz); +=C2=A0=C2=A0 =C2=A0} +=C2=A0=C2=A0 =C2=A0sbi->attrdef.entries =3D n; + +=C2=A0=C2=A0 =C2=A0return 0; +} diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 94177c1dd818..ae4465bf099f 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -18,7 +18,7 @@ =C2=A0#include "ntfs_fs.h" =C2=A0/* - * ntfs_read_mft - Read record and parses MFT. + * ntfs_read_mft - Read record and parse MFT. =C2=A0 */ =C2=A0static struct inode *ntfs_read_mft(struct inode *inode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 const struct cpu_str *name, @@ -1090,29 +1090,27 @@ int ntfs_flush_inodes(struct super_block *sb,=20 struct inode *i1, =C2=A0=C2=A0=C2=A0 =C2=A0return ret; =C2=A0} -int inode_write_data(struct inode *inode, const void *data, size_t bytes) +/* + * Helper function to read file. + */ +int inode_read_data(struct inode *inode, void *data, size_t bytes) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0pgoff_t idx; +=C2=A0=C2=A0 =C2=A0struct address_space *mapping =3D inode->i_mapping; -=C2=A0=C2=A0 =C2=A0/* Write non resident data. */ =C2=A0=C2=A0=C2=A0 =C2=A0for (idx =3D 0; bytes; idx++) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0size_t op =3D bytes > PAGE_SIZ= E ? PAGE_SIZE : bytes; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct page *page =3D ntfs_map_page(= inode->i_mapping, idx); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct page *page =3D read_mapping_p= age(mapping, idx, NULL); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0void *kaddr; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ERR(page)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return PTR_= ERR(page); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0lock_page(page); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0WARN_ON(!PageUptodate(page)); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ClearPageUptodate(page); - -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(page_address(page), data, op); - -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0flush_dcache_page(page); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0SetPageUptodate(page); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unlock_page(page); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kaddr =3D kmap_atomic(page); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(data, kaddr, op); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kunmap_atomic(kaddr); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_unmap_page(page); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0put_page(page); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0bytes -=3D op; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0data =3D Add2Ptr(data, PAGE_SI= ZE); @@ -1160,7 +1158,7 @@ ntfs_create_reparse_buffer(struct ntfs_sb_info=20 *sbi, const char *symname, =C2=A0=C2=A0=C2=A0 =C2=A0/* err =3D the length of unicode name of symlink.= */ =C2=A0=C2=A0=C2=A0 =C2=A0*nsize =3D ntfs_reparse_bytes(err); -=C2=A0=C2=A0 =C2=A0if (*nsize > sbi->reparse.max_size) { +=C2=A0=C2=A0 =C2=A0if (*nsize > sbi->attrdef.rp_max_size) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EFBIG; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -1954,7 +1952,7 @@ static noinline int ntfs_readlink_hlp(const struct=20 dentry *link_de, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0rp =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0if (size > sbi->reparse.max_size || size <=3D sizeof(u3= 2)) +=C2=A0=C2=A0 =C2=A0if (size > sbi->attrdef.rp_max_size || size <=3D sizeof= (u32)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0if (!rp) { diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index 3d6143c7abc0..1dd03ba1dc93 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -817,7 +817,6 @@ struct VOLUME_INFO { =C2=A0#define SIZEOF_ATTRIBUTE_VOLUME_INFO 0xc -#define NTFS_LABEL_MAX_LENGTH=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0(0x100 = / sizeof(short)) =C2=A0#define NTFS_ATTR_INDEXABLE=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0cpu= _to_le32(0x00000002) =C2=A0#define NTFS_ATTR_DUPALLOWED=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0cp= u_to_le32(0x00000004) =C2=A0#define NTFS_ATTR_MUST_BE_INDEXED=C2=A0=C2=A0 =C2=A0cpu_to_le32(0x00= 000010) @@ -1002,9 +1001,6 @@ struct REPARSE_POINT { =C2=A0static_assert(sizeof(struct REPARSE_POINT) =3D=3D 0x18); -/* Maximum allowed size of the reparse data. */ -#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE=C2=A0=C2=A0 =C2=A0(16 * 1024) - =C2=A0/* =C2=A0 * The value of the following constant needs to satisfy the following =C2=A0 * conditions: diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 00dec0ec5648..1d4fb6f87dea 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -201,6 +201,15 @@ struct ntfs_index { =C2=A0=C2=A0=C2=A0 =C2=A0u8 type; // index_mutex_classed =C2=A0}; +/* NOT ondisk!. Just a small copy of $AttrDef file entry. */ +struct ATTR_DEF_ENTRY_SMALL { +=C2=A0=C2=A0 =C2=A0enum ATTR_TYPE type; +=C2=A0=C2=A0 =C2=A0__le32 flags; +=C2=A0=C2=A0 =C2=A0u64 min_sz; +=C2=A0=C2=A0 =C2=A0u64 max_sz; +}; +static_assert(sizeof(struct ATTR_DEF_ENTRY_SMALL) =3D=3D 0x18); + =C2=A0/* Minimum MFT zone. */ =C2=A0#define NTFS_MIN_MFT_ZONE 100 =C2=A0/* Step to increase the MFT. */ @@ -242,9 +251,13 @@ struct ntfs_sb_info { =C2=A0=C2=A0=C2=A0 =C2=A0CLST reparse_no; =C2=A0=C2=A0=C2=A0 =C2=A0CLST usn_jrnl_no; -=C2=A0=C2=A0 =C2=A0struct ATTR_DEF_ENTRY *def_table; // Attribute definiti= on table. -=C2=A0=C2=A0 =C2=A0u32 def_entries; -=C2=A0=C2=A0 =C2=A0u32 ea_max_size; +=C2=A0=C2=A0 =C2=A0struct { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u64 rp_max_size; // 16K +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u32 entries; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u32 ea_max_size; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u32 label_max_size; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTR_DEF_ENTRY_SMALL *table; = // 'entries'. +=C2=A0=C2=A0 =C2=A0} attrdef; =C2=A0=C2=A0=C2=A0 =C2=A0struct MFT_REC *new_rec; @@ -296,7 +309,6 @@ struct ntfs_sb_info { =C2=A0=C2=A0=C2=A0 =C2=A0struct { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_index index_r; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u64 max_size; // 16K =C2=A0=C2=A0=C2=A0 =C2=A0} reparse; =C2=A0=C2=A0=C2=A0 =C2=A0struct { @@ -658,6 +670,8 @@ int run_deallocate(struct ntfs_sb_info *sbi, const=20 struct runs_tree *run, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 bool trim); =C2=A0bool valid_windows_name(struct ntfs_sb_info *sbi, const struct le_st= r=20 *name); =C2=A0int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len); +int ntfs_check_attr_def(struct ntfs_sb_info *sbi, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0const struct ATTR= _DEF_ENTRY *raw, u32 bytes); =C2=A0/* Globals from index.c */ =C2=A0int indx_used_bit(struct ntfs_index *indx, struct ntfs_inode *ni,=20 size_t *bit); @@ -714,7 +728,7 @@ int ntfs3_write_inode(struct inode *inode, struct=20 writeback_control *wbc); =C2=A0int ntfs_sync_inode(struct inode *inode); =C2=A0int ntfs_flush_inodes(struct super_block *sb, struct inode *i1, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= struct inode *i2); -int inode_write_data(struct inode *inode, const void *data, size_t bytes); +int inode_read_data(struct inode *inode, void *data, size_t bytes); =C2=A0int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= struct dentry *dentry, const struct cpu_str *uni, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= umode_t mode, dev_t dev, const char *symname, u32 size, @@ -908,22 +922,6 @@ static inline bool ntfs_is_meta_file(struct=20 ntfs_sb_info *sbi, CLST rno) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rno =3D=3D s= bi->usn_jrnl_no; =C2=A0} -static inline void ntfs_unmap_page(struct page *page) -{ -=C2=A0=C2=A0 =C2=A0kunmap(page); -=C2=A0=C2=A0 =C2=A0put_page(page); -} - -static inline struct page *ntfs_map_page(struct address_space *mapping, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0 unsigned long index) -{ -=C2=A0=C2=A0 =C2=A0struct page *page =3D read_mapping_page(mapping, index,= NULL); - -=C2=A0=C2=A0 =C2=A0if (!IS_ERR(page)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kmap(page); -=C2=A0=C2=A0 =C2=A0return page; -} - =C2=A0static inline size_t wnd_zone_bit(const struct wnd_bitmap *wnd) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0return wnd->zone_bit; diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index ac4722011140..8beefbca5769 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -624,7 +624,7 @@ static void ntfs3_free_sbi(struct ntfs_sb_info *sbi) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0kfree(sbi->new_rec); =C2=A0=C2=A0=C2=A0 =C2=A0kvfree(ntfs_put_shared(sbi->upcase)); -=C2=A0=C2=A0 =C2=A0kvfree(sbi->def_table); +=C2=A0=C2=A0 =C2=A0kfree(sbi->attrdef.table); =C2=A0=C2=A0=C2=A0 =C2=A0kfree(sbi->compress.lznt); =C2=A0#ifdef CONFIG_NTFS3_LZX_XPRESS =C2=A0=C2=A0=C2=A0 =C2=A0xpress_free_decompressor(sbi->compress.xpress); @@ -1157,8 +1157,6 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0CLST vcn, lcn, len; =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr; =C2=A0=C2=A0=C2=A0 =C2=A0const struct VOLUME_INFO *info; -=C2=A0=C2=A0 =C2=A0u32 idx, done, bytes; -=C2=A0=C2=A0 =C2=A0struct ATTR_DEF_ENTRY *t; =C2=A0=C2=A0=C2=A0 =C2=A0u16 *shared; =C2=A0=C2=A0=C2=A0 =C2=A0struct MFT_REF ref; =C2=A0=C2=A0=C2=A0 =C2=A0bool ro =3D sb_rdonly(sb); @@ -1199,7 +1197,7 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0/* =C2=A0=C2=A0=C2=A0 =C2=A0 * Load $Volume. This should be done before $LogF= ile -=C2=A0=C2=A0 =C2=A0 * 'cause 'sbi->volume.ni' is used 'ntfs_set_state'. +=C2=A0=C2=A0 =C2=A0 * 'cause 'sbi->volume.ni' is used in 'ntfs_set_state'. =C2=A0=C2=A0=C2=A0 =C2=A0 */ =C2=A0=C2=A0=C2=A0 =C2=A0ref.low =3D cpu_to_le32(MFT_REC_VOL); =C2=A0=C2=A0=C2=A0 =C2=A0ref.seq =3D cpu_to_le16(MFT_REC_VOL); @@ -1422,54 +1420,28 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto put_inode_out; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0bytes =3D inode->i_size; -=C2=A0=C2=A0 =C2=A0sbi->def_table =3D t =3D kvmalloc(bytes, GFP_KERNEL); -=C2=A0=C2=A0 =C2=A0if (!t) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -ENOMEM; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto put_inode_out; -=C2=A0=C2=A0 =C2=A0} - -=C2=A0=C2=A0 =C2=A0for (done =3D idx =3D 0; done < bytes; done +=3D PAGE_S= IZE, idx++) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unsigned long tail =3D bytes - done; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct page *page =3D ntfs_map_page(= inode->i_mapping, idx); - -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ERR(page)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D PTR_ERR(p= age); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Fai= led to read $AttrDef (%d).", err); +=C2=A0=C2=A0 =C2=A0{ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u32 bytes =3D inode->i_size; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTR_DEF_ENTRY *def_table =3D= kmalloc(bytes, GFP_KERNEL); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!def_table) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -ENOMEM; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto put_in= ode_out; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(Add2Ptr(t, done), page_addres= s(page), -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= min(PAGE_SIZE, tail)); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_unmap_page(page); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!idx && ATTR_STD !=3D t->type) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "$At= trDef is corrupted."); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EINVAL; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto put_inode_ou= t; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Read the entire file. */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D inode_read_data(inode, def_t= able, bytes); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (err) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Fai= led to read $AttrDef (%d).", err); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} else { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Check content = and store sorted array. */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D ntfs_chec= k_attr_def(sbi, def_table, bytes); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (err) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0ntfs_err(sb, "$AttrDef is corrupted."); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0} - -=C2=A0=C2=A0 =C2=A0t +=3D 1; -=C2=A0=C2=A0 =C2=A0sbi->def_entries =3D 1; -=C2=A0=C2=A0 =C2=A0done =3D sizeof(struct ATTR_DEF_ENTRY); -=C2=A0=C2=A0 =C2=A0sbi->reparse.max_size =3D MAXIMUM_REPARSE_DATA_BUFFER_S= IZE; -=C2=A0=C2=A0 =C2=A0sbi->ea_max_size =3D 0x10000; /* default formatter valu= e */ - -=C2=A0=C2=A0 =C2=A0while (done + sizeof(struct ATTR_DEF_ENTRY) <=3D bytes)= { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u32 t32 =3D le32_to_cpu(t->type); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u64 sz =3D le64_to_cpu(t->max_sz); - -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if ((t32 & 0xF) || le32_to_cpu(t[-1]= .type) >=3D t32) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; - -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (t->type =3D=3D ATTR_REPARSE) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->reparse.max_= size =3D sz; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0else if (t->type =3D=3D ATTR_EA) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->ea_max_size = =3D sz; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0done +=3D sizeof(struct ATTR_DEF_ENT= RY); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0t +=3D 1; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->def_entries +=3D 1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kfree(def_table); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (err) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto put_inode_ou= t; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0iput(inode); @@ -1489,27 +1461,22 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto put_inode_out; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0for (idx =3D 0; idx < (0x10000 * sizeof(short) >> PAGE_= SHIFT); idx++) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0const __le16 *src; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u16 *dst =3D Add2Ptr(sbi->upcase, id= x << PAGE_SHIFT); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct page *page =3D ntfs_map_page(= inode->i_mapping, idx); - -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ERR(page)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D PTR_ERR(p= age); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Fai= led to read $UpCase (%d).", err); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto put_inode_ou= t; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} - -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0src =3D page_address(page); +=C2=A0=C2=A0 =C2=A0/* Read the entire file. */ +=C2=A0=C2=A0 =C2=A0err =3D inode_read_data(inode, sbi->upcase, 0x10000 * s= izeof(short)); +=C2=A0=C2=A0 =C2=A0if (err) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sb, "Failed to read $UpCase= (%d).", err); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto put_inode_out; +=C2=A0=C2=A0 =C2=A0} =C2=A0#ifdef __BIG_ENDIAN -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0for (i =3D 0; i < PAGE_SIZE / sizeof= (u16); i++) +=C2=A0=C2=A0 =C2=A0{ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0const __le16 *src =3D sbi->upcase; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u16 *dst =3D sbi->upcase; + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0for (i =3D 0; i < 0x10000; i++) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0*dst++ =3D = le16_to_cpu(*src++); -#else -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(dst, src, PAGE_SIZE); -#endif -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_unmap_page(page); =C2=A0=C2=A0=C2=A0 =C2=A0} +#endif =C2=A0=C2=A0=C2=A0 =C2=A0shared =3D ntfs_set_shared(sbi->upcase, 0x10000 *= sizeof(short)); =C2=A0=C2=A0=C2=A0 =C2=A0if (shared && sbi->upcase !=3D shared) { diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 872df2197202..a7f122e51c04 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -99,12 +99,12 @@ static int ntfs_read_ea(struct ntfs_inode *ni,=20 struct EA_FULL **ea, =C2=A0=C2=A0=C2=A0 =C2=A0/* Check Ea limit. */ =C2=A0=C2=A0=C2=A0 =C2=A0size =3D le32_to_cpu((*info)->size); -=C2=A0=C2=A0 =C2=A0if (size > sbi->ea_max_size) { +=C2=A0=C2=A0 =C2=A0if (size > sbi->attrdef.ea_max_size) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EFBIG; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0if (attr_size(attr_ea) > sbi->ea_max_size) { +=C2=A0=C2=A0 =C2=A0if (attr_size(attr_ea) > sbi->attrdef.ea_max_size) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EFBIG; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -430,7 +430,7 @@ static noinline int ntfs_set_ea(struct inode *inode,=20 const char *name, =C2=A0=C2=A0=C2=A0 =C2=A0 * 1. Check ea_info.size_pack for overflow. =C2=A0=C2=A0=C2=A0 =C2=A0 * 2. New attribute size must fit value from $Att= rDef =C2=A0=C2=A0=C2=A0 =C2=A0 */ -=C2=A0=C2=A0 =C2=A0if (new_pack > 0xffff || size > sbi->ea_max_size) { +=C2=A0=C2=A0 =C2=A0if (new_pack > 0xffff || size > sbi->attrdef.ea_max_siz= e) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_inode_warn( =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"The size o= f extended attributes must not exceed 64KiB"); --=20 2.34.1 From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 E880013BAFB; Wed, 17 Apr 2024 13:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359346; cv=none; b=b572aq8dTQmAZIqqySVP633DgNveoWLiOnRLwjt/0rVDC7lAN0grrLcS6C21an3nfmT/8T+pinoEHXUh47AXH5OmPd4+fyMWsRBtcCrveBvp2fyRgB6IJyZ8SeejYK/My27OkSSOE71ytDMC7x4tuuTAuWbrt35ghTZ8BgLIqbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359346; c=relaxed/simple; bh=DatEFLCOpw+NbDuENy+FYJ2ABAdky5Z6lhP8M4gukFg=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=QZR9poAEGAEbvM+dg+R/yOAx4w9LQtxB4t0Jqy6bCNldHfaUKmYRMrNTKp0YNPnaUrBsMKtSdydDPwMxKwW8L95WgNOcYctTxiyEhDLYfOxtLf3oQ1AMJ22tnUjxb+5Xg4aNR86tM1Sc22ERnix7os4+m+5zbuny8XRA/q+cfek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=rnCYxvs0; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="rnCYxvs0" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 120BF2126; Wed, 17 Apr 2024 13:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358892; bh=MOOj/f32Isl8H3mG7B5vylZH6udxOz6XAGuNohryItc=; h=Date:Subject:From:To:References:In-Reply-To; b=rnCYxvs0Dbuue93udczCqEBBKnJpqbKEvt1OlSql5WaaVIR85ojHVyhtQaNpEfiyQ ZejcHoT++YsK461jmTz7+ZoUT3LzlisE58FGBvGu8nJiRAwvpnxJH/swpfnV51YgxL PnkhCmbDHiBqlEYIxZcdTUxl2cH7m5xh6aZzkI0M= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:09:00 +0300 Message-ID: <890cc224-fdb8-4c5e-a22e-b96dc86e6908@paragon-software.com> Date: Wed, 17 Apr 2024 16:09:00 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 10/11] fs/ntfs3: Remove cached label from sbi From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Add more checks using $AttrDef. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/attrib.c=C2=A0 | 71 +++++++++++++++++++++++++++++++++++++++= +++++++ =C2=A0fs/ntfs3/fsntfs.c=C2=A0 | 17 ++++------- =C2=A0fs/ntfs3/ntfs_fs.h | 27 +++++++++++++++++- =C2=A0fs/ntfs3/super.c=C2=A0=C2=A0 | 49 +++++++++++++++++++------------- =C2=A04 files changed, 132 insertions(+), 32 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index aedae36b91d0..acee4644fd8d 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -228,6 +228,7 @@ int attr_make_nonresident(struct ntfs_inode *ni,=20 struct ATTRIB *attr, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 u64 = new_size, struct runs_tree *run, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 stru= ct ATTRIB **ins_attr, struct page *page) =C2=A0{ +=C2=A0=C2=A0 =C2=A0const struct ATTR_DEF_ENTRY_SMALL *q; =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi; =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr_s; =C2=A0=C2=A0=C2=A0 =C2=A0struct MFT_REC *rec; @@ -243,6 +244,22 @@ int attr_make_nonresident(struct ntfs_inode *ni,=20 struct ATTRIB *attr, =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0sbi =3D mi->sbi; + +=C2=A0=C2=A0 =C2=A0/* Check if we can use nonresident form. */ +=C2=A0=C2=A0 =C2=A0q =3D ntfs_query_def(sbi, attr->type); +=C2=A0=C2=A0 =C2=A0if (!q) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_set_state(sbi, NTFS_DIRTY_ERROR= ); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EINVAL; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0/* Check resident form. */ +=C2=A0=C2=A0 =C2=A0if (q->flags & NTFS_ATTR_MUST_BE_RESIDENT) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_warn(sbi->sb, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 "attribute= %x is not allowed to be nonresident", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 le32_to_cp= u(attr->type)); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EINVAL; +=C2=A0=C2=A0 =C2=A0} + =C2=A0=C2=A0=C2=A0 =C2=A0rec =3D mi->mrec; =C2=A0=C2=A0=C2=A0 =C2=A0attr_s =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0used =3D le32_to_cpu(rec->used); @@ -2589,4 +2606,58 @@ int attr_force_nonresident(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0up_write(&ni->file.run_lock); =C2=A0=C2=A0=C2=A0 =C2=A0return err; +} + +/* + * Returns true if attribute is ok + */ +bool attr_check(const struct ATTRIB *attr, struct ntfs_sb_info *sbi, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni) +{ +=C2=A0=C2=A0 =C2=A0u64 size; +=C2=A0=C2=A0 =C2=A0const char *hint; +=C2=A0=C2=A0 =C2=A0const struct ATTR_DEF_ENTRY_SMALL *q =3D ntfs_query_def= (sbi, attr->type); + +=C2=A0=C2=A0 =C2=A0if (!q) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0hint =3D "unknown"; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0/* Check resident form. */ +=C2=A0=C2=A0 =C2=A0if ((q->flags & NTFS_ATTR_MUST_BE_RESIDENT) && attr->no= n_res) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0hint =3D "must be resident"; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0/* Check name. */ +=C2=A0=C2=A0 =C2=A0if ((q->flags & NTFS_ATTR_MUST_BE_NAMED) && !attr->name= _len) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0hint =3D "must be named"; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0/* Check size. */ +=C2=A0=C2=A0 =C2=A0size =3D attr_size(attr); +=C2=A0=C2=A0 =C2=A0if (size < q->min_sz) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0hint =3D "minimum size"; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0if (size > q->max_sz) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0hint =3D "maximum size"; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0/* ok. */ +=C2=A0=C2=A0 =C2=A0return true; + +out: +=C2=A0=C2=A0 =C2=A0if (ni) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_inode_err(&ni->vfs_inode, "attr= ibute type=3D%x, %s", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 le32_to_cpu(attr->type), hint); +=C2=A0=C2=A0 =C2=A0else +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err(sbi->sb, "attribute type=3D= %x, %s", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 le32_to_cpu(attr= ->type), hint); + +=C2=A0=C2=A0 =C2=A0ntfs_set_state(sbi, NTFS_DIRTY_ERROR); +=C2=A0=C2=A0 =C2=A0return false; =C2=A0} \ No newline at end of file diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index f9c60f3cadaf..5dacb8301202 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -2650,8 +2650,8 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8=20 *label, int len) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0int err; =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr; +=C2=A0=C2=A0 =C2=A0u32 uni_bytes; =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni =3D sbi->volume.ni; -=C2=A0=C2=A0 =C2=A0const u8 max_ulen =3D 0x80; /* TODO: use attrdef to get= maximum length */ =C2=A0=C2=A0=C2=A0 =C2=A0/* Allocate PATH_MAX bytes. */ =C2=A0=C2=A0=C2=A0 =C2=A0struct cpu_str *uni =3D __getname(); @@ -2663,7 +2663,8 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8=20 *label, int len) =C2=A0=C2=A0=C2=A0 =C2=A0if (err < 0) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; -=C2=A0=C2=A0 =C2=A0if (uni->len > max_ulen) { +=C2=A0=C2=A0 =C2=A0uni_bytes =3D uni->len * sizeof(u16); +=C2=A0=C2=A0 =C2=A0if (uni_bytes > sbi->attrdef.label_max_size) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_warn(sbi->sb, "new label = is too long"); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EFBIG; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; @@ -2674,19 +2675,13 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8=20 *label, int len) =C2=A0=C2=A0=C2=A0 =C2=A0/* Ignore any errors. */ =C2=A0=C2=A0=C2=A0 =C2=A0ni_remove_attr(ni, ATTR_LABEL, NULL, 0, false, NU= LL); -=C2=A0=C2=A0 =C2=A0err =3D ni_insert_resident(ni, uni->len * sizeof(u16), = ATTR_LABEL, NULL, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 0, &attr, NULL, NULL); +=C2=A0=C2=A0 =C2=A0err =3D ni_insert_resident(ni, uni_bytes, ATTR_LABEL, N= ULL, 0, &attr, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 NULL, NULL); =C2=A0=C2=A0=C2=A0 =C2=A0if (err < 0) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto unlock_out; =C2=A0=C2=A0=C2=A0 =C2=A0/* write new label in on-disk struct. */ -=C2=A0=C2=A0 =C2=A0memcpy(resident_data(attr), uni->name, uni->len * sizeo= f(u16)); - -=C2=A0=C2=A0 =C2=A0/* update cached value of current label. */ -=C2=A0=C2=A0 =C2=A0if (len >=3D ARRAY_SIZE(sbi->volume.label)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0len =3D ARRAY_SIZE(sbi->volume.label= ) - 1; -=C2=A0=C2=A0 =C2=A0memcpy(sbi->volume.label, label, len); -=C2=A0=C2=A0 =C2=A0sbi->volume.label[len] =3D 0; +=C2=A0=C2=A0 =C2=A0memcpy(resident_data(attr), uni->name, uni_bytes); =C2=A0=C2=A0=C2=A0 =C2=A0mark_inode_dirty_sync(&ni->vfs_inode); =C2=A0unlock_out: diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 1d4fb6f87dea..12c392db5b08 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -293,7 +293,6 @@ struct ntfs_sb_info { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0__le16 flags; // Cached curren= t VOLUME_INFO::flags,=20 VOLUME_FLAG_DIRTY. =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u8 major_ver; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u8 minor_ver; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0char label[256]; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0bool real_dirty; // Real fs st= ate. =C2=A0=C2=A0=C2=A0 =C2=A0} volume; @@ -465,6 +464,8 @@ int attr_collapse_range(struct ntfs_inode *ni, u64=20 vbo, u64 bytes); =C2=A0int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes); =C2=A0int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32=20 *frame_size); =C2=A0int attr_force_nonresident(struct ntfs_inode *ni); +bool attr_check(const struct ATTRIB *attr, struct ntfs_sb_info *sbi, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni); =C2=A0/* Functions from attrlist.c */ =C2=A0void al_destroy(struct ntfs_inode *ni); @@ -1152,4 +1153,28 @@ static inline void le64_sub_cpu(__le64 *var, u64 val) =C2=A0=C2=A0=C2=A0 =C2=A0*var =3D cpu_to_le64(le64_to_cpu(*var) - val); =C2=A0} +/* + * Attributes types: 0x10, 0x20, 0x30.... + * indexes in attribute table:=C2=A0 0, 1, 2... + */ +static inline const struct ATTR_DEF_ENTRY_SMALL * +ntfs_query_def(const struct ntfs_sb_info *sbi, enum ATTR_TYPE type) +{ +=C2=A0=C2=A0 =C2=A0const struct ATTR_DEF_ENTRY_SMALL *q; +=C2=A0=C2=A0 =C2=A0u32 idx =3D (le32_to_cpu(type) >> 4) - 1; + +=C2=A0=C2=A0 =C2=A0if (idx >=3D sbi->attrdef.entries) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* such attribute is not allowed in = this ntfs. */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return NULL; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0q =3D sbi->attrdef.table + idx; +=C2=A0=C2=A0 =C2=A0if (!q->type) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* such attribute is not allowed in = this ntfs. */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return NULL; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0return q; +} + =C2=A0#endif /* _LINUX_NTFS3_NTFS_FS_H */ diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 8beefbca5769..dae961d2d6f8 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -481,11 +481,39 @@ static int ntfs3_volinfo_open(struct inode *inode,=20 struct file *file) =C2=A0/* read /proc/fs/ntfs3//label */ =C2=A0static int ntfs3_label_show(struct seq_file *m, void *o) =C2=A0{ +=C2=A0=C2=A0 =C2=A0int len; =C2=A0=C2=A0=C2=A0 =C2=A0struct super_block *sb =3D m->private; =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi =3D sb->s_fs_info; +=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr; +=C2=A0=C2=A0 =C2=A0u8 *label =3D kmalloc(PAGE_SIZE, GFP_NOFS); + +=C2=A0=C2=A0 =C2=A0if (!label) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOMEM; + +=C2=A0=C2=A0 =C2=A0attr =3D ni_find_attr(sbi->volume.ni, NULL, NULL, ATTR_= LABEL, NULL, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 NULL, NULL); + +=C2=A0=C2=A0 =C2=A0if (!attr) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* It is ok if no ATTR_LABEL */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0label[0] =3D 0; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0len =3D 0; +=C2=A0=C2=A0 =C2=A0} else if (!attr_check(attr, sbi, sbi->volume.ni)) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0len =3D sprintf(label, "%pg: failed = to get label", sb->s_bdev); +=C2=A0=C2=A0 =C2=A0} else { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0len =3D ntfs_utf16_to_nls(sbi, resid= ent_data(attr), +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0le32_to_cpu(attr->res.data_size) >> 1, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0label, PAGE_SIZE); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (len < 0) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0label[0] =3D 0; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0len =3D 0; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} else if (len >=3D PAGE_SIZE) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0len =3D PAGE_SIZE= - 1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} +=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0seq_printf(m, "%s\n", sbi->volume.label); +=C2=A0=C2=A0 =C2=A0seq_printf(m, "%.*s\n", len, label); +=C2=A0=C2=A0 =C2=A0kfree(label); =C2=A0=C2=A0=C2=A0 =C2=A0return 0; =C2=A0} @@ -1210,25 +1238,6 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0ni =3D ntfs_i(inode); -=C2=A0=C2=A0 =C2=A0/* Load and save label (not necessary). */ -=C2=A0=C2=A0 =C2=A0attr =3D ni_find_attr(ni, NULL, NULL, ATTR_LABEL, NULL,= 0, NULL, NULL); - -=C2=A0=C2=A0 =C2=A0if (!attr) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* It is ok if no ATTR_LABEL */ -=C2=A0=C2=A0 =C2=A0} else if (!attr->non_res && !is_attr_ext(attr)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* $AttrDef allows labels to be up t= o 128 symbols. */ -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D utf16s_to_utf8s(resident_dat= a(attr), -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 le32_to_cpu(attr->res.data_size) >> 1, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 UTF16_LITTLE_ENDIAN, sbi->volume.label, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof(sbi->volume.label)); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (err < 0) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->volume.label= [0] =3D 0; -=C2=A0=C2=A0 =C2=A0} else { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Should we break mounting here? */ -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0//err =3D -EINVAL; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0//goto put_inode_out; -=C2=A0=C2=A0 =C2=A0} - =C2=A0=C2=A0=C2=A0 =C2=A0attr =3D ni_find_attr(ni, attr, NULL, ATTR_VOL_IN= FO, NULL, 0, NULL,=20 NULL); =C2=A0=C2=A0=C2=A0 =C2=A0if (!attr || is_attr_ext(attr) || =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 !(info =3D resident_data_ex(at= tr, SIZEOF_ATTRIBUTE_VOLUME_INFO))) { --=20 2.34.1 From nobody Fri May 17 12:14:42 2024 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 37BF4EDC; Wed, 17 Apr 2024 13:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359466; cv=none; b=dhspo5p1Z5OS/hJ41Za4Ayg2z6sqCLxYFkTw7t0IIfXoqRg7JeELpPuAYpfq5ZvW01iVgtL/90EcAJGLkEv+xmBKMFFnm9Uy4li+t7Zj+S4Opr6FkZE1DpP24cdEQP0kHpQQldzq1z8CKHacgms+6WaYzQq6SiSQKKfUBmfkEKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359466; c=relaxed/simple; bh=0YKqo7UEfJKQTsq4A++ORS6N4xFhJAVWzE9smktPIoo=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=HZ8+2PIidh606QyaDkQMKCnZuagSV/wEhbNtPw8wI1dMgJR8uYnKk9113UYK7RLF2ny/tQu8rBSG0fEqLAMmZwIo6RQrd6V1RRkMsd73f26P5vk+YtKv2Yw/dRZdHyb5Ki8TY2EHhjgg1mNxFf8/iIVYvSVNIGcRwI2QJ5u3pq0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=HfYkZrL7; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="HfYkZrL7" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 734F02126; Wed, 17 Apr 2024 13:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713359011; bh=G9XKR3MvwzmqgbDgmesN/ZrFgai4sTl/pKO/5Nm44xg=; h=Date:Subject:From:To:References:In-Reply-To; b=HfYkZrL74s4E2urBXmM9SZ7LkdD5mMF2+KT0+6GvTuamYWDEv10u/q+iiicEbpmPi XDdhhg/N1ulH+PzEczm03Tz6uzwhJ/kUWhUAby+uFzWap1CJXVwwbAMrzxuj2Z39Tu zSDt/loGGudbXmgZHZWiBA8z3VTj2/M+9AqUgYHQ= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:10:59 +0300 Message-ID: <0cb0b314-e4f6-40a2-9628-0fe7d905a676@paragon-software.com> Date: Wed, 17 Apr 2024 16:10:59 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 11/11] fs/ntfs3: Taking DOS names into account during link counting From: Konstantin Komarov To: , LKML , Linux-fsdevel , Johan Hovold , "Matthew Wilcox (Oracle)" , Anton Altaparmakov References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) When counting and checking hard links in an ntfs file record, =C2=A0 struct MFT_REC { =C2=A0=C2=A0=C2=A0 struct NTFS_RECORD_HEADER rhdr; // 'FILE' =C2=A0=C2=A0=C2=A0 __le16 seq;=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0// 0x1= 0: Sequence number for this record. >>=C2=A0 __le16 hard_links;=C2=A0=C2=A0 =C2=A0// 0x12: The number of hard = links to record. =C2=A0=C2=A0=C2=A0 __le16 attr_off;=C2=A0=C2=A0 =C2=A0// 0x14: Offset to a= ttributes. =C2=A0 ... the ntfs3 driver ignored short names (DOS names), causing the link count to be reduced by 1 and messages to be output to dmesg. For Windows, such a situation is a minor error, meaning chkdsk does not=20 report errors on such a volume, and in the case of using the /f switch, it silently corrects them, reporting that no errors were found. This does not affect the consistency of the file system. Nevertheless, the behavior in the ntfs3 driver is incorrect and changes the content of the file system. This patch should fix that. PS: most likely, there has been a confusion of concepts MFT_REC::hard_links and inode::__i_nlink. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/inode.c=C2=A0 |=C2=A0 7 ++++--- =C2=A0fs/ntfs3/record.c | 11 ++--------- =C2=A02 files changed, 6 insertions(+), 12 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index ae4465bf099f..f98200b1a4d2 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -37,7 +37,7 @@ static struct inode *ntfs_read_mft(struct inode *inode, =C2=A0=C2=A0=C2=A0 =C2=A0bool is_dir; =C2=A0=C2=A0=C2=A0 =C2=A0unsigned long ino =3D inode->i_ino; =C2=A0=C2=A0=C2=A0 =C2=A0u32 rp_fa =3D 0, asize, t32; -=C2=A0=C2=A0 =C2=A0u16 roff, rsize, names =3D 0; +=C2=A0=C2=A0 =C2=A0u16 roff, rsize, names =3D 0, links =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0const struct ATTR_FILE_NAME *fname =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0const struct INDEX_ROOT *root; =C2=A0=C2=A0=C2=A0 =C2=A0struct REPARSE_DATA_BUFFER rp; // 0x18 bytes @@ -200,11 +200,12 @@ static struct inode *ntfs_read_mft(struct inode=20 *inode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 rsize < SIZ= EOF_ATTRIBUTE_FILENAME) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0names +=3D 1; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0fname =3D Add2Ptr(attr, roff); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (fname->type =3D=3D FILE_NA= ME_DOS) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto next_a= ttr; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0names +=3D 1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0links +=3D 1; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (name && name->len =3D=3D f= name->name_len && =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 !ntfs_cmp_n= ames_cpu(name, (struct le_str *)&fname->name_len, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0NULL, false)) @@ -429,7 +430,7 @@ static struct inode *ntfs_read_mft(struct inode *inode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni->mi.dirty =3D true; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0set_nlink(inode, names); +=C2=A0=C2=A0 =C2=A0set_nlink(inode, links); =C2=A0=C2=A0=C2=A0 =C2=A0if (S_ISDIR(mode)) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni->std_fa |=3D FILE_ATTRIBUTE= _DIRECTORY; diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 6aa3a9d44df1..6c76503edc20 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -534,16 +534,9 @@ bool mi_remove_attr(struct ntfs_inode *ni, struct=20 mft_inode *mi, =C2=A0=C2=A0=C2=A0 =C2=A0if (aoff + asize > used) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return false; -=C2=A0=C2=A0 =C2=A0if (ni && is_attr_indexed(attr)) { +=C2=A0=C2=A0 =C2=A0if (ni && is_attr_indexed(attr) && attr->type =3D=3D AT= TR_NAME) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u16 links =3D le16_to_cpu(ni->= mi.mrec->hard_links); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTR_FILE_NAME *fname =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->type !=3D A= TTR_NAME ? -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0NULL : -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0resident_data_ex(attr, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 SIZEOF_ATTRIBUTE_FILENAME); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (fname && fname->type =3D=3D FILE= _NAME_DOS) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Do not decreas= e links count deleting DOS name. */ -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} else if (!links) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!links) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* minor er= ror. Not critical. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} else { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni->mi.mrec= ->hard_links =3D cpu_to_le16(links - 1); --=20 2.34.1