Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp234014pxb; Mon, 13 Sep 2021 17:55:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynSQWMlBImDxUBjuZ3HYjmWU3Q3FBoCR1YF21jqgylmzfIhiwLCgOHdXqmfLF/rohHysCm X-Received: by 2002:a92:300c:: with SMTP id x12mr3949460ile.230.1631580906215; Mon, 13 Sep 2021 17:55:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631580906; cv=none; d=google.com; s=arc-20160816; b=BL+0jWYRVLJX597kgj9rnFNB//0dWxJPYhSKGX5c1EZSp6HFTvEBnnf2Jkdl1WNa+Q s6jI7pObdw6E1c6kBrKbe+TzRuK5BTowdkGahUM6fY1VeDiZkhbTmY6ojFEp0zm/P5wn H1rMBfhzSIAFMEQ7QAbXAViIJ3XGaKRqocQr4gN/qn6MU3CYVDPfxrVwclAjrUwmW4Yr gDGAnFyxgRC062ySAJEMPTBP4bdKciUtRBXit56lUmGyfGwYgMp5NoNeAVb0QmiD7MBa DUEfoZmsthRu625LcCAUT8qhrLTK5ZAwx1DmJckxGxKcpjxHAA1JahqDKfLQmqTlejL2 9aaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:sender:dkim-signature; bh=4AWox8sawkC9CtK9PuNlbDARnSgX50OifQb05G9AldE=; b=ZNMyFUn2f+cySNri2oZZUmXU2tHkNkOrTGLDLg7+T+eVpPwW2nYYe2uYHVp6WB+LXu iyfiourF/ZvJBoamStVB0XHFynlp0pzVeNYUa2bUzIEvwYn7pOThS0uA8+hKl1ufHmq1 ixZSAdll7zDq+4xohY9RraZvSYKTyr8e7wzSIuJVx83liZaRkzGNbrtsOV9pi+2D21MB H9gCUMge00KKn7HL8XM01Pt7n7hG8nkdb2TBIV1Twh/ugwAoESjYr0oVbE8m7uNSSKHr dbITrMSaDG67dmN1l79HKJTDKupy/0XOr6FY5B5JRM12RvdTFF5kEWDPKkgC56C8O78Q ltLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Nu1zivWJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si8002261iln.95.2021.09.13.17.54.55; Mon, 13 Sep 2021 17:55:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Nu1zivWJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240752AbhIMSyM (ORCPT + 99 others); Mon, 13 Sep 2021 14:54:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233322AbhIMSyM (ORCPT ); Mon, 13 Sep 2021 14:54:12 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 165C8C061574; Mon, 13 Sep 2021 11:52:56 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id o16-20020a9d2210000000b0051b1e56c98fso14740427ota.8; Mon, 13 Sep 2021 11:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:to:cc:references:from:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=4AWox8sawkC9CtK9PuNlbDARnSgX50OifQb05G9AldE=; b=Nu1zivWJv1dHLWchmUewcCSBHoNemQBRH+ir0M38rNLxuz/7OFJQEUAgXurtWxorEA F3tVwn1PEIfNUnV9/SFuLl0/8qzOhaZoAzf1GMzPqVHfGcFjkaX/OV6Kbg3y3uYr/KqP I56nGA4rUvcQUaOBYKB7alAWmwddRjocOeD46sdEMO2t5/+737oFgqOaCytdcgTIfSrm yZWu76uUIuXTYrq5SbyNWw8GGx4a3Y4Kb4Q3rUqH7NnKaB3Kop8nhjab3SYADsV6G6dI 2CjwdE+xEGtF8JDks4aFoF/p8eJUVCqIzgfkQHI7j3l24RAefK9W9UEvZZ3R7LM3sFvK IxEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:to:cc:references:from:subject:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4AWox8sawkC9CtK9PuNlbDARnSgX50OifQb05G9AldE=; b=Z9HM93TlvfY2SJaDK64t6pProOzstufVCFlXC3g1mxamZVWPk3I++PamNJuH0addNN 28/y1FGTcapQz+aokDi8AZmfC6FTVP7pZsRHj/45uATW3TYCkVGpsrHYBXnPY1dcjEFF H2nziab1P2HXIdJARldC1LrF62+U8KvTfKyCh44yz4FgYLtGbYnjlwGyWH6VQVH0ZLdb Qrx210ZqTr/SNE3y5gn7PBBrqEwVNpTc3J+aMSUeTdjt3l5zD7cWNvHFzKq4b+S5LJeM OCfxDL+W4uuLsKsAeY28YWE1t7Fexr9ETTuR8L5jJjmWEjumhgcyYN94v5TfL8T6oIXJ XNxA== X-Gm-Message-State: AOAM531ILiNdkEwf8YxBkbw8utaYHAa6JLQhbRVi8euFDUVXZS7a9C6z VjeIr+0ObKXccjInt9+JzzikvQv7H98= X-Received: by 2002:a9d:721b:: with SMTP id u27mr11410487otj.214.1631559175413; Mon, 13 Sep 2021 11:52:55 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b24sm1902102oic.33.2021.09.13.11.52.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Sep 2021 11:52:54 -0700 (PDT) Sender: Guenter Roeck To: Sam Ravnborg Cc: "David S . Miller" , sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann References: <20210913163712.922188-1-linux@roeck-us.net> From: Guenter Roeck Subject: Re: [PATCH] sparc: mdesc: Fix compile error seen with gcc 11.x Message-ID: Date: Mon, 13 Sep 2021 11:52:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/13/21 11:02 AM, Sam Ravnborg wrote: > Hi Guenter, > > On Mon, Sep 13, 2021 at 09:37:12AM -0700, Guenter Roeck wrote: >> sparc64 images fail to compile with gcc 11.x, reporting the following >> errors. >> >> arch/sparc/kernel/mdesc.c:647:22: error: >> 'strcmp' reading 1 or more bytes from a region of size 0 >> arch/sparc/kernel/mdesc.c:692:22: error: >> 'strcmp' reading 1 or more bytes from a region of size 0 >> arch/sparc/kernel/mdesc.c:719:21: >> error: 'strcmp' reading 1 or more bytes from a region of size 0 >> >> The underlying problem is that node_block() returns a pointer beyond >> the end of struct mdesc_hdr. gcc 11.x detects that and reports the error. >> Adding an additional zero-length field to struct mdesc_hdr and pointing >> to that field fixes the problem. >> >> Cc: Arnd Bergmann >> Signed-off-by: Guenter Roeck >> --- >> My apologies if a similar patch was submitted already; I was unable to find it. >> I did find the following patch: >> https://git.busybox.net/buildroot/commit/?id=6e1106b4a9aee25d1556310d5cd1cb6dde2e6e3f >> but I failed to find it in patchwork or on lore.kernel.org, and it >> seems to be more expensive than the solution suggested here. >> >> arch/sparc/kernel/mdesc.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c >> index 8e645ddac58e..c67bdcc23727 100644 >> --- a/arch/sparc/kernel/mdesc.c >> +++ b/arch/sparc/kernel/mdesc.c >> @@ -39,6 +39,7 @@ struct mdesc_hdr { >> u32 node_sz; /* node block size */ >> u32 name_sz; /* name block size */ >> u32 data_sz; /* data block size */ >> + char data[0]; >> } __attribute__((aligned(16))); > > I do not think this will works. > See following comment: > * mdesc_hdr and mdesc_elem describe the layout of the data structure > * we get from the Hypervisor. > > With the above change you increased the size from 16 to 32 bytes, > and any code using sizeof(struct mdesc_hdr) will now point too far in > memory for the second and subsequent entries. > > I did not take any closer look, but this was from a quick analysis. > Sorry, I didn't realize that a field of size 0 increases the structure size on sparc. I had checked the size of the old and the new structure with gcc on x86_64 and didn't see a field size increase. Guenter --- Test code I had used: #include #include typedef unsigned int u32; struct mdesc_hdr { u32 version; /* Transport version */ u32 node_sz; /* node block size */ u32 name_sz; /* name block size */ u32 data_sz; /* data block size */ } __attribute__((aligned(16))); struct mdesc_hdr2 { u32 version; /* Transport version */ u32 node_sz; /* node block size */ u32 name_sz; /* name block size */ u32 data_sz; /* data block size */ char data[0]; } __attribute__((aligned(16))); int main() { printf("%ld %ld\n", sizeof(struct mdesc_hdr), sizeof(struct mdesc_hdr2)); return 0; }