lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAABuPhaMHu+mmHbVKGt2L0tcE2-EMyd5VWcok7kAfJY3DQ=-vw@mail.gmail.com>
Date:   Wed, 24 Jun 2020 16:56:18 -0700
From:   Costa Sapuntzakis <costa@...estorage.com>
To:     linux-ext4@...r.kernel.org
Subject: [BUG] invalid superblock checksum possibly due to race

Our workload: taking snapshots repeatedly of an active ext4 filesystem
(vdbench fwiw). e2fsck discovered a snapshot that had a corrupted
superblock after journal replay. Diffing the corrupted superblock to
the superblock before journal replay revealed that only s_last_orphan
and the checksum had changed.

The following race could explain it:

Thread 1 (T1): ext4_orphan_del -> update s_last_orphan to value A ->
ext4_handle_dirty_super -> ext4_superblock_csum_set -- PAUSE right
before setting es->s_checksum

T2: ext4_orphan_del -> update s_last_orphan to value B ->
ext4_handle_dirty_super -> ext4_superblock_csum_set runs to completion

T1: Resume and assign es->s_checksum

Is there higher level synchronization going on that makes this race benign?

If not, a spinlock around the calculation and assignment should fix it.

The spinlock still has the race where s_last_orphan is being updated
while the checksum is calculated. But the last thread to set
s_last_orphan will also eventually try to recalculate the checksum and
set it right (though it's possible some other thread will do it for
it). And I'm guessing/hoping jbd2 won't flush the superblock to the
journal and close a transaction until the references from
journal_get_write_access drain. The checksum is recalculated before
the get_write_access reference is dropped.

-Costa

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