treewide: use get_random_u32() when possible
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 5 Oct 2022 15:43:22 +0000 (17:43 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 11 Oct 2022 23:42:58 +0000 (17:42 -0600)
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>
71 files changed:
Documentation/networking/filter.rst
arch/parisc/kernel/process.c
arch/parisc/kernel/sys_parisc.c
arch/s390/mm/mmap.c
arch/x86/kernel/cpu/amd.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/selftests/i915_selftest.c
drivers/gpu/drm/tests/drm_buddy_test.c
drivers/gpu/drm/tests/drm_mm_test.c
drivers/infiniband/hw/cxgb4/cm.c
drivers/infiniband/hw/hfi1/tid_rdma.c
drivers/infiniband/hw/mlx4/mad.c
drivers/infiniband/ulp/ipoib/ipoib_cm.c
drivers/md/raid5-cache.c
drivers/media/test-drivers/vivid/vivid-touch-cap.c
drivers/misc/habanalabs/gaudi2/gaudi2.c
drivers/net/bonding/bond_main.c
drivers/net/ethernet/broadcom/cnic.c
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
drivers/net/ethernet/rocker/rocker_main.c
drivers/net/wireless/marvell/mwifiex/cfg80211.c
drivers/net/wireless/microchip/wilc1000/cfg80211.c
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
drivers/net/wireless/ti/wlcore/main.c
drivers/nvme/common/auth.c
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
drivers/target/iscsi/cxgbit/cxgbit_cm.c
drivers/thunderbolt/xdomain.c
drivers/video/fbdev/uvesafb.c
fs/exfat/inode.c
fs/ext4/ialloc.c
fs/ext4/ioctl.c
fs/ext4/mmp.c
fs/f2fs/namei.c
fs/fat/inode.c
fs/nfsd/nfs4state.c
fs/ntfs3/fslog.c
fs/ubifs/journal.c
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/xfs_icache.c
fs/xfs/xfs_log.c
include/net/netfilter/nf_queue.h
include/net/red.h
include/net/sock.h
kernel/bpf/bloom_filter.c
kernel/bpf/core.c
kernel/bpf/hashtab.c
kernel/bpf/verifier.c
kernel/kcsan/selftest.c
lib/random32.c
lib/reed_solomon/test_rslib.c
lib/test_fprobe.c
lib/test_kprobes.c
lib/test_min_heap.c
lib/test_rhashtable.c
mm/shmem.c
mm/slab.c
net/core/pktgen.c
net/ipv4/route.c
net/ipv4/tcp_cdg.c
net/ipv4/udp.c
net/ipv6/ip6_flowlabel.c
net/ipv6/output_core.c
net/netfilter/ipvs/ip_vs_conn.c
net/netfilter/xt_statistic.c
net/openvswitch/actions.c
net/sched/sch_cake.c
net/sched/sch_netem.c
net/sunrpc/auth_gss/gss_krb5_wrap.c
net/sunrpc/xprt.c
net/unix/af_unix.c

index 43cdc4d..f69da50 100644 (file)
@@ -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 '#'.
index 7c37e09..18c4f0e 100644 (file)
@@ -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)
index 2b34294..848b070 100644 (file)
@@ -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)
index 5980ce3..3327c47 100644 (file)
@@ -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)
index 48276c0..860b602 100644 (file)
@@ -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))
index 329ff75..7bd1861 100644 (file)
@@ -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);
index c4e9323..39da0fb 100644 (file)
@@ -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 ?
index 7a2b2d6..62f6958 100644 (file)
@@ -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;
 }
index 659d1af..c4b66ee 100644 (file)
@@ -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;
 }
index 14392c9..499a425 100644 (file)
@@ -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));
index 2a7abf7..18b05ff 100644 (file)
@@ -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);
        }
 }
