[GH-ISSUE #50] Missing the function get_random_u8 #24

Closed
opened 2026-10-13 21:05:23 +00:00 by bsakaguchi · 9 comments
Owner

Originally created by @Astromis on GitHub (Nov 13, 2024).
Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/issues/50

Hi.
Tecnhical info of my os

  Virtualization: kvm
Operating System: Ubuntu 22.04.5 LTS
          Kernel: Linux 5.15.0-125-generic
    Architecture: x86-64
 Hardware Vendor: Red Hat
  Hardware Model: KVM

Try to install amneziawg by standraed command

apt install amneziawg

But the installation is crashed. The log is as follows

Hunk #1 succeeded at 75 with fuzz 3 (offset -1 lines).
 patching file netlink.c
 patching file netlink.h
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/main.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/noise.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/device.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/peer.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/timers.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/queueing.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/send.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/receive.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/socket.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/peerlookup.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/allowedips.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/ratelimiter.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/cookie.o
   CC [M]  /var/lib/dkms/amneziawg/1.0.0/build/generated/netlink.o
 /var/lib/dkms/amneziawg/1.0.0/build/generated/netlink.c: In function ‘generate_ipv6_address_with_prefix’:
 /var/lib/dkms/amneziawg/1.0.0/build/generated/netlink.c:251:47: error: implicit declaration of function ‘get_random_u8’; did you mean ‘get_random_u64’? [-Werror=implicit-function-declaration]
   251 |                         addr[prefix_bytes] |= get_random_u8() & ~mask;
       |                                               ^~~~~~~~~~~~~
       |                                               get_random_u64
 cc1: some warnings being treated as errors
 make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/amneziawg/1.0.0/build/generated/netlink.o] Error 1
 make[1]: *** [Makefile:1910: /var/lib/dkms/amneziawg/1.0.0/build/generated] Error 2
 make: *** [Makefile:94: module] Error 2
 make: Leaving directory '/var/lib/dkms/amneziawg/1.0.0/build'
DKMSKernelVersion: 5.15.0-125-generic
Date: Wed Nov 13 09:34:27 2024
DuplicateSignature: dkms:amneziawg-dkms:1.0.0-0~202411121332+7596c5c~ubuntu22.04.1:/var/lib/dkms/amneziawg/1.0.0/build/generated/netlink.c:251:47: error: implicit declaration of function ‘get_random_u8’; did you mean ‘get_random_u64’? [-Werror=implicit-function-declaration]
Package: amneziawg-dkms 1.0.0-0~202411121332+7596c5c~ubuntu22.04.1
PackageVersion: 1.0.0-0~202411121332+7596c5c~ubuntu22.04.1
SourcePackage: amneziawg-linux-kmod
Title: amneziawg-dkms 1.0.0-0~202411121332+7596c5c~ubuntu22.04.1: amneziawg kernel module failed to build

So it says that that installation misses the function get_random_u8. The little investigation shows that actually this function is available in linux kernel headers right in official repo by this link.

I make sure that the linux headers are installed, retried the amnezia installation and it fails again. I looked at installed headers on my system and found out that it really doesn't have the above function. Here is the code snippet in the same area as in Torvalds header.

static inline void add_latent_entropy(void)
{
#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__)
        add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
#else
        add_device_randomness(NULL, 0);
#endif
}

void get_random_bytes(void *buf, size_t len);
size_t __must_check get_random_bytes_arch(void *buf, size_t len);
u32 get_random_u32(void);
u64 get_random_u64(void);
static inline unsigned int get_random_int(void)
{
        return get_random_u32();
}
static inline unsigned long get_random_long(void)
{
#if BITS_PER_LONG == 64
        return get_random_u64();
#else
        return get_random_u32();
#endif
}

/*
 * On 64-bit architectures, protect against non-terminated C string overflows
 * by zeroing out the first byte of the canary; this leaves 56 bits of entropy.
 */

