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=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 D05E9C4338F for ; Wed, 25 Aug 2021 02:41:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5D4586128A for ; Wed, 25 Aug 2021 02:41:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5D4586128A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id DB2216B006C; Tue, 24 Aug 2021 22:41:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D62938D0001; Tue, 24 Aug 2021 22:41:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C50576B0072; Tue, 24 Aug 2021 22:41:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id A8E6C6B006C for ; Tue, 24 Aug 2021 22:41:54 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2AD7325F4E for ; Wed, 25 Aug 2021 02:41:54 +0000 (UTC) X-FDA: 78512052948.18.F752B61 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf06.hostedemail.com (Postfix) with ESMTP id C720F801A89F for ; Wed, 25 Aug 2021 02:41:53 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 8C8A261178; Wed, 25 Aug 2021 02:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629859313; bh=dvM7lsbAssWsTUenDOEpjbFoXJ5SPmO2WkRtspjECoM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=oMdAyqlnGca3o945taYVjeDS18xKGKV+U53xHJFDzbQz90cTh02gw2iyu5QXaTrwC SYESZO2uwubXoAcpaQT9+VShOcmE76rYtsm0v1i0ciLnuBfIHN+Y+JXJUQ7icoj2fm yJl+EmrcMXW0l6sikXaEDtRvXHlH+FDgKU6fh0f6MPxNjh4IPZYSj4NorBFjaR70gH 9F2EHdz/HvciqPyVR+Y6T5B+onmkalXE8zQmxicXdCZaLPEhygwXckg7wVYz6dwxwP JZw85EYioP+Lr7x2K50813hr89emaG1ZGsGyol6AXIfsiQ7Wt/GuOivKb+jvsFdNUl 5RmSqOy9DqXUw== 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 To: Kees Cook , kernel test robot Cc: clang-built-linux@googlegroups.com, kbuild-all@lists.01.org, Linux Memory Management List References: <202108250548.HB9OXC36-lkp@intel.com> <202108241916.7EFB8D5E1C@keescook> From: Nathan Chancellor Message-ID: <2751fd54-f28e-6318-2fc1-3fa5d4a98b2d@kernel.org> Date: Tue, 24 Aug 2021 19:41:50 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <202108241916.7EFB8D5E1C@keescook> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oMdAyqln; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.hostedemail.com: domain of nathan@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=nathan@kernel.org X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C720F801A89F X-Stat-Signature: 3sqq5cw4uq1nuxdp7w9sapisth9wnynx X-HE-Tag: 1629859313-575000 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 8/24/2021 7:17 PM, Kees Cook wrote: > 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? >> ^ I think that this error is why there is a fortify warning below (no idea how) but applying my patch [1] which came out of [2] fixes this error and I do not see any warning in this file with that config. [1]: https://lore.kernel.org/r/20210824022640.2170859-1-nathan@kernel.org [2]: https://lore.kernel.org/r/YSQE2f5teuvKLkON@Ryzen-9-3900X.localdomain/ Cheers, Nathan >> 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. > From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============1368152731005364415==" MIME-Version: 1.0 From: Nathan Chancellor To: kbuild-all@lists.01.org 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 Date: Tue, 24 Aug 2021 19:41:50 -0700 Message-ID: <2751fd54-f28e-6318-2fc1-3fa5d4a98b2d@kernel.org> In-Reply-To: <202108241916.7EFB8D5E1C@keescook> List-Id: --===============1368152731005364415== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 8/24/2021 7:17 PM, Kees Cook wrote: > 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: E= xplicitly disable Clang support >> config: i386-randconfig-a016-20210824 (attached as .config) >> compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d26= 000e4cc2bc65e207a84fa26cb6e374d60aa12) >> reproduce (this is a W=3D1 build): >> wget https://raw.githubusercontent.com/intel/lkp-tests/master/s= bin/make.cross -O ~/bin/make.cross >> chmod +x ~/bin/make.cross >> # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-ne= xt.git/commit/?id=3D185e297653a7e0431db813764d2efb9ffd09160c >> 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=3D$HOME/0day COMPILER=3Dclang make.cross = ARCH=3Di386 >> >> 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=3D0' is not supp= orted [-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 '__built= in_frame_address' with a nonzero argument is unsafe [-Wframe-address] >> oldframe =3D __builtin_frame_address(1); >> ^~~~~~~~~~~~~~~~~~~~~~~~~~ >> arch/x86/include/asm/thread_info.h:174:11: warning: calling '__built= in_frame_address' with a nonzero argument is unsafe [-Wframe-address] >> frame =3D __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? >> ^ I think that this error is why there is a fortify warning below (no idea = how) but applying my patch [1] which came out of [2] fixes this error = and I do not see any warning in this file with that config. [1]: https://lore.kernel.org/r/20210824022640.2170859-1-nathan(a)kernel.org [2]: https://lore.kernel.org/r/YSQE2f5teuvKLkON(a)Ryzen-9-3900X.localdomain/ Cheers, Nathan >> 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_add= ress' with a nonzero argument is unsafe [-Wframe-address] >> addr =3D CALLER_ADDR1; >> ^~~~~~~~~~~~ >> include/linux/ftrace.h:830:38: note: expanded from macro 'CALLER_ADD= R1' >> #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) >> ^~~~~~~~~~~~~~~~~~~~~~~~ >> include/linux/ftrace.h:823:36: note: expanded from macro 'ftrace_ret= urn_address' >> # define ftrace_return_address(n) __builtin_return_address(n) >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~ >> include/linux/ftrace.h:846:9: warning: calling '__builtin_return_add= ress' with a nonzero argument is unsafe [-Wframe-address] >> return CALLER_ADDR2; >> ^~~~~~~~~~~~ >> include/linux/ftrace.h:831:38: note: expanded from macro 'CALLER_ADD= R2' >> #define CALLER_ADDR2 ((unsigned long)ftrace_return_address(2)) >> ^~~~~~~~~~~~~~~~~~~~~~~~ >> include/linux/ftrace.h:823:36: note: expanded from macro 'ftrace_ret= urn_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(stru= ct 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) =3D=3D sizeof(*= st)) >> c8b91accfa1059 Al Viro 2011-03-12 @131 memcpy(&buf, st, sizeof(*st)); > = > Wat. Statement above this makes that assertion impossible. >=20 --===============1368152731005364415==--