index d13ecbd..a37cfac 100644 (file)
@@ -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)
index ebb35b8..b610d36 100644 (file)
@@ -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;
index 79c7333..832d856 100644 (file)
@@ -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);
                /*
index 792660a..6cc32eb 100644 (file)
@@ -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) {
index 75c4bef..65e6cae 100644 (file)
@@ -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;
 }
index 24bb50d..e84c49b 100644 (file)
@@ -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);
index f597b31..2198e35 100644 (file)
@@ -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;
 }
index eda129d..c2e7037 100644 (file)
@@ -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);
index 023682c..5672d95 100644 (file)
@@ -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) {
index 535995e..bcd564d 100644 (file)
@@ -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;
 
index b890479..9bbfff8 100644 (file)
@@ -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;
 
index bfdf03b..73e6f94 100644 (file)
@@ -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;
 
index 3e3922d..28c0f06 100644 (file)
@@ -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 */
index 04bd28f..d90e4f0 100644 (file)
@@ -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)
index 53d91bf..c07d2e3 100644 (file)
@@ -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,
index 3336d2b..d9204c5 100644 (file)
@@ -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;
 
index bbb248a..f00b2f6 100644 (file)
@@ -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;
 }
 
index fd5d701..00d789b 100644 (file)
@@ -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));
index a795437..5590a1e 100644 (file)
@@ -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;
index 7575aa3..e9bc466 100644 (file)
@@ -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)) {
index 4d49c5c..ded5355 100644 (file)
@@ -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);
 
index 9af68a7..588cb09 100644 (file)
@@ -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;
index d5065a5..a389772 100644 (file)
@@ -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;
index a38238d..1cbcc46 100644 (file)
@@ -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;
index 198d7ab..4e71850 100644 (file)
@@ -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++;
 
index e7c4940..0d611a6 100644 (file)
@@ -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);
index 75dab0a..4619652 100644 (file)
@@ -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;
 }
index 7838b31..94db50e 100644 (file)
@@ -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;
index 2bbe791..eae7427 100644 (file)
@@ -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;
 
index f6e7e4f..f02a0dd 100644 (file)
@@ -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;
 
index 980daa6..c81021a 100644 (file)
@@ -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)
index 454ac2b..425364d 100644 (file)
@@ -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,
index 08038a3..9e464f6 100644 (file)
@@ -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;
 }
index b9ea539..48ee750 100644 (file)
@@ -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;
 }
index 53c6c98..25a54e0 100644 (file)
@@ -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);
index ed3f8a5..f39ee3e 100644 (file)
@@ -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);
 
index 6f6d2d5..014ee09 100644 (file)
@@ -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;
index 7571295..58b94de 100644 (file)
@@ -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;
 }
 
 /*
index d5d9029..d4f19e1 100644 (file)
@@ -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)
 {
index 4d241bd..848e7eb 100644 (file)
@@ -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;
index ed70637..e0381b3 100644 (file)
@@ -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;
index a5edc2e..eeb1d72 100644 (file)
@@ -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;
 }
index d19c808..7b01b43 100644 (file)
@@ -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);
index 5a1dd47..b358a74 100644 (file)
@@ -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;
index 86214d4..8280a5c 100644 (file)
@@ -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);
index a5486ff..60cd19b 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -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) {
index 5ca4f95..c376305 100644 (file)
@@ -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]);
                        }
index 795cbe1..1a37a07 100644 (file)
@@ -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;
 }
 
index ddc7ba0..efcd145 100644 (file)
@@ -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) {
index d63118c..9f26882 100644 (file)
@@ -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
index ceb85c6..18481eb 100644 (file)
@@ -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)
index 2880dc7..2685c3f 100644 (file)
@@ -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;
index fb67f1c..8c04bb5 100644 (file)
@@ -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)
index 203e24a..b26c1dc 100644 (file)
@@ -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:
index 868db46..ca3ebfd 100644 (file)
@@ -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;
index 7193d25..817cd06 100644 (file)
@@ -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)
index bab45b3..fb00ac4 100644 (file)
@@ -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
index 5f96e75..4833768 100644 (file)
@@ -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) {
index f8fae78..9407007 100644 (file)
@@ -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
index 15dbb39..b3545fc 100644 (file)
@@ -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;