From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753110Ab3COFUg (ORCPT ); Fri, 15 Mar 2013 01:20:36 -0400 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.122]:23048 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751950Ab3COFUe (ORCPT ); Fri, 15 Mar 2013 01:20:34 -0400 X-Authority-Analysis: v=2.0 cv=UN5f7Vjy c=1 sm=0 a=rXTBtCOcEpjy1lPqhTCpEQ==:17 a=mNMOxpOpBa8A:10 a=Ciwy3NGCPMMA:10 a=JvGCktBZ0moA:10 a=5SG0PmZfjMsA:10 a=bbbx4UPp9XUA:10 a=meVymXHHAAAA:8 a=moR4xaGenvAA:10 a=VwQbUJbxAAAA:8 a=xyjClV9khCZf7UbR_SUA:9 a=QEXdDO2ut3YA:10 a=jeBq3FmKZ4MA:10 a=jkc2-DoKcrND15QomGEA:9 a=rXTBtCOcEpjy1lPqhTCpEQ==:117 X-Cloudmark-Score: 0 X-Authenticated-User: X-Originating-IP: 74.67.115.198 Message-Id: <20130315052032.859147521@goodmis.org> User-Agent: quilt/0.60-1 Date: Fri, 15 Mar 2013 01:06:17 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton , Frederic Weisbecker , Subject: [PATCH 1/3 v2] tracing: Protect tracer flags with trace_types_lock References: <20130315050616.512983245@goodmis.org> Content-Disposition: inline; filename=0001-tracing-Protect-tracer-flags-with-trace_types_lock.patch Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="00GvhwF7k39YY" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --00GvhwF7k39YY Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: "Steven Rostedt (Red Hat)" Seems that the tracer flags have never been protected from synchronous writes. Luckily, admins don't usually modify the tracing flags via two different tasks. But if scripts were to be used to modify them, then they could get corrupted. Move the trace_types_lock that protects against tracers changing to also protect the flags being set. Cc: stable@vger.kernel.org Signed-off-by: Steven Rostedt --- kernel/trace/trace.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 53df283..00daf5f 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2916,6 +2916,8 @@ static int trace_set_options(char *option) cmp +=3D 2; } =20 + mutex_lock(&trace_types_lock); + for (i =3D 0; trace_options[i]; i++) { if (strcmp(cmp, trace_options[i]) =3D=3D 0) { set_tracer_flags(1 << i, !neg); @@ -2924,11 +2926,10 @@ static int trace_set_options(char *option) } =20 /* If no option could be set, test the specific tracer options */ - if (!trace_options[i]) { - mutex_lock(&trace_types_lock); + if (!trace_options[i]) ret =3D set_tracer_option(current_trace, cmp, neg); - mutex_unlock(&trace_types_lock); - } + + mutex_unlock(&trace_types_lock); =20 return ret; } @@ -4781,7 +4782,10 @@ trace_options_core_write(struct file *filp, const ch= ar __user *ubuf, size_t cnt, =20 if (val !=3D 0 && val !=3D 1) return -EINVAL; + + mutex_lock(&trace_types_lock); set_tracer_flags(1 << index, val); + mutex_unlock(&trace_types_lock); =20 *ppos +=3D cnt; =20 --=20 1.7.10.4 --00GvhwF7k39YY Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAABAgAGBQJRQq+gAAoJEOdOSU1xswtMv24H/0Eepxttz0SpLOltk7+4KPII YMfNsEXEMnEzTZt9KONWVu9jEUpMJGoRn87Dsc3AXM6gSpF7a7tOE9ZWwa+z6Yzd ueq1rIr8pV6jug98CMHxofzhOg8rKdK0BoAiy9blj0lJzIe2y11IJF78oMAsoQ9J KsWaLe9cNR2s9BIC6t/qsSVOfMd0ky/XkYVYY+74Nb6U0zH3ZPW8mcHu9H7QM/iD vWuRjERZfz0NqCEgUYmE8bvVXVkes7lgeCCWMDW8nmpDjw2s1myGhe5fTGtfYi9M K35U92PgHOPg2fYn0vzkl+7jggFx6JkRi1Fcjq1Q10e5F/uMkEr7wWoobk8lKZc= =x5lx -----END PGP SIGNATURE----- --00GvhwF7k39YY--