From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 326E2C4338F for ; Wed, 25 Aug 2021 02:17:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B55376101C for ; Wed, 25 Aug 2021 02:17:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B55376101C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0AE918D0001; Tue, 24 Aug 2021 22:17:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05F016B0071; Tue, 24 Aug 2021 22:17:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E8F4C8D0001; Tue, 24 Aug 2021 22:17:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id CCDF06B006C for ; Tue, 24 Aug 2021 22:17:33 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 635A98249980 for ; Wed, 25 Aug 2021 02:17:33 +0000 (UTC) X-FDA: 78511991586.06.11CDAC3 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf30.hostedemail.com (Postfix) with ESMTP id 0CEF4E001981 for ; Wed, 25 Aug 2021 02:17:32 +0000 (UTC) Received: by mail-pg1-f179.google.com with SMTP id k14so21621361pga.13 for ; Tue, 24 Aug 2021 19:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kDInSr8L7ift0b5jP69a65dVfelWdpVx5p0PeZjr4RU=; b=Sp4TYw1yJWy53xoB92rc4nai+ERDC7Jd2e4MhbutfT1JwuSj094n9nfUyxw3Qp9Ypo p3fqniHEhVTdCct1IEAGnxFg90kxmMyoFIePn2Le+zfKeeK8lqShG4QM5febW/KGvEDp DEkfSm7FLyZuyAlwuOreK3l87Xhf2hclmyMrE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kDInSr8L7ift0b5jP69a65dVfelWdpVx5p0PeZjr4RU=; b=jsvbKPyg8pWjvu50pLpbgPfKvbW/2haezQnRvYiAUzk7gltFPepw4/FwmOkZ+NzaAN 6xqgkwQjOJEyCKASZ3LFC7B2mAz2WfEFOvP4OA7cO3Y7OIFRozfM0erFARDgmqP/9Zwe yj6k0q6YlckWWCoTFheS9lNilg15J8iR097WI+5Urasv9BUDRJQmm3I56QgryIioLJJM /5NG/zkQnPnGg3I5X5vTtL64n5N48k47/C9LK/wcf3+2IHK2+1yXidq5f8gfuXwy29tJ 4ZWrX/C9TWR4JVo14UmEBjSY3uknIf3mAR+93qVZ6Ay7NHWziFRHTKHJ+S4Sx8FEdQ7v BDlw== X-Gm-Message-State: AOAM530cbxZ3PQEAC6kYCo10ek9PG4YJ6LcFXCRQbpepC5vobOlVwDqP 9U4I2UJAfHqEDfF3kfCMtIFi1A== X-Google-Smtp-Source: ABdhPJzWWDd1GkKji0joQk2cJNL3XpfdjYGgEi+DLppLaIYvIo+l2hwCZCJElQ2z+EzlqzqAkQAWEw== X-Received: by 2002:aa7:90d4:0:b029:3b3:2746:5449 with SMTP id k20-20020aa790d40000b02903b327465449mr42208949pfk.81.1629857852007; Tue, 24 Aug 2021 19:17:32 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c23sm23721255pgb.74.2021.08.24.19.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 19:17:31 -0700 (PDT) Date: Tue, 24 Aug 2021 19:17:30 -0700 From: Kees Cook To: kernel test robot Cc: clang-built-linux@googlegroups.com, kbuild-all@lists.01.org, Linux Memory Management List Subject: Re: [linux-next:master 8858/10077] fs/statfs.c:131:3: warning: 'memcpy' will always overflow; destination buffer has size 64, but size argument is 84 Message-ID: <202108241916.7EFB8D5E1C@keescook> References: <202108250548.HB9OXC36-lkp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202108250548.HB9OXC36-lkp@intel.com> Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Sp4TYw1y; spf=pass (imf30.hostedemail.com: domain of keescook@chromium.org designates 209.85.215.179 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Stat-Signature: i68xa5jpsrbi4a1c7t6tumtssk6demms X-Rspamd-Queue-Id: 0CEF4E001981 X-Rspamd-Server: rspam04 X-HE-Tag: 1629857852-801830 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Aug 25, 2021 at 05:59:01AM +0800, kernel test robot wrote: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master > head: 372b2891c15acbf7b90d948b08ac174bde77102c > commit: 185e297653a7e0431db813764d2efb9ffd09160c [8858/10077] fortify: Explicitly disable Clang support > config: i386-randconfig-a016-20210824 (attached as .config) > compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d26000e4cc2bc65e207a84fa26cb6e374d60aa12) > reproduce (this is a W=1 build): > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=185e297653a7e0431db813764d2efb9ffd09160c > git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git > git fetch --no-tags linux-next master > git checkout 185e297653a7e0431db813764d2efb9ffd09160c > # save the attached .config to linux build tree > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > > All warnings (new ones prefixed by >>): > > clang-14: warning: optimization flag '-falign-jumps=0' is not supported [-Wignored-optimization-argument] > In file included from fs/statfs.c:2: > In file included from include/linux/syscalls.h:76: > In file included from include/uapi/linux/aio_abi.h:31: > In file included from include/linux/fs.h:6: > In file included from include/linux/wait_bit.h:8: > In file included from include/linux/wait.h:9: > In file included from include/linux/spinlock.h:51: > In file included from include/linux/preempt.h:78: > In file included from arch/x86/include/asm/preempt.h:7: > In file included from include/linux/thread_info.h:60: > arch/x86/include/asm/thread_info.h:172:13: warning: calling '__builtin_frame_address' with a nonzero argument is unsafe [-Wframe-address] > oldframe = __builtin_frame_address(1); > ^~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/x86/include/asm/thread_info.h:174:11: warning: calling '__builtin_frame_address' with a nonzero argument is unsafe [-Wframe-address] > frame = __builtin_frame_address(2); > ^~~~~~~~~~~~~~~~~~~~~~~~~~ > In file included from fs/statfs.c:2: > In file included from include/linux/syscalls.h:87: > In file included from include/trace/syscall.h:7: > In file included from include/linux/trace_events.h:10: > In file included from include/linux/perf_event.h:49: > In file included from include/linux/ftrace.h:22: > arch/x86/include/asm/ftrace.h:7:3: error: Compiler does not support fentry? > # error Compiler does not support fentry? > ^ > In file included from fs/statfs.c:2: > In file included from include/linux/syscalls.h:87: > In file included from include/trace/syscall.h:7: > In file included from include/linux/trace_events.h:10: > In file included from include/linux/perf_event.h:49: > include/linux/ftrace.h:843:9: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] > addr = CALLER_ADDR1; > ^~~~~~~~~~~~ > include/linux/ftrace.h:830:38: note: expanded from macro 'CALLER_ADDR1' > #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) > ^~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/ftrace.h:823:36: note: expanded from macro 'ftrace_return_address' > # define ftrace_return_address(n) __builtin_return_address(n) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/ftrace.h:846:9: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] > return CALLER_ADDR2; > ^~~~~~~~~~~~ > include/linux/ftrace.h:831:38: note: expanded from macro 'CALLER_ADDR2' > #define CALLER_ADDR2 ((unsigned long)ftrace_return_address(2)) > ^~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/ftrace.h:823:36: note: expanded from macro 'ftrace_return_address' > # define ftrace_return_address(n) __builtin_return_address(n) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~ > >> fs/statfs.c:131:3: warning: 'memcpy' will always overflow; destination buffer has size 64, but size argument is 84 [-Wfortify-source] > memcpy(&buf, st, sizeof(*st)); > ^ > arch/x86/include/asm/string_32.h:182:25: note: expanded from macro 'memcpy' > #define memcpy(t, f, n) __builtin_memcpy(t, f, n) > ^ > 5 warnings and 1 error generated. > > > vim +/memcpy +131 fs/statfs.c > > c8b91accfa1059 Al Viro 2011-03-12 125 > c8b91accfa1059 Al Viro 2011-03-12 126 static int do_statfs_native(struct kstatfs *st, struct statfs __user *p) > c8b91accfa1059 Al Viro 2011-03-12 127 { > c8b91accfa1059 Al Viro 2011-03-12 128 struct statfs buf; > 7ed1ee6118ae77 Al Viro 2010-03-23 129 > c8b91accfa1059 Al Viro 2011-03-12 130 if (sizeof(buf) == sizeof(*st)) > c8b91accfa1059 Al Viro 2011-03-12 @131 memcpy(&buf, st, sizeof(*st)); Wat. Statement above this makes that assertion impossible. -- Kees Cook