gfs2: Validate i_depth for exhash directories
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 9a0045088d888c9c539c8c626a366cb52c0fbdab · < b5f46951e62377b6e406fadc18bc3c5bdf1632a7| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
gfs2: Validate i_depth for exhash directories
A fuzzer test introduced corruption that ends up with a depth of 0 in dir_e_read(), causing an undefined shift by 32 at:
index = hash >> (32 - dip->i_depth);
As calculated in an open-coded way in dir_make_exhash(), the minimum depth for an exhash directory is ilog2(sdp->sd_hash_ptrs) and 0 is invalid as sdp->sd_hash_ptrs is fixed as sdp->bsize / 16 at mount time.
So we can avoid the undefined behaviour by checking for depth values lower than the minimum in gfs2_dinode_in(). Values greater than the maximum are already being checked for there.
Also switch the calculation in dir_make_exhash() to use ilog2() to clarify how the depth is calculated.
Tested with the syzkaller repro.c and xfstests '-g quick'.
From the CVE record · Linux
The Linux kernel’s gfs2 code does not reject an invalid exhash directory depth. Processing a corrupted directory with a depth of zero can cause an undefined shift. The input does not establish how an attacker could introduce the corruption or whether authentication or user interaction is required.
Engineers running Linux kernels with gfs2 should check their versions; affected versions are not specified.