* Prevent accidental deletion of EFI variables through efivarfs that
may brick machines. We use a whitelist of known-safe variables to allow things like installing distributions to work out of the box, and instead restrict vendor-specific variable deletion by making non-whitelist variables immutable - Peter Jones -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJWvbEYAAoJEC84WcCNIz1VatYP/1kkly4lIuSYmaQrvF9V/L75 lYNHjEURT55EDq4VAHH/wey3SbDkwy3wBsmfkkJTV1zhA+SHSAG2k097xGyLP6Xr X+htIj//HH7U3SRWk66UiwkY/866sXCqVRN2vvjBxvP9Z/rTDKe7zRQdVVdCt80P 88H/1Nxy1S8eDExMGCvq8TbtWCSKV6P8197rUqUMf37Sbqr7yBM/sYDitdwOiGTW gzLwJjWJgDsKw+BWaj5NNZzVAb1Dgof5oEL5WGCU7gJSis08i4cHoRiwutYk2g8f ZbMnKvlFmiHGbjriowyNPm+pgRVDbS8JvJtORA1qXuVJFPtqV7Wdvdh+jJpdYXLp bO8EB/yfc7PTH8ScbNbIcgmCknsItRh2SDNXxM/BY/dzaSkzVI/Wr6GauWKInQJ6 IypOMijITmnJ5Sij0V4aMUTZWS5btZt15iqAg3xUqWT9DJ61bIER+eGEhV6hx+7S pSydQylbaVFpyswdCpJRsfxHfW5j0G9BxnKZGTh+LHeb6dXaughUq2EIdUNHWyEZ 3geJPC3Mh50MngO8phIq+DzjA4K84JZ9j6M3O27+x3bfLAqiktZS6HiaTSmSGNyM 95swhpyHREeLQqYUUTOWiz1rlQ9cW+Bmkhy7Wn3RBZ033YNtmpyoZup0432mwkMm Wur3Jxd0GFz7zUkqvN3O =F4YT -----END PGP SIGNATURE----- Merge tag 'efi-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi into x86/urgent Pull EFI fixes from Matt Fleming: * Prevent accidental deletion of EFI variables through efivarfs that may brick machines. We use a whitelist of known-safe variables to allow things like installing distributions to work out of the box, and instead restrict vendor-specific variable deletion by making non-whitelist variables immutable (Peter Jones) Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
commit
4682c211a8
12 changed files with 384 additions and 84 deletions
|
@ -49,3 +49,65 @@ ucs2_strncmp(const ucs2_char_t *a, const ucs2_char_t *b, size_t len)
|
|||
}
|
||||
}
|
||||
EXPORT_SYMBOL(ucs2_strncmp);
|
||||
|
||||
unsigned long
|
||||
ucs2_utf8size(const ucs2_char_t *src)
|
||||
{
|
||||
unsigned long i;
|
||||
unsigned long j = 0;
|
||||
|
||||
for (i = 0; i < ucs2_strlen(src); i++) {
|
||||
u16 c = src[i];
|
||||
|
||||
if (c > 0x800)
|
||||
j += 3;
|
||||
else if (c > 0x80)
|
||||
j += 2;
|
||||
else
|
||||
j += 1;
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
EXPORT_SYMBOL(ucs2_utf8size);
|
||||
|
||||
/*
|
||||
* copy at most maxlength bytes of whole utf8 characters to dest from the
|
||||
* ucs2 string src.
|
||||
*
|
||||
* The return value is the number of characters copied, not including the
|
||||
* final NUL character.
|
||||
*/
|
||||
unsigned long
|
||||
ucs2_as_utf8(u8 *dest, const ucs2_char_t *src, unsigned long maxlength)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned long j = 0;
|
||||
unsigned long limit = ucs2_strnlen(src, maxlength);
|
||||
|
||||
for (i = 0; maxlength && i < limit; i++) {
|
||||
u16 c = src[i];
|
||||
|
||||
if (c > 0x800) {
|
||||
if (maxlength < 3)
|
||||
break;
|
||||
maxlength -= 3;
|
||||
dest[j++] = 0xe0 | (c & 0xf000) >> 12;
|
||||
dest[j++] = 0x80 | (c & 0x0fc0) >> 8;
|
||||
dest[j++] = 0x80 | (c & 0x003f);
|
||||
} else if (c > 0x80) {
|
||||
if (maxlength < 2)
|
||||
break;
|
||||
maxlength -= 2;
|
||||
dest[j++] = 0xc0 | (c & 0xfe0) >> 5;
|
||||
dest[j++] = 0x80 | (c & 0x01f);
|
||||
} else {
|
||||
maxlength -= 1;
|
||||
dest[j++] = c & 0x7f;
|
||||
}
|
||||
}
|
||||
if (maxlength)
|
||||
dest[j] = '\0';
|
||||
return j;
|
||||
}
|
||||
EXPORT_SYMBOL(ucs2_as_utf8);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue