[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220629130201.GB13395@duo.ucw.cz>
Date: Wed, 29 Jun 2022 15:02:01 +0200
From: Pavel Machek <pavel@...x.de>
To: Sasha Levin <sashal@...nel.org>
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Kees Cook <keescook@...omium.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Tom Rix <trix@...hat.com>, llvm@...ts.linux.dev,
"Gustavo A . R . Silva" <gustavoars@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Jakub Kicinski <kuba@...nel.org>, davem@...emloft.net,
edumazet@...gle.com, pabeni@...hat.com, jiri@...dia.com,
leon@...nel.org, netdev@...r.kernel.org
Subject: Re: [PATCH AUTOSEL 5.10 30/34] hinic: Replace memcpy() with direct
assignment
Hi!
> From: Kees Cook <keescook@...omium.org>
>
> [ Upstream commit 1e70212e031528918066a631c9fdccda93a1ffaa ]
>
> Under CONFIG_FORTIFY_SOURCE=y and CONFIG_UBSAN_BOUNDS=y, Clang is bugged
> here for calculating the size of the destination buffer (0x10 instead of
> 0x14). This copy is a fixed size (sizeof(struct fw_section_info_st)), with
> the source and dest being struct fw_section_info_st, so the memcpy should
> be safe, assuming the index is within bounds, which is UBSAN_BOUNDS's
> responsibility to figure out.
>
> Avoid the whole thing and just do a direct assignment. This results in
> no change to the executable code.
This is just a workaround for Clang bug uncovered by 281d0c962752
("fortify: Add Clang support"), and we don't have that in 5.10-stable.
Please drop.
Best regards,
Pavel
> +++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
> @@ -43,9 +43,7 @@ static bool check_image_valid(struct hinic_devlink_priv *priv, const u8 *buf,
>
> for (i = 0; i < fw_image->fw_info.fw_section_cnt; i++) {
> len += fw_image->fw_section_info[i].fw_section_len;
> - memcpy(&host_image->image_section_info[i],
> - &fw_image->fw_section_info[i],
> - sizeof(struct fw_section_info_st));
> + host_image->image_section_info[i] = fw_image->fw_section_info[i];
> }
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists