⬢ DragonFlyBSD Kernel Audit
DF-4747 / hash4747.c
← back to finding ↓ download raw
/* DF-4747: DRM linux/hash.h hash_64() shim returns identically 0 for bits<=32. */
#include <sys/param.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/types.h>
typedef unsigned long long u64;
typedef unsigned int u32;
#define BITS_PER_LONG 64
#include <dev/drm/include/linux/hash.h>

static int hash4747_modevent(module_t mod, int type, void *data)
{
    switch (type) {
    case MOD_LOAD:
        kprintf("DF4747: hash_64(0x1122334455667788, 8) = 0x%llx\n",
            (unsigned long long)hash_64(0x1122334455667788ULL, 8));
        kprintf("DF4747: hash_64(0xdeadbeefcafebabe, 8) = 0x%llx\n",
            (unsigned long long)hash_64(0xdeadbeefcafebabeULL, 8));
        kprintf("DF4747: hash_64(1, 8) = 0x%llx\n",
            (unsigned long long)hash_64(1ULL, 8));
        kprintf("DF4747: hash_64(0x1122334455667788, 40) = 0x%llx\n",
            (unsigned long long)hash_64(0x1122334455667788ULL, 40));
        kprintf("DF4747: hash_32(0x11223344, 8) = 0x%x\n", hash_32(0x11223344U, 8));
        break;
    case MOD_UNLOAD:
        break;
    default:
        return EOPNOTSUPP;
    }
    return 0;
}
static moduledata_t hash4747_mod = { "hash4747", hash4747_modevent, NULL };
DECLARE_MODULE(hash4747, hash4747_mod, SI_SUB_DRIVERS, SI_ORDER_ANY);