Do you have any ideas how I can fix this?

Originally created by @Astromis on GitHub (Nov 13, 2024). Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/issues/50 Hi. Tecnhical info of my os ``` Virtualization: kvm Operating System: Ubuntu 22.04.5 LTS Kernel: Linux 5.15.0-125-generic Architecture: x86-64 Hardware Vendor: Red Hat Hardware Model: KVM ``` Try to install amneziawg by standraed command ``` apt install amneziawg ``` But the installation is crashed. The log is as follows ``` Hunk #1 succeeded at 75 with fuzz 3 (offset -1 lines). patching file netlink.c patching file netlink.h CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/main.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/noise.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/device.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/peer.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/timers.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/queueing.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/send.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/receive.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/socket.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/peerlookup.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/allowedips.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/ratelimiter.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/cookie.o CC [M] /var/lib/dkms/amneziawg/1.0.0/build/generated/netlink.o /var/lib/dkms/amneziawg/1.0.0/build/generated/netlink.c: In function ‘generate_ipv6_address_with_prefix’: /var/lib/dkms/amneziawg/1.0.0/build/generated/netlink.c:251:47: error: implicit declaration of function ‘get_random_u8’; did you mean ‘get_random_u64’? [-Werror=implicit-function-declaration] 251 | addr[prefix_bytes] |= get_random_u8() & ~mask; | ^~~~~~~~~~~~~ | get_random_u64 cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/amneziawg/1.0.0/build/generated/netlink.o] Error 1 make[1]: *** [Makefile:1910: /var/lib/dkms/amneziawg/1.0.0/build/generated] Error 2 make: *** [Makefile:94: module] Error 2 make: Leaving directory '/var/lib/dkms/amneziawg/1.0.0/build' DKMSKernelVersion: 5.15.0-125-generic Date: Wed Nov 13 09:34:27 2024 DuplicateSignature: dkms:amneziawg-dkms:1.0.0-0~202411121332+7596c5c~ubuntu22.04.1:/var/lib/dkms/amneziawg/1.0.0/build/generated/netlink.c:251:47: error: implicit declaration of function ‘get_random_u8’; did you mean ‘get_random_u64’? [-Werror=implicit-function-declaration] Package: amneziawg-dkms 1.0.0-0~202411121332+7596c5c~ubuntu22.04.1 PackageVersion: 1.0.0-0~202411121332+7596c5c~ubuntu22.04.1 SourcePackage: amneziawg-linux-kmod Title: amneziawg-dkms 1.0.0-0~202411121332+7596c5c~ubuntu22.04.1: amneziawg kernel module failed to build ``` So it says that that installation misses the function `get_random_u8`. The little investigation shows that actually this function is available in linux kernel headers right in official repo by [this link](https://github.com/torvalds/linux/blob/f1b785f4c7870c42330b35522c2514e39a1e28e7/include/linux/random.h#L40). I make sure that the linux headers are installed, retried the amnezia installation and it fails again. I looked at installed headers on my system and found out that it really doesn't have the above function. Here is the code snippet in the same area as in Torvalds header. ``` static inline void add_latent_entropy(void) { #if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy)); #else add_device_randomness(NULL, 0); #endif } void get_random_bytes(void *buf, size_t len); size_t __must_check get_random_bytes_arch(void *buf, size_t len); u32 get_random_u32(void); u64 get_random_u64(void); static inline unsigned int get_random_int(void) { return get_random_u32(); } static inline unsigned long get_random_long(void) { #if BITS_PER_LONG == 64 return get_random_u64(); #else return get_random_u32(); #endif } /* * On 64-bit architectures, protect against non-terminated C string overflows * by zeroing out the first byte of the canary; this leaves 56 bits of entropy. */ ``` Do you have any ideas how I can fix this?
Author
Owner

@G2Dolphin commented on GitHub (Nov 13, 2024):

I have the same problem on the same OS and kernel versions.

<!-- gh-comment-id:2473138068 --> @G2Dolphin commented on GitHub (Nov 13, 2024): I have the same problem on the same OS and kernel versions.
Author
Owner

@Rogov-Ilya commented on GitHub (Nov 13, 2024):

try replacing sudo apt linux-headers-$(uname -r) with sudo apt linux-headers-5.15.0-25-generic

<!-- gh-comment-id:2473635844 --> @Rogov-Ilya commented on GitHub (Nov 13, 2024): try replacing `sudo apt linux-headers-$(uname -r)` with `sudo apt linux-headers-5.15.0-25-generic`
Author
Owner

@Astromis commented on GitHub (Nov 13, 2024):

@Rogov-Ilya, thanks for reply.

I installed the another headers and remove sourced one. Unfortunately, it seems that it somewhere got to know which kernel version is installed and tried to build the module for this and if it can't find the headers for this kernel version it just skips the building. It's interesting that installation continues.

...
Building for 5.15.0-125-generic
Module build for kernel 5.15.0-125-generic was skipped since the
kernel headers for this kernel does not seem to be installed.
Setting up amneziawg (1.0.20210914-0~202410011335+c0b400c~ubuntu22.04.1) ...

Maybe I should try to install the particular kernel?

<!-- gh-comment-id:2473761272 --> @Astromis commented on GitHub (Nov 13, 2024): @Rogov-Ilya, thanks for reply. I installed the another headers and remove sourced one. Unfortunately, it seems that it somewhere got to know which kernel version is installed and tried to build the module for this and if it can't find the headers for this kernel version it just skips the building. It's interesting that installation continues. ``` ... Building for 5.15.0-125-generic Module build for kernel 5.15.0-125-generic was skipped since the kernel headers for this kernel does not seem to be installed. Setting up amneziawg (1.0.20210914-0~202410011335+c0b400c~ubuntu22.04.1) ... ``` Maybe I should try to install the particular kernel?
Author
Owner

@vasly commented on GitHub (Nov 13, 2024):

I have the same error for Ubuntu 5.15.0-125-generic

<!-- gh-comment-id:2474479490 --> @vasly commented on GitHub (Nov 13, 2024): I have the same error for Ubuntu 5.15.0-125-generic
Author
Owner

@lisachev commented on GitHub (Nov 14, 2024):

Ubuntu 22.04.5 LTS x86_64
5.15.0-125-generic

confirmed error

<!-- gh-comment-id:2475679887 --> @lisachev commented on GitHub (Nov 14, 2024): Ubuntu 22.04.5 LTS x86_64 5.15.0-125-generic confirmed error
Author
Owner

@RomikB commented on GitHub (Nov 15, 2024):

Same error. Ubuntu 5.15.0-125-generic have no definition for get_random_u8.

<!-- gh-comment-id:2478101518 --> @RomikB commented on GitHub (Nov 15, 2024): Same error. Ubuntu 5.15.0-125-generic have no definition for get_random_u8.
Author
Owner

@g0ha1 commented on GitHub (Nov 15, 2024):

same error on 5.15.0-125, tryed to install on older kernel version, like 5.15.0-25 got same error

<!-- gh-comment-id:2478378644 --> @g0ha1 commented on GitHub (Nov 15, 2024): same error on 5.15.0-125, tryed to install on older kernel version, like 5.15.0-25 got same error
Author
Owner

@vprgr commented on GitHub (Nov 15, 2024):

confirmed error

<!-- gh-comment-id:2478473371 --> @vprgr commented on GitHub (Nov 15, 2024): confirmed error
Author
Owner

@leninalive commented on GitHub (Nov 15, 2024):

Should be fixed in latest packages.

<!-- gh-comment-id:2478635614 --> @leninalive commented on GitHub (Nov 15, 2024): Should be fixed in latest packages.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-linux-kernel-module#24
No description provided.