Received: by 10.192.165.148 with SMTP id m20csp533709imm; Wed, 25 Apr 2018 03:50:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZro9NwKzoNClXxC40PlcZIRA0b1gju61/gmjfJNR3s0ag2h4svPLuczbp/sswnT+liOMJ9/ X-Received: by 10.167.131.24 with SMTP id t24mr5226854pfm.245.1524653414802; Wed, 25 Apr 2018 03:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653414; cv=none; d=google.com; s=arc-20160816; b=RZIYh3X+o4IBYRJtwUjmEYW/fa1Q1W7N+G+LP3liwkNY9Oo1CeyqdkPd2kVGBC56ku PdEgY25Ozy+7YFMHV7OoLJX4yOlpxi3CsxIntVyTRlI3zVmSn51keUF9T8f7f3Jm42NS kLCKp3mHMV3bmEukkVyAVKyt0LZIi66R5Zx/nHb+9YjWzZtYoRtC0YFKDK1SmWTJHWvL wBoCa3wgDDsJJ1YRt6ddsVQvp3t/FmfNAT6VvWkDMwkCStNvJFe5SWQ4OG5n46FmIM88 MGM+f5ueajS5+bjwTxlgkWlEVF+8XPMRtYP+EYP9NHwhK983PkTwJmHD43pAY+XwdVB5 2G8g== 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=z1FitC57LQkw3+KwP1tUtOUkK/GNed4Kyd9D8qcvyZU=; b=pEesUh0DrkLyc3j3GOEIBZPV7DSloUPqEEDapZg78yKRi+PN94yyfD9B53fIVR5e3n luqutgtDPbRJOQGzKgdcuhxwamUIenzc1e/0WcepJzzzZOw22x4CP1Xi+SCB7yKC9HFc 8KFR8H7DzAzCvhabqxbylAX4dmXG5X79aE11hbJSaPILk9ALQERBEbPHu49icdt7myH3 q0FErtkISkVM0epqHfca6f5WULyTf0iU+fyzscBv/acj2jmLtvhlH9hS+qoW7UHLsue9 0NHC5BuGj/7kmQi0rvfNTyXGjp66JJ9J+o8jNw3XahZWW9gp5qu3pD9sQD7WJAqvzKtY o/rQ== 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 i11si9269805pgn.530.2018.04.25.03.49.43; Wed, 25 Apr 2018 03:50:14 -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 S1754580AbeDYKsB (ORCPT + 99 others); Wed, 25 Apr 2018 06:48:01 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53442 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754457AbeDYKoy (ORCPT ); Wed, 25 Apr 2018 06:44:54 -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 223AF272; Wed, 25 Apr 2018 10:44:53 +0000 (UTC) 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.14 180/183] perf: Return proper values for user stack errors Date: Wed, 25 Apr 2018 12:36:40 +0200 Message-Id: <20180425103249.732757973@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@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.14-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 @@ -9750,9 +9750,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)