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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03EF6EB64D8 for ; Thu, 22 Jun 2023 13:56:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AF748D0003; Thu, 22 Jun 2023 09:56:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 85FA88D0001; Thu, 22 Jun 2023 09:56:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 700678D0003; Thu, 22 Jun 2023 09:56:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 60CD38D0001 for ; Thu, 22 Jun 2023 09:56:10 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 06FB8120B6B for ; Thu, 22 Jun 2023 13:56:10 +0000 (UTC) X-FDA: 80930532900.23.F618787 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf29.hostedemail.com (Postfix) with ESMTP id BC7CA12000A for ; Thu, 22 Jun 2023 13:56:06 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=isKr+xSX; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Nsdiw7Qa; spf=pass (imf29.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687442167; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xPaIEngRL3T7x6VRCa5QVWYsxa8/mc85dKX9wqb7yEk=; b=6CUJpjosFl4aLymD0LArwow7gd9DhPmQYwxkURXjwgLA3/grsHTNyAIVyAQLKkIs2cAwrh EhhKYS9R//iu3g1O+pj1EsvqurIWj1thpmUPSae36uSJ7TuE038Rl+DtnLO/N4VnZ8BhQG 57/3lxie69uf6O/QHDZaESt4pXNkFkw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687442167; a=rsa-sha256; cv=none; b=8kZYPUSb9c6oWaMvx6L0Vg7Xrk+9Tc4sMKqvWOMbaiBy19opCC7Gwt51gdFyUQlzIVP+nh JQXy7++oRG2hJ4CQ+6pQKf/hEir6P9aWGQiviI3Q6JurrRMaFTD7t+CFPpaXtbLucbS3md koSedeMsWV0tbL9FYqgEhppWq9r0esQ= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=isKr+xSX; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Nsdiw7Qa; spf=pass (imf29.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 19E9122A8E; Thu, 22 Jun 2023 13:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1687442165; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xPaIEngRL3T7x6VRCa5QVWYsxa8/mc85dKX9wqb7yEk=; b=isKr+xSXffF+dLyPHf9G4AsOkCRvES8RC2VV0vJMT4mbay+1c6BiM0zPqwSSiqg4NxAsY6 ZpctKYnHqkGwrrRGz74i0peP0IYGgYAvXjBUcy544q9KDAVTy+Uenf4JcEbnQ4BNL+cmdr xIKg2aE3Zc1h+bf11l3Wvdy0yT7EzKI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1687442165; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xPaIEngRL3T7x6VRCa5QVWYsxa8/mc85dKX9wqb7yEk=; b=Nsdiw7QaG941AWh+1x0X4FGGyDyQx29Cd10FMOX5WO6OcheI0MpDKySlUP5CJGTPKc7gNf GjS/cZiAvYv2AwBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B29E2132BE; Thu, 22 Jun 2023 13:56:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id A/TeKvRSlGSEDwAAMHmgww (envelope-from ); Thu, 22 Jun 2023 13:56:04 +0000 Message-ID: <3fdc76f0-6c45-c405-0024-d1d69b5bf068@suse.cz> Date: Thu, 22 Jun 2023 15:56:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v3 1/1] Randomized slab caches for kmalloc() To: "GONG, Ruiqi" , Andrew Morton , Joonsoo Kim , David Rientjes , Pekka Enberg , Christoph Lameter , Tejun Heo , Dennis Zhou , Alexander Potapenko , Marco Elver , Kees Cook , Jann Horn Cc: Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Dmitry Vyukov , Alexander Lobakin , Pedro Falcato , Paul Moore , James Morris , "Serge E . Hallyn" , Wang Weiyang , Xiu Jianfeng , linux-mm@kvack.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, gongruiqi1@huawei.com References: <20230616111843.3677378-1-gongruiqi@huaweicloud.com> <20230616111843.3677378-2-gongruiqi@huaweicloud.com> Content-Language: en-US From: Vlastimil Babka In-Reply-To: <20230616111843.3677378-2-gongruiqi@huaweicloud.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: BC7CA12000A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 65uxmkozxp6khmcwzso46qzwjgr1zewm X-HE-Tag: 1687442166-133172 X-HE-Meta: U2FsdGVkX1/Qot9l8NemgoPxXo6/sru23DaY+Arwe96UIddaRYiEcfn6T5VTkG3c3R37cgqFTSzpZOOiEzruBPJuDTFlYYdR4V9IaVxviwIwbyUYyfbXVC8sPytATbub7eHyMhdAYjCpjEZzWBh054IpZNRcFg0HXN7xFVMzpsWVNWWIcLWmtw5Zi6tJHr/2Jt8YEPDp66HQizYqO8R7rHfycAV15RTbPEPxwyyPhGCc72DdAxkppIcSAs6zBfPZ4nBaEsCE/cNx/J9HF1HLsliRY8N4OHY4ImZ4EM+4/aePS4G/QgBYWHi1lc7oPXCGcEcx0t0GFaTsg8av6KXcAUjv980pqywb002ciLjsAhEGMeMay79Qgv8F+fE6WElovmLz+0HlfnOi2Ha3wWRt8czQMbWAgd089kobPAZRcBYqPTF2qPEIj9p6dofIvI0D4+yWL6jKvh3kepHYVMe1vXvYmz2DhpNC7KrhyjBomcCLi1WyhNEcCDoInDp9+vAJhre0JpuSQJWmq0NxiaoHJxDHZxYc1uutobnSTKbRRbNzDqk3oRlAIFKqkvlvJ+rMNsaSNTIcM8Q0Gx9Qq3YoxDkn+HdXtSDZfPEGnnqtzDa3yll/BO2POv0QXqCE2O0Z+1Ya9tnTr68LhKN4zqRhPilwxSCfqcrwyfZLLKbB7NDafnWgXFAEcfJVJo67R5r2yxzjfDKmqNODKaydXxlRIYUgmZioN6Rpv2oAmTUoi/zLym9SFK+VjWHnakAVqwsqtY7/zFeS3fOK1uZ0jb2rWqsHk7EXDt0DAveteqeprLpkjUVbrMPNcDyYGdUlozmOECAmLCQ70gmgqJyw/K1bNHChbSjuCt/rZTcQnFB74B5EZp0+ewmA6AisXGr5yb1sd36WOsN0bt2TJHgnIYF983+Q8t7FPYGhbG0tAjfIo5H3FgkFHwANAoSMdVewzK7d3tQePnE80+kMQ4K+YIx 8+MhGRN6 ouG/rqcoPHU5Vmxvu+3MpneVzwjyseDfi9Pn8uyZWeFDvIIaFkfrSLkLiQrhjxqNJs7Jn1EWF/8/iWdnHdIGh2Ff41XLtExF84OJfHF8ZXQdGoJPgdwz3SkRsDBOI/y+aJhoZmgVUD1wrzkr3PlYs+rQebJH7OPvjHGlHNWFnP+Qci1yMeS/1mrI8c88U0l0CwJGzCXmgCp+WO9FdOUn825wOqwJFxoiRnCagbw1kK+6c59DKzQpzX00jS9jHdoyky4iBN0MHapCnNvZALVG4jtTIkIIcCz4uOTTl9PJ0fCL7UuLiakSFYUpL3MN4V7k+2xZm X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 6/16/23 13:18, GONG, Ruiqi wrote: > index a3c95338cd3a..6150e9a946a7 100644 > --- a/mm/Kconfig > +++ b/mm/Kconfig > @@ -337,6 +337,55 @@ config SLUB_CPU_PARTIAL > which requires the taking of locks that may cause latency spikes. > Typically one would choose no for a realtime system. > > +config RANDOM_KMALLOC_CACHES > + default n > + depends on SLUB > + bool "Random slab caches for normal kmalloc" > + help > + A hardening feature that creates multiple copies of slab caches for > + normal kmalloc allocation and makes kmalloc randomly pick one based > + on code address, which makes the attackers unable to spray vulnerable > + memory objects on the heap for exploiting memory vulnerabilities. > + > +choice > + prompt "Number of random slab caches copies" > + depends on RANDOM_KMALLOC_CACHES > + default RANDOM_KMALLOC_CACHES_16 > + help > + The number of copies of random slab caches. Bigger value makes the > + potentially vulnerable memory object less likely to collide with > + objects allocated from other subsystems or modules. When I read this, without further knowledge, why would I select anything else than the largest value? It should mention memory overhead maybe? Also would anyone really select only "2" and thus limit the collision probability to 50% and not less? "4" also seems quite low for the given purpose? Could we just pick and hardcode 8 or 16 and avoid the selection, at least until there's some more experience with the whole approach?