Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1029475pxb; Wed, 15 Sep 2021 20:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzdOrpY3WrfryPzKu4zkUPrd+1nRh0W+rOgfoQf5AktpS8spxZyXsUw38MXO2//PLEp9Hp X-Received: by 2002:a6b:e70f:: with SMTP id b15mr2655245ioh.140.1631762628572; Wed, 15 Sep 2021 20:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631762628; cv=none; d=google.com; s=arc-20160816; b=FaeGS98pPRAtGEccwiOTv7GxV5LyM37exQLCxwY78F2xh3YKmRX3Axg9wPdiN/AnfN LF3oP0ioAKAC+XcILePbxDyh2Fb1y+gUtWAwbfdJ7XRldBSBVHnCLDgHGDrXEDpwa4gv +4BMjXIjxVhyraNDo4FXrRehSI5yqio0/kc9qbwdo/aJm+vAfFOzFuc4N1r2KOeMgaDI M8CGui+VstMto/McQs7BfyIKE1OeMuEcHiWu2Dxa1E8hiQbBLzUzCAriWcxSRPos2EZR UCzudzXYAqtqDQ6eFXWC5cqvIv+ohMompucQf4TjWUYR/JeHoGuvwWXlcWWUUKc7EYi5 AWsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=SmlyKip1Am3NFWi/fvDbDVN2qzAP/RWS3QTbVHDWgOg=; b=UtDfx+jy5AMeSuh6U8NrYljhZVTF9jFU+VgNqksoG79ZJgfH5TH5Pq50tKloT/odIY m7hJX96IHUrybqnLfXeKfN4gxXqMPe9sjoD8uwH3ua1k7aLk+M7W71lfbKkhXJCqcc9J sYIoy6Zkpud1rmqVhNbgDFDYvVb7+rfFzkagRJA8FGf1ijSRvh5M27VbaZNpKhsgoSLp XXrjz8eDmBbmW1cfnKQf1L90Gx5bRw9aiwxRQHSyuokQhSI4qmDMkB+c6xZD4gCXIjZv e8GAGmn4/gorclDp5Uw3bs0An/UOKIbZarPTjF82lpETA2FEatZ+ysKEmLKBr9Ii6sCd bwpg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k3si1641246ilh.76.2021.09.15.20.23.35; Wed, 15 Sep 2021 20:23:48 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234132AbhIPDWq (ORCPT + 99 others); Wed, 15 Sep 2021 23:22:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234037AbhIPDWp (ORCPT ); Wed, 15 Sep 2021 23:22:45 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A28BC061574; Wed, 15 Sep 2021 20:21:23 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQhxh-004a4S-9q; Thu, 16 Sep 2021 03:21:21 +0000 Date: Thu, 16 Sep 2021 03:21:21 +0000 From: Al Viro To: Michael Schmitz Cc: linux-m68k@lists.linux-m68k.org, Geert Uytterhoeven , Greg Ungerer , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] m68k: leave stack mangling to asm wrapper of sigreturn() Message-ID: References: <08183665-f846-0c5e-a8c7-d0a65e78a3da@gmail.com> <48dafad1-4f0c-4ab7-792c-b34a81d26799@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48dafad1-4f0c-4ab7-792c-b34a81d26799@gmail.com> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 16, 2021 at 12:53:53PM +1200, Michael Schmitz wrote: > > You'd need to > > * load the frame type from sigcontext (and deal with EFAULT, etc.) > > * make decision based on that > > * pass the type down into sigreturn(), so we wouldn't run into > > mismatches. > > > > And all that just to avoid a single "subtract a constant from stack pointer" > > insn. We are on a very shallow kernel stack here - it's a syscall entry, > > after all. And the stack footprint of do_sigreturn() is fairly small - e.g. > > stat(2) eats a lot more. > > Thanks, that's what I was wondering. Not worth the extra complexity then. > > > > > We are not initializing the gap either - it's just reserved on stack; we only > > access it if we need to enlarge the stack frame. > > > > IOW, what would be the benefit of trying to avoid unconditional gap there? > > Avoiding a kernel stack overflow - there are comments in the code that warn > against that, but those may be largely historic... This is syscall entry; moreover, it critically relies upon the fixed stack layout - type 0 exception frame + pt_regs + switch_stack + (now) gap. Followed by fairly shallow C call chain. I suspect that the deepest you can get there is when you get an unmapped page when reading the sigframe and go into page fault handling, with call chain going into some filesystem's ->readpage(). If it was that close to stack overflow, we'd see them all the time in e.g. random net ioctl doing copy_from_user() - that's going to be deeper. Or in stat(2), for that matter.