title: How to use get_random_bytes() in linux kernel module?
body: <p>I have made simple kernel module.</p>
  <pre><code>void cb_funct(unsigned long arg)    // callback function.
  {
      int rand;
      get_random_bytes(&amp;rand, sizeof(rand));
      rand%=250;
  
      seq_printf(m, &quot;random number : %d\n&quot;, rand);
      ...
  }
  </code></pre>
  <p>I printed out rand variable using seq_printf function.</p>
  <p>cb_funct function is called five times.</p>
  <p>Below is the result.</p>
  <blockquote>
  <p>random number : 66</p>
  <p>random number : -5</p>
  <p>random number : 135</p>
  <p>random number : 178</p>
  <p>random number : -42</p>
  </blockquote>
  <p>Why negative variable is printed out?</p>
  <p>How to use <strong>get_random_bytes</strong> function in linux?</p>