From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932441AbaFTCIG (ORCPT ); Thu, 19 Jun 2014 22:08:06 -0400 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.225]:51154 "EHLO cdptpa-oedge-vip.email.rr.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754611AbaFTCIE (ORCPT ); Thu, 19 Jun 2014 22:08:04 -0400 Date: Thu, 19 Jun 2014 22:08:00 -0400 From: Steven Rostedt To: Masami Hiramatsu Cc: Josh Poimboeuf , Ingo Molnar , Namhyung Kim , Linux Kernel Mailing List , Ananth N Mavinakayanahalli Subject: Re: [PATCH -tip v2 1/3] ftrace: Simplify ftrace_hash_disable/enable path in ftrace_hash_move Message-ID: <20140619220800.5d4b790c@gandalf.local.home> In-Reply-To: <20140617110442.15167.81076.stgit@kbuild-fedora.novalocal> References: <20140617110436.15167.7179.stgit@kbuild-fedora.novalocal> <20140617110442.15167.81076.stgit@kbuild-fedora.novalocal> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-RR-Connecting-IP: 107.14.168.142:25 X-Cloudmark-Score: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Jun 2014 11:04:42 +0000 Masami Hiramatsu wrote: > Simplify ftrace_hash_disable/enable path in ftrace_hash_move > for hardening the process if the memory allocation failed. > Regardless of what we do with IPMODIFY, I pulled this into my 3.17 queue. You don't need to resend it with any new versions of the patches. -- Steve > Signed-off-by: Masami Hiramatsu > Cc: Steven Rostedt > Cc: Josh Poimboeuf > Cc: Namhyung Kim > --- > kernel/trace/ftrace.c | 33 +++++++++++---------------------- > 1 file changed, 11 insertions(+), 22 deletions(-) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 5b372e3..d65719d 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -1304,25 +1304,15 @@ ftrace_hash_move(struct ftrace_ops *ops, int enable, > struct ftrace_hash *new_hash; > int size = src->count; > int bits = 0; > - int ret; > int i; > > /* > - * Remove the current set, update the hash and add > - * them back. > - */ > - ftrace_hash_rec_disable(ops, enable); > - > - /* > * If the new source is empty, just free dst and assign it > * the empty_hash. > */ > if (!src->count) { > - free_ftrace_hash_rcu(*dst); > - rcu_assign_pointer(*dst, EMPTY_HASH); > - /* still need to update the function records */ > - ret = 0; > - goto out; > + new_hash = EMPTY_HASH; > + goto update; > } > > /* > @@ -1335,10 +1325,9 @@ ftrace_hash_move(struct ftrace_ops *ops, int enable, > if (bits > FTRACE_HASH_MAX_BITS) > bits = FTRACE_HASH_MAX_BITS; > > - ret = -ENOMEM; > new_hash = alloc_ftrace_hash(bits); > if (!new_hash) > - goto out; > + return -ENOMEM; > > size = 1 << src->size_bits; > for (i = 0; i < size; i++) { > @@ -1349,20 +1338,20 @@ ftrace_hash_move(struct ftrace_ops *ops, int enable, > } > } > > +update: > + /* > + * Remove the current set, update the hash and add > + * them back. > + */ > + ftrace_hash_rec_disable(ops, enable); > + > old_hash = *dst; > rcu_assign_pointer(*dst, new_hash); > free_ftrace_hash_rcu(old_hash); > > - ret = 0; > - out: > - /* > - * Enable regardless of ret: > - * On success, we enable the new hash. > - * On failure, we re-enable the original hash. > - */ > ftrace_hash_rec_enable(ops, enable); > > - return ret; > + return 0; > } > > /* >