All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>, linux-kernel@vger.kernel.org
Cc: brcm80211-dev-list.pdl@broadcom.com, cake@lists.bufferbloat.net,
	ceph-devel@vger.kernel.org, coreteam@netfilter.org,
	dccp@vger.kernel.org, dev@openvswitch.org,
	dmaengine@vger.kernel.org, drbd-dev@lists.linbit.com,
	dri-devel@lists.freedesktop.org, kasan-dev@googlegroups.com,
	linux-actions@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-block@vger.kernel.org, linux-crypto@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-fbdev@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-hams@vger.kernel.org, linux-media@vger.kernel.org,
	linux-mm@kvack.org, linux-mmc@vger.kernel.org,
	linux-mtd@lists.infradead.org, linux-nfs@vger.kernel.org,
	linux-nvme@lists.infradead.org, linux-raid@vger.kernel.org
Subject: Re: [PATCH v1 3/5] treewide: use get_random_u32() when possible
Date: Wed, 12 Oct 2022 12:16:53 -0700	[thread overview]
Message-ID: <f8ad3ba44d28dec1a5f7626b82c5e9c2aeefa729.camel__21203.3817240567$1665602803$gmane$org@perches.com> (raw)
In-Reply-To: <20221005214844.2699-4-Jason@zx2c4.com>

On Wed, 2022-10-05 at 23:48 +0200, Jason A. Donenfeld wrote:
> 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.
[]
> diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
[]
> @@ -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;

trivia:

There are somewhat odd size mismatches here.

I had to think a tiny bit if random() returned a value from 0 to 7
and was promoted to a 64 bit value then truncated to 32 bit.

Perhaps these would be clearer as ~7U and not ~7UL

>  	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;

etc...

drivers/infiniband/hw/cxgb4/cm.c:	u32 isn = (prandom_u32() & ~7UL) - 1;
drivers/infiniband/hw/cxgb4/cm.c:		u32 isn = (prandom_u32() & ~7UL) - 1;
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c:	rpl5->iss = cpu_to_be32((prandom_u32() & ~7UL) - 1);
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c:		u32 isn = (prandom_u32() & ~7UL) - 1;
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c:		u32 isn = (prandom_u32() & ~7UL) - 1;
drivers/target/iscsi/cxgbit/cxgbit_cm.c:	rpl5->iss = cpu_to_be32((prandom_u32() & ~7UL) - 1);


  parent reply	other threads:[~2022-10-12 19:16 UTC|newest]

