From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753583AbcD1QsF (ORCPT ); Thu, 28 Apr 2016 12:48:05 -0400 Received: from lxorguk.ukuu.org.uk ([81.2.110.251]:58086 "EHLO lxorguk.ukuu.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753535AbcD1Qrw (ORCPT ); Thu, 28 Apr 2016 12:47:52 -0400 Date: Thu, 28 Apr 2016 17:47:31 +0100 From: One Thousand Gnomes To: Kees Cook Cc: Ingo Molnar , Yinghai Lu , Baoquan He , Borislav Petkov , Ingo Molnar , "x86@kernel.org" , Andrew Morton , Andrey Ryabinin , Dmitry Vyukov , "H.J. Lu" , Josh Poimboeuf , Andy Lutomirski , LKML Subject: Re: [PATCH v2] x86/boot: Rename overlapping memcpy() to memmove() Message-ID: <20160428174731.042b7394@lxorguk.ukuu.org.uk> In-Reply-To: References: <20160426214606.GA5758@www.outflux.net> <20160428090427.GB5773@gmail.com> <20160428093741.GA23251@gmail.com> Organization: Intel Corporation X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org O> For example, this is what I've got currently: > > /* Detect and warn about potential overlaps. */ > void *memcpy(void *dest, const void *src, size_t n) > { > if (dest > src && dest - src < n) > warn("Potentially unsafe overlapping memcpy detected!"); > return __memcpy(dest, src, n); > } > > Does that seem okay? If so, I'll send the patch... Probably useful for debug, but instead of relying on __memcpy happening to handle overlaps - which isn't portable you could instead debug all platforms by doing if (...) { warn(...) memmove() } else __memcpy Alan