s390: uv: Fix loop condition in uv_find_secrets
PATCH 1/1 s390: uv: Fix loop condition in uv_find_secrets
Nothing modified start_idx between the assignment and the comparison, so the condition was always false and the do/while ran exactly once even when the UV returned UVC_RC_MORE_DATA. Systems with more than 85 UV secrets got -ENOENT for any secret past the first page.
Fix this by setting the start index at the beginning of the loop not at the end. First test if there are more secrets left by comparing start_idx with list->next_secret_idx, and then set the start index to the next secret index.
--- arch/s390/kernel/uv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/kernel/uv.c +4 -2
@@ -781,11 +781,14 @@ int uv_find_secret(const u8 secret_id[UV_SECRET_ID_LEN],struct uv_secret_list *list, struct uv_secret_list_item_hdr *secret) { - u16 start_idx = 0; + u16 start_idx;u16 list_rc;int ret; + list->next_secret_idx =0 ; + do { + start_idx = list->next_secret_idx; uv_list_secrets(list, start_idx, &list_rc, NULL); if (list_rc != UVC_RC_EXECUTED && list_rc != UVC_RC_MORE_DATA) { if (list_rc == UVC_RC_INV_CMD)
@@ -796,7 +799,6 @@ int uv_find_secret(const u8 secret_id[UV_SECRET_ID_LEN], ret =find_secret_in_page (secret_id, list, secret);if (ret ==0 )return ret; - start_idx = list->next_secret_idx; }while (list_rc ==UVC_RC_MORE_DATA && start_idx < list->next_secret_idx);return -ENOENT ;
---
base-commit: d58772d8520c7ef247c4b95c9bd76d3a25da9ff5
change-id: 20260811-uv_secrets_fix-58a63b4a4ec4
Best regards,
Signature · 1 line
Steffen Eiden <[email protected]>
Quoted 5 lines · On Tue, 11 Aug 2026 10:43:52 +0200 Steffen Eiden <[email protected]> wrote:
Nothing modified
start_idxbetween the assignment and the comparison, so the condition was always false and the do/while ran exactly once even when the UV returned UVC_RC_MORE_DATA. Systems with more than 85 UV secrets got-ENOENTfor any secret past the first page.
Quoted 7 lines
Fix this by setting the start index at the beginning of the loop not at the end. First test if there are more secrets left by comparing
start_idxwithlist->next_secret_idx, and then set the start index to the next secret index.Fixes 7c9137af2042 ("s390/uv: Retrieve UV secrets support")Signed-off-by Steffen Eiden <[email protected]>
Quoted 38 lines
--- arch/s390/kernel/uv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/s390/kernel/uv.c +4
-3@@ -781,11 +781,14 @@ int uv_find_secret(const u8 secret_id[UV_SECRET_ID_LEN],struct uv_secret_list *list, struct uv_secret_list_item_hdr *secret) { - u16 start_idx = 0; + u16 start_idx;u16 list_rc;int ret; + list->next_secret_idx =0 ; + do { + start_idx = list->next_secret_idx; uv_list_secrets(list, start_idx, &list_rc, NULL); if (list_rc != UVC_RC_EXECUTED && list_rc != UVC_RC_MORE_DATA) { if (list_rc == UVC_RC_INV_CMD)@@ -796,7 +799,6 @@ int uv_find_secret(const u8 secret_id[UV_SECRET_ID_LEN], ret =find_secret_in_page (secret_id, list, secret);if (ret ==0 )return ret; - start_idx = list->next_secret_idx; }while (list_rc ==UVC_RC_MORE_DATA && start_idx < list->next_secret_idx);return -ENOENT ; ---base-commit:
d58772d8520c7ef247c4b95c9bd76d3a25da9ff5
change-id: 20260811-uv_secrets_fix-58a63b4a4ec4Best regards,
Quoted 5 lines · Steffen Eiden
Nothing modified
start_idxbetween the assignment and the comparison, so the condition was always false and the do/while ran exactly once even when the UV returned UVC_RC_MORE_DATA. Systems with more than 85 UV secrets got-ENOENTfor any secret past the first page.
Quoted 7 lines
Fix this by setting the start index at the beginning of the loop not at the end. First test if there are more secrets left by comparing
start_idxwithlist->next_secret_idx, and then set the start index to the next secret index.Fixes 7c9137af2042 ("s390/uv: Retrieve UV secrets support")Signed-off-by Steffen Eiden <[email protected]>
Quoted 38 lines
--- arch/s390/kernel/uv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/s390/kernel/uv.c +4
-3@@ -781,11 +781,14 @@ int uv_find_secret(const u8 secret_id[UV_SECRET_ID_LEN],struct uv_secret_list *list, struct uv_secret_list_item_hdr *secret) { - u16 start_idx = 0; + u16 start_idx;u16 list_rc;int ret; + list->next_secret_idx =0 ; + do { + start_idx = list->next_secret_idx; uv_list_secrets(list, start_idx, &list_rc, NULL); if (list_rc != UVC_RC_EXECUTED && list_rc != UVC_RC_MORE_DATA) { if (list_rc == UVC_RC_INV_CMD)@@ -796,7 +799,6 @@ int uv_find_secret(const u8 secret_id[UV_SECRET_ID_LEN], ret =find_secret_in_page (secret_id, list, secret);if (ret ==0 )return ret; - start_idx = list->next_secret_idx; }while (list_rc ==UVC_RC_MORE_DATA && start_idx < list->next_secret_idx);return -ENOENT ; ---base-commit:
d58772d8520c7ef247c4b95c9bd76d3a25da9ff5
change-id: 20260811-uv_secrets_fix-58a63b4a4ec4Best regards,