lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 15 Nov 2017 09:41:00 +0100
From:   Ingo Molnar <mingo@...nel.org>
To:     Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        "H. Peter Anvin" <hpa@...or.com>, Borislav Petkov <bp@...e.de>,
        Andy Lutomirski <luto@...nel.org>,
        Tony Luck <tony.luck@...el.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        "Ravi V. Shankar" <ravi.v.shankar@...el.com>, x86@...nel.org,
        ricardo.neri@...el.com, linux-kernel@...r.kernel.org
Subject: Re: [RESEND PATCH v2 4/4] x86/umip: Warn if UMIP-protected
 instructions are used


* Ricardo Neri <ricardo.neri-calderon@...ux.intel.com> wrote:

> > > +	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!
> 
> I need to concatenate the instruction mnemonic with the a string. Does something like
> this is more acceptable?
> 
> 	unsigned char warn[50];
> 
> 	...
> 
> 	strcpy(warn, umip_insns[umip_inst]);
> 	strcat(warn, " instruction cannot be used by applications.");
> 	umip_pr_warn(regs, warn, 0);
> 
> In this manner I use the string literal directly but I still have a buffer that might
> overflow. Code looks more clear to me. I could #defines for the string lengths or
> set a maximum length.

This is still very fragile.

The right solution would be to make umip_pr_warn() a varargs helper function, so 
that you can just use it to print things the usual way. I'd also use a 
__attribute__((format(printf))) specification to get good build-time warnings.

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