From nobody Fri Dec 19 07:20:13 2025 Received: from mail-pj1-f99.google.com (mail-pj1-f99.google.com [209.85.216.99]) (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 1F3D320DD48 for ; Wed, 17 Dec 2025 05:35:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765949715; cv=none; b=mkpJMUvCjGRCQ7CjsC7CxtbHqMFfL8kU7YTBJCb6r1vCuDKMze6EfSgBF/6PUsTBIkMyw4wEu+G4QzR7B3lpoBhaP7xro0pqtUohDOM1KvnPBHGYHSDG6vWRsz70Y5PDzMSmNRwNTna1E+83Ydg16F4SQuRpCpok8VX4FVQdSK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765949715; c=relaxed/simple; bh=xUW+aJ0AIyUBNjUOSWrr/v9kRnK+74dQ2K/T8dlAGQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pp2KKDB7hkJ7QHkl4QzWZmCmxQVcpao/aWkkhHdF35CzvzSD7DD4Q8/PQhXDExhzEFSMoKrt32hLlpTWhDTHX+PglX2Ma4/vXyu8PmEUwQVrJPQV/XyBjQAWOUMHCLexaEl/nCAucS6DUC1PG3QU4oCYDFB58cWPV2Stl5FzZbA= 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=AOhkokyO; arc=none smtp.client-ip=209.85.216.99 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="AOhkokyO" Received: by mail-pj1-f99.google.com with SMTP id 98e67ed59e1d1-34c27ea32a3so385630a91.2 for ; Tue, 16 Dec 2025 21:35:12 -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=1W7GaZySinPtNdu/28BmiINfjaLT2swubxXUIgi/0VI=; b=AOhkokyOhY9siyDVCEeIP+oj1r0bQGZMWzqEPujYTrRJnJ4dW2mtnDCwnirHJIHtyn orVNLqgxOJxiraV60BhgGG8rq6fIuSo3mzP1C5js9b4mxwDZhk42SnnVapxTieKd6sEK 6Urp8hE7Yw8gMYgIUd9caOLXhimSFDr6pCseArUgrFfuarWSndCfG0DJlqWc3pQ8YDiO DABMbI2yN4hIjzHC9pUfDULLhEiqr47sSNtWtL5Ly2nkkxq/o45Q+MYI0uLmzQrsaOUd QVbPNjMYLTQpKEhvVsHTw5laGwEjyVvkzJSyCaXyk0JI9Ioxf4xtuoKUP1iozhmVBaEC JC7A== 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=1W7GaZySinPtNdu/28BmiINfjaLT2swubxXUIgi/0VI=; b=lk9w1L4jWz+2HpatLjP+rYkDANRIHtNcQqbXor3faTdCsopICEYMQqhjERxq/XVGWH 2Bfz84NZaVhaC4rKf2jKKFpYVgQJUsCL+QFXDyaePZfLfqnsfYOB/5PVjtXr71FcCVBf sokO5LYDAX9BDiZIrh0PVg3NZJZz3VHEozB4IW7PpiDY3MoGF4B3cXJoaiIPcNnQLAAY 8Ofc08IGbESrCBJcgliLAvw3ItoyaPK6myln1jmgv04CkLG4nRMEklkqiW9maYK0CUna WYqd9SpefDpRo2A7nHsV1yby5vyJoW80W8e01CJYYDpL0kxcpIhLyiba7ppDVay1WZjC thWQ== X-Forwarded-Encrypted: i=1; AJvYcCUqky617YKt0T2O/Zs4cTD7EHip7TXGm8KNzv8F3lOfTh2QOQ+WP8Eha5tXa3Opoano3AJj/+ionZXzK3I=@vger.kernel.org X-Gm-Message-State: AOJu0Yz05X/Xu5D6QYRANYNLQDr4TDhiPjEoq0HUKIcR5FY3CwwWfEit RnkLeKkdCDWmCWs+++P/eP4PDIMbxUDsEHqcnr+mTuFY5/1ZOc0ebf1DK54c+frKmIQo4xsewkA dgYYFcgHc1HLckv9WJ8T8I9+eIUDxHp7YHuTORzoioVxoKH32HSdI X-Gm-Gg: AY/fxX6WSJcSw1O8+hHdjzeVIQp6yyy3XWcZ6XDD0Dv4KdarWES/f/pLj5odU6cJ1LU 3rI7xtArNtndFm2EYYbyX50pz8/5vvpIbyoYtuEws6CCoM13RGH00p5Bn7ythks9h7FcKTVNOu7 pvbRAldKed86BtWdaOry6m4ryen1KORgfgf8mdLj7MgW12t659ma2X1Gn0RdJKVbanW/5tFN5Lc YzCMj5rnUoyZmWZ6KAHvIEC0UXoeMt8079U6O9Rng0xiYWuhcirhBoe9anhucoP8dvcVqXN1DQE CWbdm+zh0SKOKTf59HuMncT4VQjbDzmyvtkhjZG+efAW/vDwAqhDhMRG3KmH6UQstXq0jJhDiZA rA61EyASN2LmVXY7QsF+yxwuBVR4= X-Google-Smtp-Source: AGHT+IGmD0xzmGqowX1/sZtnUry9Hv+YVc2UPf0PBiv6bJ1WS1oGm9qgaFTZtLXdzHr346yX/lPuywp6sUBH X-Received: by 2002:a17:90b:2749:b0:340:e8e4:1166 with SMTP id 98e67ed59e1d1-34abd898fa3mr11743788a91.5.1765949712251; Tue, 16 Dec 2025 21:35:12 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([2620:125:9017:12:36:3:5:0]) by smtp-relay.gmail.com with ESMTPS id 98e67ed59e1d1-34cfce259ebsm224226a91.0.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 (dev-csander.dev.purestorage.com [10.7.70.37]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 8B8103420C0; Tue, 16 Dec 2025 22:35:11 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 89402E41A08; 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 02/20] block: validate interval_exp integrity limit Date: Tue, 16 Dec 2025 22:34:36 -0700 Message-ID: <20251217053455.281509-3-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" Various code assumes that the integrity interval is at least 1 sector and evenly divides the logical block size. Add these checks to blk_validate_integrity_limits(). This guards against block drivers that report invalid interval_exp values. Signed-off-by: Caleb Sander Mateos Reviewed-by: Christoph Hellwig --- block/blk-settings.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index d138abc973bb..a9e65dc090da 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -191,12 +191,17 @@ static int blk_validate_integrity_limits(struct queue= _limits *lim) return -EINVAL; } break; } =20 - if (!bi->interval_exp) + if (!bi->interval_exp) { bi->interval_exp =3D ilog2(lim->logical_block_size); + } else if (bi->interval_exp < SECTOR_SHIFT || + bi->interval_exp > ilog2(lim->logical_block_size)) { + pr_warn("invalid interval_exp %u\n", bi->interval_exp); + return -EINVAL; + } =20 /* * The PI generation / validation helpers do not expect intervals to * straddle multiple bio_vecs. Enforce alignment so that those are * never generated, and that each buffer is aligned as expected. --=20 2.45.2