From patchwork Sat Jun 18 13:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 12886419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDC3DCCA482 for ; Sat, 18 Jun 2022 14:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232419AbiFROBN (ORCPT ); Sat, 18 Jun 2022 10:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234886AbiFRNxS (ORCPT ); Sat, 18 Jun 2022 09:53:18 -0400 Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07C63E6B for ; Sat, 18 Jun 2022 06:53:16 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 3DB9213FC; Sat, 18 Jun 2022 09:52:14 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 3A3C6DC803; Sat, 18 Jun 2022 09:52:14 -0400 (EDT) From: James Simmons To: Eric Biggers , Andreas Dilger , NeilBrown Cc: linux-fscrypt@vger.kernel.org, James Simmons , Jian Yu Subject: [PATCH 21/28] lustre: uapi: avoid gcc-11 -Werror=stringop-overread warning Date: Sat, 18 Jun 2022 09:52:03 -0400 Message-Id: <1655560330-30743-22-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655560330-30743-1-git-send-email-jsimmons@infradead.org> References: <1655560330-30743-1-git-send-email-jsimmons@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org GCC 11 warns about string and memory operations on fixed address: In function 'memcpy', inlined from 'obd_uuid2str' at lustre/include/uapi/linux/lustre/lustre_user.h:1222:3, include/linux/fortify-string.h:20:33: error: '__builtin_memcpy' reading 39 bytes from a region of size 0 [-Werror=stringop-overread] 20 | #define __underlying_memcpy __builtin_memcpy | ^ include/linux/fortify-string.h:191:16: note: in expansion of macro '__underlying_memcpy' 191 | return __underlying_memcpy(p, q, size); | ^~~~~~~~~~~~~~~~~~~ The patch avoids the above warning by not using a fixed address. WC-bug-id: https://jira.whamcloud.com/browse/LU-15220 Lustre-commit: c5fb44f5ecf8494cd ("LU-15220 tests: avoid gcc-11 -Werror=stringop-overread warning") Signed-off-by: Jian Yu Reviewed-on: https://review.whamcloud.com/45777 WC-bug-id: https://jira.whamcloud.com/browse/LU-15420 Lustre-commit: 6331eadbd60a8c58c ("LU-15420 uapi: avoid gcc-11 -Werror=stringop-overread") Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/46319 Reviewed-by: Alexey Lyashkov Reviewed-by: Arshad Hussain Reviewed-by: Patrick Farrell Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- include/uapi/linux/lustre/lustre_user.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h index ee789f2..c57929b 100644 --- a/include/uapi/linux/lustre/lustre_user.h +++ b/include/uapi/linux/lustre/lustre_user.h @@ -40,26 +40,27 @@ * * @{ */ +#include +#ifndef __KERNEL__ +# define __USE_ISOC99 1 +# include +# include /* snprintf() */ +# include + +# define __USE_GNU 1 +# define FILEID_LUSTRE 0x97 /* for name_to_handle_at() (and llapi_fd2fid()) */ +#endif /* !__KERNEL__ */ #include #include #include #include -#include #include #include #include #include #include -#ifndef __KERNEL__ -# define __USE_ISOC99 1 -# include -# include /* snprintf() */ -# include -# define FILEID_LUSTRE 0x97 /* for name_to_handle_at() (and llapi_fd2fid()) */ -#endif /* __KERNEL__ */ - #if defined(__cplusplus) extern "C" { #endif @@ -937,10 +938,11 @@ static inline char *obd_uuid2str(const struct obd_uuid *uuid) /* Obviously not safe, but for printfs, no real harm done... * we're always null-terminated, even in a race. */ - static char temp[sizeof(*uuid)]; + static char temp[sizeof(*uuid->uuid)]; + + memcpy(temp, uuid->uuid, sizeof(*uuid->uuid) - 1); + temp[sizeof(*uuid->uuid) - 1] = '\0'; - memcpy(temp, uuid->uuid, sizeof(*uuid) - 1); - temp[sizeof(*uuid) - 1] = '\0'; return temp; } return (char *)(uuid->uuid);