Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2056529pxb; Mon, 12 Apr 2021 13:10:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsNyBqsRfwJ82VbViCsAnNMPB64ymdUfg6z1QYjT5GtNCJVdZszX/J/3Vsd6QnZoFgNTlf X-Received: by 2002:a63:1d41:: with SMTP id d1mr27398534pgm.135.1618258214831; Mon, 12 Apr 2021 13:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618258214; cv=none; d=google.com; s=arc-20160816; b=b5dFhF7qo8WnwhIiAxtZI5AavwrP0KX+8rkOHo13qYw3ygoG3bFy7nuJwp66vhb4yf SK9F+telJyCbXcThur0L7LLASjIvIJy9FXCCUIthsE1XrbjlvM5fNzF3cGGX9I81EmO+ qD7QBSl+AaX9/tfOkfwfZJ3z9JzPrVJ0GcAXs3os32dmAjK7JtCAuNR3c1poi8ZAHlTn dNDa3Azv79OQPRirFsZhlhZ+hUGqMudNLADwlWXT5pflxn4OpT9qMSgUibb44DC9qjB9 Nn/PqydudVuQxG1YfYAm+LWFkiBVntdlgtpPgIlhgs6d/m8drwJQjVxvaueTp35P+7j5 45Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d1gCf5G+Yr81S23BG+V0csgL9KT5JASvQeaD9J7qwmU=; b=JKL9VBfsZXhwcxtYS648NW6G/b4hKn9wFoHrhhByYYC0K/F26BJja2J2ZqBOIDB6sq XaKWUrn66ITAgZL+jye7yjrBjCnUYdz/gJPcazj0GrVSjyClfXMPRqCs7vW5y9jf4HVL Ydd+JJ99gt37Mazv7YP+eOOaa2sgibBjcUAl3p40mwa29VcWkikXTWH2ObKV4N9l0Oc9 5e/FdAxVFNPFBqhJ8GHL8SzY4Qa2epyf5n/vEJsUJ7oEq88x9LlrcWN8J2/ArpVdP4Bz 2J45YjZshHkVHzvKSiJneWJYBSbDAG8iOzYCMtsWjDB9bKR+CCJqHlyAbQkPkWP0H7GG QDOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZLI7Y5Yl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si400813plf.175.2021.04.12.13.10.02; Mon, 12 Apr 2021 13:10:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZLI7Y5Yl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238521AbhDLIuA (ORCPT + 99 others); Mon, 12 Apr 2021 04:50:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:39950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237987AbhDLIrB (ORCPT ); Mon, 12 Apr 2021 04:47:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 66CF9611F0; Mon, 12 Apr 2021 08:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217204; bh=/8jUO7xkaKdefi2LengujBqKyVbjMEW34qTtLHTxNCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZLI7Y5YlZ0mUPagQR+KdmKqpti+YjClTSs3aYcwK3KnU5ivXXjTW96ofH0FjJvSoz sMyQ1AWxjv/Fd5xjG7IkKmBwFLJ4H37RmLm13VyJ6jxJ2CMVoL96nPyyMPFt+oWMPn su1YMGwTuuMcPhXM0cEzzdediQ9eyDR/74Uk8srU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergei Trofimovich , "Dmitry V. Levin" , Oleg Nesterov , Andrew Morton , Linus Torvalds Subject: [PATCH 5.4 014/111] ia64: fix user_stack_pointer() for ptrace() Date: Mon, 12 Apr 2021 10:39:52 +0200 Message-Id: <20210412084004.699559937@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084004.200986670@linuxfoundation.org> References: <20210412084004.200986670@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sergei Trofimovich commit 7ad1e366167837daeb93d0bacb57dee820b0b898 upstream. ia64 has two stacks: - memory stack (or stack), pointed at by by r12 - register backing store (register stack), pointed at by ar.bsp/ar.bspstore with complications around dirty register frame on CPU. In [1] Dmitry noticed that PTRACE_GET_SYSCALL_INFO returns the register stack instead memory stack. The bug comes from the fact that user_stack_pointer() and current_user_stack_pointer() don't return the same register: ulong user_stack_pointer(struct pt_regs *regs) { return regs->ar_bspstore; } #define current_user_stack_pointer() (current_pt_regs()->r12) The change gets both back in sync. I think ptrace(PTRACE_GET_SYSCALL_INFO) is the only affected user by this bug on ia64. The change fixes 'rt_sigreturn.gen.test' strace test where it was observed initially. Link: https://bugs.gentoo.org/769614 [1] Link: https://lkml.kernel.org/r/20210331084447.2561532-1-slyfox@gentoo.org Signed-off-by: Sergei Trofimovich Reported-by: Dmitry V. Levin Cc: Oleg Nesterov Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- arch/ia64/include/asm/ptrace.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) --- a/arch/ia64/include/asm/ptrace.h +++ b/arch/ia64/include/asm/ptrace.h @@ -54,8 +54,7 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs) { - /* FIXME: should this be bspstore + nr_dirty regs? */ - return regs->ar_bspstore; + return regs->r12; } static inline int is_syscall_success(struct pt_regs *regs) @@ -79,11 +78,6 @@ static inline long regs_return_value(str unsigned long __ip = instruction_pointer(regs); \ (__ip & ~3UL) + ((__ip & 3UL) << 2); \ }) -/* - * Why not default? Because user_stack_pointer() on ia64 gives register - * stack backing store instead... - */ -#define current_user_stack_pointer() (current_pt_regs()->r12) /* given a pointer to a task_struct, return the user's pt_regs */ # define task_pt_regs(t) (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1)