linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: George Spelvin <lkml@sdf.org>
To: linux-kernel@vger.kernel.org, lkml@sdf.org
Cc: Lars Ellenberg <lars.ellenberg@linbit.com>,
	Philipp Reisner <philipp.reisner@linbit.com>,
	drbd-dev@tron.linbit.com
Subject: [RFC PATCH v1 41/50] drivers/block/drbd/drbd_nl.c: Use get_random_u64()
Date: Wed, 21 Aug 2019 21:30:45 -0400	[thread overview]
Message-ID: <202003281643.02SGhNSB019516@sdf.org> (raw)

There's no need to get_random_bytes() into a temporary buffer.

This is not a no-brainer change; get_random_u64() has slightly
weaker security guarantees, but they're fine for applications
like these where the random value is stored in the kernel for
as long as it's valuable.

Signed-off-by: George Spelvin <lkml@sdf.org>
Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
Cc: Philipp Reisner <philipp.reisner@linbit.com>
Cc: drbd-dev@lists.linbit.com
---
 drivers/block/drbd/drbd_nl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index de2f94d0103a6..ca8c706d47f3a 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -3223,9 +3223,7 @@ int drbd_adm_resume_io(struct sk_buff *skb, struct genl_info *info)
 			 * the refuse to re-connect or re-attach (because no
 			 * matching real data uuid exists).
 			 */
-			u64 val;
-			get_random_bytes(&val, sizeof(u64));
-			drbd_set_ed_uuid(device, val);
+			drbd_set_ed_uuid(device, get_random_u64());
 			drbd_warn(device, "Resumed without access to data; please tear down before attempting to re-configure.\n");
 		}
 		clear_bit(NEW_CUR_UUID, &device->flags);
-- 
2.26.0


                 reply	other threads:[~2020-03-28 16:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202003281643.02SGhNSB019516@sdf.org \
    --to=lkml@sdf.org \
    --cc=drbd-dev@tron.linbit.com \
    --cc=lars.ellenberg@linbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=philipp.reisner@linbit.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).