hole = sz - (proglen +sizeof(*header));/* insert a random number of int3 instructions before BPF code */#ifLINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)*image_ptr = &header->image[prandom_u32() % hole];#else*image_ptr = &header->image[32% hole];#endifreturnheader; } 开发者...
__u32 s1, s2, s3, s4; }; DECLARE_PER_CPU(struct rnd_state, net_rand_state); u32 prandom_u32_state(struct rnd_state *state); void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes); void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state); 7...
函数名称:prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)*@ep_ro: right open interval endpoint* Returns a pseudo-random number that is in interval [0, ep_ro). Note* that the result depends on PRNG being well distributed in [0, ~0U] 函数原型:static inline ...
下面是一段代码,这段代码中有标准未定义的行为。代码如下: #include<iostream> using namespace std...
Rather than incurring a division or requesting too many random bytes for the given range, use the prandom_u32_max() function, which only takes the minimum required bytes from the RNG and avoids divisions. This was done mechanically with this coccinelle script: @basic@ expression E; type T;...
> - u32 rand_num = prandom_u32(); > + u32 rand_num = get_random_u32(); > > /* We need a '~' in the prefix to make Win98 happy. */ > tilde_pos = rand_num % 8; > @@ -651,7 +651,7 @@ static void vfat_build_dummy_83_buffer(struct inode *dir, ...
__u32 s1, s2, s3, s4; }; DECLARE_PER_CPU(struct rnd_state, net_rand_state); u32 prandom_u32_state(struct rnd_state *state); void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes); void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state); 7...
Speed is prioritized over security; attacks are rare, while performance is always wanted. Replacing all callers of prandom_u32() is the quick fix. Whether to reinstate a weaker PRNG for uses which can tolerate it is an open question. Commitf227e3e("random32: update the net random state ...
@@ -16,12 +16,44 @@ void prandom_bytes(void *buf, size_t nbytes); void prandom_seed(u32 seed); void prandom_reseed_late(void); #if BITS_PER_LONG == 64 /* * The core SipHash round function. Each line can be executed in * parallel given enough CPU resources. */ #define PRND...
void prandom_seed(u32 seed); void prandom_reseed_late(void); #if BITS_PER_LONG == 64 /* * The core SipHash round function. Each line can be executed in * parallel given enough CPU resources. */ #define PRND_SIPROUND(v0, v1, v2, v3) ( \ v0 += v1, v1 = rol64(v1, 13...