Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2989281imm; Sun, 1 Jul 2018 09:49:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcLlihRHtZXFyyg9ObAruBYusG9kPx9VCgoMSMPvnPeUtTxtv0raPPZHPkNo9L3/wN8R5/N X-Received: by 2002:a62:3ece:: with SMTP id y75-v6mr14025836pfj.7.1530463741316; Sun, 01 Jul 2018 09:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530463741; cv=none; d=google.com; s=arc-20160816; b=vRoFO0WbdCVzXlpW/8FyIQ7y2KxyNisoNHgOAOw0sxHOVEiZmvXz2PWXMAjn8chd33 sh7LuF9hrnCiDO0+TPSeTx16L6sXAflLx/yhRqYSNXhtYfWSADbNIL0293LBRBZNmfSo TtrsMvAOGZ3hfANipNR7/wje7opaSc6geJt54/kxscV8I1AVMlNOHH0sxKDPj9o4sMvv 0Nk25btL8bJPj7rVHVsRDt2An0ixC1ExLl4gkfq2Hn3LYeG9MHpiIErkaTYbCvFlaHPp fETMy/NL4C/wb4x+qOUT/xypOur3eMsM7fspYvolTZbr5BIJxJmvToVCf8gCTe8GjMDE ohjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=aoLjpYIRjeuE0LuEY+kmVJ2t03j8VxgauwBVWSa2SU8=; b=zU+ERQwuAlrejcI5Q6rEbJ58DIuKZxC0jESeTuEg4lZkbbQHbcBteAXo6tz14Q0NWc gm9VzPOUzNIS8YvhouX/WQCDfIuFT+1X8agul6wntRe16Q8cUQP0RJWkQtDaKvW7cIvS HpJbaxIRAiadqv24BXndTMBe27uJQ+iu08gYXC186Cwr+a7Ef8vISN+Oz+asEiEKPtWA 4ynW53l7WasMydFARE8H6kHGagD6R1NYMUpsKgAl4lszzJrx+vYwsRFYXHvJW/qyY9zz 8S5nrAZw6As+w75i4lvVzFBmgtKz1N2TJmVAplaVG6O/cEbd9tuWXPoqvCRuQRtj1+17 kjwQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i62-v6si13715168pfc.255.2018.07.01.09.48.47; Sun, 01 Jul 2018 09:49:01 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032425AbeGAQrG (ORCPT + 99 others); Sun, 1 Jul 2018 12:47:06 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38596 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032464AbeGAQrB (ORCPT ); Sun, 1 Jul 2018 12:47:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 53332ACD; Sun, 1 Jul 2018 16:47:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, air icy , "Steven Rostedt (VMware)" Subject: [PATCH 4.17 192/220] tracing: Check for no filter when processing event filters Date: Sun, 1 Jul 2018 18:23:36 +0200 Message-Id: <20180701160916.212100002@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt (VMware) commit 70303420b5721c38998cf987e6b7d30cc62d4ff1 upstream. The syzkaller detected a out-of-bounds issue with the events filter code, specifically here: prog[N].pred = NULL; /* #13 */ prog[N].target = 1; /* TRUE */ prog[N+1].pred = NULL; prog[N+1].target = 0; /* FALSE */ -> prog[N-1].target = N; prog[N-1].when_to_branch = false; As that's the first reference to a "N-1" index, it appears that the code got here with N = 0, which means the filter parser found no filter to parse (which shouldn't ever happen, but apparently it did). Add a new error to the parsing code that will check to make sure that N is not zero before going into this part of the code. If N = 0, then -EINVAL is returned, and a error message is added to the filter. Cc: stable@vger.kernel.org Fixes: 80765597bc587 ("tracing: Rewrite filter logic to be simpler and faster") Reported-by: air icy bugzilla url: https://bugzilla.kernel.org/show_bug.cgi?id=200019 Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_filter.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -78,7 +78,8 @@ static const char * ops[] = { OPS }; C(TOO_MANY_PREDS, "Too many terms in predicate expression"), \ C(INVALID_FILTER, "Meaningless filter expression"), \ C(IP_FIELD_ONLY, "Only 'ip' field is supported for function trace"), \ - C(INVALID_VALUE, "Invalid value (did you forget quotes)?"), + C(INVALID_VALUE, "Invalid value (did you forget quotes)?"), \ + C(NO_FILTER, "No filter found"), #undef C #define C(a, b) FILT_ERR_##a @@ -550,6 +551,13 @@ predicate_parse(const char *str, int nr_ goto out_free; } + if (!N) { + /* No program? */ + ret = -EINVAL; + parse_error(pe, FILT_ERR_NO_FILTER, ptr - str); + goto out_free; + } + prog[N].pred = NULL; /* #13 */ prog[N].target = 1; /* TRUE */ prog[N+1].pred = NULL;