Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2446362yba; Mon, 6 May 2019 06:18:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKnpOuSPLV2oupOLsUd0vQsA8HT7jx3zU0F+T7BhsKWKp3cnctLS8t1GDAYOSL9PNaHrBE X-Received: by 2002:a17:902:56e:: with SMTP id 101mr31740143plf.142.1557148723544; Mon, 06 May 2019 06:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557148723; cv=none; d=google.com; s=arc-20160816; b=RZlwYT1um25JegJInI3TXpthS9h+sL+Em3P8eiE1FCzyUQmtp/rZex/XRjHiYejG8a jOsnHjZApt1Pqh+Q04FIIHrTbVAIivdvy9bedUHfbiv57MQACbvegp1zP07pWdGHn56F r7JUKb+ykzZMKBCOI+zLoVB1h2BWfYZE4oMPUuUYFtiR/btGihluRgKJ6wHcrKI4lzTd QlOIryykRf7uLnbqQgTfYhKkhUqOktUPrqhdnLhFnK/48TlPJLfvbXtx7H25i86VcrJM /xv9pJC2MfuybDtEg+4xxFciaB7DkvxBqkd2xsl7zjtwMtA5KubDFHZDFR8nT8jmtELh Qu5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=KDdxgAUUfnJ+NqBX8gKjA7KmYhCu8kE+VFKtl2K3pqw=; b=U30wdkfcuSyf2FLIw/OVQmSSSfUj1H8tnxZ7Z7rN2fMRg/AbHstcdoGUqkieIc1kCQ iuPUCpnMVgimYVTOTfgDhmQ35VU9P0+lPYQb+hwquFO1TdwaFwdg2BGVwfC+0UOt7DfV H+TBIWF5dzqTpvM3J1j60LyDwC0jbHz2C7d+QqNpMTUjKutKIU0ahgmKA9t8bz5Ecnvl Qgk/CH5DJEd6GJhY0lu9mmQrjijYV+11xqjIb12A3Go1OL3cdgTJs4/wD+ifw+dZ0BLO gbdzmVQq+3yhAWGD0twBADgx2w00LVwSDiLxdlvPf86RX9KDr0pGCGvjMAqBjbidtwkK 3OeA== 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 y24si14644619pga.57.2019.05.06.06.18.27; Mon, 06 May 2019 06:18:43 -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 S1726349AbfEFNRR (ORCPT + 99 others); Mon, 6 May 2019 09:17:17 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:47787 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725813AbfEFNRR (ORCPT ); Mon, 6 May 2019 09:17:17 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 44yNZ20xVWz9s9y; Mon, 6 May 2019 23:17:13 +1000 (AEST) From: Michael Ellerman To: "Dmitry V. Levin" , Andrew Morton Cc: Elvira Khabirova , Eugene Syromyatnikov , Benjamin Herrenschmidt , Paul Mackerras , Oleg Nesterov , Andy Lutomirski , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH linux-next v10 5/7] powerpc: define syscall_get_error() In-Reply-To: <20190415234444.GE9384@altlinux.org> References: <20190415234307.GA9364@altlinux.org> <20190415234444.GE9384@altlinux.org> Date: Mon, 06 May 2019 23:17:12 +1000 Message-ID: <87woj3wwmf.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Dmitry V. Levin" writes: > syscall_get_error() is required to be implemented on this > architecture in addition to already implemented syscall_get_nr(), > syscall_get_arguments(), syscall_get_return_value(), and > syscall_get_arch() functions in order to extend the generic > ptrace API with PTRACE_GET_SYSCALL_INFO request. > > Cc: Michael Ellerman > Cc: Elvira Khabirova > Cc: Eugene Syromyatnikov > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: Oleg Nesterov > Cc: Andy Lutomirski > Cc: linuxppc-dev@lists.ozlabs.org > Signed-off-by: Dmitry V. Levin > --- > > Michael, this patch is waiting for ACK since early December. Sorry, the more I look at our seccomp/ptrace code the more problems I find :/ This change looks OK to me, given it will only be called by your new ptrace API. Acked-by: Michael Ellerman > Notes: > v10: unchanged > v9: unchanged > v8: unchanged > v7: unchanged > v6: unchanged > v5: initial revision > > This change has been tested with > tools/testing/selftests/ptrace/get_syscall_info.c and strace, > so it's correct from PTRACE_GET_SYSCALL_INFO point of view. > > This cast doubts on commit v4.3-rc1~86^2~81 that changed > syscall_set_return_value() in a way that doesn't quite match > syscall_get_error(), but syscall_set_return_value() is out > of scope of this series, so I'll just let you know my concerns. Yeah I think you're right. My commit made it work for seccomp but only on the basis that seccomp calls syscall_set_return_value() and then immediately goes out via the syscall exit path. And only the combination of those gets things into the same state that syscall_get_error() expects. But with the way the code is currently structured if syscall_set_return_value() negated the error value, then the syscall exit path would then store the wrong thing in pt_regs->result. So I think it needs some more work rather than just reverting 1b1a3702a65c. But I think fixing that can be orthogonal to this commit going in as the code does work as it's currently written, the in-between state that syscall_set_return_value() creates via seccomp should not be visible to ptrace. cheers > See also https://lore.kernel.org/lkml/874lbbt3k6.fsf@concordia.ellerman.id.au/ > for more details on powerpc syscall_set_return_value() confusion. > > arch/powerpc/include/asm/syscall.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h > index a048fed0722f..bd9663137d57 100644 > --- a/arch/powerpc/include/asm/syscall.h > +++ b/arch/powerpc/include/asm/syscall.h > @@ -38,6 +38,16 @@ static inline void syscall_rollback(struct task_struct *task, > regs->gpr[3] = regs->orig_gpr3; > } > > +static inline long syscall_get_error(struct task_struct *task, > + struct pt_regs *regs) > +{ > + /* > + * If the system call failed, > + * regs->gpr[3] contains a positive ERRORCODE. > + */ > + return (regs->ccr & 0x10000000UL) ? -regs->gpr[3] : 0; > +} > + > static inline long syscall_get_return_value(struct task_struct *task, > struct pt_regs *regs) > { > -- > ldv