From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 8D3111B86C7 for ; Sun, 23 Nov 2025 18:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923973; cv=none; b=gP6UmfDuTNcEBxduBF4ZjDROMUBpjTTk+cLgfi/GJHz88TPucB0xcBSzc2ZBVxtiV3GI7TQWLNjeUKBnWuJ9ioXmKuFungwfzs7I7WNLR2uZpHroep63VNltPEIhCahmvoSKR9aPRWCe9bDVn2zPeO3i07Rve/wwCB5NoFA9F7g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923973; c=relaxed/simple; bh=zMI/uUxdGqoTLXglneizXg85ZqwmhQ1CImBk1AOYyEE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YxNSv6sjFIiIOjzrupV1RHZMWdmG0QnVKB/mH3Vl6VFfkz2TRpnETL+V3tbitjQ2cetfwp2h61tAOyVS+2A4zuI0AXCAh4vhzCFrFKDfFeNxuph4ljSwhKHFCiYkw1cKPIJBkbRV3fA+cRPX5OaFgHCJxJHCVC+d9mEWXDKpcZM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ewz4rxe5; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ewz4rxe5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763923970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ujJPTxD9bpRdC30uSmxe6b2EMxZkMuLoEavNYh4TQJ0=; b=Ewz4rxe5FL6sKGMF8l85eZTAgY+Br3eZr03L+8sBJTTijiTvaGf2Z5OCxX2IZMKqYqCym4 ExQBgWqfGNODfxtRPfLbBP3jpYTN91aOw4hxh9S3zrfiNAOWZzMGLxAsq52Ut/ciiOhisW uD6qlAOtG5b7yi2fTvNpyTDAunC6ePQ= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-390-bNUrHqDOMnaEBK-yTndlnQ-1; Sun, 23 Nov 2025 13:52:46 -0500 X-MC-Unique: bNUrHqDOMnaEBK-yTndlnQ-1 X-Mimecast-MFC-AGG-ID: bNUrHqDOMnaEBK-yTndlnQ_1763923962 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8F86D1800451; Sun, 23 Nov 2025 18:52:39 +0000 (UTC) Received: from fedora (unknown [10.44.32.8]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id BD6E219560A7; Sun, 23 Nov 2025 18:52:21 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 23 Nov 2025 19:52:39 +0100 (CET) Date: Sun, 23 Nov 2025 19:52:20 +0100 From: Oleg Nesterov To: "Eric W. Biederman" Cc: Bernd Edlinger , Alexander Viro , Alexey Dobriyan , Kees Cook , Andy Lutomirski , Will Drewry , Christian Brauner , Andrew Morton , Michal Hocko , Serge Hallyn , James Morris , Randy Dunlap , Suren Baghdasaryan , Yafang Shao , Helge Deller , Adrian Reber , Thomas Gleixner , Jens Axboe , Alexei Starovoitov , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, tiozhang , Luis Chamberlain , "Paulo Alcantara (SUSE)" , Sergey Senozhatsky , Frederic Weisbecker , YueHaibing , Paul Moore , Aleksa Sarai , Stefan Roesch , Chao Yu , xu xin , Jeff Layton , Jan Kara , David Hildenbrand , Dave Chinner , Shuah Khan , Elena Reshetova , David Windsor , Mateusz Guzik , Ard Biesheuvel , "Joel Fernandes (Google)" , "Matthew Wilcox (Oracle)" , Hans Liljestrand , Penglei Jiang , Lorenzo Stoakes , Adrian Ratiu , Ingo Molnar , "Peter Zijlstra (Intel)" , Cyrill Gorcunov , Eric Dumazet Subject: Re: [RFC][PATCH] exec: Move cred computation under exec_update_lock Message-ID: References: <87tsyozqdu.fsf@email.froward.int.ebiederm.org> <87wm3ky5n9.fsf@email.froward.int.ebiederm.org> <87h5uoxw06.fsf_-_@email.froward.int.ebiederm.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87h5uoxw06.fsf_-_@email.froward.int.ebiederm.org> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Eric, sorry for delay, I am on PTO, didn't read emails this week... On 11/20, Eric W. Biederman wrote: > > Instead of computing the new cred before we pass the point of no > return compute the new cred just before we use it. > > This allows the removal of fs_struct->in_exec and cred_guard_mutex. > > I am not certain why we wanted to compute the cred for the new > executable so early. Perhaps I missed something but I did not see any > common errors being signaled. So I don't think we loose anything by > computing the new cred later. > > We gain a lot. Yes. I LIKE your approach after a quick glance. And I swear, I thought about it too ;) But is it correct? I don't know. I'll try to actually read your patch next week (I am on PTO untill the end of November), but I am not sure I can provide a valuable feedback. One "obvious" problem is that, after this patch, the execing process can crash in a case when currently exec() returns an error... Oleg.