From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796264556; b=OmgmLR3iuafyfbzTDOMzqCALSiNtyfJd9aG9qWXJCYCPYtWYFyRTi+X+PZqpKICIMJb8 +89u8W8XMRrB5/Te+2P/7nO7hrOnk6I7rCzAXzzxe8iWE/zLOK2ocYTyb55xdm+lwOwjy BM+ndc8wYlrZMzNPTIGiwNIyKk5e0M6NHQk48MYguwZdDjjJYBF78fEVXP7uXbz2IQGxt PlGQo7fFGZYA5A9dzcYPp8ifEkcfxBzO0qQ5CrxvmIbO1zybJZ3uqDJKdSk9gjry46+uS RRt0tm5Ui+28/pULgjGC/k9Uid09YtdVFkPHKoFdz+hfv5igA0NO7fLwjIjovigYLcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796264556; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=/5BhMRBmmFB4p4FjF1KGx0xemQuK/p9Qc5EjpCxMv58=; b=ch9EqFOAL70y00Iq8vVXn6fueFGqd5jbUaJ2dVZxIgICMsW4p8gMQFpQjP1bHQCW1Eq2 ykMIv6H3Z9URuHJW1fruIuY/qWD5wU4sGc0J7RbRIiMpm1RAb9fuhQHZxNn3kIKUSJBZg SEHl/NX9nN/eKXJB84EV0z8baLKXuiva2O0B0puXpI1aM8kgiFsICdY9eaKofjQ0Q2rLf EDuUZrrWV0eWOlyJTeM+MW3b4CRncIVY5HlNcfU09qGrQaE8qYUh+Lumt7yLhCwmwlHTL WBNxrPRa3ak8CcqhgmtoeXWcFCdIESO+daQpgzoZC1BKxmNAZNq+sWy4hejBTF3y5UQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=modal.com; spf=pass smtp.mailfrom=modal.com; dkim=pass header.d=modal.com header.i=@modal.com header.a=rsa-sha256 header.s=google header.b=MsfiFM4B; arc=none smtp.remote-ip=209.85.160.172 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 627D9606A32C for ; Thu, 3 Dec 2026 02:22:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 627D9606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=modal.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=modal.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=modal.com header.i=@modal.com header.a=rsa-sha256 header.s=google header.b=MsfiFM4B Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-55d2d380f6aso146075021cf.2 for ; Wed, 02 Dec 2026 18:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=modal.com; s=google; t=1796264555; x=1796869355; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=/5BhMRBmmFB4p4FjF1KGx0xemQuK/p9Qc5EjpCxMv58=; b=MsfiFM4Btvmt5KB/oDlZ4SG2fX6E0pHKE1p7I1LIw8iSMXKg8pWJxH95zem6oM9+jx 51oWInj/JqW/Zz0H6eD5zEc7yjbtbdrWQBpcRmQOzjKRrdgXa3LmtSdFlJm9mSvX/eNJ UIZo2IzIB2jqhWpQVv5N8VYOYofMtMNqit9ZFOlQolfeOVWyPiLZxsE8lvT7nj8OUrGr xKy+Pk+j3pl3S9TpQQnZ2aYYo9llPrleqYBNnbCrsG8DDMX/LxeBv1FtB76S8c4rUcyg vWzQ6z6KKqw1KdwVa97pUKyuLv0IgorUABT93TbvGrmGq4nhkbwKA3x//6ks/tbsJykT osig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796264555; x=1796869355; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/5BhMRBmmFB4p4FjF1KGx0xemQuK/p9Qc5EjpCxMv58=; b=KVHu81dUg8QTMtxuKHbgFBReEdEYh9QBWolgO+kp+U3laEIK4tFkoJHPClmHRyf3lC MDJJj1NmCDzUhfzVkf8elESLHyy/iVwINg4Su9s+rjlyGa3FYMNJqBbc91eNpUmn3vLV Qf2O/HcJmBm00NSjdk+LwWFMGl0KqjL4gZgaNHLp1XIM11IFjUjwFTj6k9KTlJo/GBIM iutTEpO4GyZQJtN6r1jr/U5B8jsD0guDbtvOHFsyoeynVf7u2e2DHC0KiE+LbBPpRyLT ihhP9U9KCPyjH3O3f312qunoYJa6+kOrYB1hKlAmLMLVjcbF6G4gHRrsJKG983S4rIrx hOBA== X-Forwarded-Encrypted: i=1; AL+hErENFuSZkCZHUvEfPNXE1l52Vkz5A4J2Kyet2RVCJvbBYZoQhtDdNVx2v7sUAuKC8RffR6egzRQ=@lists.linux.dev X-Gm-Message-State: APuU4Z+UPzNW13Tm3q7JJeM7V/yGOOq2+gv6C3Jbdk/kZrtt/MWy+HW6 0C52IraAQsu2xEf6DwUpx9FcQ7Pwrj4OuiFR+Qt5aBGXUf3eFqCF/DRiyQrNFNcNw1k= X-Gm-Gg: AZFdTZd62zLcEtVApY5EgBiNTOjtw4FrzAoFnttILkWfo89lY5fsCBMUBJnJgUFvW8a RzWoLhiDguHm7IHBLM001aOgPMPhMQPT7o5pKuCphFG+UTrvHOChuXWuAR3syluA3sBcywbvide JsgdOMWIl4CP7uvxrlWlHvQBY8wT2JIWNXbHNJ3EPHhG8ElXX/KJpmzM3cwQ1khpzJv9oUdyfOL D7iFNgnnnvaGkG9ni7GE8DPsJO7+Q48EmLqiZzAuT9TrHcwZB0IViqRasPWH3/7q9jz9RaibHDc 2fiIWi8gaELVYJM1n6HGmSgAs7JQewo6vKMr5nyt8ByullyIwbAW+iDfQK/xTB+S6y3awTF7uvH WWGKc9fTzSe6hLSyn/rssQHVKS8Sw0FQuijZEKxjJ2+KLVIvXOS58d4/e0NGQ+1cmLJka2yvSVm Sy3OC4OxZCyJ8M1olzblu01IT31Ovg1YV66blgTJwXJmvgwnFmhQT9C5FZrqgJJLwFrH9GvORhF RrvVHTpmbjF3fne0jHMdhBJC/GwqhQhSZIpUrAxypJP6gNrIufJBrXCOJjRZkeB75YOS0w4G/t9 oqkLY5+Md742HFIUT/encE44A/bx+vao5ygvg97UVMVRMWpeEe11xv994Kc5gCDyUvuNOqUQGFK u421wADDSeVIi5iTKZA== X-Received: by 2002:ac8:598a:0:b0:533:3fc2:8b19 with SMTP id d75a77b69052e-55d769e1664mr810723281cf.20.1796264555174; Wed, 02 Dec 2026 18:22:35 -0800 (PST) Received: from devbox-amit-63ec.ec2.internal (ec2-44-214-141-241.compute-1.amazonaws.com. [44.214.141.241]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-9217fd18b2asm211195766d6.21.2026.12.02.18.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 18:22:34 -0800 (PST) From: Amit Prasad To: apopple@nvidia.com, brauner@kernel.org, viro@zeniv.linux.org.uk Cc: jack@suse.cz, willy@infradead.org, djwong@kernel.org, alison.schofield@intel.com, nvdimm@lists.linux.dev, linux-fsdevel@vger.kernel.org, Amit Prasad Subject: [PATCH v2 0/2] fsdax: handle short dax_direct_access() ranges Date: Thu, 3 Dec 2026 02:21:37 +0000 Message-ID: <20261203022139.1022927-1-amit@modal.com> X-Mailer: git-send-email 2.56.0 X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit dax_direct_access() can map fewer pages than asked for. Earlier changes caused fsdax's copy-on-write, unshare, and dedupe paths to skip a check of the returned length, which can result in reads and writes outside the mapped range. For example, dm-stripe ends each range at a chunk boundary, so dax_direct_access() returns a shorter length than requested. On a filesystem with both DAX and reflinks (e.g. XFS) mounted on the striped device, fsdax doesn't respect the size of the mapped range, and can read/write outside of it. The first patch minimally fixes this and explicitly returns an error. The second patch makes the above scenario work properly across such short device boundaries. Tested against v7.4-rc5 in a VM with two pmem devices, beneath a dm-stripe target with 64 KiB chunks, XFS with reflink=1 and dax=always: - unpatched: funshare of a reflinked file corrupts it, and a dedupe of two identical files reports them as different. - patch 1: funshare fails with EINVAL without corrupting the file. - patches 1-2: funshare succeeds and dedupe returns a valid result. Reproducer (needs a 1 GiB pmem device, e.g. memmap=1G!4G): dmsetup create stripe \ --table "0 2097152 striped 2 128 /dev/pmem0 0 /dev/pmem0 1048576" mkfs.xfs -f -m reflink=1 /dev/mapper/stripe mount -o dax=always /dev/mapper/stripe /mnt head -c 1M /dev/urandom > /mnt/a cp --reflink=always /mnt/a /mnt/b xfs_io -c "funshare 0 1m" /mnt/b cmp /mnt/a /mnt/b Creates a dm-stripe across two chunks of a pmem device. Unpatched, cmp reports differences. With patch 1, funshare fails with EINVAL, and with both patches cmp shows the files are identical. The bug was reproduced and fixed with the help of an AI coding assistant (Claude Opus 5.5). Changes since v1: - Patch 1: describe the new SIGBUS condition in the commit message. - Patch 2: add Alistair's Acked-by. - No code changes. v1: https://lore.kernel.org/nvdimm/20261201174324.5991-1-amit@modal.com/ Amit Prasad (2): fsdax: check the mapped length for all dax_iomap_direct_access() callers fsdax: iterate over short dax_direct_access() ranges fs/dax.c | 118 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 33 deletions(-) base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 -- 2.54.0