lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220614210902.744318-1-e.velu@criteo.com>
Date:   Tue, 14 Jun 2022 23:09:01 +0200
From:   Erwan Velu <erwanaliasr1@...il.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     Erwan Velu <e.velu@...teo.com>, Keith Busch <kbusch@...nel.org>,
        Jens Axboe <axboe@...com>, Christoph Hellwig <hch@....de>,
        Sagi Grimberg <sagi@...mberg.me>,
        linux-nvme@...ts.infradead.org (open list:NVM EXPRESS DRIVER),
        linux-kernel@...r.kernel.org (open list)
Subject: [PATCH 1/2] nvme: Ensure char members of struct nvme_id_ctrl are null-terminated

When issueing an identify command, the resulting data structure stored
as a nvme_id_ctrl struct, contains a couple of char members.

These char members features:
- the serial number (sn)
- the model number (mn)
- the firmware revision (fr)

As per the current code, nothing enforce these members to be
null-terminated which causes issues when manipulating them with regular
string manupulation functions.

This commit ensure the three of them are always null-terminated.

Signed-off-by: Erwan Velu <e.velu@...teo.com>
---
 drivers/nvme/host/core.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 24165daee3c8..0f7e625e8bd0 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1274,6 +1274,13 @@ static int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
 			sizeof(struct nvme_id_ctrl));
 	if (error)
 		kfree(*id);
+	else {
+		/* Ensure that model, serial and firmware fields are always null-terminated */
+		(*id)->mn[sizeof((*id)->mn)-1] = 0;
+		(*id)->sn[sizeof((*id)->sn)-1] = 0;
+		(*id)->fr[sizeof((*id)->fr)-1] = 0;
+	}
+
 	return error;
 }
 
-- 
2.35.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