提交 07ae5ac2 编写于 作者: M Mike Christie 提交者: Zheng Zengkai

scsi: libiscsi: Reset max/exp cmdsn during recovery

mainline inclusion
from mainline-v5.12-rc1
commit c8447e4c
category: bugfix
bugzilla: 107448
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c8447e4c2eb77dbb96012ae96e7c83179cecf880

-----------------------------------------------

If we lose the session then relogin, but the new cmdsn window has shrunk
(due to something like an admin changing a setting) we will have the old
exp/max_cmdsn values and will never be able to update them. For example,
max_cmdsn would be 64, but if on the target the user set the window to be
smaller then the target could try to return the max_cmdsn as 32. We will
see that new max_cmdsn in the rsp but because it's lower than the old
max_cmdsn when the window was larger we will not update it.

So this patch has us reset the window values during session cleanup so they
can be updated after a new login.

Link: https://lore.kernel.org/r/20210207044608.27585-8-michael.christie@oracle.comReviewed-by: NLee Duncan <lduncan@suse.com>
Signed-off-by: NMike Christie <michael.christie@oracle.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NYe Bin <yebin10@huawei.com>
Reviewed-by: NJason Yan <yanaijie@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 73db803f
...@@ -3253,6 +3253,13 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session, ...@@ -3253,6 +3253,13 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
session->leadconn = conn; session->leadconn = conn;
spin_unlock_bh(&session->frwd_lock); spin_unlock_bh(&session->frwd_lock);
/*
* The target could have reduced it's window size between logins, so
* we have to reset max/exp cmdsn so we can see the new values.
*/
spin_lock_bh(&session->back_lock);
session->max_cmdsn = session->exp_cmdsn = session->cmdsn + 1;
spin_unlock_bh(&session->back_lock);
/* /*
* Unblock xmitworker(), Login Phase will pass through. * Unblock xmitworker(), Login Phase will pass through.
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册