schedule();
 }
 
-volatile unsigned int huge = INT_MAX - 2;
-volatile unsigned int ignored;
+static volatile unsigned int huge = INT_MAX - 2;
+static volatile unsigned int ignored;
 
 static void lkdtm_OVERFLOW_SIGNED(void)
 {
        ignored = value;
 }
 
-/* Intentionally using old-style flex array definition of 1 byte. */
+/* Intentionally using unannotated flex array definition. */
 struct array_bounds_flex_array {
        int one;
        int two;
                pr_expected_config(CONFIG_UBSAN_BOUNDS);
 }
 
+struct lkdtm_annotated {
+       unsigned long flags;
+       int count;
+       int array[] __counted_by(count);
+};
+
+static volatile int fam_count = 4;
+
+static void lkdtm_FAM_BOUNDS(void)
+{
+       struct lkdtm_annotated *inst;
+
+       inst = kzalloc(struct_size(inst, array, fam_count + 1), GFP_KERNEL);
+       if (!inst) {
+               pr_err("FAIL: could not allocate test struct!\n");
+               return;
+       }
+
+       inst->count = fam_count;
+       pr_info("Array access within bounds ...\n");
+       inst->array[1] = fam_count;
+       ignored = inst->array[1];
+
+       pr_info("Array access beyond bounds ...\n");
+       inst->array[fam_count] = fam_count;
+       ignored = inst->array[fam_count];
+
+       kfree(inst);
+
+       pr_err("FAIL: survived access of invalid flexible array member index!\n");
+
+       if (!__has_attribute(__counted_by__))
+               pr_warn("This is expected since this %s was built a compiler supporting __counted_by\n",
+                       lkdtm_kernel_info);
+       else if (IS_ENABLED(CONFIG_UBSAN_BOUNDS))
+               pr_expected_config(CONFIG_UBSAN_TRAP);
+       else
+               pr_expected_config(CONFIG_UBSAN_BOUNDS);
+}
+
 static void lkdtm_CORRUPT_LIST_ADD(void)
 {
        /*
        CRASHTYPE(OVERFLOW_SIGNED),
        CRASHTYPE(OVERFLOW_UNSIGNED),
        CRASHTYPE(ARRAY_BOUNDS),
+       CRASHTYPE(FAM_BOUNDS),
        CRASHTYPE(CORRUPT_LIST_ADD),
        CRASHTYPE(CORRUPT_LIST_DEL),
        CRASHTYPE(STACK_GUARD_PAGE_LEADING),