From nobody Fri Dec 19 07:19:27 2025 Received: from mail-qk1-f225.google.com (mail-qk1-f225.google.com [209.85.222.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8846C238C1B for ; Wed, 17 Dec 2025 05:35:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765949716; cv=none; b=PVGKc7Ia6AuTHxYTDTa23r5/8Lcq1kD563pTiKFe5y8XbhzE7v34k7peTF7mhDxLi5f4FkZV/iamn1TDRN8v1InOsBi/BJ3SSXDAu+jLiUiT423CvbAkmevJ3k6U5NvIjpv+r+OgO+4e386mU/01lExDOEYPscdxnxEDwXWxSSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765949716; c=relaxed/simple; bh=Pyh2W1i8IZlUeBaqc00BgLkYCHlkSrQShsXZSzjfZ7c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZGmLMtnl/TrT44s4h1cyH7k8K6k4mWvkvDAnJFw47eQznjltGYBc7nI7LJuEBnYbKsmOjPeGCIgHOExTEQ5l16AiA1V9jjtshtheqDh2zJyIhYeyGKuOYjypPKiBUEfTbN5RcMAiXSCKbnG5QXm+RkNjjJpPZQ+/eE6MKvdlp4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=IHdg87Ke; arc=none smtp.client-ip=209.85.222.225 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="IHdg87Ke" Received: by mail-qk1-f225.google.com with SMTP id af79cd13be357-8b2da4fb076so84631985a.2 for ; Tue, 16 Dec 2025 21:35:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1765949712; x=1766554512; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R2Q4EUjN96I8JLsrl8Thk8/d3aPnxYAXF44AaVOt3uI=; b=IHdg87KeUrILc8yIhZahuIqFXNHWECMj4wnXxIkZRn67g0x3QwyZyWmlnzAA71n95A dUTQnW9vfnJgTAJn0D36rCoU+m7WDw8MLVaf0ZPVwQR4KS6yqIujaVHadXEW8WoLqG7I i7tPzy820mLTMw37aeu/ETOvuN5npxNhPXD/LylpgQkGoFXpTGl7yQsCKRAi9N0XnP/9 s98Yju4OZGFpZ2fKB2/Qsq9CLKDaqjCl0ovOz3U49zU6/XT2O9g3nnV3ROZOP1CAihqv jcfp8qcClLkXqewm4yVPmH9Odc4baYsQQPu2nVPV5CyYcVzDlSpNXRDRdrQkjzvQO4RS xgMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765949712; x=1766554512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=R2Q4EUjN96I8JLsrl8Thk8/d3aPnxYAXF44AaVOt3uI=; b=etRTm2nudbuQVt1kBFNrAv5nMw4dFpPERh9K8xrsOsvM9rpJ2o/9I8qqbYWe4jJsG6 dwkneq+1InCC0jeHHK0wmO0UOJQp3qWDchbjCcnRWNCuFNf84zqW5WANwzsOPz+xFHsC g9km0sl06BfAYPUyvwTMTQoftS5ZJSTk6mAoQTRf62RGNyHkxwfJyAxiaRJEH3JF7J32 o2sLMh8XG83DK5F+TPvMhRxmCqU9HWz8dvO8ciQGa4bvX/lU0tLNywwSThAYiuwIrAKE 9afpa7PkLcl52koXh64pG2gXZvs+m8INiKQgUF0yHI8k+R6jgvOPVCoX4hQ4gpuGlhaC kAyQ== X-Forwarded-Encrypted: i=1; AJvYcCWe9DOhzwNl4Rkmwi+4YXq7xJjTbZBtuqa03jMLART0tGqDcoFSrRp0DhE2cyUWHcd6zSFsJzS6t411yUU=@vger.kernel.org X-Gm-Message-State: AOJu0Yy09semUM3IgCW5cT3sgZLDy65gD7nyyunoRKFFJf7BJPO17mlG DhE7LKPeY2MwqPtjAGCDbpv6UxT2E940Is0sT7o4oV9drtguChRPgUxpYPy+hfc/+EhPDtbUK5Z Iu2yOG/M6qeifEd7yzTEQUCnFqmo42hnWipt3 X-Gm-Gg: AY/fxX5HG8NTDB8TgljievF9lSpsyyhH/0kTc17zbhpvTeMulFsNUzKZ8xseFVfZk4a QCf7WmFCs4EULMokj4Mrd8sH1IMAA/aHbVsmM8umA+K8cPtR14uG4c3tZKrObAhAoKjqKLLr2Wp T4j2HuF+WX8YjNl5ZT5IkmSqlI2wAA6Uxq6qDE2F6xeEr+CEniUG48IMSVf7yph0QmMHWfwrJkW 3OtkMnAHDfXH9Nfy3bZk1S6+s80fu/WAWvfUP7prOWNhUtn8yV11Xy+6fUaET7Znbs5GLVZ9CIh A6DPqPPeF7cEAbvu3/NLdec2d3F1FprCTmXejewBePQwbnnJB2rt13uhCpIMUU79hFmiZoyOPKw ptglsXXR3gkQ5ekwyGopHv5uwmbfRjRgipMoowyJATw== X-Google-Smtp-Source: AGHT+IEwQVVahKTBzODwZ9LCNp7ytSuh2rRQqS2AIb4ql60egeJB6RRbKK8HEAJwdh0Tw0BDMeZ7L4T+UOA8 X-Received: by 2002:a05:622a:610:b0:4ec:f9c2:c200 with SMTP id d75a77b69052e-4f1d0655504mr181608401cf.11.1765949712259; Tue, 16 Dec 2025 21:35:12 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.128]) by smtp-relay.gmail.com with ESMTPS id 6a1803df08f44-8899dc07525sm19327636d6.15.2025.12.16.21.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Dec 2025 21:35:12 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (unknown [IPv6:2620:125:9007:640:ffff::1199]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 6A40F3404B4; Tue, 16 Dec 2025 22:35:11 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 67759E41A08; Tue, 16 Dec 2025 22:35:11 -0700 (MST) From: Caleb Sander Mateos To: Ming Lei , Jens Axboe , Shuah Khan Cc: linux-block@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Stanley Zhang , Uday Shankar , Caleb Sander Mateos Subject: [PATCH 01/20] block: validate pi_offset integrity limit Date: Tue, 16 Dec 2025 22:34:35 -0700 Message-ID: <20251217053455.281509-2-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251217053455.281509-1-csander@purestorage.com> References: <20251217053455.281509-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The PI tuple must be contained within the metadata value, so validate that pi_offset + pi_tuple_size <=3D metadata_size. This guards against block drivers that report invalid pi_offset values. Signed-off-by: Caleb Sander Mateos Reviewed-by: Christoph Hellwig --- block/blk-settings.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index 51401f08ce05..d138abc973bb 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -159,14 +159,13 @@ static int blk_validate_integrity_limits(struct queue= _limits *lim) (bi->flags & BLK_INTEGRITY_REF_TAG)) { pr_warn("ref tag not support without checksum.\n"); return -EINVAL; } =20 - if (bi->pi_tuple_size > bi->metadata_size) { - pr_warn("pi_tuple_size (%u) exceeds metadata_size (%u)\n", - bi->pi_tuple_size, - bi->metadata_size); + if (bi->pi_offset + bi->pi_tuple_size > bi->metadata_size) { + pr_warn("pi_offset (%u) + pi_tuple_size (%u) exceeds metadata_size (%u)\= n", + bi->pi_offset, bi->pi_tuple_size, bi->metadata_size); return -EINVAL; } =20 switch (bi->csum_type) { case BLK_INTEGRITY_CSUM_NONE: --=20 2.45.2