From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 961CEC67871 for ; Thu, 27 Oct 2022 06:48:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234484AbiJ0GsZ (ORCPT ); Thu, 27 Oct 2022 02:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234457AbiJ0GsY (ORCPT ); Thu, 27 Oct 2022 02:48:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37B98148FE4; Wed, 26 Oct 2022 23:48:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D0D40621A6; Thu, 27 Oct 2022 06:48:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD611C433C1; Thu, 27 Oct 2022 06:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666853302; bh=WfnvbZ0ZCG3kuH4jEsDaJ1/vqilkTKeoMzcOu0I4SPs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Kysx0dc6L/J0j3nGVVM2jJFOtqJIRbGQx5Y3yxQpNzm7DLQpaQQZjKTg4Iv01dVxS ALAPc63FhXCIsLFO3+dSkJEfWZwktJpfSSygdudzkl2vgFq6o4YbPdQAIrSqkj22Cu d2S2Dr8xeqVfH7UfulHYlNpfKSyx9LYqSRuGJzko= Date: Thu, 27 Oct 2022 08:49:15 +0200 From: Greg Kroah-Hartman To: Kees Cook Cc: "Eric W. Biederman" , David Howells , Luis Chamberlain , Russ Weight , "Rafael J. Wysocki" , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Namjae Jeon , Sergey Senozhatsky , Trond Myklebust , Anna Schumaker , Chuck Lever , Jeff Layton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal =?iso-8859-1?Q?Koutn=FD?= , Peter Zijlstra , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] cred: Do not default to init_cred in prepare_kernel_cred() Message-ID: References: <20221026232943.never.775-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221026232943.never.775-kees@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org On Wed, Oct 26, 2022 at 04:31:11PM -0700, Kees Cook wrote: > A common exploit pattern for ROP attacks is to abuse prepare_kernel_cred() > in order to construct escalated privileges[1]. Instead of providing a > short-hand argument (NULL) to the "daemon" argument to indicate using > init_cred as the base cred, require that "daemon" is always set to > an actual task. Replace all existing callers that were passing NULL > with &init_task. > > Future attacks will need to have sufficiently powerful read/write > primitives to have found an appropriately privileged task and written it > to the ROP stack as an argument to succeed, which is similarly difficult > to the prior effort needed to escalate privileges before struct cred > existed: locate the current cred and overwrite the uid member. > > This has the added benefit of meaning that prepare_kernel_cred() can no > longer exceed the privileges of the init task, which may have changed from > the original init_cred (e.g. dropping capabilities from the bounding set). > > [1] https://google.com/search?q=commit_creds(prepare_kernel_cred(0)) > > Cc: "Eric W. Biederman" > Cc: David Howells > Cc: Luis Chamberlain > Cc: Russ Weight > Cc: Greg Kroah-Hartman > Cc: "Rafael J. Wysocki" > Cc: Steve French > Cc: Paulo Alcantara > Cc: Ronnie Sahlberg > Cc: Shyam Prasad N > Cc: Tom Talpey > Cc: Namjae Jeon > Cc: Sergey Senozhatsky > Cc: Trond Myklebust > Cc: Anna Schumaker > Cc: Chuck Lever > Cc: Jeff Layton > Cc: "David S. Miller" > Cc: Eric Dumazet > Cc: Jakub Kicinski > Cc: Paolo Abeni > Cc: "Michal Koutný" > Cc: Peter Zijlstra > Cc: linux-cifs@vger.kernel.org > Cc: samba-technical@lists.samba.org > Cc: linux-nfs@vger.kernel.org > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook Acked-by: Greg Kroah-Hartman