Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5111428ybc; Tue, 26 Nov 2019 21:47:59 -0800 (PST) X-Google-Smtp-Source: APXvYqxlvyP59vK5dMvCTGYqOUraXvw4UH5pQOOsOxzfGfTgJWHnZJ/KwQk7EnhwO0kJYWZaFQ1v X-Received: by 2002:a50:fc18:: with SMTP id i24mr29847121edr.41.1574833679106; Tue, 26 Nov 2019 21:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574833679; cv=none; d=google.com; s=arc-20160816; b=tA/ckYvNw8E1LGndp29iyL+OlZuj9kYNaFX0BUys7V68HmkbhFMVeb+s/4zQsusm9N 0MgoVFGk3HOzNcJYs+++RuXBp6tmY/xxetQgEbP5hLkJ75/XauuJ49n0TbFt4pe23bS3 EF30N/puaPAH0Z8kOXo94tNLejnBU/YoZHFXo5+wNC26sas95COTS2js9CPFG/DF/ACd ikrUABXo6JuoQKUUwQZQoDrj9UM8UHcnUGfZB0sZTn5cW8n5A72rmawseEVSBcyoXDbT G0ttdDk/cshBvSozpXJ5b14RxmI3YNn8EZcJ8e0nb2McPLwtXqEbPQYbIQ9w5twJnnRa JPIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rRwoirEH8PPNILMMjUuQ4sYs5WPR43X6ZVOc4Xwz1E8=; b=yYxuXpyifuuzke8RIgWwvu6rhYZURwNFB9rbAjPYOVc40AeC1PJ7cJ2C4yag3zY5Gp +JW/jfLS5bmwa8EQKaPrmT9T+8ygd4EyoTuRs2UCo7p/xk8HiuARp99yaQOGDSdkd2P0 EtuPnOkqjcmG0y4Dy9ExE1s2gquTPrJ5SMnoB9p6HP+/XKAASfJMTbLLpWtlVV60KBWg 6lqHONmxGf/J2iYTJ2sB0wY3vCIlFEaT6Wa2Pn0wfecX0EgvClHFUW4MsiahDBZ/Y3Dw qkjfundyxodjmbMXJMJxXZa2JadN2NaFwz67rU7rUdpg/m/m0d6251Fm2GJYGieAPHky alJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AdSr0gQG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z17si2853729edr.229.2019.11.26.21.47.34; Tue, 26 Nov 2019 21:47:59 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=AdSr0gQG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726470AbfK0Fq2 (ORCPT + 99 others); Wed, 27 Nov 2019 00:46:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:51864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726061AbfK0Fq2 (ORCPT ); Wed, 27 Nov 2019 00:46:28 -0500 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5C5A42084B for ; Wed, 27 Nov 2019 05:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574833587; bh=oQiJiVUECmkuTnAwoFBoV84O+kVtT61Ej5+OnFy1dCE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=AdSr0gQG7P2SKzLEN+rfnH5OX5yxQl7ZNqSPcZS0qv8blSgjhoGKGytjWliG9hG0I BKYSfGjRJswjxMs4hf/tLG52dDMGYwUHYBgZmow+Gboo5alx+gBtvDl0e0e8xVsA2x 4yEC3W2XJmRYDRgpPYN9NpIoG3KwZfE9TrVMY+1E= Received: by mail-wm1-f47.google.com with SMTP id g206so5681873wme.1 for ; Tue, 26 Nov 2019 21:46:27 -0800 (PST) X-Gm-Message-State: APjAAAV4KLN/f5LyNe5R+hSNjtFsaQaGBL5pPCivLQ51ywRz4fntqZK6 CzdUr2U3v/5XK3+9OMcDBtD6upOaPXMzfPARDCQe4w== X-Received: by 2002:a1c:1f8d:: with SMTP id f135mr2394132wmf.79.1574833585808; Tue, 26 Nov 2019 21:46:25 -0800 (PST) MIME-Version: 1.0 References: <20191126110659.GA14042@redhat.com> <20191126110758.GA14051@redhat.com> In-Reply-To: From: Andy Lutomirski Date: Tue, 26 Nov 2019 21:46:14 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ptrace/x86: introduce TS_COMPAT_RESTART to fix get_nr_restart_syscall() To: Linus Torvalds Cc: Oleg Nesterov , Andrew Morton , Andy Lutomirski , Borislav Petkov , Ingo Molnar , Jan Kratochvil , Pedro Alves , Peter Anvin , Thomas Gleixner , Linux Kernel Mailing List , "the arch/x86 maintainers" 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 On Tue, Nov 26, 2019 at 8:04 PM Linus Torvalds wrote: > > On Tue, Nov 26, 2019 at 3:08 AM Oleg Nesterov wrote: > > > > Alternatively we could add ->compat_restart into struct restart_block, > > logically this is the same thing. > > That sounds like the better model to me. That's what the restart_block > is about: it's supposed to contain the restart information. > > I'd much rather see the system call number added into the restart > block (or just the "compat bit" - but we have that X32 case too, so > why not put it all there). And then the get_nr_restart_syscall() hack > goes away and is just "set state from the restart block". > > How painful would that be? I guess right now we always just set all > the restart_block info manually in all the restart cases, and that > could make it a bit painful to add this kind of architecture-specific > flag, but it _sounds_ conceptually like the right thing to do. How about we rename restart_block::fn to __fn, add fields restart_syscall_nr and restart_syscall_arch, and do: long restart_block_activate(long (*fn)(struct restart_block *)) { current->restart_block.__fn = fn; arch_restart_block_activate(); return -ERESTART_RESTARTBLOCK; current->restart_block.syscall_nr } IMO the ideal solution would be to add a new syscall nr to restart a syscall and make it the same on all architectures. This has unfortunate interactions with seccomp, though. --Andy