treewide: use get_random_u32() when possible
The prandom_u32() function has been a deprecated inline wrapper around get_random_u32() for several releases now, and compiles down to the exact same code. Replace the deprecated wrapper with a direct call to the real function. The same also applies to get_random_int(), which is just a wrapper around get_random_u32(). This was done as a basic find and replace. Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Yury Norov <yury.norov@gmail.com> Reviewed-by: Jan Kara <jack@suse.cz> # for ext4 Acked-by: Toke Høiland-Jørgensen <toke@toke.dk> # for sch_cake Acked-by: Chuck Lever <chuck.lever@oracle.com> # for nfsd Acked-by: Jakub Kicinski <kuba@kernel.org> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for thunderbolt Acked-by: Darrick J. Wong <djwong@kernel.org> # for xfs Acked-by: Helge Deller <deller@gmx.de> # for parisc Acked-by: Heiko Carstens <hca@linux.ibm.com> # for s390 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
f743f16c54
commit
a251c17aa5
|
@ -305,7 +305,7 @@ Possible BPF extensions are shown in the following table:
|
|||
vlan_tci skb_vlan_tag_get(skb)
|
||||
vlan_avail skb_vlan_tag_present(skb)
|
||||
vlan_tpid skb->vlan_proto
|
||||
rand prandom_u32()
|
||||
rand get_random_u32()
|
||||
=================================== =================================================
|
||||
|
||||
These extensions can also be prefixed with '#'.
|
||||
|
|
|
@ -288,7 +288,7 @@ __get_wchan(struct task_struct *p)
|
|||
|
||||
static inline unsigned long brk_rnd(void)
|
||||
{
|
||||
return (get_random_int() & BRK_RND_MASK) << PAGE_SHIFT;
|
||||
return (get_random_u32() & BRK_RND_MASK) << PAGE_SHIFT;
|
||||
}
|
||||
|
||||
unsigned long arch_randomize_brk(struct mm_struct *mm)
|
||||
|
|
|
@ -239,14 +239,14 @@ static unsigned long mmap_rnd(void)
|
|||
unsigned long rnd = 0;
|
||||
|
||||
if (current->flags & PF_RANDOMIZE)
|
||||
rnd = get_random_int() & MMAP_RND_MASK;
|
||||
rnd = get_random_u32() & MMAP_RND_MASK;
|
||||
|
||||
return rnd << PAGE_SHIFT;
|
||||
}
|
||||
|
||||
unsigned long arch_mmap_rnd(void)
|
||||
{
|
||||
return (get_random_int() & MMAP_RND_MASK) << PAGE_SHIFT;
|
||||
return (get_random_u32() & MMAP_RND_MASK) << PAGE_SHIFT;
|
||||
}
|
||||
|
||||
static unsigned long mmap_legacy_base(void)
|
||||
|
|
|
@ -37,7 +37,7 @@ static inline int mmap_is_legacy(struct rlimit *rlim_stack)
|
|||
|
||||
unsigned long arch_mmap_rnd(void)
|
||||
{
|
||||
return (get_random_int() & MMAP_RND_MASK) << PAGE_SHIFT;
|
||||
return (get_random_u32() & MMAP_RND_MASK) << PAGE_SHIFT;
|
||||
}
|
||||
|
||||
static unsigned long mmap_base_legacy(unsigned long rnd)
|
||||
|
|
|
@ -503,7 +503,7 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
|
|||
va_align.flags = ALIGN_VA_32 | ALIGN_VA_64;
|
||||
|
||||
/* A random value per boot for bit slice [12:upper_bit) */
|
||||
va_align.bits = get_random_int() & va_align.mask;
|
||||
va_align.bits = get_random_u32() & va_align.mask;
|
||||
}
|
||||
|
||||
if (cpu_has(c, X86_FEATURE_MWAITX))
|
||||
|
|
|
@ -137,12 +137,12 @@ static u64 random_offset(u64 start, u64 end, u64 len, u64 align)
|
|||
range = round_down(end - len, align) - round_up(start, align);
|
||||
if (range) {
|
||||
if (sizeof(unsigned long) == sizeof(u64)) {
|
||||
addr = get_random_long();
|
||||
addr = get_random_u64();
|
||||
} else {
|
||||
addr = get_random_int();
|
||||
addr = get_random_u32();
|
||||
if (range > U32_MAX) {
|
||||
addr <<= 32;
|
||||
addr |= get_random_int();
|
||||
addr |= get_random_u32();
|
||||
}
|
||||
}
|
||||
div64_u64_rem(addr, range, &addr);
|
||||
|
|
|
@ -135,7 +135,7 @@ static int __run_selftests(const char *name,
|
|||
int err = 0;
|
||||
|
||||
while (!i915_selftest.random_seed)
|
||||
i915_selftest.random_seed = get_random_int();
|
||||
i915_selftest.random_seed = get_random_u32();
|
||||
|
||||
i915_selftest.timeout_jiffies =
|
||||
i915_selftest.timeout_ms ?
|
||||
|
|
|
@ -729,7 +729,7 @@ static void drm_test_buddy_alloc_limit(struct kunit *test)
|
|||
static int drm_buddy_init_test(struct kunit *test)
|
||||
{
|
||||
while (!random_seed)
|
||||
random_seed = get_random_int();
|
||||
random_seed = get_random_u32();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2212,7 +2212,7 @@ err_nodes:
|
|||
static int drm_mm_init_test(struct kunit *test)
|
||||
{
|
||||
while (!random_seed)
|
||||
random_seed = get_random_int();
|
||||
random_seed = get_random_u32();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -734,7 +734,7 @@ static int send_connect(struct c4iw_ep *ep)
|
|||
&ep->com.remote_addr;
|
||||
int ret;
|
||||
enum chip_type adapter_type = ep->com.dev->rdev.lldi.adapter_type;
|
||||
u32 isn = (prandom_u32() & ~7UL) - 1;
|
||||
u32 isn = (get_random_u32() & ~7UL) - 1;
|
||||
struct net_device *netdev;
|
||||
u64 params;
|
||||
|
||||
|
@ -2469,7 +2469,7 @@ static int accept_cr(struct c4iw_ep *ep, struct sk_buff *skb,
|
|||
}
|
||||
|
||||
if (!is_t4(adapter_type)) {
|
||||
u32 isn = (prandom_u32() & ~7UL) - 1;
|
||||
u32 isn = (get_random_u32() & ~7UL) - 1;
|
||||
|
||||
skb = get_skb(skb, roundup(sizeof(*rpl5), 16), GFP_KERNEL);
|
||||
rpl5 = __skb_put_zero(skb, roundup(sizeof(*rpl5), 16));
|
||||
|
|
|
@ -850,7 +850,7 @@ void hfi1_kern_init_ctxt_generations(struct hfi1_ctxtdata *rcd)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < RXE_NUM_TID_FLOWS; i++) {
|
||||
rcd->flows[i].generation = mask_generation(prandom_u32());
|
||||
rcd->flows[i].generation = mask_generation(get_random_u32());
|
||||
kern_set_hw_flow(rcd, KERN_GENERATION_RESERVED, i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ static void __propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
|
|||
__be64 mlx4_ib_gen_node_guid(void)
|
||||
{
|
||||
#define NODE_GUID_HI ((u64) (((u64)IB_OPENIB_OUI) << 40))
|
||||
return cpu_to_be64(NODE_GUID_HI | prandom_u32());
|
||||
return cpu_to_be64(NODE_GUID_HI | get_random_u32());
|
||||
}
|
||||
|
||||
__be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
|
||||
|
|
|
@ -465,7 +465,7 @@ static int ipoib_cm_req_handler(struct ib_cm_id *cm_id,
|
|||
goto err_qp;
|
||||
}
|
||||
|
||||
psn = prandom_u32() & 0xffffff;
|
||||
psn = get_random_u32() & 0xffffff;
|
||||
ret = ipoib_cm_modify_rx_qp(dev, cm_id, p->qp, psn);
|
||||
if (ret)
|
||||
goto err_modify;
|
||||
|
|
|
@ -2994,7 +2994,7 @@ static int r5l_load_log(struct r5l_log *log)
|
|||
}
|
||||
create:
|
||||
if (create_super) {
|
||||
log->last_cp_seq = prandom_u32();
|
||||
log->last_cp_seq = get_random_u32();
|
||||
cp = 0;
|
||||
r5l_log_write_empty_meta_block(log, cp, log->last_cp_seq);
|
||||
/*
|
||||
|
|
|
@ -210,7 +210,7 @@ static void vivid_fill_buff_noise(__s16 *tch_buf, int size)
|
|||
|
||||
/* Fill 10% of the values within range -3 and 3, zero the others */
|
||||
for (i = 0; i < size; i++) {
|
||||
unsigned int rand = get_random_int();
|
||||
unsigned int rand = get_random_u32();
|
||||
|
||||
if (rand % 10)
|
||||
tch_buf[i] = 0;
|
||||
|
@ -272,7 +272,7 @@ void vivid_fillbuff_tch(struct vivid_dev *dev, struct vivid_buffer *buf)
|
|||
return;
|
||||
|
||||
if (test_pat_idx == 0)
|
||||
dev->tch_pat_random = get_random_int();
|
||||
dev->tch_pat_random = get_random_u32();
|
||||
rand = dev->tch_pat_random;
|
||||
|
||||
switch (test_pattern) {
|
||||
|
|
|
@ -2948,7 +2948,7 @@ static void gaudi2_user_interrupt_setup(struct hl_device *hdev)
|
|||
|
||||
static inline int gaudi2_get_non_zero_random_int(void)
|
||||
{
|
||||
int rand = get_random_int();
|
||||
int rand = get_random_u32();
|
||||
|
||||
return rand ? rand : 1;
|
||||
}
|
||||
|
|
|
@ -4806,7 +4806,7 @@ static u32 bond_rr_gen_slave_id(struct bonding *bond)
|
|||
|
||||
switch (packets_per_slave) {
|
||||
case 0:
|
||||
slave_id = prandom_u32();
|
||||
slave_id = get_random_u32();
|
||||
break;
|
||||
case 1:
|
||||
slave_id = this_cpu_inc_return(*bond->rr_tx_counter);
|
||||
|
|
|
@ -4164,7 +4164,7 @@ static int cnic_cm_init_bnx2_hw(struct cnic_dev *dev)
|
|||
{
|
||||
u32 seed;
|
||||
|
||||
seed = prandom_u32();
|
||||
seed = get_random_u32();
|
||||
cnic_ctx_wr(dev, 45, 0, seed);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1063,7 +1063,7 @@ static void chtls_pass_accept_rpl(struct sk_buff *skb,
|
|||
opt2 |= WND_SCALE_EN_V(WSCALE_OK(tp));
|
||||
rpl5->opt0 = cpu_to_be64(opt0);
|
||||
rpl5->opt2 = cpu_to_be32(opt2);
|
||||
rpl5->iss = cpu_to_be32((prandom_u32() & ~7UL) - 1);
|
||||
rpl5->iss = cpu_to_be32((get_random_u32() & ~7UL) - 1);
|
||||
set_wr_txq(skb, CPL_PRIORITY_SETUP, csk->port_id);
|
||||
t4_set_arp_err_handler(skb, sk, chtls_accept_rpl_arp_failure);
|
||||
cxgb4_l2t_send(csk->egress_dev, skb, csk->l2t_entry);
|
||||
|
|
|
@ -129,7 +129,7 @@ static int rocker_reg_test(const struct rocker *rocker)
|
|||
u64 test_reg;
|
||||
u64 rnd;
|
||||
|
||||
rnd = prandom_u32();
|
||||
rnd = get_random_u32();
|
||||
rnd >>= 1;
|
||||
rocker_write32(rocker, TEST_REG, rnd);
|
||||
test_reg = rocker_read32(rocker, TEST_REG);
|
||||
|
@ -139,9 +139,9 @@ static int rocker_reg_test(const struct rocker *rocker)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
rnd = prandom_u32();
|
||||
rnd = get_random_u32();
|
||||
rnd <<= 31;
|
||||
rnd |= prandom_u32();
|
||||
rnd |= get_random_u32();
|
||||
rocker_write64(rocker, TEST_REG64, rnd);
|
||||
test_reg = rocker_read64(rocker, TEST_REG64);
|
||||
if (test_reg != rnd * 2) {
|
||||
|
|
|
@ -239,7 +239,7 @@ mwifiex_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
|
|||
tx_info->pkt_len = pkt_len;
|
||||
|
||||
mwifiex_form_mgmt_frame(skb, buf, len);
|
||||
*cookie = prandom_u32() | 1;
|
||||
*cookie = get_random_u32() | 1;
|
||||
|
||||
if (ieee80211_is_action(mgmt->frame_control))
|
||||
skb = mwifiex_clone_skb_for_tx_status(priv,
|
||||
|
@ -303,7 +303,7 @@ mwifiex_cfg80211_remain_on_channel(struct wiphy *wiphy,
|
|||
duration);
|
||||
|
||||
if (!ret) {
|
||||
*cookie = prandom_u32() | 1;
|
||||
*cookie = get_random_u32() | 1;
|
||||
priv->roc_cfg.cookie = *cookie;
|
||||
priv->roc_cfg.chan = *chan;
|
||||
|
||||
|
|
|
@ -1161,7 +1161,7 @@ static int mgmt_tx(struct wiphy *wiphy,
|
|||
const u8 *vendor_ie;
|
||||
int ret = 0;
|
||||
|
||||
*cookie = prandom_u32();
|
||||
*cookie = get_random_u32();
|
||||
priv->tx_cookie = *cookie;
|
||||
mgmt = (const struct ieee80211_mgmt *)buf;
|
||||
|
||||
|
|
|
@ -449,7 +449,7 @@ qtnf_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
|
|||
{
|
||||
struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev);
|
||||
const struct ieee80211_mgmt *mgmt_frame = (void *)params->buf;
|
||||
u32 short_cookie = prandom_u32();
|
||||
u32 short_cookie = get_random_u32();
|
||||
u16 flags = 0;
|
||||
u16 freq;
|
||||
|
||||
|
|
|
@ -6100,7 +6100,7 @@ static int wl1271_register_hw(struct wl1271 *wl)
|
|||
wl1271_warning("Fuse mac address is zero. using random mac");
|
||||
/* Use TI oui and a random nic */
|
||||
oui_addr = WLCORE_TI_OUI_ADDRESS;
|
||||
nic_addr = get_random_int();
|
||||
nic_addr = get_random_u32();
|
||||
} else {
|
||||
oui_addr = wl->fuse_oui_addr;
|
||||
/* fuse has the BD_ADDR, the WLAN addresses are the next two */
|
||||
|
|
|
@ -23,7 +23,7 @@ u32 nvme_auth_get_seqnum(void)
|
|||
|
||||
mutex_lock(&nvme_dhchap_mutex);
|
||||
if (!nvme_dhchap_seqnum)
|
||||
nvme_dhchap_seqnum = prandom_u32();
|
||||
nvme_dhchap_seqnum = get_random_u32();
|
||||
else {
|
||||
nvme_dhchap_seqnum++;
|
||||
if (!nvme_dhchap_seqnum)
|
||||
|
|
|
@ -254,7 +254,7 @@ static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb,
|
|||
} else if (is_t5(lldi->adapter_type)) {
|
||||
struct cpl_t5_act_open_req *req =
|
||||
(struct cpl_t5_act_open_req *)skb->head;
|
||||
u32 isn = (prandom_u32() & ~7UL) - 1;
|
||||
u32 isn = (get_random_u32() & ~7UL) - 1;
|
||||
|
||||
INIT_TP_WR(req, 0);
|
||||
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_ACT_OPEN_REQ,
|
||||
|
@ -282,7 +282,7 @@ static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb,
|
|||
} else {
|
||||
struct cpl_t6_act_open_req *req =
|
||||
(struct cpl_t6_act_open_req *)skb->head;
|
||||
u32 isn = (prandom_u32() & ~7UL) - 1;
|
||||
u32 isn = (get_random_u32() & ~7UL) - 1;
|
||||
|
||||
INIT_TP_WR(req, 0);
|
||||
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_ACT_OPEN_REQ,
|
||||
|
|
|
@ -1202,7 +1202,7 @@ cxgbit_pass_accept_rpl(struct cxgbit_sock *csk, struct cpl_pass_accept_req *req)
|
|||
opt2 |= CONG_CNTRL_V(CONG_ALG_NEWRENO);
|
||||
|
||||
opt2 |= T5_ISS_F;
|
||||
rpl5->iss = cpu_to_be32((prandom_u32() & ~7UL) - 1);
|
||||
rpl5->iss = cpu_to_be32((get_random_u32() & ~7UL) - 1);
|
||||
|
||||
opt2 |= T5_OPT_2_VALID_F;
|
||||
|
||||
|
|
|
@ -2437,7 +2437,7 @@ int tb_xdomain_init(void)
|
|||
tb_property_add_immediate(xdomain_property_dir, "deviceid", 0x1);
|
||||
tb_property_add_immediate(xdomain_property_dir, "devicerv", 0x80000100);
|
||||
|
||||
xdomain_property_block_gen = prandom_u32();
|
||||
xdomain_property_block_gen = get_random_u32();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ static int uvesafb_exec(struct uvesafb_ktask *task)
|
|||
memcpy(&m->id, &uvesafb_cn_id, sizeof(m->id));
|
||||
m->seq = seq;
|
||||
m->len = len;
|
||||
m->ack = prandom_u32();
|
||||
m->ack = get_random_u32();
|
||||
|
||||
/* uvesafb_task structure */
|
||||
memcpy(m + 1, &task->t, sizeof(task->t));
|
||||
|
|
|
@ -552,7 +552,7 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)
|
|||
inode->i_uid = sbi->options.fs_uid;
|
||||
inode->i_gid = sbi->options.fs_gid;
|
||||
inode_inc_iversion(inode);
|
||||
inode->i_generation = prandom_u32();
|
||||
inode->i_generation = get_random_u32();
|
||||
|
||||
if (info->attr & ATTR_SUBDIR) { /* directory */
|
||||
inode->i_generation &= ~1;
|
||||
|
|
|
@ -1279,7 +1279,7 @@ got:
|
|||
EXT4_GROUP_INFO_IBITMAP_CORRUPT);
|
||||
goto out;
|
||||
}
|
||||
inode->i_generation = prandom_u32();
|
||||
inode->i_generation = get_random_u32();
|
||||
|
||||
/* Precompute checksum seed for inode metadata */
|
||||
if (ext4_has_metadata_csum(sb)) {
|
||||
|
|
|
@ -454,8 +454,8 @@ static long swap_inode_boot_loader(struct super_block *sb,
|
|||
inode->i_ctime = inode_bl->i_ctime = current_time(inode);
|
||||
inode_inc_iversion(inode);
|
||||
|
||||
inode->i_generation = prandom_u32();
|
||||
inode_bl->i_generation = prandom_u32();
|
||||
inode->i_generation = get_random_u32();
|
||||
inode_bl->i_generation = get_random_u32();
|
||||
ext4_reset_inode_seed(inode);
|
||||
ext4_reset_inode_seed(inode_bl);
|
||||
|
||||
|
|
|
@ -265,7 +265,7 @@ static unsigned int mmp_new_seq(void)
|
|||
u32 new_seq;
|
||||
|
||||
do {
|
||||
new_seq = prandom_u32();
|
||||
new_seq = get_random_u32();
|
||||
} while (new_seq > EXT4_MMP_SEQ_MAX);
|
||||
|
||||
return new_seq;
|
||||
|
|
|
@ -50,7 +50,7 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
|
|||
inode->i_blocks = 0;
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
|
||||
F2FS_I(inode)->i_crtime = inode->i_mtime;
|
||||
inode->i_generation = prandom_u32();
|
||||
inode->i_generation = get_random_u32();
|
||||
|
||||
if (S_ISDIR(inode->i_mode))
|
||||
F2FS_I(inode)->i_current_depth = 1;
|
||||
|
|
|
@ -523,7 +523,7 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
|
|||
inode->i_uid = sbi->options.fs_uid;
|
||||
inode->i_gid = sbi->options.fs_gid;
|
||||
inode_inc_iversion(inode);
|
||||
inode->i_generation = prandom_u32();
|
||||
inode->i_generation = get_random_u32();
|
||||
|
||||
if ((de->attr & ATTR_DIR) && !IS_FREE(de->name)) {
|
||||
inode->i_generation &= ~1;
|
||||
|
|
|
@ -4375,8 +4375,8 @@ nfsd4_init_leases_net(struct nfsd_net *nn)
|
|||
nn->nfsd4_grace = 90;
|
||||
nn->somebody_reclaimed = false;
|
||||
nn->track_reclaim_completes = false;
|
||||
nn->clverifier_counter = prandom_u32();
|
||||
nn->clientid_base = prandom_u32();
|
||||
nn->clverifier_counter = get_random_u32();
|
||||
nn->clientid_base = get_random_u32();
|
||||
nn->clientid_counter = nn->clientid_base + 1;
|
||||
nn->s2s_cp_cl_id = nn->clientid_counter++;
|
||||
|
||||
|
|
|
@ -3819,7 +3819,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)
|
|||
}
|
||||
|
||||
log_init_pg_hdr(log, page_size, page_size, 1, 1);
|
||||
log_create(log, l_size, 0, get_random_int(), false, false);
|
||||
log_create(log, l_size, 0, get_random_u32(), false, false);
|
||||
|
||||
log->ra = ra;
|
||||
|
||||
|
@ -3893,7 +3893,7 @@ check_restart_area:
|
|||
|
||||
/* Do some checks based on whether we have a valid log page. */
|
||||
if (!rst_info.valid_page) {
|
||||
open_log_count = get_random_int();
|
||||
open_log_count = get_random_u32();
|
||||
goto init_log_instance;
|
||||
}
|
||||
open_log_count = le32_to_cpu(ra2->open_log_count);
|
||||
|
@ -4044,7 +4044,7 @@ find_oldest:
|
|||
memcpy(ra->clients, Add2Ptr(ra2, t16),
|
||||
le16_to_cpu(ra2->ra_len) - t16);
|
||||
|
||||
log->current_openlog_count = get_random_int();
|
||||
log->current_openlog_count = get_random_u32();
|
||||
ra->open_log_count = cpu_to_le32(log->current_openlog_count);
|
||||
log->ra_size = offsetof(struct RESTART_AREA, clients) +
|
||||
sizeof(struct CLIENT_REC);
|
||||
|
|
|
@ -503,7 +503,7 @@ static void mark_inode_clean(struct ubifs_info *c, struct ubifs_inode *ui)
|
|||
static void set_dent_cookie(struct ubifs_info *c, struct ubifs_dent_node *dent)
|
||||
{
|
||||
if (c->double_hash)
|
||||
dent->cookie = (__force __le32) prandom_u32();
|
||||
dent->cookie = (__force __le32) get_random_u32();
|
||||
else
|
||||
dent->cookie = 0;
|
||||
}
|
||||
|
|
|
@ -805,7 +805,7 @@ sparse_alloc:
|
|||
* number from being easily guessable.
|
||||
*/
|
||||
error = xfs_ialloc_inode_init(args.mp, tp, NULL, newlen, pag->pag_agno,
|
||||
args.agbno, args.len, prandom_u32());
|
||||
args.agbno, args.len, get_random_u32());
|
||||
|
||||
if (error)
|
||||
return error;
|
||||
|
|
|
@ -596,7 +596,7 @@ xfs_iget_cache_miss(
|
|||
*/
|
||||
if (xfs_has_v3inodes(mp) &&
|
||||
(flags & XFS_IGET_CREATE) && !xfs_has_ikeep(mp)) {
|
||||
VFS_I(ip)->i_generation = prandom_u32();
|
||||
VFS_I(ip)->i_generation = get_random_u32();
|
||||
} else {
|
||||
struct xfs_buf *bp;
|
||||
|
||||
|
|
|
@ -3544,7 +3544,7 @@ xlog_ticket_alloc(
|
|||
tic->t_curr_res = unit_res;
|
||||
tic->t_cnt = cnt;
|
||||
tic->t_ocnt = cnt;
|
||||
tic->t_tid = prandom_u32();
|
||||
tic->t_tid = get_random_u32();
|
||||
if (permanent)
|
||||
tic->t_flags |= XLOG_TIC_PERM_RESERV;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ void nf_queue_entry_free(struct nf_queue_entry *entry);
|
|||
static inline void init_hashrandom(u32 *jhash_initval)
|
||||
{
|
||||
while (*jhash_initval == 0)
|
||||
*jhash_initval = prandom_u32();
|
||||
*jhash_initval = get_random_u32();
|
||||
}
|
||||
|
||||
static inline u32 hash_v4(const struct iphdr *iph, u32 initval)
|
||||
|
|
|
@ -363,7 +363,7 @@ static inline unsigned long red_calc_qavg(const struct red_parms *p,
|
|||
|
||||
static inline u32 red_random(const struct red_parms *p)
|
||||
{
|
||||
return reciprocal_divide(prandom_u32(), p->max_P_reciprocal);
|
||||
return reciprocal_divide(get_random_u32(), p->max_P_reciprocal);
|
||||
}
|
||||
|
||||
static inline int red_mark_probability(const struct red_parms *p,
|
||||
|
|
|
@ -2109,7 +2109,7 @@ static inline kuid_t sock_net_uid(const struct net *net, const struct sock *sk)
|
|||
|
||||
static inline u32 net_tx_rndhash(void)
|
||||
{
|
||||
u32 v = prandom_u32();
|
||||
u32 v = get_random_u32();
|
||||
|
||||
return v ?: 1;
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ static struct bpf_map *bloom_map_alloc(union bpf_attr *attr)
|
|||
attr->value_size / sizeof(u32);
|
||||
|
||||
if (!(attr->map_flags & BPF_F_ZERO_SEED))
|
||||
bloom->hash_seed = get_random_int();
|
||||
bloom->hash_seed = get_random_u32();
|
||||
|
||||
return &bloom->map;
|
||||
}
|
||||
|
|
|
@ -1216,7 +1216,7 @@ static int bpf_jit_blind_insn(const struct bpf_insn *from,
|
|||
bool emit_zext)
|
||||
{
|
||||
struct bpf_insn *to = to_buff;
|
||||
u32 imm_rnd = get_random_int();
|
||||
u32 imm_rnd = get_random_u32();
|
||||
s16 off;
|
||||
|
||||
BUILD_BUG_ON(BPF_REG_AX + 1 != MAX_BPF_JIT_REG);
|
||||
|
|
|
@ -527,7 +527,7 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
|
|||
if (htab->map.map_flags & BPF_F_ZERO_SEED)
|
||||
htab->hashrnd = 0;
|
||||
else
|
||||
htab->hashrnd = get_random_int();
|
||||
htab->hashrnd = get_random_u32();
|
||||
|
||||
htab_init_buckets(htab);
|
||||
|
||||
|
|
|
@ -13350,7 +13350,7 @@ static int opt_subreg_zext_lo32_rnd_hi32(struct bpf_verifier_env *env,
|
|||
aux[adj_idx].ptr_type == PTR_TO_CTX)
|
||||
continue;
|
||||
|
||||
imm_rnd = get_random_int();
|
||||
imm_rnd = get_random_u32();
|
||||
rnd_hi32_patch[0] = insn;
|
||||
rnd_hi32_patch[1].imm = imm_rnd;
|
||||
rnd_hi32_patch[3].dst_reg = load_reg;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
static bool __init test_requires(void)
|
||||
{
|
||||
/* random should be initialized for the below tests */
|
||||
return prandom_u32() + prandom_u32() != 0;
|
||||
return get_random_u32() + get_random_u32() != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
* @state: pointer to state structure holding seeded state.
|
||||
*
|
||||
* This is used for pseudo-randomness with no outside seeding.
|
||||
* For more random results, use prandom_u32().
|
||||
* For more random results, use get_random_u32().
|
||||
*/
|
||||
u32 prandom_u32_state(struct rnd_state *state)
|
||||
{
|
||||
|
|
|
@ -164,7 +164,7 @@ static int get_rcw_we(struct rs_control *rs, struct wspace *ws,
|
|||
|
||||
/* Load c with random data and encode */
|
||||
for (i = 0; i < dlen; i++)
|
||||
c[i] = prandom_u32() & nn;
|
||||
c[i] = get_random_u32() & nn;
|
||||
|
||||
memset(c + dlen, 0, nroots * sizeof(*c));
|
||||
encode_rs16(rs, c, dlen, c + dlen, 0);
|
||||
|
@ -178,7 +178,7 @@ static int get_rcw_we(struct rs_control *rs, struct wspace *ws,
|
|||
for (i = 0; i < errs; i++) {
|
||||
do {
|
||||
/* Error value must be nonzero */
|
||||
errval = prandom_u32() & nn;
|
||||
errval = get_random_u32() & nn;
|
||||
} while (errval == 0);
|
||||
|
||||
do {
|
||||
|
@ -206,7 +206,7 @@ static int get_rcw_we(struct rs_control *rs, struct wspace *ws,
|
|||
/* Erasure with corrupted symbol */
|
||||
do {
|
||||
/* Error value must be nonzero */
|
||||
errval = prandom_u32() & nn;
|
||||
errval = get_random_u32() & nn;
|
||||
} while (errval == 0);
|
||||
|
||||
errlocs[errloc] = 1;
|
||||
|
|
|
@ -145,7 +145,7 @@ static unsigned long get_ftrace_location(void *func)
|
|||
static int fprobe_test_init(struct kunit *test)
|
||||
{
|
||||
do {
|
||||
rand1 = prandom_u32();
|
||||
rand1 = get_random_u32();
|
||||
} while (rand1 <= div_factor);
|
||||
|
||||
target = fprobe_selftest_target;
|
||||
|
|
|
@ -341,7 +341,7 @@ static int kprobes_test_init(struct kunit *test)
|
|||
stacktrace_driver = kprobe_stacktrace_driver;
|
||||
|
||||
do {
|
||||
rand1 = prandom_u32();
|
||||
rand1 = get_random_u32();
|
||||
} while (rand1 <= div_factor);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ static __init int test_heapify_all(bool min_heap)
|
|||
/* Test with randomly generated values. */
|
||||
heap.nr = ARRAY_SIZE(values);
|
||||
for (i = 0; i < heap.nr; i++)
|
||||
values[i] = get_random_int();
|
||||
values[i] = get_random_u32();
|
||||
|
||||
min_heapify_all(&heap, &funcs);
|
||||
err += pop_verify_heap(min_heap, &heap, &funcs);
|
||||
|
@ -116,7 +116,7 @@ static __init int test_heap_push(bool min_heap)
|
|||
|
||||
/* Test with randomly generated values. */
|
||||
while (heap.nr < heap.size) {
|
||||
temp = get_random_int();
|
||||
temp = get_random_u32();
|
||||
min_heap_push(&heap, &temp, &funcs);
|
||||
}
|
||||
err += pop_verify_heap(min_heap, &heap, &funcs);
|
||||
|
@ -158,7 +158,7 @@ static __init int test_heap_pop_push(bool min_heap)
|
|||
|
||||
/* Test with randomly generated values. */
|
||||
for (i = 0; i < ARRAY_SIZE(data); i++) {
|
||||
temp = get_random_int();
|
||||
temp = get_random_u32();
|
||||
min_heap_pop_push(&heap, &temp, &funcs);
|
||||
}
|
||||
err += pop_verify_heap(min_heap, &heap, &funcs);
|
||||
|
|
|
@ -291,7 +291,7 @@ static int __init test_rhltable(unsigned int entries)
|
|||
if (WARN_ON(err))
|
||||
goto out_free;
|
||||
|
||||
k = prandom_u32();
|
||||
k = get_random_u32();
|
||||
ret = 0;
|
||||
for (i = 0; i < entries; i++) {
|
||||
rhl_test_objects[i].value.id = k;
|
||||
|
@ -369,12 +369,12 @@ static int __init test_rhltable(unsigned int entries)
|
|||
pr_info("test %d random rhlist add/delete operations\n", entries);
|
||||
for (j = 0; j < entries; j++) {
|
||||
u32 i = prandom_u32_max(entries);
|
||||
u32 prand = prandom_u32();
|
||||
u32 prand = get_random_u32();
|
||||
|
||||
cond_resched();
|
||||
|
||||
if (prand == 0)
|
||||
prand = prandom_u32();
|
||||
prand = get_random_u32();
|
||||
|
||||
if (prand & 1) {
|
||||
prand >>= 1;
|
||||
|
|
|
@ -2332,7 +2332,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, struct inode *dir,
|
|||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode->i_blocks = 0;
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
|
||||
inode->i_generation = prandom_u32();
|
||||
inode->i_generation = get_random_u32();
|
||||
info = SHMEM_I(inode);
|
||||
memset(info, 0, (char *)inode - (char *)info);
|
||||
spin_lock_init(&info->lock);
|
||||
|
|
|
@ -2380,7 +2380,7 @@ static bool freelist_state_initialize(union freelist_init_state *state,
|
|||
unsigned int rand;
|
||||
|
||||
/* Use best entropy available to define a random shift */
|
||||
rand = get_random_int();
|
||||
rand = get_random_u32();
|
||||
|
||||
/* Use a random state if the pre-computed list is not available */
|
||||
if (!cachep->random_seq) {
|
||||
|
|
|
@ -2464,7 +2464,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
|
|||
for (i = 0; i < pkt_dev->nr_labels; i++)
|
||||
if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM)
|
||||
pkt_dev->labels[i] = MPLS_STACK_BOTTOM |
|
||||
((__force __be32)prandom_u32() &
|
||||
((__force __be32)get_random_u32() &
|
||||
htonl(0x000fffff));
|
||||
}
|
||||
|
||||
|
@ -2568,7 +2568,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
|
|||
|
||||
for (i = 0; i < 4; i++) {
|
||||
pkt_dev->cur_in6_daddr.s6_addr32[i] =
|
||||
(((__force __be32)prandom_u32() |
|
||||
(((__force __be32)get_random_u32() |
|
||||
pkt_dev->min_in6_daddr.s6_addr32[i]) &
|
||||
pkt_dev->max_in6_daddr.s6_addr32[i]);
|
||||
}
|
||||
|
|
|
@ -3664,7 +3664,7 @@ static __net_init int rt_genid_init(struct net *net)
|
|||
{
|
||||
atomic_set(&net->ipv4.rt_genid, 0);
|
||||
atomic_set(&net->fnhe_genid, 0);
|
||||
atomic_set(&net->ipv4.dev_addr_genid, get_random_int());
|
||||
atomic_set(&net->ipv4.dev_addr_genid, get_random_u32());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ static bool tcp_cdg_backoff(struct sock *sk, u32 grad)
|
|||
struct cdg *ca = inet_csk_ca(sk);
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
|
||||
if (prandom_u32() <= nexp_u32(grad * backoff_factor))
|
||||
if (get_random_u32() <= nexp_u32(grad * backoff_factor))
|
||||
return false;
|
||||
|
||||
if (use_ineff) {
|
||||
|
|
|
@ -246,7 +246,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
|
|||
inet_get_local_port_range(net, &low, &high);
|
||||
remaining = (high - low) + 1;
|
||||
|
||||
rand = prandom_u32();
|
||||
rand = get_random_u32();
|
||||
first = reciprocal_scale(rand, remaining) + low;
|
||||
/*
|
||||
* force rand to be an odd multiple of UDP_HTABLE_SIZE
|
||||
|
|
|
@ -220,7 +220,7 @@ static struct ip6_flowlabel *fl_intern(struct net *net,
|
|||
spin_lock_bh(&ip6_fl_lock);
|
||||
if (label == 0) {
|
||||
for (;;) {
|
||||
fl->label = htonl(prandom_u32())&IPV6_FLOWLABEL_MASK;
|
||||
fl->label = htonl(get_random_u32())&IPV6_FLOWLABEL_MASK;
|
||||
if (fl->label) {
|
||||
lfl = __fl_lookup(net, fl->label);
|
||||
if (!lfl)
|
||||
|
|
|
@ -18,7 +18,7 @@ static u32 __ipv6_select_ident(struct net *net,
|
|||
u32 id;
|
||||
|
||||
do {
|
||||
id = prandom_u32();
|
||||
id = get_random_u32();
|
||||
} while (!id);
|
||||
|
||||
return id;
|
||||
|
|
|
@ -1308,7 +1308,7 @@ void ip_vs_random_dropentry(struct netns_ipvs *ipvs)
|
|||
* Randomly scan 1/32 of the whole table every second
|
||||
*/
|
||||
for (idx = 0; idx < (ip_vs_conn_tab_size>>5); idx++) {
|
||||
unsigned int hash = prandom_u32() & ip_vs_conn_tab_mask;
|
||||
unsigned int hash = get_random_u32() & ip_vs_conn_tab_mask;
|
||||
|
||||
hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) {
|
||||
if (cp->ipvs != ipvs)
|
||||
|
|
|
@ -34,7 +34,7 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
|
|||
|
||||
switch (info->mode) {
|
||||
case XT_STATISTIC_MODE_RANDOM:
|
||||
if ((prandom_u32() & 0x7FFFFFFF) < info->u.random.probability)
|
||||
if ((get_random_u32() & 0x7FFFFFFF) < info->u.random.probability)
|
||||
ret = !ret;
|
||||
break;
|
||||
case XT_STATISTIC_MODE_NTH:
|
||||
|
|
|
@ -1033,7 +1033,7 @@ static int sample(struct datapath *dp, struct sk_buff *skb,
|
|||
actions = nla_next(sample_arg, &rem);
|
||||
|
||||
if ((arg->probability != U32_MAX) &&
|
||||
(!arg->probability || prandom_u32() > arg->probability)) {
|
||||
(!arg->probability || get_random_u32() > arg->probability)) {
|
||||
if (last)
|
||||
consume_skb(skb);
|
||||
return 0;
|
||||
|
|
|
@ -573,7 +573,7 @@ static bool cobalt_should_drop(struct cobalt_vars *vars,
|
|||
|
||||
/* Simple BLUE implementation. Lack of ECN is deliberate. */
|
||||
if (vars->p_drop)
|
||||
drop |= (prandom_u32() < vars->p_drop);
|
||||
drop |= (get_random_u32() < vars->p_drop);
|
||||
|
||||
/* Overload the drop_next field as an activity timeout */
|
||||
if (!vars->count)
|
||||
|
|
|
@ -171,7 +171,7 @@ static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb)
|
|||
static void init_crandom(struct crndstate *state, unsigned long rho)
|
||||
{
|
||||
state->rho = rho;
|
||||
state->last = prandom_u32();
|
||||
state->last = get_random_u32();
|
||||
}
|
||||
|
||||
/* get_crandom - correlated random number generator
|
||||
|
@ -184,9 +184,9 @@ static u32 get_crandom(struct crndstate *state)
|
|||
unsigned long answer;
|
||||
|
||||
if (!state || state->rho == 0) /* no correlation */
|
||||
return prandom_u32();
|
||||
return get_random_u32();
|
||||
|
||||
value = prandom_u32();
|
||||
value = get_random_u32();
|
||||
rho = (u64)state->rho + 1;
|
||||
answer = (value * ((1ull<<32) - rho) + state->last * rho) >> 32;
|
||||
state->last = answer;
|
||||
|
@ -200,7 +200,7 @@ static u32 get_crandom(struct crndstate *state)
|
|||
static bool loss_4state(struct netem_sched_data *q)
|
||||
{
|
||||
struct clgstate *clg = &q->clg;
|
||||
u32 rnd = prandom_u32();
|
||||
u32 rnd = get_random_u32();
|
||||
|
||||
/*
|
||||
* Makes a comparison between rnd and the transition
|
||||
|
@ -268,15 +268,15 @@ static bool loss_gilb_ell(struct netem_sched_data *q)
|
|||
|
||||
switch (clg->state) {
|
||||
case GOOD_STATE:
|
||||
if (prandom_u32() < clg->a1)
|
||||
if (get_random_u32() < clg->a1)
|
||||
clg->state = BAD_STATE;
|
||||
if (prandom_u32() < clg->a4)
|
||||
if (get_random_u32() < clg->a4)
|
||||
return true;
|
||||
break;
|
||||
case BAD_STATE:
|
||||
if (prandom_u32() < clg->a2)
|
||||
if (get_random_u32() < clg->a2)
|
||||
clg->state = GOOD_STATE;
|
||||
if (prandom_u32() > clg->a3)
|
||||
if (get_random_u32() > clg->a3)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -632,7 +632,7 @@ static void get_slot_next(struct netem_sched_data *q, u64 now)
|
|||
|
||||
if (!q->slot_dist)
|
||||
next_delay = q->slot_config.min_delay +
|
||||
(prandom_u32() *
|
||||
(get_random_u32() *
|
||||
(q->slot_config.max_delay -
|
||||
q->slot_config.min_delay) >> 32);
|
||||
else
|
||||
|
|
|
@ -130,8 +130,8 @@ gss_krb5_make_confounder(char *p, u32 conflen)
|
|||
|
||||
/* initialize to random value */
|
||||
if (i == 0) {
|
||||
i = prandom_u32();
|
||||
i = (i << 32) | prandom_u32();
|
||||
i = get_random_u32();
|
||||
i = (i << 32) | get_random_u32();
|
||||
}
|
||||
|
||||
switch (conflen) {
|
||||
|
|
|
@ -1868,7 +1868,7 @@ xprt_alloc_xid(struct rpc_xprt *xprt)
|
|||
static void
|
||||
xprt_init_xid(struct rpc_xprt *xprt)
|
||||
{
|
||||
xprt->xid = prandom_u32();
|
||||
xprt->xid = get_random_u32();
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1147,7 +1147,7 @@ static int unix_autobind(struct sock *sk)
|
|||
addr->name->sun_family = AF_UNIX;
|
||||
refcount_set(&addr->refcnt, 1);
|
||||
|
||||
ordernum = prandom_u32();
|
||||
ordernum = get_random_u32();
|
||||
lastnum = ordernum & 0xFFFFF;
|
||||
retry:
|
||||
ordernum = (ordernum + 1) & 0xFFFFF;
|
||||
|
|
Loading…
Reference in New Issue