Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4647290rwd; Tue, 23 May 2023 10:20:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PKHFAjSdVnWJX6g5d0Up1pLSTWBEdWBuroZkDjeSVIPHUPBlw2W6XpGMbdzzoTzamIJXa X-Received: by 2002:a17:902:7009:b0:1ac:5717:fd5 with SMTP id y9-20020a170902700900b001ac57170fd5mr13064847plk.60.1684862459241; Tue, 23 May 2023 10:20:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684862459; cv=none; d=google.com; s=arc-20160816; b=NFMsoAnbDKQQQREfAstmIYIvSppRYWTwcVXCcoew5M1S89JK7XyxJhyL5cxOA9k3Sy eaLSrgcwh6eAwnR6CMWSFC/wjs7IkAIpxHwJRPQnfjk0RsNk6Ur4Mg3YXpl/hNMirbPx MkZtgTwlrgkrXsCz8dw9pJW3SYnEvC2vtdX5vYjp3nI4/684R/W9IjSWle1nSSsdJ5rY gITAJedhu5gAwk8E06efuupJyxJ7H+WnMPSDatz26Aq2dUUXFq75m3qnGv9GIcerl2w9 7UqgbOm4Rj0pMAhxao8nzxeTYxelz4UuOJ7KQ7C9S1573TdTD1tDhljcBME6my7eAiB2 e/3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LD/AHmnjp0NpxhS4p9Yvs385A6w+BDeBdMrso5+Dd0Q=; b=yabhfdgqzyxpEeQssBTvJ9H7eHjxVLin47SgfBnNMqWW1AJ4gYA7yiCQC5KNwdPFPK gmbfgZcGbfhuTYEE1GFxD/TyACQTpZSc3NouRBiQsy3X8X/1Y810gfUxHD3qHg4V0UUu HEFoffyAK8tEUUfMXNtNzfYf5JV3vamuDkCGro9GEWz9951JkD2fSpdTdNYmpqjFvSJE ZCFgYDbW0fO/nK8QenYpuFe7bcXOe6e90sKlvl6XPnq/j9/NZaiN0RAncgsFwCf6suWs DhboA+FHoYb5Zv8S80e34rpZ4Ehzol2c+GvyGn6FShs0h0kZ6QZbSsmyK6uGJeuVZLcv M0eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lzYLf2Qh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ja1-20020a170902efc100b001ac6430f68csi2767624plb.96.2023.05.23.10.20.46; Tue, 23 May 2023 10:20:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lzYLf2Qh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237928AbjEWRC3 (ORCPT + 99 others); Tue, 23 May 2023 13:02:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237938AbjEWRCX (ORCPT ); Tue, 23 May 2023 13:02:23 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C70A7132 for ; Tue, 23 May 2023 10:02:19 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1a516fb6523so69321725ad.3 for ; Tue, 23 May 2023 10:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684861339; x=1687453339; 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=LD/AHmnjp0NpxhS4p9Yvs385A6w+BDeBdMrso5+Dd0Q=; b=lzYLf2QhhI3UYhDz/x7zeHwaOXZjxjX8RJUlSR/iSQkPre1BbQqZhNaRDgEu4WxPpP WNcoECD735LmNk3jkktPP1QBpuInwgX0QeDE+Je8kuS96RaNEoN22PMzB0jQKtPJ45VK TC6KZnWUWzT8p80Ad1hgSWEZcepO1zypQ1sME= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684861339; x=1687453339; 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=LD/AHmnjp0NpxhS4p9Yvs385A6w+BDeBdMrso5+Dd0Q=; b=cBv1ngSYHVPvmLuoLUGjcFpu2nwUO4YYTg8h4Q4UrukhqHhDQSYp4pqPnGFcwd/4Ra gK8GRJT/zzvmg1wxijaXMlAzmcDjv/zixC/ZzbbX/U/0hN+Pr1GS5kGiBcWt0roijZst 1dq5RKW0btkwY0CignJe4Jb4Pe7r9i5MJ50oMHISx5TQih3BMSZf3rGVMIONtx1f9eBJ lTK/O9MNgh1sIV8hpAcWfIAs/OZni6CxdFBKuj3k2HYn96CwjbFnrdaUrT6EIFjsUrwe ePhYVSZsU49vnjq1s/cyU1CpQFRxuicD4AoBcaLDBOJMVB1MztcgsGyUwngI5k/NFV+F oBCA== X-Gm-Message-State: AC+VfDywoyJxADnh42Fs4c4ityFdLzsvp0S42q/UuY/x6Qufs1KUHEoV aWogIO64+iqLcJ7qa8yo8Q6aGw== X-Received: by 2002:a17:902:f815:b0:1ac:aaf6:ee3a with SMTP id ix21-20020a170902f81500b001acaaf6ee3amr13420526plb.32.1684861339266; Tue, 23 May 2023 10:02:19 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id r6-20020a170902be0600b001aafde15ff3sm6960489pls.293.2023.05.23.10.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 10:02:18 -0700 (PDT) Date: Tue, 23 May 2023 10:02:17 -0700 From: Kees Cook To: David Hildenbrand Cc: Lorenzo Stoakes , Vlastimil Babka , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-hardening@vger.kernel.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/slab: remove HAVE_HARDENED_USERCOPY_ALLOCATOR Message-ID: <202305231001.08BC6058@keescook> References: <20230523073136.4900-1-vbabka@suse.cz> <310077ed-6f3f-41fe-afcf-36500a9408ec@lucifer.local> <623a87c6-c0d2-799a-c39e-0d14dcdfa6df@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 23, 2023 at 10:14:24AM +0200, David Hildenbrand wrote: > On 23.05.23 09:56, Lorenzo Stoakes wrote: > > On Tue, May 23, 2023 at 09:46:46AM +0200, Vlastimil Babka wrote: > > > On 5/23/23 09:42, Lorenzo Stoakes wrote: > > > > On Tue, May 23, 2023 at 09:31:36AM +0200, Vlastimil Babka wrote: > > > > > With SLOB removed, both remaining allocators support hardened usercopy, > > > > > so remove the config and associated #ifdef. > > > > > > > > > > Signed-off-by: Vlastimil Babka > > > > > --- > > > > > mm/Kconfig | 2 -- > > > > > mm/slab.h | 9 --------- > > > > > security/Kconfig | 8 -------- > > > > > 3 files changed, 19 deletions(-) > > > > > > > > > > diff --git a/mm/Kconfig b/mm/Kconfig > > > > > index 7672a22647b4..041f0da42f2b 100644 > > > > > --- a/mm/Kconfig > > > > > +++ b/mm/Kconfig > > > > > @@ -221,7 +221,6 @@ choice > > > > > config SLAB > > > > > bool "SLAB" > > > > > depends on !PREEMPT_RT > > > > > - select HAVE_HARDENED_USERCOPY_ALLOCATOR > > > > > help > > > > > The regular slab allocator that is established and known to work > > > > > well in all environments. It organizes cache hot objects in > > > > > @@ -229,7 +228,6 @@ config SLAB > > > > > > > > > > config SLUB > > > > > bool "SLUB (Unqueued Allocator)" > > > > > - select HAVE_HARDENED_USERCOPY_ALLOCATOR > > > > > help > > > > > SLUB is a slab allocator that minimizes cache line usage > > > > > instead of managing queues of cached objects (SLAB approach). > > > > > diff --git a/mm/slab.h b/mm/slab.h > > > > > index f01ac256a8f5..695ef96b4b5b 100644 > > > > > --- a/mm/slab.h > > > > > +++ b/mm/slab.h > > > > > @@ -832,17 +832,8 @@ struct kmem_obj_info { > > > > > void __kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct slab *slab); > > > > > #endif > > > > > > > > > > -#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR > > > > > void __check_heap_object(const void *ptr, unsigned long n, > > > > > const struct slab *slab, bool to_user); > > > > > -#else > > > > > -static inline > > > > > -void __check_heap_object(const void *ptr, unsigned long n, > > > > > - const struct slab *slab, bool to_user) > > > > > -{ > > > > > -} > > > > > -#endif > > > > > > > > Hm, this is still defined in slab.c/slub.c and invoked in usercopy.c, do we > > > > not want the prototype? > > > > > > Well I didn't delete the prototype, just the ifdef/else around, so now it's > > > there unconditionally. > > > > > > > Perhaps replacing with #ifdef > > > > CONFIG_HARDENED_USERCOPY instead? I may be missing something here :) > > > > > > Putting it under that #ifdef would work and match that the implementations > > > of that function are under that same ifdef, but maybe it's unnecessary noise > > > in the header? > > > > > > > Yeah my brain inserted extra '-'s there, sorry! > > > > Given we only define __check_heap_object() in sl[au]b.c if > > CONFIG_HARDENED_USERCOPY wouldn't we need to keep the empty version around > > if !CONFIG_HARDENED_USERCOPY since check_heap_object() appears to be called > > unconditionally? > > > > The file is only compiled with CONFIG_HARDENED_USERCOPY: > > mm/Makefile:obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o Right. > Reviewed-by: David Hildenbrand Thanks! Reviewed-by: Kees Cook -- Kees Cook