Skip to content

Commit da87c77

Browse files
committed
Merge tag 's390-6.9-6' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 fixes from Alexander Gordeev: - The function __storage_key_init_range() expects the end address to be the first byte outside the range to be initialized. Fix the callers that provide the last byte within the range instead. - 3270 Channel Command Word (CCW) may contain zero data address in case there is no data in the request. Add data availability check to avoid erroneous non-zero value as result of virt_to_dma32(NULL) application in cases there is no data - Add missing CFI directives for an unwinder to restore the return address in the vDSO assembler code - NUL-terminate kernel buffer when duplicating user space memory region on Channel IO (CIO) debugfs write inject - Fix wrong format string in zcrypt debug output - Return -EBUSY code when a CCA card is temporarily unavailabile - Restore a loop that retries derivation of a protected key from a secure key in cases the low level reports temporarily unavailability with -EBUSY code * tag 's390-6.9-6' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/paes: Reestablish retry loop in paes s390/zcrypt: Use EBUSY to indicate temp unavailability s390/zcrypt: Handle ep11 cprb return code s390/zcrypt: Fix wrong format string in debug feature printout s390/cio: Ensure the copied buf is NUL terminated s390/vdso: Add CFI for RA register to asm macro vdso_func s390/3270: Fix buffer assignment s390/mm: Fix clearing storage keys for huge pages s390/mm: Fix storage key clearing for guest huge pages
2 parents 09bf0f1 + 7bbe449 commit da87c77

File tree

9 files changed

+73
-11
lines changed

9 files changed

+73
-11
lines changed

arch/s390/crypto/paes_s390.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,19 @@ struct s390_pxts_ctx {
125125
static inline int __paes_keyblob2pkey(struct key_blob *kb,
126126
struct pkey_protkey *pk)
127127
{
128-
return pkey_keyblob2pkey(kb->key, kb->keylen,
129-
pk->protkey, &pk->len, &pk->type);
128+
int i, ret = -EIO;
129+
130+
/* try three times in case of busy card */
131+
for (i = 0; ret && i < 3; i++) {
132+
if (ret == -EBUSY && in_task()) {
133+
if (msleep_interruptible(1000))
134+
return -EINTR;
135+
}
136+
ret = pkey_keyblob2pkey(kb->key, kb->keylen,
137+
pk->protkey, &pk->len, &pk->type);
138+
}
139+
140+
return ret;
130141
}
131142

132143
static inline int __paes_convert_key(struct s390_paes_ctx *ctx)

arch/s390/include/asm/dwarf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define CFI_DEF_CFA_OFFSET .cfi_def_cfa_offset
1010
#define CFI_ADJUST_CFA_OFFSET .cfi_adjust_cfa_offset
1111
#define CFI_RESTORE .cfi_restore
12+
#define CFI_REL_OFFSET .cfi_rel_offset
1213

1314
#ifdef CONFIG_AS_CFI_VAL_OFFSET
1415
#define CFI_VAL_OFFSET .cfi_val_offset

arch/s390/kernel/vdso64/vdso_user_wrapper.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ __kernel_\func:
2424
CFI_DEF_CFA_OFFSET (STACK_FRAME_OVERHEAD + WRAPPER_FRAME_SIZE)
2525
CFI_VAL_OFFSET 15, -STACK_FRAME_OVERHEAD
2626
stg %r14,STACK_FRAME_OVERHEAD(%r15)
27+
CFI_REL_OFFSET 14, STACK_FRAME_OVERHEAD
2728
brasl %r14,__s390_vdso_\func
2829
lg %r14,STACK_FRAME_OVERHEAD(%r15)
30+
CFI_RESTORE 14
2931
aghi %r15,WRAPPER_FRAME_SIZE
3032
CFI_DEF_CFA_OFFSET STACK_FRAME_OVERHEAD
3133
CFI_RESTORE 15

arch/s390/mm/gmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2661,7 +2661,7 @@ static int __s390_enable_skey_hugetlb(pte_t *pte, unsigned long addr,
26612661
return 0;
26622662

26632663
start = pmd_val(*pmd) & HPAGE_MASK;
2664-
end = start + HPAGE_SIZE - 1;
2664+
end = start + HPAGE_SIZE;
26652665
__storage_key_init_range(start, end);
26662666
set_bit(PG_arch_1, &page->flags);
26672667
cond_resched();

arch/s390/mm/hugetlbpage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void clear_huge_pte_skeys(struct mm_struct *mm, unsigned long rste)
139139
}
140140

141141
if (!test_and_set_bit(PG_arch_1, &page->flags))
142-
__storage_key_init_range(paddr, paddr + size - 1);
142+
__storage_key_init_range(paddr, paddr + size);
143143
}
144144

145145
void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr,

drivers/s390/char/raw3270.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ struct raw3270_request *raw3270_request_alloc(size_t size)
162162
/*
163163
* Setup ccw.
164164
*/
165-
rq->ccw.cda = virt_to_dma32(rq->buffer);
165+
if (rq->buffer)
166+
rq->ccw.cda = virt_to_dma32(rq->buffer);
166167
rq->ccw.flags = CCW_FLAG_SLI;
167168

