Messages in this thread | | | Date | Tue, 14 Nov 2017 08:34:08 +0100 | From | Ingo Molnar <> | Subject | Re: [RESEND PATCH v2 4/4] x86/umip: Warn if UMIP-protected instructions are used |
| |
* Ricardo Neri <ricardo.neri-calderon@linux.intel.com> wrote:
> +const char * const umip_insns[5] = { > + [UMIP_INST_SGDT] = "sgdt", > + [UMIP_INST_SIDT] = "sidt", > + [UMIP_INST_SMSW] = "smsw", > + [UMIP_INST_SLDT] = "sldt", > + [UMIP_INST_STR] = "str", > +};
Sigh ...
> +/* > + * If you change these strings, ensure that buffers using them are sufficiently > + * large. > + */ > +static const char umip_warn_use[] = "cannot be used by applications."; > +static const char umip_warn_emu[] = "For now, expensive software emulation returns result.";
Please use the string literals directly, don't add an extra obfuscation layer.
Plus:
> + unsigned char buf[MAX_INSN_SIZE], warn[128];
> + snprintf(warn, sizeof(warn), "%s %s", umip_insns[umip_inst], > + umip_warn_use);
This is incredibly fragile against future buffer overflows, and warning about it in comments does not make it less fragile!
Thanks,
Ingo
| |