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 46C2AECAAA1 for ; Thu, 27 Oct 2022 13:07:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235985AbiJ0NHd (ORCPT ); Thu, 27 Oct 2022 09:07:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236006AbiJ0NH1 (ORCPT ); Thu, 27 Oct 2022 09:07:27 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E34D1799B8 for ; Thu, 27 Oct 2022 06:07:25 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id c15-20020a17090a1d0f00b0021365864446so1398841pjd.4 for ; Thu, 27 Oct 2022 06:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=bA5UIXoeSiPSdpk42SIcKNh5Hs0RGjWIBYmqNZvV8z0=; b=WMK5ErddZ+UAaVGwb6JZd/hV/xL45PeKozs9Y8Ts6Dl5wl6x54N23+uGqZ1KF/inKX lOIqkJkEFXdPaCgyh2+I9CKKgAPy3C6QQKf0OrAYKwXF1akmSsXU/T7s+DaDMjIXac0f P1VQieyooXdBGZPT78rPl5bE5TaCNoldXNwXU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bA5UIXoeSiPSdpk42SIcKNh5Hs0RGjWIBYmqNZvV8z0=; b=l0z22gUDkZc7r6zHzwIzSts1wv9AuqJ8Kfy+5zJdRDQySoRu6Ll1YZ5inmaUWYld97 YDE8U+QYzSEZ62mAfC24JsadIrEgM+z/gs6CHm+Eb77joDG3xFXV23ZqJP5XhgU0RhXX v12I6uzC3UEJgEK6rWmR7VebDNotnQ2rvCA+LSUH/ANvp2Ba9oKmEmP+K7/yGtM7uJA8 sgnSx9wXeqdWaFXiiQs8FbUtQd2OE1dmJdQw+Eq7cDtFX11R5hcYoNZTrYDWfzEUI0rc cGKwBzAiMwNBOJH1TuBFX9Je1t8MirjLhp/77lYoxxEtAVLmmk6DA43uYMlMoKXF1gF+ ugyg== X-Gm-Message-State: ACrzQf31U9XEKFLbaCaRoBFGrOuBSQC443egbaYmZf5JFVjTMTh8BvrY 4HJRBKDRF7e0pfbHkqWUx5q2fw== X-Google-Smtp-Source: AMsMyM6XvKHWZb4CUg/of1JGw7Fw/JFlLofrdFN0ZHBinRybiUgEUdo0acHehvuEcDop9LoIA26AjA== X-Received: by 2002:a17:903:2306:b0:185:43a2:3d1c with SMTP id d6-20020a170903230600b0018543a23d1cmr19357662plh.154.1666876044670; Thu, 27 Oct 2022 06:07:24 -0700 (PDT) Received: from google.com ([240f:75:7537:3187:a253:6b21:b32f:c252]) by smtp.gmail.com with ESMTPSA id x14-20020aa7956e000000b0056265011136sm1138963pfq.112.2022.10.27.06.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 06:07:24 -0700 (PDT) Date: Thu, 27 Oct 2022 22:07:15 +0900 From: Sergey Senozhatsky To: Kees Cook Cc: "Eric W. Biederman" , David Howells , Luis Chamberlain , Russ Weight , Greg Kroah-Hartman , "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=us-ascii Content-Disposition: inline In-Reply-To: <20221026232943.never.775-kees@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On (22/10/26 16:31), 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). Reviewed-by: Sergey Senozhatsky