nvme-cli: enforce memory buffer for Host Identifier
PATCH 1/1 nvme-cli: enforce memory buffer for Host Identifier
According to the NVMe spec, the NVMe Set Features command for Host Identifier (fid=0x81) must use memory buffer for its attributes. Enforce that and set the correct data length (16 for extended Host Identifier, 8 for non-extended). The data for the Host Identifier
can be taken from a data file or from the stdin (same as before):
1. stdin example:
- echo "host1234" | nvme set-feature /dev/nvme2n1 --feature-id=0x81 --value=0
2. data file example:
- echo "host5555" > /tmp/hostid.data
- nvme set-feature /dev/nvme2n1 --feature-id=0x81 --value=0 --data=/tmp/hostid.data
--- nvme.c | 6 ++++++ 1 file changed, 6 insertions(+)
nvme.c +6 -0
@@ -3279,6 +3279,12 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin }if (cfg.feature_id ==NVME_FEAT_LBA_RANGE ) cfg.data_len =4096 ; +if (cfg.feature_id ==NVME_FEAT_HOST_ID ) { + cfg.data_len =8 ; +/* check for Extended Host Identifier */ +if (cfg.value &0x1 ) + cfg.data_len =16 ; + }if (cfg.data_len) {if (posix_memalign (&buf,getpagesize (), cfg.data_len)) {fprintf (stderr,"can not allocate feature payload\n" );
Signature · 1 line
1.8.3.1
PATCH 1/1 nvme-cli: enforce memory buffer for Host Identifier
Keith/Johannes,
can you have a look on this please ?
Quoted 33 lines · Max Gurtovoy
According to the NVMe spec, the NVMe Set Features command for Host Identifier (fid=0x81) must use memory buffer for its attributes. Enforce that and set the correct data length (16 for extended Host Identifier, 8 for non-extended). The data for the Host Identifier
can be taken from a data file or from the stdin (same as before):
1. stdin example:
- echo "host1234" | nvme set-feature/dev/nvme2n1--feature-id=0x81 --value=0
2. data file example:
- echo "host5555" >/tmp/hostid.data
- nvme set-feature/dev/nvme2n1--feature-id=0x81 --value=0 --data=/tmp/hostid.dataSigned-off-by Max Gurtovoy <maxg at mellanox.com>--- nvme.c | 6 ++++++ 1 file changed, 6 insertions(+)nvme.c +6
-0@@ -3279,6 +3279,12 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin }if (cfg.feature_id ==NVME_FEAT_LBA_RANGE ) cfg.data_len =4096 ; +if (cfg.feature_id ==NVME_FEAT_HOST_ID ) { + cfg.data_len =8 ; +/* check for Extended Host Identifier */ +if (cfg.value &0x1 ) + cfg.data_len =16 ; + }if (cfg.data_len) {if (posix_memalign (&buf,getpagesize (), cfg.data_len)) {fprintf (stderr,"can not allocate feature payload\n" );
PATCH 1/1 nvme-cli: enforce memory buffer for Host Identifier
+ Sarika who has been working with Keith on this.
-----Original Message-----
From: Max Gurtovoy <[email protected]>
Sent: Monday, March 4, 2019 1:21 AM
To: linux-nvme at lists.infradead.org; keith.busch at intel.com; hch at lst.de; sagi at grimberg.me; Johannes Thumshirn <jthumshirn at suse.de>
Cc: Aviad Yehezkel <aviadye at mellanox.com>; oren at mellanox.com; Boris Pinzur <bpinzur at mellanox.com>; Omri Kahalon <omrik at mellanox.com>
Subject: Re: [Suspected-Phishing][PATCH 1/1] nvme-cli: enforce memory buffer for Host Identifier
Keith/Johannes,
can you have a look on this please ?
Quoted 34 lines · Max Gurtovoy
According to the NVMe spec, the NVMe Set Features command for Host Identifier (fid=0x81) must use memory buffer for its attributes. Enforce that and set the correct data length (16 for extended Host Identifier, 8 for non-extended). The data for the Host Identifier can be taken from a data file or from the stdin (same as before):
1. stdin example:
- echo "host1234" | nvme set-feature/dev/nvme2n1--feature-id=0x81
--value=0 2. data file example:
- echo "host5555" >/tmp/hostid.data
- nvme set-feature/dev/nvme2n1--feature-id=0x81 --value=0
--data=/tmp/hostid.dataSigned-off-by Max Gurtovoy <maxg at mellanox.com>--- nvme.c | 6 ++++++ 1 file changed, 6 insertions(+)nvme.c +6
-0@@ -3279,6 +3279,12 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin }if (cfg.feature_id ==NVME_FEAT_LBA_RANGE ) cfg.data_len =4096 ; +if (cfg.feature_id ==NVME_FEAT_HOST_ID ) { + cfg.data_len =8 ; +/* check for Extended Host Identifier */ +if (cfg.value &0x1 ) + cfg.data_len =16 ; + }if (cfg.data_len) {if (posix_memalign (&buf,getpagesize (), cfg.data_len)) {fprintf (stderr,"can not allocate feature payload\n" );
PATCH 1/1 nvme-cli: enforce memory buffer for Host Identifier
Thanks Jeremiah. Moving you to BCC.
Thanks,
S?rik?
-----Original Message-----
From: Jeremiah Samli [mailto:[email protected]]
Sent: Monday, March 04, 2019 7:44 PM
To: Max Gurtovoy <maxg at mellanox.com>; linux-nvme at lists.infradead.org; Busch, Keith <keith.busch at intel.com>; hch at lst.de; sagi at grimberg.me; Johannes Thumshirn <jthumshirn at suse.de>; Mehta, Sarika K <sarika.k.mehta at intel.com>
Cc: Aviad Yehezkel <aviadye at mellanox.com>; oren at mellanox.com; Boris Pinzur <bpinzur at mellanox.com>; Omri Kahalon <omrik at mellanox.com>
Subject: RE: [Suspected-Phishing][PATCH 1/1] nvme-cli: enforce memory buffer for Host Identifier
+ Sarika who has been working with Keith on this.
-----Original Message-----
From: Max Gurtovoy <[email protected]>
Sent: Monday, March 4, 2019 1:21 AM
To: linux-nvme at lists.infradead.org; keith.busch at intel.com; hch at lst.de; sagi at grimberg.me; Johannes Thumshirn <jthumshirn at suse.de>
Cc: Aviad Yehezkel <aviadye at mellanox.com>; oren at mellanox.com; Boris Pinzur <bpinzur at mellanox.com>; Omri Kahalon <omrik at mellanox.com>
Subject: Re: [Suspected-Phishing][PATCH 1/1] nvme-cli: enforce memory buffer for Host Identifier
Keith/Johannes,
can you have a look on this please ?
Quoted 34 lines · Max Gurtovoy
According to the NVMe spec, the NVMe Set Features command for Host Identifier (fid=0x81) must use memory buffer for its attributes. Enforce that and set the correct data length (16 for extended Host Identifier, 8 for non-extended). The data for the Host Identifier can be taken from a data file or from the stdin (same as before):
1. stdin example:
- echo "host1234" | nvme set-feature/dev/nvme2n1--feature-id=0x81
--value=0 2. data file example:
- echo "host5555" >/tmp/hostid.data
- nvme set-feature/dev/nvme2n1--feature-id=0x81 --value=0
--data=/tmp/hostid.dataSigned-off-by Max Gurtovoy <maxg at mellanox.com>--- nvme.c | 6 ++++++ 1 file changed, 6 insertions(+)nvme.c +6
-0@@ -3279,6 +3279,12 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin }if (cfg.feature_id ==NVME_FEAT_LBA_RANGE ) cfg.data_len =4096 ; +if (cfg.feature_id ==NVME_FEAT_HOST_ID ) { + cfg.data_len =8 ; +/* check for Extended Host Identifier */ +if (cfg.value &0x1 ) + cfg.data_len =16 ; + }if (cfg.data_len) {if (posix_memalign (&buf,getpagesize (), cfg.data_len)) {fprintf (stderr,"can not allocate feature payload\n" );
PATCH 1/1 nvme-cli: enforce memory buffer for Host Identifier
In reply to Max GurtovoyLooks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Keith Busch
maintainerPATCH 1/1 nvme-cli: enforce memory buffer for Host Identifier
Thanks, this looks good. Patch applied.