Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3953477imm; Sun, 13 May 2018 23:52:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoxDnCoTXgg+tGWauF6iGRIyQE+waybVfgsg1Znf5TquRBx9/ZpQK02BhuBIXw/gX5ZrjRG X-Received: by 2002:a62:5050:: with SMTP id e77-v6mr9322523pfb.16.1526280721583; Sun, 13 May 2018 23:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526280721; cv=none; d=google.com; s=arc-20160816; b=rWJ4Ns8zlXZHhw73awWyX2Aj+z06AJEmqmEX8AEIWfMxyiI/yX4/mXIi1EHa1+UxP2 lZi/dKZmg1Mcq91VO/nW2VCODd6UPw1GvdYBJ2WTT/rXlo1IPNfGhz+FqQU2pp91E2VE 8RUJFfU8swhVB/ku9wtiOZD/7SgS3TEPkDspkYDS1dICoSxuPA8/ovYOGU8vWjstsEZd 6CEdrLeQ+q/EJpGqTvlpf6zxLVaWxMWMCCvAaqdXs2dcd+iVVs6njIESaJAf01yngJLi g/bj/Md90g6xnWPV+4omsshrIEAZB93MHoWQNdLhFgtwA2+eakH6Zwa5IlDmmUGYVTzx A/zQ== 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:dkim-signature :arc-authentication-results; bh=xIBf8uUZszFZnaR8ahQtEePkLw5N08TYX6qx8ycQ124=; b=W9/jKqHQhRNjfNAqnF+krYRKDQeg5oGoAGd2yWoL7zUVVwtXDiv64N9SaHkcZls6je mmj7Xlj2nGyP91t+Oof/2CNTyCj0amCjHGXcegsLTykmJGfVbkZqU4W/FR1ZEdt76EH3 t2bDlxgYkkTgtQrlmca21Ng7VBevdvtQlOMm+8ky4E7/2FIdsO/e8/yhkTKW/Bw82Jfd D62QrLAmWg5GEggmqiqhW/Agt4Kq5f33n3A+mvKrKkQydI1bR6mYC+OJBrU6D0GPQO3K 9XavtffL5hb79QQLlWX1uw9saas3USQi/X/V5XNVxDSYppCVGdljajt66bNBA1zuIKMo Aerw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UrFzRoHK; 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 k75-v6si8699552pfk.369.2018.05.13.23.51.47; Sun, 13 May 2018 23:52: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; dkim=pass header.i=@kernel.org header.s=default header.b=UrFzRoHK; 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 S1752237AbeENGua (ORCPT + 99 others); Mon, 14 May 2018 02:50:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:57160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752219AbeENGu0 (ORCPT ); Mon, 14 May 2018 02:50:26 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 7046321746; Mon, 14 May 2018 06:50:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526280625; bh=m/9yBvu5u5czuH23GESIOi9/Q25nn8AKLprfD2V/d+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UrFzRoHKuXHCRh3HOW+imKGmUncp5ot+7DGeO2tmP/4bvUsey4dNEjUAegDzMlbCw KHe7hbWro8PyQ1J7UqB5gXCuhOegmib4M7E9nc9fymkUQwglRxXCiZZfMYEfEvzXDH JBiVQ4M/JwTmheW5TVEZcI6c/Vr2bBzxic3Diurs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven Rostedt (VMware)" Subject: [PATCH 3.18 21/23] tracing: Fix regex_match_front() to not over compare the test string Date: Mon, 14 May 2018 08:48:50 +0200 Message-Id: <20180514064704.936636221@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514064704.046463679@linuxfoundation.org> References: <20180514064704.046463679@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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt (VMware) commit dc432c3d7f9bceb3de6f5b44fb9c657c9810ed6d upstream. The regex match function regex_match_front() in the tracing filter logic, was fixed to test just the pattern length from testing the entire test string. That is, it went from strncmp(str, r->pattern, len) to strcmp(str, r->pattern, r->len). The issue is that str is not guaranteed to be nul terminated, and if r->len is greater than the length of str, it can access more memory than is allocated. The solution is to add a simple test if (len < r->len) return 0. Cc: stable@vger.kernel.org Fixes: 285caad415f45 ("tracing/filters: Fix MATCH_FRONT_ONLY filter matching") Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_filter.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -273,6 +273,9 @@ static int regex_match_full(char *str, s static int regex_match_front(char *str, struct regex *r, int len) { + if (len < r->len) + return 0; + if (strncmp(str, r->pattern, r->len) == 0) return 1; return 0;