From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (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 B2E5B3932C5 for ; Mon, 20 Jul 2026 20:11:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784578271; cv=none; b=LX7KCon5btey6Q6rCBpHkmEQin2/aPdredKGKhORr8M0NtsnA5bGNE6M3J+gRVBjZJ6u+N+bJjPh5Hc/QoFkYSEAiz3bxn1nm0oU+Un82AZnu9wzUqzZiHtVnmB9eZF44Ahuz4LtDQCh/BaIcal9nTnmbG47dXYqFEzgYjShETU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784578271; c=relaxed/simple; bh=OUuOHmPuAVyZLe5WHXkb7v0Ym0I+unXVLFV/t/XYvXo=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Af60KZgvsCyOUfV++iXoirQRk8Bb6Cq9A4wFLb3QObNbOV47W9MFzwDNnm1drFv6Sb9Aa8guwhKWQlSCQ9VK+hpVUdvPhSpm2qWJi+1PJa2bUJzVBxD5xx14ToZoLa29neE230QnYALrzGJnyLnvY2Y7bWo8BMe1W7wSyqakD+M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=EEjuFbNK; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="EEjuFbNK" Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66KJQ2cd2765559 for ; Mon, 20 Jul 2026 13:11:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=s2048-2025-q2; bh=dA9VgY7XPpIvG6wKms Q9cynp3tOwpPa627n1rXVynfo=; b=EEjuFbNKz5JEQJxT/k6+kAi44fF0m3esd+ ZoTE2OvJk43E3se6O9zO7dSIn9Wwkl4yzNdhRYlyXXvKcL2PJyAcSCaPHv+83qTK ZfMG7zDEQwCuX6oa+iPlDslagGTFV/cSDWMsVjUwz+tgtOCYHGYlY9BO7osM96p/ IPfIdiAodCUoFyqTH/uV8ZG7mH5AefTZTFzyKQx3BrzAdcMRzWA4xRir1kECb33e 6+XgzJtiqpHHSv7sKay5I8Ojw+w3DuyKHp8l87N2LZSAU/O8TOp+JRzGuooL37Fe 8XgI7p6BLYvYjpg6BK9gS4fzUf9D4kNkc0ZMM1qDMVScIqpmDsTg== Received: from maileast.thefacebook.com ([163.114.135.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 4fhcyq4qfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 20 Jul 2026 13:11:07 -0700 (PDT) Received: from twshared40132.32.frc3.facebook.com (2620:10d:c0a8:1b::8e35) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.41; Mon, 20 Jul 2026 20:11:06 +0000 Received: by devbig197.nha3.facebook.com (Postfix, from userid 544533) id 890F525A00281; Mon, 20 Jul 2026 13:11:03 -0700 (PDT) From: Keith Busch To: , CC: , , , , , , Keith Busch Subject: [PATCH RESEND 0/5] block: validate direct I/O memory alignment Date: Mon, 20 Jul 2026 13:10:52 -0700 Message-ID: <20260720201057.1862857-1-kbusch@meta.com> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: ZRlo7tsIa4bIXG-OHri-7fZZ9TOKQ8BJ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIwMDIyMCBTYWx0ZWRfX8wiBqMc1y4Dy YuMSy1PDlSil9rGE7leKqWiG+8MoSt1vhOwSfgrQofctds4xm42NQLN8O0wBBIFV6C3PF+a26hh T+NhoGn+kgWxs7MiECll8vBP7oHyPijYkr3gh3CIUCJeKihE8nh0sIPstImNjKetBqJtxf4QhqU 18H80W+fXxknrgX56MHuW2baGwmY0/yBuU796dEmucVIIcxeHFexpL2roHlRjiZCtrD++o++Waa ojU1njFuSLP98vkCh9URSBq8Ho3zm8dH4Z0iFDKTRqcLbKQlGFCJtYTNApDbz13ZYVoNM+whwf9 zJH2IuAonL3wnD2uTHxwEYejmQcUSsuQYFvRIwz1/RDAnr1xSKemkByf4fg0k+t4bEpU6poUFmi AcX3/BCvu7gfuSPa91KjnbIOGWYjxiRgTJBdIAFz8Adi3cF13yUXI8CpXjP4QqfI05rZHffCM/K pQNDNXROeQXO3ZY4PBg== X-Proofpoint-GUID: ZRlo7tsIa4bIXG-OHri-7fZZ9TOKQ8BJ X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIwMDIyMCBTYWx0ZWRfXxXl4B9dCJYYU 5RzujZR/WIEC4zCYjOlURZVC7P5O6CrghTWfdZbXSMUZizVsDHacq3ZWPMcNaea9WiQVEF/UpI7 RgfuLKONXBPRjnU4J0sbFBk1of6ZZ1E= X-Authority-Analysis: v=2.4 cv=Z+rc2nRA c=1 sm=1 tr=0 ts=6a5e80db cx=c_pps a=MfjaFnPeirRr97d5FC5oHw==:117 a=MfjaFnPeirRr97d5FC5oHw==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=7x6HtfJdh03M6CCDgxCd:22 a=tpM8CJlwf7uhpglF1g9U:22 a=VwQbUJbxAAAA:8 a=pGLkceISAAAA:8 a=VabnemYjAAAA:8 a=rFgjrMAfHNG0gpnDTA8A:9 a=gKebqoRLp9LExxC7YDUY:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-20_05,2026-07-20_03,2025-10-01_01 From: Keith Busch Resending in case this got lost. This addresses the misaligned direct-io problem behind various threads: https://lore.kernel.org/linux-xfs/20260610145218.141369-1-cem@kernel.org= / https://lore.kernel.org/all/CAC_j7i1R7oy+nRhxEjCTba=3DDUgn02w9X+p94DCu0a= Hv5+5tKnQ@mail.gmail.com/ https://lore.kernel.org/linux-block/ai7rnH20IYeSmY8s@gallifrey/ https://lore.kernel.org/linux-block/20260616154009.2123183-1-kbusch@meta= .com/ The previously tested fixes are correct as far as they go, but they treat the symptom: they only matter because an invalid bio reaches those drivers in the first place. The reason it reaches them is an assumption I made when I removed direct-io alignment checks in 5ff3f74e145a ("block: simplify direct io validity check") and 7eac331869575 ("iomap: simplify direct io validity check"): every bio is eventually split to the device limits, and the upper layers cope with resulting errors once the bio has formed. Both were optimistic assumptions. Drivers with their own ->submit_bio may never pass through blk_mq_submit_bio()'s split, so the check never runs for them, and as numerous threads showed, the consumers don't uniformly handle this condition. This series stops the invalid bio at the source instead. It validates the buffer's alignment against the alignment limits when the bio is built from the iov_iter. The check is folded into the bvec extraction that already walks the vectors, so it adds only a comparison on a path that is pinning direct-io pages anyway. Misalignment is now uniformly rejected with EINVAL before submission for every direct-io path. Only changes in this version are just adding the reviewers from the previous: https://lore.kernel.org/linux-block/20260624170905.3972095-1-kbusch@meta.= com/ Keith Busch (5): block: use blkdev_iov_iter_get_pages status for errors block: fix dio leak on metadata mapping error loop: set dma_alignment from the backing file for direct I/O zloop: set dma_alignment from the backing files for direct I/O block: validate user space vectors during extraction block/bio.c | 56 ++++++++++++++++++++++++++++++++++++++++--- block/blk-map.c | 2 +- block/fops.c | 10 ++++---- drivers/block/loop.c | 46 ++++++++++++++++++++++++++++------- drivers/block/zloop.c | 35 +++++++++++++++++++-------- fs/iomap/direct-io.c | 1 + include/linux/bio.h | 2 +- include/linux/uio.h | 10 +++++++- lib/iov_iter.c | 9 ++++++- 9 files changed, 142 insertions(+), 29 deletions(-) --=20 2.52.0