From patchwork Fri Feb 2 14:59:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 126723 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp717440ljc; Fri, 2 Feb 2018 07:00:23 -0800 (PST) X-Google-Smtp-Source: AH8x225zdL44+XNqDYRT4Jo/c5nzQy6RcoWz0H1d3P6gU7fMkGbPEAnbshVvgz8SsYOtB4YOuhRW X-Received: by 2002:a17:902:82cb:: with SMTP id u11-v6mr15420239plz.391.1517583623213; Fri, 02 Feb 2018 07:00:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517583623; cv=none; d=google.com; s=arc-20160816; b=k/Vn07o0DJxZFMvN704cdbuFuOH+ytZTL8zO4xUeL/2nCtKLKgdHDWs0jTc+kYthWr cfZm5jdw7UZLTpb0ptUmI3p/SRauzqpuROf3HtnMQD/4tx3yzP1Zw47KQuxE5U+C9O6x iJJ+xjcTSHIfqHKaFOFnaPB/VEq2K1vyfHllTPa1k0sB8OObMk6EauQ5zKfaQJ2oDTaD RJi6dtADr/NISq9oIo6qIg+msgYuxif9UDnQW32co2+6uBas2zY9b9g26ksjO/wy7FA9 DpIzK3jumM70idlWUUo/z4EcHZiCOQA2gWITvWe0T5LYgfVoyAcBMhV6RGEqUIcgZfcD Te6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ZdnArLQrAROolaOhRcTJ//4TohpPhiArX1t9Ovuyie8=; b=c31qCfOGqIZD2PyGm0uEV2q5AQoIuh3N19nVR+xOcviRP6baNF2SyixV6ntcvrXcI3 q+QQRDnjK6lDEZM2I0YD+uVhFQ8IbHi5csZIEjADIevpG2rF5bSpK8mlgVLPP75JM17g wbAu0v0Mss5qtTKSMiWxEoZeEipMlappnHycZsc+WvTgB72oas3RHn3DkQvBwpblq62P 60eJBPc8lkOMW8Wo+8+ij3T7swDhEgc/CdjBRGpnmlZVZl/ldeDs3XK+DIcwInjfhJl5 uhc+RewZC9AdIuRYMPhzjfs7P/oAAB2oVSTwytPOFUa1OV4Wf+DBgMYssbtE+Xtb58DX ViOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k187si1565234pgc.178.2018.02.02.07.00.22; Fri, 02 Feb 2018 07:00:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752484AbeBBPAU (ORCPT + 28 others); Fri, 2 Feb 2018 10:00:20 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:51639 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752188AbeBBPAN (ORCPT ); Fri, 2 Feb 2018 10:00:13 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lbr40-1f71Oz1tie-00jHXD; Fri, 02 Feb 2018 15:59:57 +0100 From: Arnd Bergmann To: Jason Wessel , Daniel Thompson Cc: Nicolas Pitre , Andi Kleen , Arnd Bergmann , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] kdb: use memmove instead of overlapping memcpy Date: Fri, 2 Feb 2018 15:59:40 +0100 Message-Id: <20180202145952.285505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VVwzU9Rjo6jvPgFqV+9ONEQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc discovered that the memcpy() arguments in kdbnearsym() overlap, so we should really use memmove(), which is defined to handle that correctly: In function 'memcpy', inlined from 'kdbnearsym' at /git/arm-soc/kernel/debug/kdb/kdb_support.c:132:4: /git/arm-soc/include/linux/string.h:353:9: error: '__builtin_memcpy' accessing 792 bytes at offsets 0 and 8 overlaps 784 bytes at offset 8 [-Werror=restrict] return __builtin_memcpy(p, q, size); Signed-off-by: Arnd Bergmann --- kernel/debug/kdb/kdb_support.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.0 Reviewed-by: Jason Wessel diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c index 5d8ef3a07ecd..1ad4370ccbf0 100644 --- a/kernel/debug/kdb/kdb_support.c +++ b/kernel/debug/kdb/kdb_support.c @@ -129,13 +129,13 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab) } if (i >= ARRAY_SIZE(kdb_name_table)) { debug_kfree(kdb_name_table[0]); - memcpy(kdb_name_table, kdb_name_table+1, + memmove(kdb_name_table, kdb_name_table+1, sizeof(kdb_name_table[0]) * (ARRAY_SIZE(kdb_name_table)-1)); } else { debug_kfree(knt1); knt1 = kdb_name_table[i]; - memcpy(kdb_name_table+i, kdb_name_table+i+1, + memmove(kdb_name_table+i, kdb_name_table+i+1, sizeof(kdb_name_table[0]) * (ARRAY_SIZE(kdb_name_table)-i-1)); }