s390 fixes for 4.19-rc4
One fix for the zcrypt driver to correctly handle incomplete encryption/decryption operations. A cleanup for the aqmask/apmask parsing to avoid variable length arrays on the stack. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJbmkYUAAoJEDjwexyKj9rgrugH/21Uf1S0mkkRfDeYxD6lJva6 zNmEZ3V+GXc8L/0CisFWQOcIU1fO+jozp9HPGkQxeTvAuqIfVhBRVoMMxiTRaZb3 xdSBel8EvAGxlZq/6eq6fU59HPWGm+N53rC9J5MMQQqgpSmq8F2QeO5CoidflRh8 bdio9cliLsjPu+3P2JU3noolhb/f577J3dgP4gKARRpOfh8vUI7NLU3Mham+7886 ASjG8s/zr9spPnrErJusloOLDJt4M94J8KrIbB/WAT1wZv7GxClaGsCoyCuk4cDt TV8zIgMK9TChedwMOO0T8WMaxq+XJV+iI0dC1eZ7xNUlaIBw+UbifxCG335L3E0= =dHq1 -----END PGP SIGNATURE----- Merge tag 's390-4.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux Pull s390 fixes from Martin Schwidefsky: - One fix for the zcrypt driver to correctly handle incomplete encryption/decryption operations. - A cleanup for the aqmask/apmask parsing to avoid variable length arrays on the stack. * tag 's390-4.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/zcrypt: remove VLA usage from the AP bus s390/crypto: Fix return code checking in cbc_paes_crypt()
This commit is contained in:
commit
1d176582c7
@ -208,7 +208,7 @@ static int cbc_paes_crypt(struct blkcipher_desc *desc, unsigned long modifier,
|
|||||||
walk->dst.virt.addr, walk->src.virt.addr, n);
|
walk->dst.virt.addr, walk->src.virt.addr, n);
|
||||||
if (k)
|
if (k)
|
||||||
ret = blkcipher_walk_done(desc, walk, nbytes - k);
|
ret = blkcipher_walk_done(desc, walk, nbytes - k);
|
||||||
if (n < k) {
|
if (k < n) {
|
||||||
if (__cbc_paes_set_key(ctx) != 0)
|
if (__cbc_paes_set_key(ctx) != 0)
|
||||||
return blkcipher_walk_done(desc, walk, -EIO);
|
return blkcipher_walk_done(desc, walk, -EIO);
|
||||||
memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
|
memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
|
||||||
|
@ -872,8 +872,6 @@ static int hex2bitmap(const char *str, unsigned long *bitmap, int bits)
|
|||||||
if (bits & 0x07)
|
if (bits & 0x07)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
memset(bitmap, 0, bits / 8);
|
|
||||||
|
|
||||||
if (str[0] == '0' && str[1] == 'x')
|
if (str[0] == '0' && str[1] == 'x')
|
||||||
str++;
|
str++;
|
||||||
if (*str == 'x')
|
if (*str == 'x')
|
||||||
@ -895,25 +893,23 @@ static int hex2bitmap(const char *str, unsigned long *bitmap, int bits)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* str2clrsetmasks() - parse bitmask argument and set the clear and
|
* modify_bitmap() - parse bitmask argument and modify an existing
|
||||||
* the set bitmap mask. A concatenation (done with ',') of these terms
|
* bit mask accordingly. A concatenation (done with ',') of these
|
||||||
* is recognized:
|
* terms is recognized:
|
||||||
* +<bitnr>[-<bitnr>] or -<bitnr>[-<bitnr>]
|
* +<bitnr>[-<bitnr>] or -<bitnr>[-<bitnr>]
|
||||||
* <bitnr> may be any valid number (hex, decimal or octal) in the range
|
* <bitnr> may be any valid number (hex, decimal or octal) in the range
|
||||||
* 0...bits-1; the leading + or - is required. Here are some examples:
|
* 0...bits-1; the leading + or - is required. Here are some examples:
|
||||||
* +0-15,+32,-128,-0xFF
|
* +0-15,+32,-128,-0xFF
|
||||||
* -0-255,+1-16,+0x128
|
* -0-255,+1-16,+0x128
|
||||||
* +1,+2,+3,+4,-5,-7-10
|
* +1,+2,+3,+4,-5,-7-10
|
||||||
* Returns a clear and a set bitmask. Every positive value in the string
|
* Returns the new bitmap after all changes have been applied. Every
|
||||||
* results in a bit set in the set mask and every negative value in the
|
* positive value in the string will set a bit and every negative value
|
||||||
* string results in a bit SET in the clear mask. As a bit may be touched
|
* in the string will clear a bit. As a bit may be touched more than once,
|
||||||
* more than once, the last 'operation' wins: +0-255,-128 = all but bit
|
* the last 'operation' wins:
|
||||||
* 128 set in the set mask, only bit 128 set in the clear mask.
|
* +0-255,-128 = first bits 0-255 will be set, then bit 128 will be
|
||||||
|
* cleared again. All other bits are unmodified.
|
||||||
*/
|
*/
|
||||||
static int str2clrsetmasks(const char *str,
|
static int modify_bitmap(const char *str, unsigned long *bitmap, int bits)
|
||||||
unsigned long *clrmap,
|
|
||||||
unsigned long *setmap,
|
|
||||||
int bits)
|
|
||||||
{
|
{
|
||||||
int a, i, z;
|
int a, i, z;
|
||||||
char *np, sign;
|
char *np, sign;
|
||||||
@ -922,9 +918,6 @@ static int str2clrsetmasks(const char *str,
|
|||||||
if (bits & 0x07)
|
if (bits & 0x07)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
memset(clrmap, 0, bits / 8);
|
|
||||||
memset(setmap, 0, bits / 8);
|
|
||||||
|
|
||||||
while (*str) {
|
while (*str) {
|
||||||
sign = *str++;
|
sign = *str++;
|
||||||
if (sign != '+' && sign != '-')
|
if (sign != '+' && sign != '-')
|
||||||
@ -940,13 +933,10 @@ static int str2clrsetmasks(const char *str,
|
|||||||
str = np;
|
str = np;
|
||||||
}
|
}
|
||||||
for (i = a; i <= z; i++)
|
for (i = a; i <= z; i++)
|
||||||
if (sign == '+') {
|
if (sign == '+')
|
||||||
set_bit_inv(i, setmap);
|
set_bit_inv(i, bitmap);
|
||||||
clear_bit_inv(i, clrmap);
|
else
|
||||||
} else {
|
clear_bit_inv(i, bitmap);
|
||||||
clear_bit_inv(i, setmap);
|
|
||||||
set_bit_inv(i, clrmap);
|
|
||||||
}
|
|
||||||
while (*str == ',' || *str == '\n')
|
while (*str == ',' || *str == '\n')
|
||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
@ -970,44 +960,34 @@ static int process_mask_arg(const char *str,
|
|||||||
unsigned long *bitmap, int bits,
|
unsigned long *bitmap, int bits,
|
||||||
struct mutex *lock)
|
struct mutex *lock)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned long *newmap, size;
|
||||||
|
int rc;
|
||||||
|
|
||||||
/* bits needs to be a multiple of 8 */
|
/* bits needs to be a multiple of 8 */
|
||||||
if (bits & 0x07)
|
if (bits & 0x07)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (*str == '+' || *str == '-') {
|
size = BITS_TO_LONGS(bits)*sizeof(unsigned long);
|
||||||
DECLARE_BITMAP(clrm, bits);
|
newmap = kmalloc(size, GFP_KERNEL);
|
||||||
DECLARE_BITMAP(setm, bits);
|
if (!newmap)
|
||||||
|
return -ENOMEM;
|
||||||
i = str2clrsetmasks(str, clrm, setm, bits);
|
if (mutex_lock_interruptible(lock)) {
|
||||||
if (i)
|
kfree(newmap);
|
||||||
return i;
|
return -ERESTARTSYS;
|
||||||
if (mutex_lock_interruptible(lock))
|
|
||||||
return -ERESTARTSYS;
|
|
||||||
for (i = 0; i < bits; i++) {
|
|
||||||
if (test_bit_inv(i, clrm))
|
|
||||||
clear_bit_inv(i, bitmap);
|
|
||||||
if (test_bit_inv(i, setm))
|
|
||||||
set_bit_inv(i, bitmap);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DECLARE_BITMAP(setm, bits);
|
|
||||||
|
|
||||||
i = hex2bitmap(str, setm, bits);
|
|
||||||
if (i)
|
|
||||||
return i;
|
|
||||||
if (mutex_lock_interruptible(lock))
|
|
||||||
return -ERESTARTSYS;
|
|
||||||
for (i = 0; i < bits; i++)
|
|
||||||
if (test_bit_inv(i, setm))
|
|
||||||
set_bit_inv(i, bitmap);
|
|
||||||
else
|
|
||||||
clear_bit_inv(i, bitmap);
|
|
||||||
}
|
}
|
||||||
mutex_unlock(lock);
|
|
||||||
|
|
||||||
return 0;
|
if (*str == '+' || *str == '-') {
|
||||||
|
memcpy(newmap, bitmap, size);
|
||||||
|
rc = modify_bitmap(str, newmap, bits);
|
||||||
|
} else {
|
||||||
|
memset(newmap, 0, size);
|
||||||
|
rc = hex2bitmap(str, newmap, bits);
|
||||||
|
}
|
||||||
|
if (rc == 0)
|
||||||
|
memcpy(bitmap, newmap, size);
|
||||||
|
mutex_unlock(lock);
|
||||||
|
kfree(newmap);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user