]> git.baikalelectronics.ru Git - kernel.git/commit
tcm_vhost: Fix vhost_scsi_target structure alignment
authorMichael S. Tsirkin <mst@redhat.com>
Sat, 18 Aug 2012 22:44:09 +0000 (15:44 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Mon, 20 Aug 2012 21:52:11 +0000 (14:52 -0700)
commita8a75cb481c645843462ce8ffa05fbc80f6f6e83
tree3958d4cf730acc08fb9f9f1ad3be4cb132eca17e
parentf03a0a426f0ec88b80a5ff3c3a3b2fa70dfc436a
tcm_vhost: Fix vhost_scsi_target structure alignment

Here TRANSPORT_IQN_LEN is 224, which is a multiple of 4.
Since vhost_tpgt is 2 bytes and abi_version is 4, the total size would
be 230.  But gcc needs struct size be aligned to first field size, which
is 4 bytes, so it pads the structure by extra 2 bytes to the total of
232.

This padding is very undesirable in an ABI:
- it can not be initialized easily
- it can not be checked easily
- it can leak information between kernel and userspace

Simplest solution is probably just to make the padding
explicit.

(v2: Add check for zero'ed backend->reserved field for VHOST_SCSI_SET_ENDPOINT
     and VHOST_SCSI_CLEAR_ENDPOINT ops as requested by MST)

Reported-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/vhost/tcm_vhost.c
drivers/vhost/tcm_vhost.h