From nobody Mon Feb 9 12:02:02 2026 Received: from mail-dl1-f104.google.com (mail-dl1-f104.google.com [74.125.82.104]) (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 D37A03A7F73 for ; Thu, 8 Jan 2026 09:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.104 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767863074; cv=none; b=bmb9rho3fhUOHvvO14K73FyfB5pNTdk2VklGz060wYryZu1N+Qto02KG57HwNb/BmISzTyjizUSyq6s2Pfcm7I9shYVFPVrZ66jSZxIq1LCMXGeQHqwvuxft0gaCBO9j9+TFMIajCU5RAmj1QC9PXD5K7l1868V1BBAteEisLp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767863074; c=relaxed/simple; bh=Am/NsbIssEWB9H0i0wfR0XCMC0CBLwlmllXF/BaRvgM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=glkc1bb5Cx59EWR98c+x3itQioZbmypnxnnzEvisB0vEo2FetaNmUV65/CtjDokbtViilF5IIal1QP9NkOAo0bV0/Qa0+ExfvWFkbNS0X+smEwR9F97NxW7D+dT9Fai+zMUHCza6hAeGLCy4tSbaZCvMo7Vf944t1QTXJOWtcSE= 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=NhVWhtaf; arc=none smtp.client-ip=74.125.82.104 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="NhVWhtaf" Received: by mail-dl1-f104.google.com with SMTP id a92af1059eb24-11f42e9724bso227891c88.0 for ; Thu, 08 Jan 2026 01:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1767863059; x=1768467859; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PdHkxStoLKgmVMOV/xVGdqRGUULkLJrp+peytBAVxWI=; b=NhVWhtafqm4lcC1tp4+WW6Y1Ex36kjN5WT9uGEUetPo9K/706r0QR+nVk6o8UaWrGG kcxnResBcNj9yuugcETQh5RyWYPBJltw8QjMy42A2MQeElz8KwwrXeDALIUr9WLLk9oS 2erc+CqhF5hkr1OGBwW7h88QuYaoRbbLv+voO78/Ql00UtcFs3ge+o+5ep1uFMxZzXdj xl5p1BbUAcPSjKHGF5mK834ckSTbqQh08n7baGHHYkKrcsYcqTkuPf0olF1+tKXsfwEb Sk2miXEWXrg8jCfWsPrpiR3L139jZ6nN/moqNXUOHZiJzdBakk+Fo4ojkcAfUaCsD3Mh j6FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767863059; x=1768467859; 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; bh=PdHkxStoLKgmVMOV/xVGdqRGUULkLJrp+peytBAVxWI=; b=Ecp/FUaatmGhTS8gK7Wf4wRJ0ao5RgtWqzcc9jL78wwElU0MwMhZN88BCq6M4B6gDj Bai0IQbDpbmFhFkDgDCFz29SThFF16JAo+E5Qpv6Buv1YBujXPuy0zrIchCSoEb685ZG susbAHMVLSCbCfPQStzb0CXuIfw5g+H+5/TYFg4vmerkYNZfmRFCVwfwB3QNrcgRuq3T PpYOXdcIKQcNh7EKscpGcE3wvQjdHLTch4BTXk+gZYlLF0xWH34+1EJL5leMQwnxPq6Q zX3vTEWrd23rs9RnQYpv5h/BqXaMBdzA1gaE1ly6RrLcQUyLWI9ABtzNd+m57bpP8qCX 5ZTA== X-Forwarded-Encrypted: i=1; AJvYcCUA0fYLFGXAgcMw8jAHMFpnAXSKlk9ObBtGcd3/5qaOY6hK3sgkGquDSbgp2KqZmr72yBWNu9BDTt0iPAs=@vger.kernel.org X-Gm-Message-State: AOJu0YwAkv08EmIBVfyJqxEv1zcThDlj9VkNhXxNmgHm/JLDAusauYQM cYKqSFkw4yXlfO3wK+sx/66nERuucc8VbbYuNrvmS5z30exS2w55xrpfWPNe3EotK+wbaUGcS4c QW82/+ceMcjIkjaGgKsEmdciZFPLW6RqZDVW4BS1bQCD7sLfYGlzk X-Gm-Gg: AY/fxX5LtSejyR5qDDt9VLbuJQo7K8InGfz9HfnlPrkYNq/hxfIFFPJsW3Xytq6S0Lq glCzBrgzyfOH6XEDCjIyUemtUvtPMPat4aTvzdDLqsQBeIoCdapQGI0TvwTNsytNibIXn44lI9M 8MtoCVLKAjbT3TabPnB74DkfYgChFURR+wjdmY9947BdbwBvKg34wVm7TK64pv1tThqPlBZmzWS s6HJERjESggxUVYpzRIhsosGEqfEc/Lz/JR+swNfy3YSjXDn2LH8PsTIJuX07MUszoVVXNIuIq7 PYWEbPUMGMuQpuIyGzI3Ka845DdgPZttYhfzJEkWNcROEAzdRzhumy6ziIyoDnn4zr6BQYbUzcr FxQ5nPtk8qVfUCIppA69Ly3HzkH0= X-Google-Smtp-Source: AGHT+IFJzN8MKSxRPKQU7O8d5YxBPcYnaUvp+rDbCJAGQC8z4KZIh0HiLwHq/SlHNB0bu+MAJT2L1G2QmqlI X-Received: by 2002:a05:7022:238b:b0:119:e56b:46ba with SMTP id a92af1059eb24-121f8b45a84mr2747647c88.4.1767863057049; Thu, 08 Jan 2026 01:04:17 -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 a92af1059eb24-121f24a554dsm1602845c88.7.2026.01.08.01.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 01:04:17 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.6.120]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 7C79834052B; Thu, 8 Jan 2026 02:04:16 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 674BFE42F2C; Thu, 8 Jan 2026 02:04:16 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe Cc: Christoph Hellwig , Caleb Sander Mateos , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] block: initialize auto integrity buffer opaque Date: Thu, 8 Jan 2026 02:03:59 -0700 Message-ID: <20260108090401.1091352-1-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 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 auto-generated integrity buffer for writes needs to be fully initialized before being passed to the underlying block device, otherwise the uninitialized memory can be read back by userspace or anyone with physical access to the storage device. If protection information is generated, that portion of the integrity buffer will be initialized. The integrity buffer is also zeroed if PI generation is disabled via sysfs or the PI tuple size is 0. However, this misses the case where the PI is generated and the PI tuple size is nonzero, but the metadata size is larger than the PI tuple. In this case, the remainder ("opaque") of the metadata is left uninitialized. Generalize the BLK_INTEGRITY_CSUM_NONE check to cover any case when the metadata is larger than just the PI tuple. Switch the gfp_t variable to bool zero_buffer since it's only used to compute the zero_buffer argument to bio_integrity_alloc_buf(). Signed-off-by: Caleb Sander Mateos Fixes: c546d6f43833 ("block: only zero non-PI metadata tuples in bio_integr= ity_prep") Reviewed-by: Anuj Gupta --- block/bio-integrity-auto.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/bio-integrity-auto.c b/block/bio-integrity-auto.c index 9850c338548d..605403b52c90 100644 --- a/block/bio-integrity-auto.c +++ b/block/bio-integrity-auto.c @@ -107,11 +107,11 @@ bool __bio_integrity_endio(struct bio *bio) bool bio_integrity_prep(struct bio *bio) { struct blk_integrity *bi =3D blk_get_integrity(bio->bi_bdev->bd_disk); struct bio_integrity_data *bid; bool set_flags =3D true; - gfp_t gfp =3D GFP_NOIO; + bool zero_buffer =3D false; =20 if (!bi) return true; =20 if (!bio_sectors(bio)) @@ -137,13 +137,14 @@ bool bio_integrity_prep(struct bio *bio) */ if (bi->flags & BLK_INTEGRITY_NOGENERATE) { if (bi_offload_capable(bi)) return true; set_flags =3D false; - gfp |=3D __GFP_ZERO; - } else if (bi->csum_type =3D=3D BLK_INTEGRITY_CSUM_NONE) - gfp |=3D __GFP_ZERO; + zero_buffer =3D true; + } else { + zero_buffer =3D bi->metadata_size > bi->pi_tuple_size; + } break; default: return true; } =20 @@ -152,11 +153,11 @@ bool bio_integrity_prep(struct bio *bio) =20 bid =3D mempool_alloc(&bid_pool, GFP_NOIO); bio_integrity_init(bio, &bid->bip, &bid->bvec, 1); bid->bio =3D bio; bid->bip.bip_flags |=3D BIP_BLOCK_INTEGRITY; - bio_integrity_alloc_buf(bio, gfp & __GFP_ZERO); + bio_integrity_alloc_buf(bio, zero_buffer); =20 bip_set_seed(&bid->bip, bio->bi_iter.bi_sector); =20 if (set_flags) { if (bi->csum_type =3D=3D BLK_INTEGRITY_CSUM_IP) --=20 2.45.2