Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752663AbcDVVF4 (ORCPT ); Fri, 22 Apr 2016 17:05:56 -0400 Received: from mailscanner02.zoner.fi ([84.34.166.11]:36965 "EHLO mailscanner02.zoner.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751794AbcDVVFz (ORCPT ); Fri, 22 Apr 2016 17:05:55 -0400 Date: Sat, 23 Apr 2016 00:05:30 +0300 From: Lasse Collin To: keescook@chromium.org Cc: aryabinin@virtuozzo.com, peterz@infradead.org, dvlasenk@redhat.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, hpa@zytor.com, luto@kernel.org, yinghai@kernel.org, jpoimboe@redhat.com, bp@suse.de, dvyukov@google.com, torvalds@linux-foundation.org, mingo@kernel.org, bhe@redhat.com, tglx@linutronix.de, bp@alien8.de, brgerst@gmail.com, luto@amacapital.net, hjl.tools@gmail.com Subject: Re: [tip:x86/boot] x86/boot: Make memcpy() handle overlaps Message-ID: <20160423000530.38b4f1c9@tukaani.org> In-Reply-To: References: <1461185746-8017-5-git-send-email-keescook@chromium.org> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Antivirus-Scanner: Clean mail though you should still use an Antivirus Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1067 Lines: 26 On 2016-04-22 tip-bot for Kees Cook wrote: > x86/boot: Make memcpy() handle overlaps > > Two uses of memcpy() (screen scrolling and ELF parsing) were handling > overlapping memory areas. While there were no explicitly noticed bugs > here (yet), it is best to fix this so that the copying will always be > safe. > > Instead of making a new memmove() function that might collide with > other memmove() definitions in the decompressors, this just makes the > compressed boot code's copy of memcpy() overlap-safe. So far lib/decompress_unxz.c is the only decompressor that needs memmove(). There the local definition is inside #ifndef to make it easy to omit it and to use another memmove() implementation. It's enough to do this: #define memmove memmove To me it sounds less confusing if a function that works on overlapping buffers is named memmove() instead of memcpy(). In those places where buffers can overlap one would then use memmove() so that it's clear to the reader that overlapping is possible. -- Lasse Collin | IRC: Larhzu @ IRCnet & Freenode