Received: by 10.192.165.148 with SMTP id m20csp854769imm; Fri, 27 Apr 2018 08:34:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZruqLh3wAeU95//JOoUKQYW9/weZaGDlB+0EKOToACwUpnJ2Tb1JfwADibOl/C02yTBiUgZ X-Received: by 10.98.202.74 with SMTP id n71mr2619778pfg.149.1524843247160; Fri, 27 Apr 2018 08:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524843247; cv=none; d=google.com; s=arc-20160816; b=K3f1fP1vr1i/CDHATrCoFe4QnMUl+QFxsELk7oHZ7r7/1JCr+Qr6PC+dmkQcMmid6d E7o4VuP9UNoZLHnL2ae9tNHxy3+UiP/Hn5Jr5qKU2FmI6DB7YdHCJsV661aG42sTXqlh vZfrB9cRbTPxnpGQeQTMheaPZzkKl+qe55rNSgja4tvC1OFfVQu0LBbmN19fdcpMDRoQ mJr/68bqAxK5tv6ikYhMz047eEEzU/tnUk2wF7BCOp8HxtyaHhPmGVlEXF3RkyREBlBB T2mgXmLtHlBo1buybK51CIPVcx0gzGayKHRwZywm6KtM4ydZjCb4gUc1sYMluVho61si T8CA== 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:dmarc-filter :arc-authentication-results; bh=6OALhr3DT6rQ0bTknnDjaM3JNb6XmOY8ILq7BSHfiUo=; b=IthJh9d2rH/y1vEDribl5EGRJv7oirDW6co1TNCfuReoPWNFB55NOQwPPNcyXqGIPd Ey4+J87A3xJUoZft+Vz5oiAC6/UUKtEAoW6ickO1CE20gpldxgMsEwyFVZgFuW0f8C0G J8MM4lIqh6UjToaB9F9ymDskVgH7Lh7X7Q7yeIYHuukcvJl424v/ccKYnJF80mv0H6BI lHUqH8Mawrvlb8weik6exgXGHBqrOAZ0ZjeGdnUQfDqPNFljFHPlFfWWophsYpLv9ZNF c2/2q0pmo5tQrLSqNj5rAHub+g0Ok68UJKyFnSML2NXXWFkNDmiwMce1+qkPNGtHtI6a h8pA== 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 b186-v6si1353798pgc.569.2018.04.27.08.33.53; Fri, 27 Apr 2018 08:34:07 -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 S933023AbeD0OAp (ORCPT + 99 others); Fri, 27 Apr 2018 10:00:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:47822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932821AbeD0OAl (ORCPT ); Fri, 27 Apr 2018 10:00:41 -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 EB85A2189D; Fri, 27 Apr 2018 14:00:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB85A2189D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Olsa , Alexander Shishkin , Andi Kleen , "H. Peter Anvin" , Namhyung Kim , Peter Zijlstra , Stephane Eranian , Thomas Gleixner , syzkaller-bugs@googlegroups.com, x86@kernel.org, Arnaldo Carvalho de Melo Subject: [PATCH 4.4 03/50] perf: Return proper values for user stack errors Date: Fri, 27 Apr 2018 15:58:05 +0200 Message-Id: <20180427135655.846786908@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135655.623669681@linuxfoundation.org> References: <20180427135655.623669681@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiri Olsa commit 78b562fbfa2cf0a9fcb23c3154756b690f4905c1 upstream. Return immediately when we find issue in the user stack checks. The error value could get overwritten by following check for PERF_SAMPLE_REGS_INTR. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: H. Peter Anvin Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: syzkaller-bugs@googlegroups.com Cc: x86@kernel.org Fixes: 60e2364e60e8 ("perf: Add ability to sample machine state on interrupt") Link: http://lkml.kernel.org/r/20180415092352.12403-1-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- kernel/events/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -8133,9 +8133,9 @@ static int perf_copy_attr(struct perf_ev * __u16 sample size limit. */ if (attr->sample_stack_user >= USHRT_MAX) - ret = -EINVAL; + return -EINVAL; else if (!IS_ALIGNED(attr->sample_stack_user, sizeof(u64))) - ret = -EINVAL; + return -EINVAL; } if (attr->sample_type & PERF_SAMPLE_REGS_INTR)