Linux Hardening
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Dave Chinner <david@fromorbit.com>,
	linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH v3][next] xfs: Replace one-element arrays with flexible-array members
Date: Fri, 9 Apr 2021 01:54:08 -0500	[thread overview]
Message-ID: <b9973292-efe6-5f95-a3a5-5d86e4081803@embeddedor.com> (raw)
In-Reply-To: <20210320214831.GA22100@magnolia>


Hi!

I think I might have caught the issue:

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index e5e0713bebcd8..9231457371100 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1937,17 +1937,17 @@ xfs_init_zones(void)
 		goto out_destroy_trans_zone;

 	xfs_efd_zone = kmem_cache_create("xfs_efd_item",
-					(sizeof(struct xfs_efd_log_item) +
-					(XFS_EFD_MAX_FAST_EXTENTS - 1) *
-					sizeof(struct xfs_extent)),
-					0, 0, NULL);
+					 struct_size((struct xfs_efd_log_item *)0,
+					 efd_format.efd_extents,
+					 XFS_EFD_MAX_FAST_EXTENTS),
+					 0, 0, NULL);
 	if (!xfs_efd_zone)
 		goto out_destroy_buf_item_zone;

 	xfs_efi_zone = kmem_cache_create("xfs_efi_item",
-					 (sizeof(struct xfs_efi_log_item) +
-					 (XFS_EFI_MAX_FAST_EXTENTS - 1) *
-					 sizeof(struct xfs_extent)),
+					 struct_size((struct xfs_efi_log_item *)0,
+					 efi_format.efi_extents,
+					 XFS_EFI_MAX_FAST_EXTENTS),
 					 0, 0, NULL);
 	if (!xfs_efi_zone)
 		goto out_destroy_efd_zone;

I'm currently testing the patch with the fix above:

https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/commit/?h=testing/xfs-fixed

--
Gustavo

On 3/20/21 16:48, Darrick J. Wong wrote:
> On Sat, Mar 20, 2021 at 03:20:55PM -0500, Gustavo A. R. Silva wrote:
>>
>>
>> On 3/20/21 15:17, Darrick J. Wong wrote:
>>>>>> Below are the results of running xfstests for groups shutdown and log
>>>>>> with the following configuration in local.config:
>>>>>>
>>>>>> export TEST_DEV=/dev/sda3
>>>>>> export TEST_DIR=/mnt/test
>>>>>> export SCRATCH_DEV=/dev/sda4
>>>>>> export SCRATCH_MNT=/mnt/scratch
>>>>>>
>>>>>> The size for both partitions /dev/sda3 and /dev/sda4 is 25GB.
>>>>>
>>>>> Looks good to me, will toss it at my fstests cloud and see if anything
>>>>> shakes out.  Thanks for cleaning up this goofy thorn-pile!
>>>>
>>>> Great. It's been fun to work on this. :p
>>>
>>> Did you run the /entire/ fstests suite?  With this patch applied to
>>> 5.12-rc2, I keep seeing list corruption assertions about an hour into
>>
>> Nope; I run xfstests 'shutdown' and 'log' groups on 5.11.0, only.
>>
>> How do you run the entire fstests?
>> Could you give me some pointers?
> 
> ./check -g all
> 
> (instead of "./check -g shutdown")
> 
>>> the test run, and usually on some test that heavily exercises allocating
>>> and deleting file extents.  I'll try to look at this patch more closely
>>> next week, but I figured I should let you know early, on the off chance
>>> something sticks out to you.
>>
>> OK. I'll go run my tests on 5.12-rc2.
>>
>> Should I run the entire xfstests, too?
> 
> Yes, please.
> 
> --D
> 
>> Thanks
>> --
>> Gustavo

  reply	other threads:[~2021-04-09  7:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11  4:23 [PATCH v3][next] xfs: Replace one-element arrays with flexible-array members Gustavo A. R. Silva
2021-03-11  4:47 ` Darrick J. Wong
2021-03-15 18:31   ` Gustavo A. R. Silva
2021-03-20 20:17     ` Darrick J. Wong
2021-03-20 20:20       ` Gustavo A. R. Silva
2021-03-20 21:48         ` Darrick J. Wong
2021-04-09  6:54           ` Gustavo A. R. Silva [this message]
2021-04-10  0:08             ` Gustavo A. R. Silva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9973292-efe6-5f95-a3a5-5d86e4081803@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=gustavoars@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox