From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753507AbdKNHeS (ORCPT ); Tue, 14 Nov 2017 02:34:18 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:52855 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751872AbdKNHeM (ORCPT ); Tue, 14 Nov 2017 02:34:12 -0500 X-Google-Smtp-Source: AGs4zMaE+QF1v+QMI4jhOx23eiIA1ak7SDjOhtjMxwwW7YcMljRn46hO9KgFGRAtGYlGsi/oMrec7g== Date: Tue, 14 Nov 2017 08:34:08 +0100 From: Ingo Molnar To: Ricardo Neri Cc: Thomas Gleixner , "H. Peter Anvin" , Borislav Petkov , Andy Lutomirski , Tony Luck , Paolo Bonzini , "Ravi V. Shankar" , x86@kernel.org, ricardo.neri@intel.com, linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH v2 4/4] x86/umip: Warn if UMIP-protected instructions are used Message-ID: <20171114073408.tir3raeas7ouvyzp@gmail.com> References: <1510640985-18412-1-git-send-email-ricardo.neri-calderon@linux.intel.com> <1510640985-18412-5-git-send-email-ricardo.neri-calderon@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1510640985-18412-5-git-send-email-ricardo.neri-calderon@linux.intel.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Ricardo Neri 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