Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp849387imm; Wed, 25 Jul 2018 07:15:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdYf/VZyhGNUGvskXCWdigWkOAcIoq6UusUKGwMRs3pilkanddTVfJAYElFCsqQ/jWI42oi X-Received: by 2002:a17:902:280b:: with SMTP id e11-v6mr21167580plb.298.1532528120254; Wed, 25 Jul 2018 07:15:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532528120; cv=none; d=google.com; s=arc-20160816; b=YUMsgAsoO5bNEFoPMKLcJfitsbrxcVKdLdtP9wNw8oorOJs/4SUlE3gpck7s1bYwR2 Vkv7I8mVy+7+vOkpUCGrRUcwrSvtJ5MQwDE7THw+VGkSCW67dsB6cpnXsPP/RA1tYu05 +pxeORQh1XO//A40g8IxagQ4L/l7GV39czdWiHry0ZbLC3TthwOE2aNI4ZPEbe+E8OgE dPBcLAJbfYXtywdyh3R18nD6k0/M38dXoFqPPNy+JLyr2B837R6QgWEQOD/BUyle+K/c KmhOQygVlIq6lS1Nm+vNiShaCLewAwyCiuXS3+u8SsP0HPWGE0XPtweQcNxR2UJ0EOpz 0ByQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=QzeSgGLbfpeH7VBesWot/c3pX0t0QdgHx0aHJup901Q=; b=UXvh6sj+iziME1hvJrj4JYyCP/zhYin1mtTXziLGAbaRYgIKF+xtAWNVrdPn00+sNq TH0hE/1h+uHAudNAQvIj2DI5AkwvUAV8c+e7li6hAO2MsIaJPizXVkOA9Loy6eQrWNz1 CC7n+mUhqjQIlyYmgnimEOccKo7KmVseq/ZqtMvKlppLAC8+ySgPDhomi6e+KdJCBlVX 4ME1Xss2LeEUoeoQGMXKZEXgBSGuNSEgcHq6b1SjQyy8Exiw5H4iPXE1dlX9kPoVW08R 5+z792u/ee742PhIHGyjkD/7icThBsOWlAPyzBXEa0meZ9An2NdSDxdHJWBFWmojRevA jFTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aPHkag17; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b18-v6si14253139pge.666.2018.07.25.07.15.05; Wed, 25 Jul 2018 07:15:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aPHkag17; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729194AbeGYPZ6 (ORCPT + 99 others); Wed, 25 Jul 2018 11:25:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:49654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728608AbeGYPZ6 (ORCPT ); Wed, 25 Jul 2018 11:25:58 -0400 Received: from devbox (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5A1D120843; Wed, 25 Jul 2018 14:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1532528046; bh=IsArdNKx9qLUg3zCYe5+tgSxzAOsxWouKewk9UZgGb4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aPHkag173/tIGR2JRNBj1oyai0bYHyY/DTHm2tL2rf5ouEx9xNGChArMtcH+zILRT /gOzMiCGKbo5mDufs+9rbVWfuj0522bN8V3LoqUDnHhIoyST/fCjAEwMeIeUYipmta srdThTU3uig46+g4+USYNdjZgDjxPLcObOXdtfN8= Date: Wed, 25 Jul 2018 23:14:02 +0900 From: Masami Hiramatsu To: Steven Rostedt Cc: Tom Zanussi , Ingo Molnar , Shuah Khan , Hiraku Toyooka , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 1/3] [BUGFIX] tracing: Fix double free of event_trigger_data Message-Id: <20180725231402.1f9d8754cee6b35b7dee7b3c@kernel.org> In-Reply-To: <20180724224149.0767fd13@gandalf.local.home> References: <153149923649.11274.14970833360963898112.stgit@devbox> <153149926702.11274.12489440326560729788.stgit@devbox> <20180723221006.60cc7aa9@vmware.local.home> <20180725000909.6c8b2f3881ee75c4f6bd466b@kernel.org> <20180724164959.3cbc1422@gandalf.local.home> <20180724173008.454cdf10@gandalf.local.home> <20180724191331.738eb819@gandalf.local.home> <20180725101653.09e095092a4bb77e6fc558df@kernel.org> <20180724224149.0767fd13@gandalf.local.home> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 24 Jul 2018 22:41:49 -0400 Steven Rostedt wrote: > On Wed, 25 Jul 2018 10:16:53 +0900 > Masami Hiramatsu wrote: > > > Hm, as far as I can see, when register_trigger() returns >= 0, it already > > calls ->init the trigger_data. This means its refcount++, and in that > > case, below patch will miss to free the trigger_data. > > How about below for tentative fix? > > > > if (!ret) { > > ret = -ENOENT; > > /* We have to forcibly free the trigger_data */ > > goto out_free; > > } else if (ret > 0) > > ret = 0; > > Or better yet, match it properly: OK, this looks good to me :) Reviewed-by: Masami Hiramatsu Thanks! > > out_reg: > /* Up the trigger_data count to make sure reg doesn't free it on failure */ > event_trigger_init(trigger_ops, trigger_data); > ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file); > /* > * The above returns on success the # of functions enabled, > * but if it didn't find any functions it returns zero. > * Consider no functions a failure too. > */ > if (!ret) { > cmd_ops->unreg(glob, trigger_ops, trigger_data, file); > ret = -ENOENT; > } else if (ret > 0) > ret = 0; > > /* Down the counter of trigger_data or free it if not used anymore */ > event_trigger_free(trigger_ops, trigger_data); > out: > return ret; > > -- Steve -- Masami Hiramatsu