Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2082750pxb; Mon, 12 Apr 2021 13:59:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyR2IRwvufFKsx4ZpH+B6GPo5s08ql2NaA6yTxWI4j35VfUwgrqJifHJE09isLrSlHIcar X-Received: by 2002:a17:906:c348:: with SMTP id ci8mr9812858ejb.303.1618261152168; Mon, 12 Apr 2021 13:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618261152; cv=none; d=google.com; s=arc-20160816; b=qntYOx+a1sdmW1VVJKioC/Is9GOoiX51TDc2vbCSWcLoSCNdU25yeECZgPvMxDsa80 zpUK6Wojs6ADo7wElUbNMPQEMHwfKiAakdFwg/xSFy18h4o1yt9DkFpP7GqUlxYu2+gT ZTA5YRPWY8QEQ/z88PHa55BZXRbB8B0yLJegTvzMUnSptsMkCjvLSTm6K8o2dV/8VuFX ih4QJ5D45WtBVl5VsHD+Zku7zWpXWcJZkMyE6OGmSI/xIAQePqJHu/+7kFgMZXgt9uGW WmwKj8KZt4T3gODv5MxzlQywacc62Q1yP0GEPXk1UF6gz2ZCZ40LCGSySYIWptQ2HcM4 SnMw== 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=CXu/bFTXa7XNh0ht8okLyf0dNHuz/WE6IXydA8/tItHToDBB1SKQQHVLZK9nv/7I9q dDQgP/ygnxrvzWlrixKnr8bcj4MtCHhTUmWjV99wmXtMWVS9ESJ4WDnwd13M6C8/ggmX 2zdPdXs9ugR5Q3ZHoeLcOIPjoDHDGZIsmQ0wKjxPglwZ1ZGxNJsNNME8jZ8GHmL5ho0T B7OHzcXEJc3eUkimmyMC6OBU3vwtK7i9cUSu6dpiozhy9q3bNYOr4LNQpU2bqjjik38k JUWfpOfpmJJ0UQ2wM/Qq9eMK40ewib2uXRauvGOZreoL9pGd4LTmBwABiZQD0h6AWRPl w9gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yssCnIYB; 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 w19si8171681edr.83.2021.04.12.13.58.47; Mon, 12 Apr 2021 13:59:12 -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=yssCnIYB; 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 S238852AbhDLJCF (ORCPT + 99 others); Mon, 12 Apr 2021 05:02:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:47812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238529AbhDLIyL (ORCPT ); Mon, 12 Apr 2021 04:54:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 13A6C61368; Mon, 12 Apr 2021 08:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217537; bh=/8jUO7xkaKdefi2LengujBqKyVbjMEW34qTtLHTxNCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yssCnIYBOsb33K4jxu5wXE70V6dN0orygfWukdu/XrHjmWqzxzUU9tQLOM725VC9a sXbxFD9ZUjUE1IkF2nkio4ynHmbaQd3PXpgmSV5D59E9fxnQWJ5yCuLTvQtLTpilp/ XRmkpM88SJuiinZ7qYiDKk5nBiKlMgY7hr+a6j10= 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.10 023/188] ia64: fix user_stack_pointer() for ptrace() Date: Mon, 12 Apr 2021 10:38:57 +0200 Message-Id: <20210412084014.420438665@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084013.643370347@linuxfoundation.org> References: <20210412084013.643370347@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)