From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D53113FB25; Thu, 23 Nov 2023 16:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YRHhRKo6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C60A2C433CA; Thu, 23 Nov 2023 16:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700757195; bh=SG11iwaP+p3koKgEoIVWXgRVVhH7qW0Y0/2cmw+cMpw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YRHhRKo69OXirFp+Rt89lJzssRTbqTsohTNQcXFTUxdRnQHui3q8TSYSPO8SKrQC/ apsxzb02JH6F8E2/A8Y+mQWA9CSforGzyx14GmG7KtRdXJ7Fwo5ozuYo+xctTezX+6 e4Z/UJVWbDFeJ+rPhV9+qTdkb0dQIV4kJSt7WVlBa/pi5TVSzIOXE77wAvq/ekeZ7Y fR0IriTFRegUMQnRs0pPjjJJoK6QZUFgQN2caRms+YlTkpkK8Xcqkvp6z5rxLi9DZg yQ5mBweHcpFEcaw+ukuWs7hps2RwbRsdWJWFym5IL855bTKNlgyA7iJNkrhXvxnXMP jiPPfmnIZs8Hw== Date: Thu, 23 Nov 2023 17:33:05 +0100 From: Christian Brauner To: Mark Brown Cc: "Rick P. Edgecombe" , Deepak Gupta , Szabolcs Nagy , "H.J. Lu" , Florian Weimer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Shuah Khan , linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , Kees Cook , jannh@google.com, linux-kselftest@vger.kernel.org, linux-api@vger.kernel.org Subject: Re: [PATCH RFT v3 2/5] fork: Add shadow stack support to clone3() Message-ID: <20231123-ausziehen-harpune-d020d47f964c@brauner> References: <20231120-clone3-shadow-stack-v3-0-a7b8ed3e2acc@kernel.org> <20231120-clone3-shadow-stack-v3-2-a7b8ed3e2acc@kernel.org> <20231123-derivate-freikarte-6de8984caf85@brauner> Precedence: bulk X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Thu, Nov 23, 2023 at 12:17:19PM +0000, Mark Brown wrote: > On Thu, Nov 23, 2023 at 11:28:47AM +0100, Christian Brauner wrote: > > On Mon, Nov 20, 2023 at 11:54:30PM +0000, Mark Brown wrote: > > > Any reasonably maximum that should be assumed here? IOW, what happens if > > userspace starts specifying 4G shadow_stack_size with each clone3() call > > for lolz? > > I guess we could impose RLIMIT_STACK? Yeah, that also seems to be what acct_stack_growth() is using. > > > > + } else { > > > + /* > > > + * For CLONE_VFORK the child will share the parents > > > + * shadow stack. Make sure to clear the internal > > > + * tracking of the thread shadow stack so the freeing > > > + * logic run for child knows to leave it alone. > > > + */ > > > + if (clone_flags & CLONE_VFORK) { > > > + shstk->base = 0; > > > + shstk->size = 0; > > > + return 0; > > > + } > > > Why is the CLONE_VFORK handling only necessary if shadow_stack_size is > > unset? In general, a comment or explanation on the interaction between > > CLONE_VFORK and shadow_stack_size would be helpful. > > This is the existing implicit behaviour that clone() has, it's current > ABI for x86. The intent is that if the user has explicitly configured a > shadow stack then we just do whatever they asked us to do, if they So what I'm asking is: if the calling process is suspended until the child exits or exec's does it make sense for the child to even get a shadow stack? I don't know the answer which is why I'm asking.