nvme: null terminate nvme_tls_attrs
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tue, 24 Sep 2024 09:01:34 +0000 (18:01 +0900)
committerKeith Busch <kbusch@kernel.org>
Wed, 25 Sep 2024 06:34:13 +0000 (23:34 -0700)
Commit 1e48b34c9bc7 ("nvme: split off TLS sysfs attributes into a
separate group") introduced the struct attribute array nvme_tls_attrs.
However, the array was not null terminated and caused BUG KASAN global-
out-of-bounds. To avoid the BUG, null terminate the array.

Reported-by: Yi Zhang <yi.zhang@redhat.com>
Closes: https://lore.kernel.org/linux-nvme/jhllwfxcedrcxcnbajwl4x2l2ujcqowqcd4ps574zrafrqhjna@f4icvecutekm/
Fixes: 1e48b34c9bc7 ("nvme: split off TLS sysfs attributes into a separate group")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tested-by: Yi Zhang <yi.zhang@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/sysfs.c

index eb345551d6fe3bc29761175843edb5a23595df5a..b68a9e5f1ea395eba40998394d561a8466c88913 100644 (file)
@@ -767,6 +767,7 @@ static struct attribute *nvme_tls_attrs[] = {
        &dev_attr_tls_key.attr,
        &dev_attr_tls_configured_key.attr,
        &dev_attr_tls_keyring.attr,
+       NULL,
 };
 
 static umode_t nvme_tls_attrs_are_visible(struct kobject *kobj,