DragonFlyBSD Kernel Audit
DF-0766 / sizes.c
← back to finding ↓ download raw
/* DF-0766 reachability probe: verify kernel struct sizes + alignment invariant. */
#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/mount.h>

/* pull the NFS definitions the way the kernel uses them */
#define NFSX_UNSIGNED 4
struct nfsuint64 { uint32_t q[2]; };
#define NFSX_V3FATTR 84
struct flrep {
	struct nfsuint64 fl_off;
	u_int32_t fl_postopok;
	u_int32_t fl_fattr[NFSX_V3FATTR / sizeof(u_int32_t)];
	u_int32_t fl_fhok;
	u_int32_t fl_fhsize;
	u_int32_t fl_nfh[sizeof(fhandle_t) / sizeof(u_int32_t)];
};

int main(void) {
	printf("sizeof(fhandle_t)   = %zu  (NFSX_V3FH)\n", sizeof(fhandle_t));
	printf("sizeof(struct flrep)= %zu  mod4=%zu\n", sizeof(struct flrep), sizeof(struct flrep)%4);
	printf("NFSX_V3FATTR        = %d\n", NFSX_V3FATTR);
	return 0;
}