mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 19:19:32 +03:00
Prevent null dereferences when accessing dbuf kstat
In arc_buf_info(), the arc_buf_t may have no header. If not, don't try to fetch the arc buffer stats and instead just zero them. The null dereferences were observed while accessing the dbuf kstat with awk on a system in which millions of small files were being created in order to overflow the system's metadata limit. Signed-off-by: Tim Chase <tim@chase2k.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Chunwei Chen <david.chen@osnexus.com> Closes #4837
This commit is contained in:
parent
8d9e124515
commit
8887c7d778
@ -1461,6 +1461,13 @@ arc_buf_info(arc_buf_t *ab, arc_buf_info_t *abi, int state_index)
|
|||||||
l2arc_buf_hdr_t *l2hdr = NULL;
|
l2arc_buf_hdr_t *l2hdr = NULL;
|
||||||
arc_state_t *state = NULL;
|
arc_state_t *state = NULL;
|
||||||
|
|
||||||
|
memset(abi, 0, sizeof (arc_buf_info_t));
|
||||||
|
|
||||||
|
if (hdr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
abi->abi_flags = hdr->b_flags;
|
||||||
|
|
||||||
if (HDR_HAS_L1HDR(hdr)) {
|
if (HDR_HAS_L1HDR(hdr)) {
|
||||||
l1hdr = &hdr->b_l1hdr;
|
l1hdr = &hdr->b_l1hdr;
|
||||||
state = l1hdr->b_state;
|
state = l1hdr->b_state;
|
||||||
@ -1468,9 +1475,6 @@ arc_buf_info(arc_buf_t *ab, arc_buf_info_t *abi, int state_index)
|
|||||||
if (HDR_HAS_L2HDR(hdr))
|
if (HDR_HAS_L2HDR(hdr))
|
||||||
l2hdr = &hdr->b_l2hdr;
|
l2hdr = &hdr->b_l2hdr;
|
||||||
|
|
||||||
memset(abi, 0, sizeof (arc_buf_info_t));
|
|
||||||
abi->abi_flags = hdr->b_flags;
|
|
||||||
|
|
||||||
if (l1hdr) {
|
if (l1hdr) {
|
||||||
abi->abi_datacnt = l1hdr->b_datacnt;
|
abi->abi_datacnt = l1hdr->b_datacnt;
|
||||||
abi->abi_access = l1hdr->b_arc_access;
|
abi->abi_access = l1hdr->b_arc_access;
|
||||||
|
Loading…
Reference in New Issue
Block a user