Thread overview: 207+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 21:48 [f2fs-dev] [PATCH v1 0/5] treewide cleanup of random integer usage Jason A. Donenfeld via Linux-f2fs-devel
2022-10-05 21:48 ` Jason A. Donenfeld via dev
2022-10-05 21:48 ` Jason A. Donenfeld
2022-10-05 21:48 ` Jason A. Donenfeld
2022-10-05 21:48 ` Jason A. Donenfeld
2022-10-05 21:48 ` Jason A. Donenfeld
2022-10-05 21:48 ` Jason A. Donenfeld
2022-10-05 21:48 ` [f2fs-dev] [PATCH v1 1/5] treewide: use prandom_u32_max() when possible Jason A. Donenfeld via Linux-f2fs-devel
2022-10-05 21:48   ` Jason A. Donenfeld via Linux-f2fs-devel
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-06  4:16   ` Kees Cook
2022-10-06  4:16     ` Kees Cook
2022-10-06  4:16     ` Kees Cook
2022-10-06  4:16     ` Kees Cook
2022-10-06  4:16     ` Kees Cook
2022-10-06  4:16     ` [f2fs-dev] " Kees Cook
2022-10-06  4:22     ` KP Singh
2022-10-06  4:22       ` KP Singh
2022-10-06  4:22       ` KP Singh
2022-10-06  4:22       ` KP Singh
2022-10-06  4:22       ` KP Singh
2022-10-06  4:22       ` KP Singh
2022-10-06 12:45     ` [f2fs-dev] " Jason A. Donenfeld via Linux-f2fs-devel
2022-10-06 12:45       ` Jason A. Donenfeld via dev
2022-10-06 12:45       ` Jason A. Donenfeld
2022-10-06 12:45       ` Jason A. Donenfeld
2022-10-06 12:45       ` Jason A. Donenfeld
2022-10-06 12:45       ` Jason A. Donenfeld
2022-10-06 12:55       ` Jason Gunthorpe
2022-10-06 12:55         ` Jason Gunthorpe
2022-10-06 12:55         ` Jason Gunthorpe
2022-10-06 12:55         ` Jason Gunthorpe
2022-10-06 12:55         ` Jason Gunthorpe
2022-10-06 12:55         ` [f2fs-dev] " Jason Gunthorpe
2022-10-06 13:05         ` Andy Shevchenko
2022-10-06 13:05           ` Andy Shevchenko
2022-10-06 13:05           ` Andy Shevchenko
2022-10-06 13:05           ` Andy Shevchenko
2022-10-06 13:05           ` Andy Shevchenko
2022-10-06 13:05           ` Andy Shevchenko
2022-10-06  9:07   ` Christoph Böhmwalder
2022-10-05 21:48 ` [f2fs-dev] [PATCH v1 2/5] treewide: use get_random_{u8, u16}() " Jason A. Donenfeld via Linux-f2fs-devel
2022-10-05 21:48   ` Jason A. Donenfeld via dev
2022-10-05 21:48   ` [PATCH v1 2/5] treewide: use get_random_{u8,u16}() " Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-06  4:38   ` Kees Cook
2022-10-06  4:38     ` [PATCH v1 2/5] treewide: use get_random_{u8, u16}() " Kees Cook
2022-10-06  4:38     ` [PATCH v1 2/5] treewide: use get_random_{u8,u16}() " Kees Cook
2022-10-06  4:38     ` Kees Cook
2022-10-06  4:38     ` Kees Cook
2022-10-06  4:38     ` [f2fs-dev] [PATCH v1 2/5] treewide: use get_random_{u8, u16}() " Kees Cook
2022-10-06 12:28     ` Jason A. Donenfeld via Linux-f2fs-devel
2022-10-06 12:28       ` Jason A. Donenfeld via dev
2022-10-06 12:28       ` [PATCH v1 2/5] treewide: use get_random_{u8,u16}() " Jason A. Donenfeld
2022-10-06 12:28       ` Jason A. Donenfeld
2022-10-06 12:28       ` Jason A. Donenfeld
2022-10-06 12:28       ` Jason A. Donenfeld
2022-10-06 13:37   ` Toke Høiland-Jørgensen
2022-10-05 21:48 ` [f2fs-dev] [PATCH v1 3/5] treewide: use get_random_u32() " Jason A. Donenfeld via Linux-f2fs-devel
2022-10-05 21:48   ` Jason A. Donenfeld via Linux-f2fs-devel
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-06  8:43   ` [f2fs-dev] " Jan Kara
2022-10-06  8:43     ` Jan Kara
2022-10-06  8:43     ` Jan Kara
2022-10-06  8:43     ` Jan Kara
2022-10-06  8:43     ` Jan Kara
2022-10-06  8:43     ` Jan Kara
2022-10-06 12:33     ` [f2fs-dev] " Jason A. Donenfeld via Linux-f2fs-devel
2022-10-06 12:33       ` Jason A. Donenfeld via dev
2022-10-06 12:33       ` Jason A. Donenfeld
2022-10-06 12:33       ` Jason A. Donenfeld
2022-10-06 12:33       ` Jason A. Donenfeld
2022-10-06 12:33       ` Jason A. Donenfeld
2022-10-06 12:56       ` Andy Shevchenko
2022-10-06 13:01         ` Andy Shevchenko
2022-10-06 13:01         ` Andy Shevchenko
2022-10-06 13:01         ` Andy Shevchenko
2022-10-06 13:01         ` Andy Shevchenko
2022-10-06 13:01         ` Andy Shevchenko
2022-10-06 13:01         ` Andy Shevchenko
2022-10-06 13:07         ` Jason A. Donenfeld
2022-10-06 13:07           ` Jason A. Donenfeld via Linux-f2fs-devel
2022-10-06 13:07           ` [f2fs-dev] " Jason A. Donenfeld
2022-10-06 13:07           ` Jason A. Donenfeld
2022-10-06 13:07           ` Jason A. Donenfeld
2022-10-06 13:07           ` Jason A. Donenfeld
2022-10-06 13:07           ` Jason A. Donenfeld via Linux-f2fs-devel
2022-10-06 12:47   ` Jason Gunthorpe
2022-10-06 12:47     ` Jason Gunthorpe
2022-10-06 12:47     ` Jason Gunthorpe
2022-10-06 12:47     ` Jason Gunthorpe
2022-10-06 12:47     ` Jason Gunthorpe
2022-10-06 12:47     ` [f2fs-dev] " Jason Gunthorpe
2022-10-06 13:05     ` Jason A. Donenfeld via Linux-f2fs-devel
2022-10-06 13:05       ` Jason A. Donenfeld via dev
2022-10-06 13:05       ` Jason A. Donenfeld
2022-10-06 13:05       ` Jason A. Donenfeld
2022-10-06 13:05       ` Jason A. Donenfeld
2022-10-06 13:05       ` Jason A. Donenfeld
2022-10-06 13:15       ` Jason Gunthorpe
2022-10-06 13:15         ` Jason Gunthorpe
2022-10-06 13:15         ` Jason Gunthorpe
2022-10-06 13:15         ` Jason Gunthorpe
2022-10-06 13:15         ` Jason Gunthorpe
2022-10-06 13:15         ` Jason Gunthorpe
2022-10-06 13:15         ` [f2fs-dev] " Jason Gunthorpe
2022-10-06 13:20       ` Andy Shevchenko
2022-10-06 13:20         ` Andy Shevchenko
2022-10-06 13:20         ` Andy Shevchenko
2022-10-06 13:20         ` Andy Shevchenko
2022-10-06 13:20         ` Andy Shevchenko
2022-10-06 13:20         ` Andy Shevchenko
2022-10-06 13:20         ` Andy Shevchenko
2022-10-06 13:20         ` [f2fs-dev] " Andy Shevchenko
2022-10-06 13:38   ` Toke Høiland-Jørgensen
     [not found]   ` <20221005214844.2699-4-Jason-OnJsPKxuuEcAvxtiuMwx3w@public.gmane.org>
2022-10-12 19:16     ` Joe Perches
2022-10-12 19:16   ` Joe Perches [this message]
2022-10-12 19:16   ` Joe Perches
2022-10-12 19:16     ` Joe Perches
2022-10-12 19:16     ` Joe Perches
2022-10-12 19:16     ` [f2fs-dev] " Joe Perches
2022-10-12 19:16     ` Joe Perches
2022-10-12 19:16     ` Joe Perches
2022-10-12 19:16     ` Joe Perches
2022-10-12 21:29     ` David Laight
2022-10-12 21:29       ` David Laight
2022-10-12 21:29       ` David Laight
2022-10-12 21:29       ` David Laight
2022-10-12 21:29       ` [f2fs-dev] " David Laight
2022-10-12 21:29       ` David Laight
2022-10-12 21:29       ` David Laight
2022-10-12 21:29       ` David Laight
2022-10-13  1:37       ` Joe Perches
2022-10-13  1:37         ` Joe Perches
2022-10-13  1:37         ` Joe Perches
2022-10-13  1:37         ` Joe Perches
2022-10-13  1:37         ` Joe Perches
2022-10-13  1:37         ` Joe Perches
2022-10-13  1:37         ` Joe Perches
2022-10-13  1:37         ` [f2fs-dev] " Joe Perches
2022-10-05 21:48 ` [f2fs-dev] [PATCH v1 4/5] treewide: use get_random_bytes " Jason A. Donenfeld via Linux-f2fs-devel
2022-10-05 21:48   ` Jason A. Donenfeld via Linux-f2fs-devel
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-06  4:45   ` [f2fs-dev] " Kees Cook
2022-10-06  4:45     ` Kees Cook
2022-10-06  4:45     ` Kees Cook
2022-10-06  4:45     ` Kees Cook
2022-10-06  4:45     ` Kees Cook
2022-10-06  4:45     ` Kees Cook
2022-10-06  4:48   ` Kees Cook
2022-10-06  4:48     ` Kees Cook
2022-10-06  4:48     ` Kees Cook
2022-10-06  4:48     ` Kees Cook
2022-10-06  4:48     ` Kees Cook
2022-10-06  4:48     ` [f2fs-dev] " Kees Cook
2022-10-05 21:48 ` [f2fs-dev] [PATCH v1 5/5] prandom: remove unused functions Jason A. Donenfeld via Linux-f2fs-devel
2022-10-05 21:48   ` Jason A. Donenfeld via dev
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-05 21:48   ` Jason A. Donenfeld
2022-10-06  4:39   ` [f2fs-dev] " Kees Cook
2022-10-06  4:39     ` Kees Cook
2022-10-06  4:39     ` Kees Cook
2022-10-06  4:39     ` Kees Cook
2022-10-06  4:39     ` Kees Cook
2022-10-06  4:39     ` Kees Cook
2022-10-06  4:55 ` [PATCH v1 0/5] treewide cleanup of random integer usage Kees Cook
2022-10-06  4:55   ` Kees Cook
2022-10-06  4:55   ` Kees Cook
2022-10-06  4:55   ` Kees Cook
2022-10-06  4:55   ` Kees Cook
2022-10-06  4:55   ` [f2fs-dev] " Kees Cook
2022-10-06  5:40   ` Kees Cook
2022-10-06  5:40     ` Kees Cook
2022-10-06  5:40     ` Kees Cook
2022-10-06  5:40     ` Kees Cook
2022-10-06  5:40     ` Kees Cook
2022-10-06  5:40     ` Kees Cook
2022-10-06 12:53   ` [f2fs-dev] " Jason A. Donenfeld via Linux-f2fs-devel
2022-10-06 12:53     ` Jason A. Donenfeld via dev
2022-10-06 12:53     ` Jason A. Donenfeld
2022-10-06 12:53     ` Jason A. Donenfeld
2022-10-06 12:53     ` Jason A. Donenfeld
2022-10-06 12:53     ` Jason A. Donenfeld
2022-10-06  6:15 ` Kees Cook
2022-10-06 12:58   ` Jason A. Donenfeld
2022-10-06  8:17 ` Yann Droneaud
2022-10-06 13:49 ` [f2fs-dev] " Jason A. Donenfeld via Linux-f2fs-devel
2022-10-06 13:49   ` Jason A. Donenfeld
2022-10-06 13:49   ` Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='f8ad3ba44d28dec1a5f7626b82c5e9c2aeefa729.camel__21203.3817240567$1665602803$gmane$org@perches.com' \
    --to=joe@perches.com \
    --cc=Jason@zx2c4.com \
    --cc=brcm80211-dev-list.pdl@broadcom.com \
    --cc=cake@lists.bufferbloat.net \
    --cc=ceph-devel@vger.kernel.org \
    --cc=coreteam@netfilter.org \
    --cc=dccp@vger.kernel.org \
    --cc=dev@openvswitch.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=drbd-dev@lists.linbit.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-actions@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-hams@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-raid@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.