Date: Sun, 29 Jan 2012 16:44:21 +0000 (UTC) From: Attilio Rao <attilio@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r230750 - user/attilio/vmcontention/sys/vm Message-ID: <201201291644.q0TGiLVw044226@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: attilio Date: Sun Jan 29 16:44:21 2012 New Revision: 230750 URL: http://svn.freebsd.org/changeset/base/230750 Log: Fix a bug in vm_radix_leaf() where the shifting start address can wrap-up at some point. This bug is triggered very easilly by indirect blocks in UFS which grow negative resulting in very high counts. In collabouration with: flo Modified: user/attilio/vmcontention/sys/vm/vm_radix.c user/attilio/vmcontention/sys/vm/vm_radix.h Modified: user/attilio/vmcontention/sys/vm/vm_radix.c ============================================================================== --- user/attilio/vmcontention/sys/vm/vm_radix.c Sun Jan 29 16:29:06 2012 (r230749) +++ user/attilio/vmcontention/sys/vm/vm_radix.c Sun Jan 29 16:44:21 2012 (r230750) @@ -458,6 +458,12 @@ restart: */ inc = 1LL << (level * VM_RADIX_WIDTH); start &= ~VM_RADIX_MAX(level); + + /* Avoid start address wrapping up. */ + if ((VM_RADIX_MAXVAL - start) < inc) { + rnode = NULL; + goto out; + } start += inc; slot++; CTR5(KTR_VM, @@ -473,6 +479,10 @@ restart: rnode = rnode->rn_child[slot]; break; } + if ((VM_RADIX_MAXVAL - start) < inc) { + rnode = NULL; + goto out; + } } if (slot == VM_RADIX_COUNT) goto restart; Modified: user/attilio/vmcontention/sys/vm/vm_radix.h ============================================================================== --- user/attilio/vmcontention/sys/vm/vm_radix.h Sun Jan 29 16:29:06 2012 (r230749) +++ user/attilio/vmcontention/sys/vm/vm_radix.h Sun Jan 29 16:44:21 2012 (r230750) @@ -35,6 +35,7 @@ #define VM_RADIX_WIDTH 5 #define VM_RADIX_COUNT (1 << VM_RADIX_WIDTH) #define VM_RADIX_MASK (VM_RADIX_COUNT - 1) +#define VM_RADIX_MAXVAL ((vm_pindex_t)-1) #define VM_RADIX_LIMIT howmany((sizeof(vm_pindex_t) * NBBY), VM_RADIX_WIDTH) #define VM_RADIX_FLAGS 0x3 /* Flag bits stored in node pointers. */ #define VM_RADIX_BLACK 0x1 /* Black node. (leaf only) */ @@ -46,7 +47,7 @@ /* Calculates maximum value for a tree of height h. */ #define VM_RADIX_MAX(h) \ - ((h) == VM_RADIX_LIMIT ? ((vm_pindex_t)-1) : \ + ((h) == VM_RADIX_LIMIT ? VM_RADIX_MAXVAL : \ (((vm_pindex_t)1 << ((h) * VM_RADIX_WIDTH)) - 1)) /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201291644.q0TGiLVw044226>