Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1593782pxb; Mon, 12 Apr 2021 01:45:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuQjZEmznl2ZSxt4kc+M0nK/TZ044hriZWfJM23U/7+8MYyauyEx9V7iEvvrrZIk+0jJMO X-Received: by 2002:a17:90a:4816:: with SMTP id a22mr16578859pjh.132.1618217117248; Mon, 12 Apr 2021 01:45:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618217117; cv=none; d=google.com; s=arc-20160816; b=IMAzrIGhEjVbOMO5CJgse9GBwL07FrqspHwUQSqVS4wupDGn5yIwwBuyoCYlqGaJYz nmeMAE6yiKmKetH9IjM8AewyQ7zgWgQqYM46dZ2+CxV/BFrJQ8xgUyKM7KLo5z2DXWMC VDRH48XG85XZjJy2MnLOT367Mn+gLAsZluE3s32gZHRDv9tbVWxohBL4Zl0Jnyw2B+pj e3xheIhPbF6PiCCzcrbwI4Sfg65pIsOaqs0pe4zwdNuTAVgvM6crPFG1zp36noHHEuGT atjiDsCIcJWZFCXcncQjzaBOb3rafP4ypRipax5d9LPT8MGQbA4HmPyCPn2ZFRvLfX/L nAAA== 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=jCDipa4LzS9jdHooJMA/K+/EkwnaWferjDFcd2YwTx4M9ba6UzbTFmPiP5Mq/phWhd DgvofY+edaCHgvNZzxJo4swbfWqvtXg2WqrQIfogRv7PSW5D/kS3rK9Uct6yz4yHIDx/ ZKVsDCusXiPYoAVhZUbtf4wZaerjJZeei0E8PzAuZyfzLNYj6PZmG7ReVSRefT/9nV2m 2A7erGbDOuIr4ajZEk7/B8VTFwUZtw5Mcnwxbt7bSdzzdcznOMnoPWgU2k9vcIQ2XUbd nZoFlui43TxyQEFI4TBO77DR9xmPVnNYAYbuawuumqLmeesIuPQQMtevV9QPozxXL+v+ QXZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vfVSwQdh; 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 m14si14106994pjq.134.2021.04.12.01.45.05; Mon, 12 Apr 2021 01:45:17 -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=vfVSwQdh; 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 S237337AbhDLIoK (ORCPT + 99 others); Mon, 12 Apr 2021 04:44:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:35556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237554AbhDLInr (ORCPT ); Mon, 12 Apr 2021 04:43:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0F60861241; Mon, 12 Apr 2021 08:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217009; bh=/8jUO7xkaKdefi2LengujBqKyVbjMEW34qTtLHTxNCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vfVSwQdhn2FNIU7eLLLbhFg2KNiDFar/QGQ59+XexVSihnSn3BwVcWfjC8rjdg6Lg 7UOmKjnLvqxWGg5hdacf3c/12vqz7zLw+fE59Yj94JiuBYqPXqDxSTOUwP/PBwnmOQ nOgZrszIDRD5bnAlRzto9SBIgkwpwY8Hi772UGbk= 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 4.19 09/66] ia64: fix user_stack_pointer() for ptrace() Date: Mon, 12 Apr 2021 10:40:15 +0200 Message-Id: <20210412083958.439553951@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412083958.129944265@linuxfoundation.org> References: <20210412083958.129944265@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)