Hello,

I've been trying to run open-iscsi with a 32bit userspce and a 64bit kernel with no luck. I found references to this issue in the following links:
https://groups.google.com/forum/?fromgroups=#!searchin/open-iscsi/64bit/open-iscsi/CQXCBczvIrE/NdXbde__HFIJ
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=502845

This issue is caused by two structs in the union iscsi_uevent.u in 
include/iscsi_if.h and linux/scsi/iscsi_if.h differning in
size on 32bit and 64bit systems. When this happens the union iscsi_uevent.r is 
offset by 4 bytes, causing reads in the 32bit
userspace to read in the wrong values.

I've attached the below patches which can be applied to both the kernel and the 
open-iscsi client. They have been tested on
x86/x86 user/kernel, and a x86/x86_64 user/kernel. This still needs to be 
tested on an x86_64/x86_64 user/kernel as well as any
other system that has a 32bit userspace and a 64bit kernel.

Thanks,
~Lisa M

open-iscsi.-alignment.patch:
--- a/include/iscsi_if.h
+++ b/include/iscsi_if.h
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2005 Dmitry Yusupov
  * Copyright (C) 2005 Alex Aizman
+ * Copyright (C) 2012 Lisa Maginnis
  * maintained by open-iscsi@googlegroups.com
  *
  * This program is free software; you can redistribute it and/or modify
@@ -106,6 +107,14 @@ struct iscsi_uevent {
        uint32_t iferror; /* carries interface or resource errors */
        uint64_t transport_handle;

+       /* Structs in this union can differ on size between 32bit and 64bit
+        * systems. This will break systems running a 32bit userspace with a
+ * 64bit kernel. It is important to specify an alignment for the + * struct(s) so that their sizes match on both in both 32 and 64bit
+        * systems. Currently the two largest structs are:
+        * msg_bind_conn: 20 bytes, 24 aligned to the sizeof(uint64_t)
+        * stop_conn:     20 bytes, 24 aligned to the sizeof(uint64_t)
+        */
        union {
                /* messages u -> k */
                struct msg_create_session {
@@ -131,7 +140,7 @@ struct iscsi_uevent {
                        uint32_t        cid;
                        uint64_t        transport_eph;
                        uint32_t        is_leading;
-               } b_conn;
+               } b_conn __attribute__((aligned (sizeof(uint64_t))));
                struct msg_destroy_conn {
                        uint32_t        sid;
                        uint32_t        cid;
@@ -157,7 +166,7 @@ struct iscsi_uevent {
                        uint32_t        cid;
                        uint64_t        conn_handle;
                        uint32_t        flag;
-               } stop_conn;
+               } stop_conn __attribute__((aligned (sizeof(uint64_t))));
                struct msg_get_stats {
                        uint32_t        sid;
                        uint32_t        cid;

linux-3.2-iscsi_if_alginment.patch:
--- a/linux-source-3.2/include/scsi/iscsi_if.h
+++ b/linux-source-3.2-patched/include/scsi/iscsi_if.h
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2005 Dmitry Yusupov
  * Copyright (C) 2005 Alex Aizman
+ * Copyright (C) 2012 Lisa Maginnis
  * maintained by open-iscsi@googlegroups.com
  *
  * This program is free software; you can redistribute it and/or modify
@@ -85,6 +86,14 @@ struct iscsi_uevent {
        uint32_t iferror; /* carries interface or resource errors */
        uint64_t transport_handle;

+       /* Structs in this union can differ on size between 32bit and 64bit
+        * systems. This will break systems running a 32bit userspace with a
+ * 64bit kernel. It is important to specify an alignment for the + * struct(s) so that their sizes match on both in both 32 and 64bit
+        * systems. Currently the two largest structs are:
+        * msg_bind_conn: 20 bytes, 24 aligned to the sizeof(uint64_t)
+        * stop_conn:     20 bytes, 24 aligned to the sizeof(uint64_t)
+        */
        union {
                /* messages u -> k */
                struct msg_create_session {
@@ -110,7 +119,7 @@ struct iscsi_uevent {
                        uint32_t        cid;
                        uint64_t        transport_eph;
                        uint32_t        is_leading;
-               } b_conn;
+               } b_conn __attribute__((aligned (sizeof(uint64_t))));
                struct msg_destroy_conn {
                        uint32_t        sid;
                        uint32_t        cid;
@@ -136,7 +145,7 @@ struct iscsi_uevent {
                        uint32_t        cid;
                        uint64_t        conn_handle;
                        uint32_t        flag;
-               } stop_conn;
+               } stop_conn __attribute__((aligned (sizeof(uint64_t))));
                struct msg_get_stats {
                        uint32_t        sid;
                        uint32_t        cid;

--
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to