linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Linux-Next Mailing List <linux-next@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Rik van Riel <riel@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>
Subject: linux-next: manual merge of the random tree with Linus' tree
Date: Fri, 14 Jul 2017 11:57:25 +1000	[thread overview]
Message-ID: <20170714115725.3de3a75a@canb.auug.org.au> (raw)

Hi all,

[I think I have reported this before ...]

Today's linux-next merge of the random tree got a conflict in:

  include/linux/random.h

between commit:

  022c204040f3 ("random,stackprotect: introduce get_random_canary function")

from Linus' tree and commit:

  da9ba564bd68 ("random: add get_random_{bytes,u32,u64,int,long,once}_wait family")

from the random tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc include/linux/random.h
index 1fa0dc880bd7,4aecc339558d..000000000000
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@@ -57,27 -58,31 +58,52 @@@ static inline unsigned long get_random_
  #endif
  }
  
 +/*
 + * On 64-bit architectures, protect against non-terminated C string overflows
 + * by zeroing out the first byte of the canary; this leaves 56 bits of entropy.
 + */
 +#ifdef CONFIG_64BIT
 +# ifdef __LITTLE_ENDIAN
 +#  define CANARY_MASK 0xffffffffffffff00UL
 +# else /* big endian, 64 bits: */
 +#  define CANARY_MASK 0x00ffffffffffffffUL
 +# endif
 +#else /* 32 bits: */
 +# define CANARY_MASK 0xffffffffUL
 +#endif
 +
 +static inline unsigned long get_random_canary(void)
 +{
 +	unsigned long val = get_random_long();
 +
 +	return val & CANARY_MASK;
 +}
 +
+ /* Calls wait_for_random_bytes() and then calls get_random_bytes(buf, nbytes).
+  * Returns the result of the call to wait_for_random_bytes. */
+ static inline int get_random_bytes_wait(void *buf, int nbytes)
+ {
+ 	int ret = wait_for_random_bytes();
+ 	if (unlikely(ret))
+ 		return ret;
+ 	get_random_bytes(buf, nbytes);
+ 	return 0;
+ }
+ 
+ #define declare_get_random_var_wait(var) \
+ 	static inline int get_random_ ## var ## _wait(var *out) { \
+ 		int ret = wait_for_random_bytes(); \
+ 		if (unlikely(ret)) \
+ 			return ret; \
+ 		*out = get_random_ ## var(); \
+ 		return 0; \
+ 	}
+ declare_get_random_var_wait(u32)
+ declare_get_random_var_wait(u64)
+ declare_get_random_var_wait(int)
+ declare_get_random_var_wait(long)
+ #undef declare_get_random_var
+ 
  unsigned long randomize_page(unsigned long start, unsigned long range);
  
  u32 prandom_u32(void);

             reply	other threads:[~2017-07-14  1:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-14  1:57 Stephen Rothwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-10-07  4:54 linux-next: manual merge of the random tree with Linus' tree Stephen Rothwell
2014-03-19  5:56 Stephen Rothwell
2013-11-04  6:04 Stephen Rothwell
2013-11-04 12:39 ` Greg Kroah-Hartman
2013-09-23  4:04 Stephen Rothwell

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=20170714115725.3de3a75a@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=Jason@zx2c4.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=riel@redhat.com \
    --cc=tytso@mit.edu \
    /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).