Linux-Security-Module Archive on lore.kernel.org
 help / color / Atom feed
* kernel panic while using get_random_bytes
@ 2019-10-14  8:21 Temp Sha
  2019-11-04  9:35 ` Temp Sha
  2019-11-05  9:12 ` Ondrej Mosnacek
  0 siblings, 2 replies; 3+ messages in thread
From: Temp Sha @ 2019-10-14  8:21 UTC (permalink / raw)
  To: linux-security-module

hi,

i use get_random_bytes() function for my randomness requirement in
kernel version 4.14.142
however is gives panic as soon as I call   get_random_bytes() in my module.


Oct 10 07:20:18 BUG: unable to handle kernel paging request at 00007f5563ced000
IP: chacha20_block+0x24d/0x280
PGD 800000010f7f8067 P4D 800000010f7f8067 PUD 161316067 PMD 1015a8067 PTE 0
Oops: 0002 [#1] PREEMPT SMP PTI
Modules linked in: ipi_hsl(PO) mymod(PO) e1000 ipv6 ftdi_sio usbserial
xt_tcpudp xt_mark iptable_nat nf_nat_ipv4 nf_conntrack_ipv4
nf_defrag_ipv4 nf_nat xt_connlimit nf_conntrack iptable_filter
ip_tables x_tables
CPU: 0 PID: 1841 Comm: hexdump Tainted: P           O    4.14.142-ws-symbol #1
Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
task: ffff8881611da000 task.stack: ffffc900504c4000
RIP: 0010:chacha20_block+0x24d/0x280
RSP: 0018:ffffc900504c7c70 EFLAGS: 00010886
RAX: 0000000000000000 RBX: 00000000a88c95b0 RCX: 00007f5563ced000
RDX: ffff88810f79da00 RSI: 0000000015c4332e RDI: 000000007613f298
RBP: ffffc900504c7d00 R08: 000000009d39d68d R09: 00000000bfbdb51f
R10: 00000000ed798a26 R11: 0000000083c184dc R12: 0000000036fc61e0
R13: 00000000f9004639 R14: 0000000042c0d351 R15: 000000008a6cef0f
FS:  00007f5563cef700(0000) GS:ffff888167e00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f5563ced000 CR3: 000000016117c000 CR4: 00000000000006b0
Call Trace:
 _extract_crng+0x6d/0xc0
 extract_crng+0x3a/0x40
 _get_random_bytes+0x56/0x1c0
 ? vprintk_func+0x3f/0xd0
 ? printk+0x3e/0x46
 get_random_bytes+0x2f/0x40
 xyz_packets+0x1110/0x11e0 [mymod]
 proc_reg_read+0x3d/0x60
 __vfs_read+0x23/0x120
 ? vm_mmap_pgoff+0x9d/0xd0
 vfs_read+0x8e/0x110
 SyS_read+0x48/0xc0
 do_syscall_64+0x5c/0x260
 entry_SYSCALL_64_after_hwframe+0x3d/0xa2
RIP: 0033:0x7f55631f


what could be the problem?


thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: kernel panic while using get_random_bytes
  2019-10-14  8:21 kernel panic while using get_random_bytes Temp Sha
@ 2019-11-04  9:35 ` Temp Sha
  2019-11-05  9:12 ` Ondrej Mosnacek
  1 sibling, 0 replies; 3+ messages in thread
From: Temp Sha @ 2019-11-04  9:35 UTC (permalink / raw)
  To: linux-security-module

hi, can any one help me with this issue?  please let me know if this
is not correct form to ask this question?
thanks

On Mon, Oct 14, 2019 at 1:51 PM Temp Sha <temp.sha@gmail.com> wrote:
>
> hi,
>
> i use get_random_bytes() function for my randomness requirement in
> kernel version 4.14.142
> however is gives panic as soon as I call   get_random_bytes() in my module.
>
>
> Oct 10 07:20:18 BUG: unable to handle kernel paging request at 00007f5563ced000
> IP: chacha20_block+0x24d/0x280
> PGD 800000010f7f8067 P4D 800000010f7f8067 PUD 161316067 PMD 1015a8067 PTE 0
> Oops: 0002 [#1] PREEMPT SMP PTI
> Modules linked in: ipi_hsl(PO) mymod(PO) e1000 ipv6 ftdi_sio usbserial
> xt_tcpudp xt_mark iptable_nat nf_nat_ipv4 nf_conntrack_ipv4
> nf_defrag_ipv4 nf_nat xt_connlimit nf_conntrack iptable_filter
> ip_tables x_tables
> CPU: 0 PID: 1841 Comm: hexdump Tainted: P           O    4.14.142-ws-symbol #1
> Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
> task: ffff8881611da000 task.stack: ffffc900504c4000
> RIP: 0010:chacha20_block+0x24d/0x280
> RSP: 0018:ffffc900504c7c70 EFLAGS: 00010886
> RAX: 0000000000000000 RBX: 00000000a88c95b0 RCX: 00007f5563ced000
> RDX: ffff88810f79da00 RSI: 0000000015c4332e RDI: 000000007613f298
> RBP: ffffc900504c7d00 R08: 000000009d39d68d R09: 00000000bfbdb51f
> R10: 00000000ed798a26 R11: 0000000083c184dc R12: 0000000036fc61e0
> R13: 00000000f9004639 R14: 0000000042c0d351 R15: 000000008a6cef0f
> FS:  00007f5563cef700(0000) GS:ffff888167e00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007f5563ced000 CR3: 000000016117c000 CR4: 00000000000006b0
> Call Trace:
>  _extract_crng+0x6d/0xc0
>  extract_crng+0x3a/0x40
>  _get_random_bytes+0x56/0x1c0
>  ? vprintk_func+0x3f/0xd0
>  ? printk+0x3e/0x46
>  get_random_bytes+0x2f/0x40
>  xyz_packets+0x1110/0x11e0 [mymod]
>  proc_reg_read+0x3d/0x60
>  __vfs_read+0x23/0x120
>  ? vm_mmap_pgoff+0x9d/0xd0
>  vfs_read+0x8e/0x110
>  SyS_read+0x48/0xc0
>  do_syscall_64+0x5c/0x260
>  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
> RIP: 0033:0x7f55631f
>
>
> what could be the problem?
>
>
> thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: kernel panic while using get_random_bytes
  2019-10-14  8:21 kernel panic while using get_random_bytes Temp Sha
  2019-11-04  9:35 ` Temp Sha
@ 2019-11-05  9:12 ` Ondrej Mosnacek
  1 sibling, 0 replies; 3+ messages in thread
From: Ondrej Mosnacek @ 2019-11-05  9:12 UTC (permalink / raw)
  To: Temp Sha; +Cc: Linux Security Module list, linux-crypto

Hi Temp,

On Mon, Oct 14, 2019 at 10:21 AM Temp Sha <temp.sha@gmail.com> wrote:
>
> hi,
>
> i use get_random_bytes() function for my randomness requirement in
> kernel version 4.14.142
> however is gives panic as soon as I call   get_random_bytes() in my module.
>
>
> Oct 10 07:20:18 BUG: unable to handle kernel paging request at 00007f5563ced000
> IP: chacha20_block+0x24d/0x280
> PGD 800000010f7f8067 P4D 800000010f7f8067 PUD 161316067 PMD 1015a8067 PTE 0
> Oops: 0002 [#1] PREEMPT SMP PTI
> Modules linked in: ipi_hsl(PO) mymod(PO) e1000 ipv6 ftdi_sio usbserial
> xt_tcpudp xt_mark iptable_nat nf_nat_ipv4 nf_conntrack_ipv4
> nf_defrag_ipv4 nf_nat xt_connlimit nf_conntrack iptable_filter
> ip_tables x_tables
> CPU: 0 PID: 1841 Comm: hexdump Tainted: P           O    4.14.142-ws-symbol #1
> Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
> task: ffff8881611da000 task.stack: ffffc900504c4000
> RIP: 0010:chacha20_block+0x24d/0x280
> RSP: 0018:ffffc900504c7c70 EFLAGS: 00010886
> RAX: 0000000000000000 RBX: 00000000a88c95b0 RCX: 00007f5563ced000
> RDX: ffff88810f79da00 RSI: 0000000015c4332e RDI: 000000007613f298
> RBP: ffffc900504c7d00 R08: 000000009d39d68d R09: 00000000bfbdb51f
> R10: 00000000ed798a26 R11: 0000000083c184dc R12: 0000000036fc61e0
> R13: 00000000f9004639 R14: 0000000042c0d351 R15: 000000008a6cef0f
> FS:  00007f5563cef700(0000) GS:ffff888167e00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007f5563ced000 CR3: 000000016117c000 CR4: 00000000000006b0
> Call Trace:
>  _extract_crng+0x6d/0xc0
>  extract_crng+0x3a/0x40
>  _get_random_bytes+0x56/0x1c0
>  ? vprintk_func+0x3f/0xd0
>  ? printk+0x3e/0x46
>  get_random_bytes+0x2f/0x40
>  xyz_packets+0x1110/0x11e0 [mymod]
>  proc_reg_read+0x3d/0x60
>  __vfs_read+0x23/0x120
>  ? vm_mmap_pgoff+0x9d/0xd0
>  vfs_read+0x8e/0x110
>  SyS_read+0x48/0xc0
>  do_syscall_64+0x5c/0x260
>  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
> RIP: 0033:0x7f55631f
>
>
> what could be the problem?

Since no one else is replying, I'll try to give you some hints. First,
you are posting on the wrong list - linux-security-module@ is for
Linux Security Modules (see Documentation/security/lsm.rst [1]).
Random number generation is more relevant for linux-crypto@ (now in
Cc). Second, the most likely explanation for why you are getting the
crash is that you pass invalid buffer/length to the function. Please
double-check the code in your module whether the pointer and length is
valid. If you fail to find any issue with your code, then ideally post
the full source of you module if possible so people can try to
reproduce and investigate the issue. You could also try to reproduce
the issue with a recent mainline kernel to see if it is an issue that
has been already fixed. If it works with the new kernel then the
stable 4.14 branch you are using likely lacks a backport of the fix.

Hope that helps,

[1] https://www.kernel.org/doc/html/latest/security/lsm.html

-- 
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-14  8:21 kernel panic while using get_random_bytes Temp Sha
2019-11-04  9:35 ` Temp Sha
2019-11-05  9:12 ` Ondrej Mosnacek

Linux-Security-Module Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-security-module/0 linux-security-module/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-security-module linux-security-module/ https://lore.kernel.org/linux-security-module \
		linux-security-module@vger.kernel.org
	public-inbox-index linux-security-module

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-security-module


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git