From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Subject: Re: [BUG -next] "random: make /dev/urandom scalable for silly userspace programs" causes crash Date: Thu, 28 Jul 2016 11:12:09 -0700 Message-ID: <1469729529.3998.59.camel@perches.com> References: <20160727071400.GA3912@osiris> <20160728034601.GC20032@thunk.org> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20160728034601.GC20032@thunk.org> Sender: owner-linux-mm@kvack.org To: Theodore Ts'o , Heiko Carstens Cc: linux-next@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Martin Schwidefsky List-Id: linux-next.vger.kernel.org On Wed, 2016-07-27 at 23:46 -0400, Theodore Ts'o wrote: > On Wed, Jul 27, 2016 at 09:14:00AM +0200, Heiko Carstens wrote: > >=20 > > it looks like your patch "random: make /dev/urandom scalable for sill= y > > userspace programs" within linux-next seems to be a bit broken: > >=20 > > It causes this allocation failure and subsequent crash on s390 with f= ake > > NUMA enabled > Thanks for reporting this.=A0=A0This patch fixes things for you, yes? trivia: > diff --git a/drivers/char/random.c b/drivers/char/random.c [] > @@ -1668,13 +1668,12 @@ static int rand_initialize(void) > =A0#ifdef CONFIG_NUMA > =A0 pool =3D kmalloc(num_nodes * sizeof(void *), > =A0 =A0=A0=A0=A0=A0=A0=A0GFP_KERNEL|__GFP_NOFAIL|__GFP_ZERO); The __GFP_ZERO is unusual and this could use kcalloc instead. > - for (i=3D0; i < num_nodes; i++) { > + for_each_online_node(i) { > =A0 crng =3D kmalloc_node(sizeof(struct crng_state), > =A0 =A0=A0=A0=A0GFP_KERNEL | __GFP_NOFAIL, i); > =A0 spin_lock_init(&crng->lock); > =A0 crng_initialize(crng); > =A0 pool[i] =3D crng; > - > =A0 } > =A0 mb(); > =A0 crng_node_pool =3D pool; -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f69.google.com (mail-it0-f69.google.com [209.85.214.69]) by kanga.kvack.org (Postfix) with ESMTP id 3A8926B0253 for ; Thu, 28 Jul 2016 14:12:14 -0400 (EDT) Received: by mail-it0-f69.google.com with SMTP id d65so96190588ith.0 for ; Thu, 28 Jul 2016 11:12:14 -0700 (PDT) Received: from smtprelay.hostedemail.com (smtprelay0003.hostedemail.com. [216.40.44.3]) by mx.google.com with ESMTPS id g131si14167047iof.190.2016.07.28.11.12.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 11:12:13 -0700 (PDT) Message-ID: <1469729529.3998.59.camel@perches.com> Subject: Re: [BUG -next] "random: make /dev/urandom scalable for silly userspace programs" causes crash From: Joe Perches Date: Thu, 28 Jul 2016 11:12:09 -0700 In-Reply-To: <20160728034601.GC20032@thunk.org> References: <20160727071400.GA3912@osiris> <20160728034601.GC20032@thunk.org> Content-Type: text/plain; charset="ISO-8859-1" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: owner-linux-mm@kvack.org List-ID: To: Theodore Ts'o , Heiko Carstens Cc: linux-next@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Martin Schwidefsky On Wed, 2016-07-27 at 23:46 -0400, Theodore Ts'o wrote: > On Wed, Jul 27, 2016 at 09:14:00AM +0200, Heiko Carstens wrote: > > > > it looks like your patch "random: make /dev/urandom scalable for silly > > userspace programs" within linux-next seems to be a bit broken: > > > > It causes this allocation failure and subsequent crash on s390 with fake > > NUMA enabled > Thanks for reporting this. This patch fixes things for you, yes? trivia: > diff --git a/drivers/char/random.c b/drivers/char/random.c [] > @@ -1668,13 +1668,12 @@ static int rand_initialize(void) > #ifdef CONFIG_NUMA > pool = kmalloc(num_nodes * sizeof(void *), > GFP_KERNEL|__GFP_NOFAIL|__GFP_ZERO); The __GFP_ZERO is unusual and this could use kcalloc instead. > - for (i=0; i < num_nodes; i++) { > + for_each_online_node(i) { > crng = kmalloc_node(sizeof(struct crng_state), > GFP_KERNEL | __GFP_NOFAIL, i); > spin_lock_init(&crng->lock); > crng_initialize(crng); > pool[i] = crng; > - > } > mb(); > crng_node_pool = pool; -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756330AbcG1SMW (ORCPT ); Thu, 28 Jul 2016 14:12:22 -0400 Received: from smtprelay0248.hostedemail.com ([216.40.44.248]:55083 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752508AbcG1SMO (ORCPT ); Thu, 28 Jul 2016 14:12:14 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:960:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2828:2899:2919:3138:3139:3140:3141:3142:3352:3622:3865:3867:3868:3871:3872:3873:4321:5007:6117:10004:10400:10848:11026:11232:11658:11783:11914:12043:12296:12438:12517:12519:12740:13069:13161:13229:13255:13311:13357:13439:13894:14659:14721:21080:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: north61_4d3c60ecdf600 X-Filterd-Recvd-Size: 1981 Message-ID: <1469729529.3998.59.camel@perches.com> Subject: Re: [BUG -next] "random: make /dev/urandom scalable for silly userspace programs" causes crash From: Joe Perches To: "Theodore Ts'o" , Heiko Carstens Cc: linux-next@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Martin Schwidefsky Date: Thu, 28 Jul 2016 11:12:09 -0700 In-Reply-To: <20160728034601.GC20032@thunk.org> References: <20160727071400.GA3912@osiris> <20160728034601.GC20032@thunk.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2016-07-27 at 23:46 -0400, Theodore Ts'o wrote: > On Wed, Jul 27, 2016 at 09:14:00AM +0200, Heiko Carstens wrote: > > > > it looks like your patch "random: make /dev/urandom scalable for silly > > userspace programs" within linux-next seems to be a bit broken: > > > > It causes this allocation failure and subsequent crash on s390 with fake > > NUMA enabled > Thanks for reporting this.  This patch fixes things for you, yes? trivia: > diff --git a/drivers/char/random.c b/drivers/char/random.c [] > @@ -1668,13 +1668,12 @@ static int rand_initialize(void) >  #ifdef CONFIG_NUMA >   pool = kmalloc(num_nodes * sizeof(void *), >          GFP_KERNEL|__GFP_NOFAIL|__GFP_ZERO); The __GFP_ZERO is unusual and this could use kcalloc instead. > - for (i=0; i < num_nodes; i++) { > + for_each_online_node(i) { >   crng = kmalloc_node(sizeof(struct crng_state), >       GFP_KERNEL | __GFP_NOFAIL, i); >   spin_lock_init(&crng->lock); >   crng_initialize(crng); >   pool[i] = crng; > - >   } >   mb(); >   crng_node_pool = pool;