Received: by 10.192.165.148 with SMTP id m20csp523929imm; Wed, 25 Apr 2018 03:38:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/shaNTcNTAyZz80srky+GmSg4fSJV+u81FErvWGPtrFztl5D78H2rMDwhmRIDG7D87NvMW X-Received: by 10.99.136.73 with SMTP id l70mr23834315pgd.49.1524652704400; Wed, 25 Apr 2018 03:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524652704; cv=none; d=google.com; s=arc-20160816; b=DrAcAQkB+y/UZdDpm0mOrnWnUF1gvZD3go0bU+6W0LU6Yee43Vy+cwJmgEXBTj5mmw obG3ES07wA92DvEn0A9b0F71pcgBjIAgQVWfM4vyh69B//Ui23UfIo4CZPELuJi4uYpZ Lbfgc7aHML82imGaxAMoolLgRjHPY8/cZgRSuOeYV3g/zrWZInEhznsgh0KLlKc5inDV 4Xt2Ifz9tMekmxiEWLVH3S7hnjLS2E9a9qkSE+U9Ma6SJrvhZcdkK0swX/6dmDgFKepN D5IfTpHXoYB0frGJz2cAyVr0fPGb/C6EGYFsl5d/t8MKUfx3QB4dEf01vY6P4osdfdjv 6qmA== 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=VUwOEjDz6BbNLBtH4EW+hcCA7UX8t05emRV6q7Z2kwQ=; b=I2PTUx46Z7pK8yVdMm3yYJnmyRhpx7uk9XIVhO39L4KckutJq1PARsKg/3S6+QFAjI Z/CcUMkZUdmiEX6gMqjGvwKd7w3NZPVdES1eUiXIMW3q+49qi1PC+pAzCoZOZTe2WC7F lE5ku1vcOAZ9/jflvQ5DAbaXOPukaj7uJx4U1Ue1JlTTdtWnQa1lBZBpBGAbmSOz7wS6 XqFH9xol9EjgiJ/J4BbDznPUKhOf0MUVxgTAnqsCao143NPSpKnTfsfpIVgozwRRQ3hr ow4QGS6BLQwZRoTLl0rVMu34JFlCO/lOAlybZbIdp6FtPtWjojU5wXNevciSbtmRk8f4 B3Ug== 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 d16-v6si4600859pli.176.2018.04.25.03.38.10; Wed, 25 Apr 2018 03:38:24 -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 S1752949AbeDYKg1 (ORCPT + 99 others); Wed, 25 Apr 2018 06:36:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50906 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752431AbeDYKef (ORCPT ); Wed, 25 Apr 2018 06:34:35 -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 8EB2F480; Wed, 25 Apr 2018 10:34:34 +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.16 24/26] perf: Return proper values for user stack errors Date: Wed, 25 Apr 2018 12:33:33 +0200 Message-Id: <20180425103315.809210197@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103314.842517924@linuxfoundation.org> References: <20180425103314.842517924@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.16-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 @@ -9730,9 +9730,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)