open-iscsi / tcmu-runner

A daemon that handles the userspace side of the LIO TCM-User backstore.
Apache License 2.0
189 stars 148 forks source link

Use get_unaligned_be*() to avoid UB #682

Closed dmitryash closed 1 year ago

dmitryash commented 2 years ago

In most cases using strict aliasing is undefined behaviour. Obviously cdb is supposed to be an array of bytes and accessing any CDB field using strict aliasing leads to misaligned read which may cause even a crash.

See here

lxbsz commented 2 years ago

@dmitryash

Could you add the signed-of-by: and add some comments in commit ? And what the UB means here ? Thanks!

dmitryash commented 1 year ago

@lxbsz Hi, I added the requested information, review please.

lxbsz commented 1 year ago

LGTM. Thanks!