168169
return rq;
@@ -188,7 +189,8 @@ int raw3270_request_reset(struct raw3270_request *rq)
188189
return -EBUSY;
189190
rq->ccw.cmd_code = 0;
190191
rq->ccw.count = 0;
191-
rq->ccw.cda = virt_to_dma32(rq->buffer);
192+
if (rq->buffer)
193+
rq->ccw.cda = virt_to_dma32(rq->buffer);
192194
rq->ccw.flags = CCW_FLAG_SLI;
193195
rq->rescnt = 0;
194196
rq->rc = 0;

drivers/s390/cio/cio_inject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static ssize_t crw_inject_write(struct file *file, const char __user *buf,
9595
return -EINVAL;
9696
}
9797

98-
buffer = vmemdup_user(buf, lbuf);
98+
buffer = memdup_user_nul(buf, lbuf);
9999
if (IS_ERR(buffer))
100100
return -ENOMEM;
101101

drivers/s390/crypto/zcrypt_ccamisc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ int cca_sec2protkey(u16 cardnr, u16 domain,
658658
(int)prepcblk->ccp_rtcode,
659659
(int)prepcblk->ccp_rscode);
660660
if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290)
661-
rc = -EAGAIN;
661+
rc = -EBUSY;
662662
else
663663
rc = -EIO;
664664
goto out;
@@ -1263,7 +1263,7 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey,
12631263
(int)prepcblk->ccp_rtcode,
12641264
(int)prepcblk->ccp_rscode);
12651265
if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290)
1266-
rc = -EAGAIN;
1266+
rc = -EBUSY;
12671267
else
12681268
rc = -EIO;
12691269
goto out;
@@ -1426,7 +1426,7 @@ int cca_ecc2protkey(u16 cardnr, u16 domain, const u8 *key,
14261426
(int)prepcblk->ccp_rtcode,
14271427
(int)prepcblk->ccp_rscode);
14281428
if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290)
1429-
rc = -EAGAIN;
1429+
rc = -EBUSY;
14301430
else
14311431
rc = -EIO;
14321432
goto out;

drivers/s390/crypto/zcrypt_ep11misc.c

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,29 @@ static int check_reply_pl(const u8 *pl, const char *func)
556556
pl += 2;
557557
ret = *((u32 *)pl);
558558
if (ret != 0) {
559-
ZCRYPT_DBF_ERR("%s return value 0x%04x != 0\n", func, ret);
559+
ZCRYPT_DBF_ERR("%s return value 0x%08x != 0\n", func, ret);
560560
return -EIO;
561561
}
562562

563563
return 0;
564564
}
565565

566+
/* Check ep11 reply cprb, return 0 or suggested errno value. */
567+
static int check_reply_cprb(const struct ep11_cprb *rep, const char *func)
568+
{
569+
/* check ep11 reply return code field */
570+
if (rep->ret_code) {
571+
ZCRYPT_DBF_ERR("%s ep11 reply ret_code=0x%08x\n", __func__,
572+
rep->ret_code);
573+
if (rep->ret_code == 0x000c0003)
574+
return -EBUSY;
575+
else
576+
return -EIO;
577+
}
578+
579+
return 0;
580+
}
581+
566582
/*
567583
* Helper function which does an ep11 query with given query type.
568584
*/
@@ -627,6 +643,12 @@ static int ep11_query_info(u16 cardnr, u16 domain, u32 query_type,
627643
goto out;
628644
}
629645

646+
/* check ep11 reply cprb */
647+
rc = check_reply_cprb(rep, __func__);
648+
if (rc)
649+
goto out;
650+
651+
/* check payload */
630652
rc = check_reply_pl((u8 *)rep_pl, __func__);
631653
if (rc)
632654
goto out;
@@ -877,6 +899,12 @@ static int _ep11_genaeskey(u16 card, u16 domain,
877899
goto out;
878900
}
879901

902+
/* check ep11 reply cprb */
903+
rc = check_reply_cprb(rep, __func__);
904+
if (rc)
905+
goto out;
906+
907+
/* check payload */
880908
rc = check_reply_pl((u8 *)rep_pl, __func__);
881909
if (rc)
882910
goto out;
@@ -1028,6 +1056,12 @@ static int ep11_cryptsingle(u16 card, u16 domain,
10281056
goto out;
10291057
}
10301058

1059+
/* check ep11 reply cprb */
1060+
rc = check_reply_cprb(rep, __func__);
1061+
if (rc)
1062+
goto out;
1063+
1064+
/* check payload */
10311065
rc = check_reply_pl((u8 *)rep_pl, __func__);
10321066
if (rc)
10331067
goto out;
@@ -1185,6 +1219,12 @@ static int _ep11_unwrapkey(u16 card, u16 domain,
11851219
goto out;
11861220
}
11871221

1222+
/* check ep11 reply cprb */
1223+
rc = check_reply_cprb(rep, __func__);
1224+
if (rc)
1225+
goto out;
1226+
1227+
/* check payload */
11881228
rc = check_reply_pl((u8 *)rep_pl, __func__);
11891229
if (rc)
11901230
goto out;
@@ -1339,6 +1379,12 @@ static int _ep11_wrapkey(u16 card, u16 domain,
13391379
goto out;
13401380
}
13411381

1382+
/* check ep11 reply cprb */
1383+
rc = check_reply_cprb(rep, __func__);
1384+
if (rc)
1385+
goto out;
1386+
1387+
/* check payload */
13421388
rc = check_reply_pl((u8 *)rep_pl, __func__);
13431389
if (rc)
13441390
goto out;

0 commit comments

Comments
 (0)