Message ID | 20230720151458.never.673-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp3199850vqt; Thu, 20 Jul 2023 08:30:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlEC4yq+ABdKIfIiY33jlSqMCYH2hWKsDGN+IqMfjE6+DbHnZ447s7DZD9ob92POJANeoSX+ X-Received: by 2002:a17:902:cecc:b0:1ae:6947:e63b with SMTP id d12-20020a170902cecc00b001ae6947e63bmr8081241plg.16.1689867006210; Thu, 20 Jul 2023 08:30:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689867006; cv=none; d=google.com; s=arc-20160816; b=bBP8e1Z6i2f1j1TUy/5pbZmEPEKGFrjnRC9q+5Z/Q26x2oWto5Sj21HxGfb9QM03Ds zG6iiz/Y3jD3fjmijXCni7FvQnb0zdGW0MEavs2HhC0n5Ud5uE9UQaYICkjH+mg5xJN9 s/aLPw0nLfYzU6Ae59Hdv2xXP0UMax53xmZZD+I8jtqppx9kceR1HybqG0T7tim/SNav qGv6lksg5ugPuTiaxFPXUlZ2ZWFESLSlvLcKcAYXNgxFiYFMdd4xOx5WUBjoWnq/R+/e FOyk5+tietIHIS2Vy1rkEOxvdCyk35nmT0Zhty+vcWy0tXZbaLYFwSS3gEeebZrnQ+DF di+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=igmOeAaO/nUKTsFVfVJFzonWyTXDvfkuPJ6/bFmba2Q=; fh=PDOg3W0PpS8JwJfvQgTFuGjYhc56+1CJVDc2IB1isRw=; b=jpJdVVXrJZYy3/0phqLbIOXy9XwejLLmW1FcKjrdpbQKkCv8HEiKYPlDUKi3tXGVFC XLAt+NbW/lxkmoYvjdL7LDbgR1HmcVzjazYRbxJn5qUVCoRTINNEFo344Dpc3oLPIQJR W812uNLqfpJ0yAHyGKo4p9bnyjA3VmWvbVRYYD1xc0E/oeqaKjJ2Zyu4/hIOInK/i974 4zgrxvBO72qcHiZrDqi65RhVaH/y8WbNyUMDgJISdKuqQR5rMk67M1INT3EX4Ieo4XSc 6jSxP8AkRZjUmsee7xqYf90tetxTePZC/gIB2fww68+PB5BGe8/IrtNI6QBqdPkO9XPV 6FQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ifjX9YZC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l2-20020a170903244200b001b54bdd6412si1173725pls.396.2023.07.20.08.29.52; Thu, 20 Jul 2023 08:30:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ifjX9YZC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbjGTPPm (ORCPT <rfc822;assdfgzxcv4@gmail.com> + 99 others); Thu, 20 Jul 2023 11:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232487AbjGTPPR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 20 Jul 2023 11:15:17 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56E89270B for <linux-kernel@vger.kernel.org>; Thu, 20 Jul 2023 08:15:15 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1b8a8154f9cso6744875ad.1 for <linux-kernel@vger.kernel.org>; Thu, 20 Jul 2023 08:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689866115; x=1690470915; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=igmOeAaO/nUKTsFVfVJFzonWyTXDvfkuPJ6/bFmba2Q=; b=ifjX9YZCkg2s4O+drZO6YGL7/Lsgz1x+slvY8Cgw55/87DZkfZKcjA7poVCMbh+5yu ZgPUB3PlIzjll6WwO8kRw6wk4Xgl1yVBybwpUF2Zu9dRe0ldpUHu2lVsHkjscH4fPV0z CTkGCdiot7DvhOgsXAcbi36udOxdwU3PHMysE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689866115; x=1690470915; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=igmOeAaO/nUKTsFVfVJFzonWyTXDvfkuPJ6/bFmba2Q=; b=befwvQgHanqm3RTwqK1qUkhCyzIymT4vvMniNfGf9BfrB5mjNBvT9P+963PL/etYdi yYth27D0VPaMIbIvErzqB2UQD680FJfvm+qMx6mulbBjLjR6OFFO+Q0f+AO61ukyM/Yd vO59Vlp/ygefrMupo+hSp1PRCLxpJqvmzgPlG0GXoVj5O1yPFQO8n6K+yc6ozCgmsg2j a80gaFCevX52hpqr+IdWcZupJWFQATMP8MKj/0uCs1NdmI0O2QuAqv1/X7S/PuKDdzoU twtMFfzGaJnRIn7QKMmaH6j2gmKopt1dEgOnFWEZFUCpe0j9tG8d4Jk0m8Vi5RCXld85 TEmw== X-Gm-Message-State: ABy/qLawepSEKD/OQmfhW8IzV2dyJwTufzSZAyq6KeKBiLVKzm/FRNFf 3xc8fXFX3ogz1+X9jEYo0iSfKw== X-Received: by 2002:a17:903:41cd:b0:1b8:9846:a3b2 with SMTP id u13-20020a17090341cd00b001b89846a3b2mr7290941ple.14.1689866114697; Thu, 20 Jul 2023 08:15:14 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id e3-20020a170902b78300b001b88af04175sm1522076pls.41.2023.07.20.08.15.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 08:15:13 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Hans de Goede <hdegoede@redhat.com> Cc: Kees Cook <keescook@chromium.org>, Larry Finger <Larry.Finger@lwfinger.net>, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] vboxsf: Use flexible arrays for trailing string member Date: Thu, 20 Jul 2023 08:15:06 -0700 Message-Id: <20230720151458.never.673-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1230; i=keescook@chromium.org; h=from:subject:message-id; bh=FPWlWMLBWLQk41wEHtF9Aoh4CSJCJMajyADIdaljriw=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBkuU96kJssYE7C3IMQG/og8R3QooDvyV0Ltszxl wFYSldLCqGJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZLlPegAKCRCJcvTf3G3A Jv+KD/4mMkxhrBH89W97Tm+qKvrzrmOjhG0Y4dB0j6sgNitbBZxCAFMdTAMSXNeK7c6MG8rpk0m u8Aq/XYopofblby5FeWyYmYKtxr6fMn0yifFAPOwlv/Y/k0UGAm9KmteX9xrEg/+sL+tH9vDH52 4PJTLar11KucciW4cdPPWQqdp4nY9H+ONRbKRycWlIXjP4HXFMsU07MioErLoIzJM73VLDOr2nt FQQEk5M6q+zmwIsdzheUle0/b79f12dbkD81rEVvFmXv+5mYpBU4tPZyCFEs+CqsjIJENYwGoFM F2jkyVp9T6HdBonaiqRRv8++PcExWotGJrHVXeb6tZTtJ+xiUHaHVAO2dbFTCGD8Oq1Qxj8LSR2 XdEndk3wVvPqs/5hiQB/9hxeL2GRlHBlrvzMvOVG7Ofn3mvpojtAmQbLD9guxt3u/BEXnrLqqxK RCESTcBs5Lcy0EcYRBCACtjztpkxF16dwE794hUChM7rxTtdrp2vMEFhPsXxoKgoakdlGbsZDfp GgIeLFk5+spiGqODrZXQjQYoLD1vWQdWdEXcdENVN8qddA/cQMMK1kGSgCgso0zl+mvUm+AuLtc gtVSOQInlTRfeUsrzoTCCdJi+uvbi4iB2EFYCPWMn76WNSbwb0Z+5zZ/ThQnDRg0h6OPNDe62vm FV/WbHK fCuhPHJQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771953986083799236 X-GMAIL-MSGID: 1771953986083799236 |
Series |
vboxsf: Use flexible arrays for trailing string member
|
|
Commit Message
Kees Cook
July 20, 2023, 3:15 p.m. UTC
The declaration of struct shfl_string used trailing fake flexible arrays for the string member. This was tripping FORTIFY_SOURCE since commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"). Replace the utf8 and utf16 members with actual flexible arrays, drop the unused ucs2 member, and retriain a 2 byte padding to keep the structure size the same. Reported-by: Larry Finger <Larry.Finger@lwfinger.net> Closes: https://lore.kernel.org/lkml/ab3a70e9-60ed-0f13-e3d4-8866eaccc8c1@lwfinger.net/ Tested-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Kees Cook <keescook@chromium.org> --- fs/vboxsf/shfl_hostintf.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Comments
Hi Kees, Larry, On 7/20/23 17:15, Kees Cook wrote: > The declaration of struct shfl_string used trailing fake flexible arrays > for the string member. This was tripping FORTIFY_SOURCE since commit > df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"). Replace the > utf8 and utf16 members with actual flexible arrays, drop the unused ucs2 > member, and retriain a 2 byte padding to keep the structure size the same. > > Reported-by: Larry Finger <Larry.Finger@lwfinger.net> > Closes: https://lore.kernel.org/lkml/ab3a70e9-60ed-0f13-e3d4-8866eaccc8c1@lwfinger.net/ > Tested-by: Larry Finger <Larry.Finger@lwfinger.net> > Signed-off-by: Kees Cook <keescook@chromium.org> Kees, Larry thank you for fixing this while I was on vacation. The patch looks good to me: Reviewed-by: Hans de Goede <hdegoede@redhat.com> Kees, I'm the vboxsf maintainer and it would be easiest for me if you can include this in a future 6.5 fixes pull-request to Linus if that is possible ? Regards, Hans > --- > fs/vboxsf/shfl_hostintf.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fs/vboxsf/shfl_hostintf.h b/fs/vboxsf/shfl_hostintf.h > index aca829062c12..069a019c9247 100644 > --- a/fs/vboxsf/shfl_hostintf.h > +++ b/fs/vboxsf/shfl_hostintf.h > @@ -68,9 +68,9 @@ struct shfl_string { > > /** UTF-8 or UTF-16 string. Nul terminated. */ > union { > - u8 utf8[2]; > - u16 utf16[1]; > - u16 ucs2[1]; /* misnomer, use utf16. */ > + u8 legacy_padding[2]; > + DECLARE_FLEX_ARRAY(u8, utf8); > + DECLARE_FLEX_ARRAY(u16, utf16); > } string; > }; > VMMDEV_ASSERT_SIZE(shfl_string, 6);
On Thu, 20 Jul 2023 08:15:06 -0700, Kees Cook wrote: > The declaration of struct shfl_string used trailing fake flexible arrays > for the string member. This was tripping FORTIFY_SOURCE since commit > df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"). Replace the > utf8 and utf16 members with actual flexible arrays, drop the unused ucs2 > member, and retriain a 2 byte padding to keep the structure size the same. > > > [...] Applied to for-linus/hardening, thanks! [1/1] vboxsf: Use flexible arrays for trailing string member https://git.kernel.org/kees/c/a8f014ec6a21 Best regards,
On 7/26/23 16:55, Kees Cook wrote: > > On Thu, 20 Jul 2023 08:15:06 -0700, Kees Cook wrote: >> The declaration of struct shfl_string used trailing fake flexible arrays >> for the string member. This was tripping FORTIFY_SOURCE since commit >> df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"). Replace the >> utf8 and utf16 members with actual flexible arrays, drop the unused ucs2 >> member, and retriain a 2 byte padding to keep the structure size the same. >> >> >> [...] > > Applied to for-linus/hardening, thanks! > > [1/1] vboxsf: Use flexible arrays for trailing string member > https://git.kernel.org/kees/c/a8f014ec6a21 Kees, This patch has not been applied to kernel 6.5-rc5. Is there some problem? Larry
On Tue, Aug 08, 2023 at 02:20:06PM -0500, Larry Finger wrote: > On 7/26/23 16:55, Kees Cook wrote: > > > > On Thu, 20 Jul 2023 08:15:06 -0700, Kees Cook wrote: > > > The declaration of struct shfl_string used trailing fake flexible arrays > > > for the string member. This was tripping FORTIFY_SOURCE since commit > > > df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"). Replace the > > > utf8 and utf16 members with actual flexible arrays, drop the unused ucs2 > > > member, and retriain a 2 byte padding to keep the structure size the same. > > > > > > > > > [...] > > > > Applied to for-linus/hardening, thanks! > > > > [1/1] vboxsf: Use flexible arrays for trailing string member > > https://git.kernel.org/kees/c/a8f014ec6a21 > > Kees, > > This patch has not been applied to kernel 6.5-rc5. Is there some problem? Hi! Sorry, I was waiting for linux-next testing, and then got distracted on Friday. I will send the PR to Linus today. Thanks for the poke! -Kees
diff --git a/fs/vboxsf/shfl_hostintf.h b/fs/vboxsf/shfl_hostintf.h index aca829062c12..069a019c9247 100644 --- a/fs/vboxsf/shfl_hostintf.h +++ b/fs/vboxsf/shfl_hostintf.h @@ -68,9 +68,9 @@ struct shfl_string { /** UTF-8 or UTF-16 string. Nul terminated. */ union { - u8 utf8[2]; - u16 utf16[1]; - u16 ucs2[1]; /* misnomer, use utf16. */ + u8 legacy_padding[2]; + DECLARE_FLEX_ARRAY(u8, utf8); + DECLARE_FLEX_ARRAY(u16, utf16); } string; }; VMMDEV_ASSERT_SIZE(shfl_string, 6);