From patchwork Sat Jun 12 09:40:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Naour X-Patchwork-Id: 1491250 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=uhBMrsh2; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G2CPW13pmz9sj5 for ; Sat, 12 Jun 2021 19:40:29 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9BE1683D44; Sat, 12 Jun 2021 09:40:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id crswHLvnTJdd; Sat, 12 Jun 2021 09:40:25 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id B035683D58; Sat, 12 Jun 2021 09:40:24 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 746ED1BF47D for ; Sat, 12 Jun 2021 09:40:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 6AA68400C5 for ; Sat, 12 Jun 2021 09:40:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fDSdORHucySQ for ; Sat, 12 Jun 2021 09:40:22 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by smtp2.osuosl.org (Postfix) with ESMTPS id E983C400BA for ; Sat, 12 Jun 2021 09:40:21 +0000 (UTC) Received: by mail-wm1-x335.google.com with SMTP id h22-20020a05600c3516b02901a826f84095so9956565wmq.5 for ; Sat, 12 Jun 2021 02:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q3Bm+BSCPwrviNCJIqqiOLAUYnQ4WsPGIiyYtGLNWGw=; b=uhBMrsh2xJcFC8vh3g4m5/D99eeOzBG7a6pjEmObqFuuFrkxydUv/KUyOmFSJ9L/MX YhY8aLwnBo/K4X43ZMcIq9qI708fD4ga9V6LCr7WIXj1wTVnaCob+yTXrSl/r3HLnTOW NbYsNlimnzHbgeZ14s8t1qMT9/4liIPEqPRS5G0H6wJ9W6LAsYrO8x5Sods3yyZsG1Vn dplV6sOcCjjRtjAyl/tF0dxE3dVX6H3/m7NebL2mJkCuUfw1Ps1URugDWoHqnoZy8cBx utce+sDD1YRXYzke1/o5c7vwCBWJ+4cru3bjCUkgA9LOwf5JKFB0LaMApBXcIsb8ZGEk lMow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q3Bm+BSCPwrviNCJIqqiOLAUYnQ4WsPGIiyYtGLNWGw=; b=bqN+UGTrOO6m14oTGe0TYY4uuowfi5CfZx0dhI2wUWF9HGM8nbklUkSM2g9TFWXHms YAT0a3YOyw5yd3CvXkKKDNFzGfq/jAMqMVcLbZTB8cL87kAm7ETvDWO/QbTfqWGiFH+p cVs5AXyF155sJ+CzWgmxrsRBILjSUL01rJhRb28EkuPj9vD8pibZRDsck43gYonwUKWv QqyaxidkxrXVct/fRmfV2HE3CXKTnUF6Ua4Ec5Zc8MMX1bzxXSBGg28lQb3JUjSlZ42e 57NQC/VD+Zky4TShCSIDboU2tv7ibg1ram5Oz2Ir15tgd+U8jgLLjoUJ5kODTu2D+Ztd qmYw== X-Gm-Message-State: AOAM5332RvbYk2pO919xOv8yubMBZm/Ok47uHclLevYZiS5foHYtCn+V oWQdf5xY7CoeqB1hVtLcph+kAeIJmuk= X-Google-Smtp-Source: ABdhPJzUclod5IIBNQZTPn5jqhZKHSi/Z0ApLFMJPGRZ+AMdiBVEZ21AVBvMfy/HhuOe3T25dCWnnw== X-Received: by 2002:a7b:c005:: with SMTP id c5mr7748421wmb.113.1623490819780; Sat, 12 Jun 2021 02:40:19 -0700 (PDT) Received: from localhost.localdomain (2a01cb058f8a180022164e4eb697b4ce.ipv6.abo.wanadoo.fr. [2a01:cb05:8f8a:1800:2216:4e4e:b697:b4ce]) by smtp.gmail.com with ESMTPSA id m6sm11999077wrw.9.2021.06.12.02.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 02:40:19 -0700 (PDT) From: Romain Naour To: buildroot@buildroot.org Date: Sat, 12 Jun 2021 11:40:10 +0200 Message-Id: <20210612094015.6792-1-romain.naour@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 1/6] board/qemu/sparc64-sun4u: avoid gcc-11 warning to build the kernel X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Romain Naour Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" gcc-11 warns about what appears to be an out-of-range array access but stop the build due to -Werror added to cflags: arch/sparc/kernel/mdesc.c: In function 'mdesc_node_by_name': arch/sparc/kernel/mdesc.c:647:22: error: 'strcmp' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread] 647 | if (!strcmp(names + ep[ret].name_offset, name)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/sparc/kernel/mdesc.c:77:33: note: at offset 16 into source object 'mdesc' of size 16 77 | struct mdesc_hdr mdesc; | ^~~~~ arch/sparc/kernel/mdesc.c: In function 'mdesc_get_property': arch/sparc/kernel/mdesc.c:692:22: error: 'strcmp' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread] 692 | if (!strcmp(names + ep->name_offset, name)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/sparc/kernel/mdesc.c:77:33: note: at offset 16 into source object 'mdesc' of size 16 77 | struct mdesc_hdr mdesc; | ^~~~~ arch/sparc/kernel/mdesc.c: In function 'mdesc_next_arc': arch/sparc/kernel/mdesc.c:719:21: error: 'strcmp' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread] 719 | if (strcmp(names + ep->name_offset, arc_type)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/sparc/kernel/mdesc.c:77:33: note: at offset 16 into source object 'mdesc' of size 16 77 | struct mdesc_hdr mdesc; | ^~~~~ cc1: all warnings being treated as errors The issue was initially reported to gcc [1] where it was analized. As suggested, change the struct mdesc_elem * accesses from the end of mdesc to those from the beginning of the data array. Update the prototype of node_block(), name_block() and data_block() since the code really seems to want to do is to compute the address somewhere into the chunk pointed to by hp. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100262 Upstream status: Pending https://www.spinics.net/lists/sparclinux/msg26385.html Signed-off-by: Romain Naour --- ...ringop-overread-warning-to-access-Ma.patch | 154 ++++++++++++++++++ configs/qemu_sparc64_sun4u_defconfig | 3 + 2 files changed, 157 insertions(+) create mode 100644 board/qemu/sparc64-sun4u/patches/linux/0001-sparc64-avoid-stringop-overread-warning-to-access-Ma.patch diff --git a/board/qemu/sparc64-sun4u/patches/linux/0001-sparc64-avoid-stringop-overread-warning-to-access-Ma.patch b/board/qemu/sparc64-sun4u/patches/linux/0001-sparc64-avoid-stringop-overread-warning-to-access-Ma.patch new file mode 100644 index 0000000000..c02704696d --- /dev/null +++ b/board/qemu/sparc64-sun4u/patches/linux/0001-sparc64-avoid-stringop-overread-warning-to-access-Ma.patch @@ -0,0 +1,154 @@ +From 82d91965519c20639c24aadd022b2859461562bc Mon Sep 17 00:00:00 2001 +From: Romain Naour +Date: Tue, 27 Apr 2021 14:54:28 +0200 +Subject: [PATCH] sparc64: avoid stringop-overread warning to access Machine + description datas + +gcc-11 warns about what appears to be an out-of-range array access but +stop the build due to -Werror added to cflags: + +arch/sparc/kernel/mdesc.c: In function 'mdesc_node_by_name': +arch/sparc/kernel/mdesc.c:647:22: error: 'strcmp' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread] + 647 | if (!strcmp(names + ep[ret].name_offset, name)) + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +arch/sparc/kernel/mdesc.c:77:33: note: at offset 16 into source object 'mdesc' of size 16 + 77 | struct mdesc_hdr mdesc; + | ^~~~~ +arch/sparc/kernel/mdesc.c: In function 'mdesc_get_property': +arch/sparc/kernel/mdesc.c:692:22: error: 'strcmp' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread] + 692 | if (!strcmp(names + ep->name_offset, name)) { + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +arch/sparc/kernel/mdesc.c:77:33: note: at offset 16 into source object 'mdesc' of size 16 + 77 | struct mdesc_hdr mdesc; + | ^~~~~ +arch/sparc/kernel/mdesc.c: In function 'mdesc_next_arc': +arch/sparc/kernel/mdesc.c:719:21: error: 'strcmp' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread] + 719 | if (strcmp(names + ep->name_offset, arc_type)) + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +arch/sparc/kernel/mdesc.c:77:33: note: at offset 16 into source object 'mdesc' of size 16 + 77 | struct mdesc_hdr mdesc; + | ^~~~~ +cc1: all warnings being treated as errors + +The issue was initially reported to gcc [1] where it was analized. +As suggested, change the struct mdesc_elem * accesses from the end +of mdesc to those from the beginning of the data array. + +Update the prototype of node_block(), name_block() and data_block() +since the code really seems to want to do is to compute the address +somewhere into the chunk pointed to by hp. + +[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100262 + +Upstream status: Pending +https://www.spinics.net/lists/sparclinux/msg26385.html + +Signed-off-by: Romain Naour +--- + arch/sparc/kernel/mdesc.c | 37 +++++++++++++++++++++---------------- + 1 file changed, 21 insertions(+), 16 deletions(-) + +diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c +index 8e645ddac58e..3403555aa1e2 100644 +--- a/arch/sparc/kernel/mdesc.c ++++ b/arch/sparc/kernel/mdesc.c +@@ -75,6 +75,7 @@ struct mdesc_handle { + refcount_t refcnt; + unsigned int handle_size; + struct mdesc_hdr mdesc; ++ char data[]; + }; + + typedef int (*mdesc_node_info_get_f)(struct mdesc_handle *, u64, +@@ -610,26 +611,30 @@ int mdesc_get_node_info(struct mdesc_handle *hp, u64 node, + } + EXPORT_SYMBOL(mdesc_get_node_info); + +-static struct mdesc_elem *node_block(struct mdesc_hdr *mdesc) ++static struct mdesc_elem *node_block(struct mdesc_handle *hp) + { +- return (struct mdesc_elem *) (mdesc + 1); ++ return (struct mdesc_elem *) hp + offsetof(struct mdesc_handle, data); + } + +-static void *name_block(struct mdesc_hdr *mdesc) ++static void *name_block(struct mdesc_handle *hp) + { +- return ((void *) node_block(mdesc)) + mdesc->node_sz; ++ struct mdesc_hdr *mdesc = &hp->mdesc; ++ ++ return ((void *) node_block(hp)) + mdesc->node_sz; + } + +-static void *data_block(struct mdesc_hdr *mdesc) ++static void *data_block(struct mdesc_handle *hp) + { +- return ((void *) name_block(mdesc)) + mdesc->name_sz; ++ struct mdesc_hdr *mdesc = &hp->mdesc; ++ ++ return ((void *) name_block(hp)) + mdesc->name_sz; + } + + u64 mdesc_node_by_name(struct mdesc_handle *hp, + u64 from_node, const char *name) + { +- struct mdesc_elem *ep = node_block(&hp->mdesc); +- const char *names = name_block(&hp->mdesc); ++ struct mdesc_elem *ep = node_block(hp); ++ const char *names = name_block(hp); + u64 last_node = hp->mdesc.node_sz / 16; + u64 ret; + +@@ -657,15 +662,15 @@ EXPORT_SYMBOL(mdesc_node_by_name); + const void *mdesc_get_property(struct mdesc_handle *hp, u64 node, + const char *name, int *lenp) + { +- const char *names = name_block(&hp->mdesc); ++ const char *names = name_block(hp); + u64 last_node = hp->mdesc.node_sz / 16; +- void *data = data_block(&hp->mdesc); ++ void *data = data_block(hp); + struct mdesc_elem *ep; + + if (node == MDESC_NODE_NULL || node >= last_node) + return NULL; + +- ep = node_block(&hp->mdesc) + node; ++ ep = node_block(hp) + node; + ep++; + for (; ep->tag != MD_NODE_END; ep++) { + void *val = NULL; +@@ -702,8 +707,8 @@ EXPORT_SYMBOL(mdesc_get_property); + + u64 mdesc_next_arc(struct mdesc_handle *hp, u64 from, const char *arc_type) + { +- struct mdesc_elem *ep, *base = node_block(&hp->mdesc); +- const char *names = name_block(&hp->mdesc); ++ struct mdesc_elem *ep, *base = node_block(hp); ++ const char *names = name_block(hp); + u64 last_node = hp->mdesc.node_sz / 16; + + if (from == MDESC_NODE_NULL || from >= last_node) +@@ -728,7 +733,7 @@ EXPORT_SYMBOL(mdesc_next_arc); + + u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc) + { +- struct mdesc_elem *ep, *base = node_block(&hp->mdesc); ++ struct mdesc_elem *ep, *base = node_block(hp); + + ep = base + arc; + +@@ -738,8 +743,8 @@ EXPORT_SYMBOL(mdesc_arc_target); + + const char *mdesc_node_name(struct mdesc_handle *hp, u64 node) + { +- struct mdesc_elem *ep, *base = node_block(&hp->mdesc); +- const char *names = name_block(&hp->mdesc); ++ struct mdesc_elem *ep, *base = node_block(hp); ++ const char *names = name_block(hp); + u64 last_node = hp->mdesc.node_sz / 16; + + if (node == MDESC_NODE_NULL || node >= last_node) +-- +2.30.2 + diff --git a/configs/qemu_sparc64_sun4u_defconfig b/configs/qemu_sparc64_sun4u_defconfig index cff0c2968a..6a999298eb 100644 --- a/configs/qemu_sparc64_sun4u_defconfig +++ b/configs/qemu_sparc64_sun4u_defconfig @@ -2,6 +2,9 @@ BR2_sparc64=y BR2_sparc_v9=y +# Patches +BR2_GLOBAL_PATCH_DIR="board/qemu/sparc64-sun4u/patches" + # System BR2_SYSTEM_DHCP="eth0"