Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp721976ybe; Fri, 6 Sep 2019 06:24:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgNUwh6DlpWKYtawP/iNTiXGWPcSmez/l0rGo2fgSpH3ZsE4S799whD3sOM+tjav63nf1m X-Received: by 2002:a17:90a:8987:: with SMTP id v7mr9827313pjn.115.1567776248187; Fri, 06 Sep 2019 06:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567776248; cv=none; d=google.com; s=arc-20160816; b=TecGba/pS052irtBhqIFe1Y0iEtv/Bf0Oy5LdWQeZ4VinVA0gVB1FyK9h0UH2AW8Zc ZDXBo7ct26Ll9evgdJiV+WsIl2AKj1IDE4V5gtq8Pm9v07FMzogYJjlX5u/DSLAjPOgy mZSLJofsVl5PqLpxo3UyU7mktldLcY3pvVXwx7tfUWUTFyoN88nuJ8PLJz2ZllWfF5oB RfTAd64f4y4CW5gmZjd7mAx7YDeJDVUtk3g6SP6z03pDeZRDId+NkOdMWSu2WAybmjvr MkrE62RnBpILeUtZkLH7WIiWIy/+9AS8Wb75P3jZxh7DfmQKVJ0iHjaM0M7XEcyE5jrQ p78A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=vSFHpzC4INHpG0cSt2svrNOuEK/OxIUTPosJMc8PE4c=; b=SgHCylVmqy3+vISYhMtDlwHNXXvyw30hDnbCX9A8sRBUTkUFxrwTY822inDYDSmXyp fh2bt9ptU5nNeOIROXV2Dnt1rLSuuG5fxxRrVpltIysdgkgFt51wzI+hY8EBI+VY4I/n KACaoASCTpVfRlfnEf0yc9lXe6Rxcizu9FyOpZFgMcT4YRjnU2cMzo0UL6D5cjJ1zbWU jI40EiQDaqNG10dTbTNRg2WZdIHoDnVJSbVGPWDGkKL4pKkt6tYWo0S9r1GqQGe/nftq +LuysWyrRl+YfTbplbluZfuhJJR705SjskRBgNkzfsRA8Jjafe8spzGz0fPDqOKDph1u qOXw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e19si5181882plq.253.2019.09.06.06.23.51; Fri, 06 Sep 2019 06:24:08 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388619AbfIFGBw (ORCPT + 99 others); Fri, 6 Sep 2019 02:01:52 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:5647 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726080AbfIFGBw (ORCPT ); Fri, 6 Sep 2019 02:01:52 -0400 X-UUID: fceac7b8c77f4dd78fb93eda6adf6708-20190906 X-UUID: fceac7b8c77f4dd78fb93eda6adf6708-20190906 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1335698442; Fri, 06 Sep 2019 14:01:44 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 6 Sep 2019 14:01:31 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 6 Sep 2019 14:01:31 +0800 From: Mark-PK Tsai To: , , , , , , CC: , , , Mark-PK Tsai , YJ Chiang , Alix Wu Subject: [PATCH] perf/hw_breakpoint: Fix arch_hw_breakpoint use-before-initialization Date: Fri, 6 Sep 2019 14:01:16 +0800 Message-ID: <20190906060115.9460-1-mark-pk.tsai@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we disable the compiler's auto-initialization feature (-fplugin-arg-structleak_plugin-byref or -ftrivial-auto-var-init=pattern) is disabled, arch_hw_breakpoint may be used before initialization after the change 9a4903dde2c86. (perf/hw_breakpoint: Split attribute parse and commit) On our arm platform, the struct step_ctrl in arch_hw_breakpoint, which used to be zero-initialized by kzalloc, may be used in arch_install_hw_breakpoint without initialization. Signed-off-by: Mark-PK Tsai Cc: YJ Chiang Cc: Alix Wu --- kernel/events/hw_breakpoint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c index c5cd852fe86b..8fb842394924 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c @@ -413,7 +413,7 @@ static int hw_breakpoint_parse(struct perf_event *bp, int register_perf_hw_breakpoint(struct perf_event *bp) { - struct arch_hw_breakpoint hw; + struct arch_hw_breakpoint hw = {0}; int err; err = reserve_bp_slot(bp); @@ -461,7 +461,7 @@ int modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr, bool check) { - struct arch_hw_breakpoint hw; + struct arch_hw_breakpoint hw = {0}; int err; err = hw_breakpoint_parse(bp, attr, &hw); -- 2.18.0