summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
| * | sysfs: Verify parameter of sysfs_device_get()Wenchao Hao2020-12-121-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | In sysfs_device_get() we should firstly check whether devpath pointer is NULL before accessing it Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Wu Bo <wubo40@huawei.com>
| * | fwparam_ppc: Fix NULL pointer dereference in find_devtree()Wenchao Hao2020-12-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | If strdup() returns NULL, find_devtree() just return NULL to indicate this function execute failed. Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Wu Bo <wubo40@huawei.com>
| * | open-iscsi: Clean user_param list when process exitWenchao Hao2020-12-124-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both in iscsiadm and iscsistart, a list is initialized to management struct iscsi_param which allocated by idbm_alloc_user_param(). While both of iscsiadm and iscsistart did not free these iscsi_param when process exit, this patch add a free flow when process exit. Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Wu Bo <wubo40@huawei.com>
| * | iscsi_net_util: Fix NULL pointer dereference in find_vlan_dev()Wenchao Hao2020-12-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | if_nameindex() returns NULL on error, if it returns NULL, we just print the error info and return NULL. Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Wu Bo <wubo40@huawei.com>
| * | open-iscsi: Fix NULL pointer dereference in mgmt_ipc_read_req()Wenchao Hao2020-12-121-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | If malloc() returns NULL on fail, we should return -ENOMEM to avoid NULL pointer dereference. Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Wu Bo <wubo40@huawei.com>
| * | open-iscsi: Fix invalid pointer deference in find_initiator()Wenchao Hao2020-12-121-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | If calloc() returns NULL just return ENOMEM; if strdup() returns NULL we should free dev and return errno. Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
| * | iscsiuio: Fix invalid parameter when call fstat()Wenchao Hao2020-12-122-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both qedi_open() and bnx2x_open() perform 15 times retry to make system call open() successful, while this retry mechanism can not make sure open() can execute successfully. So this patch verify return value of open(), if it is still INVALID_FD just print error info and return the errno. Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
| * | iscsi-iname: Verify open() return value before calling read()Wenchao Hao2020-12-121-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | System call open() might return -1 if an error occurred which should be taken into consideration. Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Wu Bo <wubo40@huawei.com>
| * | iscsi_sysfs: Fix NULL pointer deference in iscsi_sysfs_read_ifaceWenchao Hao2020-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Check if t is valid before accessing it. Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Wu Bo <wubo40@huawei.com>
| * | Update .gitignore for cscope and gtags data baseWenchao Hao2020-12-121-0/+5
|/ / | | | | | | Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
* | Merge pull request #233 from wenchao-hao/masterLee Duncan2020-11-301-52/+37
|\ \ | | | | | | iscsiadm: Optimize the the verification of mode paramters by doing so sooner and in one place.
| * | iscsiadm: Optimize the the verification of mode paramtersWenchao Hao2020-11-231-52/+37
|/ / | | | | | | | | | | | | | | | | | | The mode parameters should be check earlier when recognize the mode, rather than mutiple calls after all commandline parameters are parsed. Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Wu Bo <wubo40@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
* | Merge pull request #229 from gulams/masterLee Duncan2020-11-173-2/+3
|\ \ | | | | | | iscsid: Poll timeout value to 1 minute for iscsid
| * | iscsid: Poll timeout value to 1 minute for iscsidGulam Mohamed2020-11-173-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Description =========== This patch has the following two changes ------------------------------------------ Change 1: Specify the poll timeout value to 1 minute as third parameter to the function iscsid_exec_req() when called from sync_session() Reason: Currently the poll timeout value sent sent to iscsid_response() from iscsid_exec_req() is "info->iscsid_req_tmo" which is -1 as set in "iscsi_sysfs_for_each_session()". When iscsid_response() receives this -1, it sets the timeout value to ISCSID_REQ_TIMEOUT (1000 ms) and also sets a local variable "poll_wait" to 1. There is a while loop below this which checks the value of "poll_wait". If "poll_wait" is set to 1, then it calls "continue". For sessions which are giving continuous connection errors (like target service stopped OR target node is shutdown OR any other continuous connection errors etc ...), this results in an indefinite while loop, as nothing will be written to the poll fd, resulting in further sessions not getting synced (or recovered) when the iscsid is restarted due to any reason (either manual restart of iscsid or rpm install). Poll timeout of 1 minute seems to be a reasonable value for the slow connections Change 2: Change the return error code from the function iscsid_response() to ISCSI_ERR_SESSION_NOT_CONNECTED when the poll times out and returns error 0 Reason: Currently the iscsid_response() function returns ISCSI_ERR_ISCSID_NOTCONN error code in case if the poll times out and the poll_wait variable is 0 (i.e poll timeout sent to iscsid_response() was -1). Returning this error code doesn't seem to be correct for the following two reasons: a. ISCSI_ERR_ISCSID_NOTCONN should be returned only when we are not able to connect to iscsid but we are in iscsid_response() function indicating that we were able to connect to iscsid successfully b. When ISCSI_ERR_ISCSID_NOTCONN is returned, the sync_session() will retry the request till 30 retries are reached. This causes an overlap of multiple "iscsi login task" in kernel and the kernel will return an error to the user-space indicating "Login/Text in progress. Cannot start new task.". This is repeated continuously which results in session not getting recovered even after it comes back up. Also at one point of time we observed that the kernel panics in "iscsi_sw_tcp_conn_set_param()" while trying to set the param ISCSI_PARAM_DATADGST_EN. We have a kernel fix for this panic which is in review for upstream
* | | Merge pull request #231 from yoshkosh/masterLee Duncan2020-11-162-2/+2
|\ \ \ | | | | | | | | iscsid: fix logging level when starting and shutting down daemon
| * | | iscsid: fix logging level when starting and shutting down daemonYoshifumi Kinoshita2020-11-112-2/+2
| | | |
* | | | iscsiadm: fix host stats mode coredumpLee Duncan2020-11-141-2/+14
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The command: > iscsiadm -m host -C stats -H <mac_addr> Copies in the user-supplied mac address without checking its length, but the maximum length is 17 characters. This overflows the next field in the structure, or if libc checking is enabled, produces this error: > *** buffer overflow detected ***: iscsiadm terminated Fix this by checking the length of the supply MAC address before copying it into the array. Some extra debugging error messages were added in the process.
* | | Merge pull request #230 from wenchao-hao/masterLee Duncan2020-11-101-1/+5
|\ \ \ | | | | | | | | Fix memory leak in sysfs_get_str
| * | | Fix memory leak in sysfs_get_strWenchao Hao2020-11-041-1/+5
| |/ / | | | | | | | | | | | | | | | | | | strlen(sysfs_value) return 0 do not mean sysfs_value is NULL and this memory should be freed Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
* | | Merge pull request #227 from kraj/masterLee Duncan2020-11-101-1/+1
|\ \ \ | | | | | | | | libopeniscsiusr: Compare with max int instead of max long
| * | | libopeniscsiusr: Compare with max int instead of max longKhem Raj2020-10-211-1/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This compares value member of int_list_tbl struct which is of unsigned int type. struct int_list_tbl { const char *name; unsigned int value; }; Clang compiler reports this comparison when -Wtautological-constant-out-of-range-compare is enabled | idbm.c:1042:2: error: result of comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always true [-Werror,-Wtautological-constant-out-of-range-compare] | _rec_int_list(SESSION_CHAP_ALGS, recs, node, session.auth.chap_algs, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | idbm.c:263:23: note: expanded from macro '_rec_int_list' | if (_org->_name[_i] != ~0UL) { \ | ~~~~~~~~~~~~~~~ ^ ~~~~ Since max value for int can be less than unsinged long e.g. on LP64 its better to use UINT_MAX here Signed-off-by: Khem Raj <raj.khem@gmail.com>
* | | Updated iscsiadm man page.Lee Duncan2020-11-091-36/+70
|/ / | | | | | | | | | | Fixed some quoting and spacing, but also cleaned up list of transports, as they were seriously out of date.
* | TODO: Update to todo list.sonukumar159842@gmail.com2020-10-131-0/+13
| | | | | | | | | | This patch is to update the todo list. Tasks are suggested by The Lee-Man
* | Implement login "no_wait" for iscsiadm NODE modeLee Duncan2020-10-083-38/+54
| | | | | | | | | | | | | | | | | | Commit 46183ffd36c9 added the "-W"/"--no_wait" flag to iscsiadm, in "node" mode, when doing loginall. This commit adds this functionality to mode node when logging into a single target. The man page was also updated, as was the README file, where appropriate.
* | Merge pull request #224 from cleech/for_upstreamChris Leech2020-09-211-0/+1
|\ \ | | | | | | iscsiadm buffer overflow regression when discovering many targets at …
| * | iscsiadm buffer overflow regression when discovering many targets at onceChris Leech2020-09-171-0/+1
|/ / | | | | | | | | | | int_list type didn't zero the output string, so as the rec struct was reused repeatedly during discovery it would keep growing with repeated values triggering a strcat buffer overflow
* | Merge pull request #221 from gulams/masterLee Duncan2020-09-101-1/+6
|\ \ | | | | | | Check Invalid Session id for stop connection
| * | iscsid: Check Invalid Session id for stop connectiongulams2020-09-101-1/+6
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Description: If the initiator is rebooting then after the reboot, it will try to resync (recreate) the existing the connections by reading the sysfs. While initiator is doing this, i.e when the initiator tries to connect to the target but if the target service is not yet started, then the initiator connection will fail. The session id is also not yet assigned and it will be at its initial value 0xFFFFFFFF which is invalid. The session id is assigned a valid value only after a successful connection. Since the connection is failed, the initiator code will queue the connection for re-open. The connection state is still at ISCSI_CONN_STATE_XPT_WAIT as its very first login attemp after the reboot. Due to my Pull #206 request the code will invoke the stop connection to decrement the socket_fd reference count to properly close the connecion (details are in pull request #206). But since the session id is not valid, the stop connection will fail and the code will go ahead and queue the re-open without attempting the connect again. This is repeated till 120 seconds (stop connection failing and requeuing the reopen without invoking connect) and the connection will be shutdown resulting the storage unavailable. Fix: We need to check the validity of the session id before calling the stop connection. If the session id is valid then only invoke the stop connection. Due to this, the code will go ahead and attempt the connet call. If the target service comes up anytime in 120 seconds, then the connect will be successful and we will get connected to the target.
* | Merge pull request #218 from gonzoleeman/async-login-v2Lee Duncan2020-08-152-15/+30
|\ \ | | | | | | Add ability to attempt target logins asynchronously
| * | Add ability to attempt target logins asynchronouslyLee Duncan2020-08-152-15/+30
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Add a "no wait" flag to iscsiadm, for use when it is logging into all targets of a certain "type", i.e. using the "--loginaall=" option, which iscsiadm will pass to the login_by_startup() routine. The wait/no-wait code was already present there, so just hook into it. NOTE: this means that "iscsiadm -m node ... -L=all -W" will return success if it is able to send a login request for each node, whether or not the logins succeed. The man page and usage info was also updated to document this new flag.
* | Preparing for version 2.1.22.1.2coverity_scanLee Duncan2020-07-243-2/+45
| |
* | Merge pull request #217 from ddiss/openssl_randLee Duncan2020-07-241-40/+16
|\ \ | | | | | | use openssl RAND_bytes() for mutual CHAP challenge buffer generation
| * | drop unused get_random_bytes()David Disseldorp2020-07-221-37/+0
| | | | | | | | | | | | | | | | | | | | | openssl's RAND_bytes() is now used instead, so this can be dropped. Suggested-by: Marcus Meissner <meissner@suse.de> Signed-off-by: David Disseldorp <ddiss@suse.de>
| * | use openssl for random data generationDavid Disseldorp2020-07-221-3/+16
|/ / | | | | | | | | | | | | | | 48a4e5b475836bcb952fb53a8bde45bdf68fe38f added an openssl dependency, so use it for obtaining random buffers via RAND_bytes(). Suggested-by: Marcus Meissner <meissner@suse.de> Signed-off-by: David Disseldorp <ddiss@suse.de>
* | Merge pull request #216 from rafaeldtinoco/masterLee Duncan2020-07-031-2/+2
|\ \ | | | | | | Misspelled socket name might cause confusion to inexperienced user.
| * | Misspelled socket name might cause confusion to inexperienced user.Rafael David Tinoco2020-07-021-2/+2
|/ / | | | | | | Signed-off-by: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>
* | Merge pull request #213 from wubo009/masterLee Duncan2020-06-261-1/+2
|\ \ | | | | | | iscsi/libopeniscsiusr:Fix libopeniscsiusr_node.h file is not installed
| * | iscsi/libopeniscsiusr:add libopeniscsiuser_node.h to HEADERSwubo0092020-06-151-1/+2
| | |
* | | Merge pull request #211 from liubozju/iscsi-devLee Duncan2020-06-061-1/+4
|\ \ \ | | | | | | | | iscsi: Add break to while loop
| * | | iscsi: Add break to while loopwubo0092020-06-041-1/+4
| | | |
* | | | Merge pull request #212 from lixiaokeng/masterLee Duncan2020-06-061-0/+1
|\ \ \ \ | |/ / / |/| | | iscsi: fix fd leak
| * | | iscsi: fix fd leakwubo0092020-06-041-0/+1
|/ / /
* | | Merge pull request #210 from gonzoleeman/fix-zero-len-and-moreLee Duncan2020-06-033-8/+18
|\ \ \ | | | | | | | | Fix zero length array usage, and some iscsiuio compiler issues
| * | | Fix compiler complaint about string copy in iscsiuioLee Duncan2020-06-031-5/+15
| | | | | | | | | | | | | | | | | | | | This makes the compiler happy when searching for uio%d sysfs directories.
| * | | Fix a compiler complaint about writing one byteLee Duncan2020-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When playing with IPv6 IP addresses, which are described in C using a union, and the gcc-10 compiler didn't like that we were not specifying which member of the union we wanted to address of, when in fact all members have the same address. The fix is to be more explicit.
| * | | Fix issue with zero-length arrays at end of structLee Duncan2020-06-031-2/+2
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A common practice in C coding, over the years, has been to add a zero-length array at the end of the structure when trying to represent a possibly-empty array of bytes that may be appended to the struct. But the gcc-10 compiler does not like such structures, taking the zero-length literally. The following errors are fixed by this commit: > iscsiadm.c: In function ‘session_stats’: > iscsiadm.c:939:56: error: array subscript ‘(<unknown>) + -1’ is outside the bounds of an interior zero-length array ‘struct iscsi_stats_custom[0]’ [-Werror=zero-length-bounds] > 939 | (unsigned long long)rsp.u.getstats.stats.custom[i].value); > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ > In file included from initiator.h:29, > from iscsiadm.c:36: > ../include/iscsi_if.h:844:28: note: while referencing ‘custom’ > 844 | struct iscsi_stats_custom custom[0] > | ^~~~~~ > iscsiadm.c:938:56: error: array subscript ‘(<unknown>) + -1’ is outside the bounds of an interior zero-length array ‘struct iscsi_stats_custom[0]’ [-Werror=zero-length-bounds] > 938 | printf("\t%s: %llu\n", rsp.u.getstats.stats.custom[i].desc, > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ > In file included from initiator.h:29, > from iscsiadm.c:36: > ../include/iscsi_if.h:844:28: note: while referencing ‘custom’ > 844 | struct iscsi_stats_custom custom[0] > | ^~~~~~ > cc1: all warnings being treated as errors The work around is to convert the two "custom[0]" structure members to use "custom[]".
* | | Merge pull request #207 from LorbusChris/init-serviceLee Duncan2020-05-262-3/+11
|\ \ \ | | | | | | | | Add iscsi-init.service
| * | | Add iscsi-init.serviceChristian Glombek2020-05-062-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Per Fedora Packaging Guidelines [1], initial configuration of a service should happen in a one-off init service in order to ensure idempotency, and not in the %post directive of the RPM spec. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1493296 [1]: https://docs.fedoraproject.org/en-US/packaging-guidelines/Initial_Service_Setup/
* | | | Merge pull request #206 from gulams/patch-1Lee Duncan2020-05-061-5/+1
|\ \ \ \ | |/ / / |/| | | Proper disconnect of TCP connection
| * | | Proper disconnect of TCP connectiongulams2020-05-041-5/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Due to configuration issues, the logins from iSCSI initiator were getting rejected by the target 2. The initiator was retrying the login again and again 3. Each time the initiator tries to log in, the host number gets incremented by 1 4. At one point of time, the host number reached 65535 5. During the login process, once the TCP connection is established, the initiator tries to set the host parameters for the network interface if its not the default interface 6. While setting these host parameters, it will try to do a lookup of the host based upon the host number 7. The host number in "iscsi_uevent" structure is uint32_t. This is given as an argument to the scsi_host_lookup() function 8. This scsi_host_lookup() function takes it as unsigned short. So, when it receives the host number above 65535, the value is wrapped and starts from 0 again 9. Thus the incorrect value of host number is received by the scsi_host_lookup() function and hence it returns with error that the host is not existing in the list 10. Due to this "host not found error", the open-iscsi will retry this particular connection again and again 11. In this each retry, it will disconnect and then connect again with the same connection pointer, i.e it re-opens the connection multiple times till 120 seconds timeout 12. During these 120 seconds, observed that its trying to re-open the connection aroung 400+ times with each time disconnect and connect 13. After 120 seconds, the connection and session will be destroyed 14. So, while doing multiple retries of connect and disconnect during the 120 seconds, when the connect is successful it will try to bind the connection to the session 15. When it binds the connection and session, the reference count for the socket is incremented 16. When it disconnects, its trying to close the socket with close(sockfd) system call 17. This close() system call is entering into the kernel and NOT going forward till the networking layrer to call tcp_close() to send the FIN packet to the target 18. Its not going till tcp_close() because the reference count of the socket is still 1 19. So, the initiator is not sending the FIN packet to target and hence target is timing out and sending FIN after its timeout. This happens for all the retries (400+) 20. At some point, when this FIN packet is received by the initiator, the connection was destroyed and the memory was re-used for some other purpose and hence we see the panic Fix: == Fix is to decrement the reference count of the socket fd after disconnect by calling the stop connection Corrected the indentation for the change in the function iscsi_login_eh()