Message ID | 20240424214104.3248214-5-keescook@chromium.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 02219C4345F for <linux-mm@archiver.kernel.org>; Wed, 24 Apr 2024 21:41:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95FD36B031E; Wed, 24 Apr 2024 17:41:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84E7E6B0320; Wed, 24 Apr 2024 17:41:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DAB98D0031; Wed, 24 Apr 2024 17:41:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 41FAF6B0320 for <linux-mm@kvack.org>; Wed, 24 Apr 2024 17:41:14 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EBA0B1601EE for <linux-mm@kvack.org>; Wed, 24 Apr 2024 21:41:13 +0000 (UTC) X-FDA: 82045746426.09.E2691A3 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) by imf09.hostedemail.com (Postfix) with ESMTP id 0BA38140009 for <linux-mm@kvack.org>; Wed, 24 Apr 2024 21:41:11 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=LTrvwCwq; spf=pass (imf09.hostedemail.com: domain of keescook@chromium.org designates 209.85.167.176 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713994872; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0dfA8VHRufYC0/a/WgaXWD6BvTAtlULzh1yIW0W2iCw=; b=m9jMypKHqxG9f/mRrc4eOzQM1vE7qo+0R99ld0RiSllyU5yVS7Sl3D6rSg179ZIBJpfjdL 47ZOYB/10KK9Q+LqiXhFytlqmTqOQ631RzyLpyxlO4kvnEIBdZ1hJVTYI6lFl2Q48aBqzA uE1i+DEuAKw9gPmkv41KN6jgXWILjyk= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=LTrvwCwq; spf=pass (imf09.hostedemail.com: domain of keescook@chromium.org designates 209.85.167.176 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713994872; a=rsa-sha256; cv=none; b=YZHo59M7XLTL65l7ijUzJPfkSvPndHKditM2IUYOcKafFQ5rLioAfG5jrazSL1Xr204mP+ yyY9eWNg4CcQgC2motHfttL8QlPYvNrD/w2Pn+tYO/gBEoTk70sjCSzkkoezRKj8CnFLDl gqC6CJ3o7G0/ohFRn+aIpP6kCAmRQ+I= Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3c74b27179dso225570b6e.1 for <linux-mm@kvack.org>; Wed, 24 Apr 2024 14:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713994871; x=1714599671; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0dfA8VHRufYC0/a/WgaXWD6BvTAtlULzh1yIW0W2iCw=; b=LTrvwCwqwM4PBp4rdedyPVGfEB2GqpuC4filpo5Y+v+7v1xz2NRGDkBT/BSIadHtvo 0+I6iMjmQMddB5YbCyjcnv8tJ2AwcyyWQubCkO0Z+chqoPClzXV86n2qc6sAS8bVAAMo sN354OesCyBcIHgTZNF0+VnGq0/EgxVYrMNTg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713994871; x=1714599671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0dfA8VHRufYC0/a/WgaXWD6BvTAtlULzh1yIW0W2iCw=; b=sp17+irk3mB5oka90VIjs2hPE6GOQyegPvwsa84mfms1sKEP28DndXYDOY5HdcoAcs frdQHoIbZXrh8aa7dtDj+vJGc4VyM2H3VgZLIu1ij5IQ6yK6Y8leIAidaU+hRVRzUouu tUoeTj1iHz8SJYneuKiqKqvZ93HLTME0pf8GxYLaa5SzOa2aW1zXyyXNA/SxTPcpedu3 axDjAVRTYoVjEgWXJ0Z5tB2L98S/gGn6pzu7cnjqvhtBFTnCKR2V+D1aeNzx0bcRaj44 Lh+UXHuPq7cNFGvdxVsrn0hzwfbals0yaC6kUHoNVZkA01hvfZE0IvjkEUdFNTbkfgzQ uqXA== X-Forwarded-Encrypted: i=1; AJvYcCV0DAvwSWS82lXGss96Tumro3amY4RGBEpwAYyLIV16wWPGzqXp7lZCaqDZrozMkFesoxoEcu6VVXG94XbvOHnd/cs= X-Gm-Message-State: AOJu0Yx969D1XhwrS+moqJHoJmTI4Akmx4HhUz/kiWaxOBl9fhN3W6zS zlFPmLxa+U9SmjsdnesyJyjygtkzSoQI2P3AloFfoHibxytD2+gJDslPHG60lA== X-Google-Smtp-Source: AGHT+IGTuYDjFaVfAgXkNY0pfv1mQjL/tXjniKZW/5Pacc5OQoxVYohiXozhOD8xw9pwqeWMR48vVw== X-Received: by 2002:aca:2201:0:b0:3c7:3b4b:a0c7 with SMTP id b1-20020aca2201000000b003c73b4ba0c7mr3979160oic.11.1713994870911; Wed, 24 Apr 2024 14:41:10 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id a38-20020a631a26000000b005e4fa511505sm11445807pga.69.2024.04.24.14.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 14:41:09 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Vlastimil Babka <vbabka@suse.cz> Cc: Kees Cook <keescook@chromium.org>, "GONG, Ruiqi" <gongruiqi@huaweicloud.com>, Xiu Jianfeng <xiujianfeng@huawei.com>, Suren Baghdasaryan <surenb@google.com>, Kent Overstreet <kent.overstreet@linux.dev>, Jann Horn <jannh@google.com>, Matteo Rizzo <matteorizzo@google.com>, Andrew Morton <akpm@linux-foundation.org>, Christoph Lameter <cl@linux.com>, Pekka Enberg <penberg@kernel.org>, David Rientjes <rientjes@google.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Roman Gushchin <roman.gushchin@linux.dev>, Hyeonggon Yoo <42.hyeyoo@gmail.com>, Thomas Graf <tgraf@suug.ch>, Herbert Xu <herbert@gondor.apana.org.au>, julien.voisin@dustri.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org Subject: [PATCH v3 5/6] ipc, msg: Use dedicated slab buckets for alloc_msg() Date: Wed, 24 Apr 2024 14:41:02 -0700 Message-Id: <20240424214104.3248214-5-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424213019.make.366-kees@kernel.org> References: <20240424213019.make.366-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2189; i=keescook@chromium.org; h=from:subject; bh=KdH6ME94d/1vtX6KQzOA990YXFPl16sDmJgA9NILnME=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmKXxufNt0iRDMEi0UPkW2GLKPPmjE/aN5Rd00e n0cfMEJ/H6JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZil8bgAKCRCJcvTf3G3A JkdID/sHJNQORdFCM/cUq/ZcYZpyyvQIcnzDV0Z965jFp87JwowP6i4oI+FBo9uCykMh+11Rrlu NQNcUFmJmo6LQpfaqi0B05b1CRJ477vtFjlz2E7iovHNz3HYXXQS/vzGQ/VQH/Sv0F4EzoSOn1l UHfroyky4aryqJjcJX6ieL75C9QED2YiAGSVez2BD9J6JQGhA43blUULYTI434b7898CwOpbG46 patNilg7fBIku4FUOr2K59si/Pzdtj99qzMLg3XRQMJYclitl++HUzWC7Dxg32YdMfqNiX2aQQq svnMXyh8tO9LQ+fNnIm3P+frmSHbfPjtC4CDynsNU6cCbfvmxn0HIY1Wk+nYHcEB63BSmjNca+z lCmwiBUp8svDj9Xh6LO9/AWzHR8ag+sXmENKUaWLGO3Z41XoSWwFir9WU5GzjDKKl9t82MfijIy QevedZy6odm1fVxYoObyDu0WndH3xDKEKIPaz6I0Fun46Z0Itu+gz8v/gwFw5nYTDhFyTfXqucx UX0IAG/fElAHOxq2HNfmsTXeBXIFhtGjqJpBtFTojR1EeuQ6rsOhrJZl+x1KJAMztGf7xR/2lRm ZQ4a+ovdgDGs998x2Xl084sou5A9U0NffnvW9SXI5UKYquH4wK1z+qtZghjKn8ArTIPCB0gBzx+ fIU7zdwHzbc6QFw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Stat-Signature: qyzmsp5hjug79m1wi37dn5zq6n7qj94p X-Rspamd-Queue-Id: 0BA38140009 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1713994871-710494 X-HE-Meta: U2FsdGVkX19J/Kl2MmTpv6fn6JhqOU1WazIHCfuF/8KoQsESh7YCKkoUwZjL5ajLRPgMdXq2715KtjErF+OTtOba3prFCJOSc1erfidKVGvYYT7S65x2VE2Y4/8fQKf95mndenlrlD3ZEiDJD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j6Tid2HBKW08wDc4kVls7T9Pvt2NMZDwS1Qbzs5obBwoK2Van41+pX+eimxsT8t6oUXxaypo1SDSLIW2lhdG+BxlumLeB0QwX8VPu7NYpxsHXdZbdXB5AUFcOuc/bvINT7N7s/DOyfRVesbIt26n2NUvRgNjXrUen6XVBgATqsqudsVISQLhd0tfJVXxmHq2b7gw+Ga4Dni/qqTb7SKVSR6b6cLhdO0fDFCPL50PZV2kt0duP7+IH2ZBqTpBgu6KsLKYvqz/CaeZuVWcXr2EVMeklNZNSPiyKUOZOfocuZUO0FE2ifBWRcRdjp/cp3JMd/nUcQTI0iKIEDX5iB77Ovtrv+O2AjP6PzmLRJHFFelDZyI2MoCs4p2eW8HNrX9lCDYxeaR9D3u/mTQcsv0bUfvKR/VIKdLM9j8qmDCXvge5UX1AEutQwwYu0naLWBXr+Hzbm/zeNRic5U64bCRaJLFYsIhU+IGCztOwelkyvuSXBpyvsjEZNrVbLptyNxokz6mvFB40JPTBIHzhn0FCfTjp3TOZCQzVdgg4HGFmkXZscZ/hRkHnKgzezIQR7yfi1Q4mTVHbNwyFQqutPdNkWA6okEneyA6bwti/rs+tmhiC8gsAdjhInJ4ORfn1YYEgO0EQVHMxEYgK07kU/fwO71CM8oqVjH1EF4CK+BuCe6GGYda2aJ7YlKvDSBlG2YW+DiP4eJy54ceqDq205QfEK6wAH3HcTmaEziE829pkHH6Y62U7B7tjhFDTl WEsMvIjt bNdgH94Z0hCDvaSt9NVBGEBFrjp4NiIiQgbqc16dKONwCeDH6tjUd7v6vElEp66ugLrqZK3zV+DTTED57Uu2KkxmJsdHLbZqOsXi6yeBpM+3F8oWTbmM50wcv99gf9049xvKrvI4MHCl+p3zxW9QueRrGPNt+dTKm+fus3u7lehcIYwqKXr48rKWyRTULN54OElWSdTa89mW15ctyP9AXdstYeSUr94QOYLiH9iFi3Y= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
slab: Introduce dedicated bucket allocator
|
expand
|
diff --git a/ipc/msgutil.c b/ipc/msgutil.c index d0a0e877cadd..f392f30a057a 100644 --- a/ipc/msgutil.c +++ b/ipc/msgutil.c @@ -42,6 +42,17 @@ struct msg_msgseg { #define DATALEN_MSG ((size_t)PAGE_SIZE-sizeof(struct msg_msg)) #define DATALEN_SEG ((size_t)PAGE_SIZE-sizeof(struct msg_msgseg)) +static kmem_buckets *msg_buckets __ro_after_init; + +static int __init init_msg_buckets(void) +{ + msg_buckets = kmem_buckets_create("msg_msg", 0, SLAB_ACCOUNT, + sizeof(struct msg_msg), + DATALEN_MSG, NULL); + + return 0; +} +subsys_initcall(init_msg_buckets); static struct msg_msg *alloc_msg(size_t len) { @@ -50,7 +61,7 @@ static struct msg_msg *alloc_msg(size_t len) size_t alen; alen = min(len, DATALEN_MSG); - msg = kmalloc(sizeof(*msg) + alen, GFP_KERNEL_ACCOUNT); + msg = kmem_buckets_alloc(msg_buckets, sizeof(*msg) + alen, GFP_KERNEL); if (msg == NULL) return NULL;
The msg subsystem is a common target for exploiting[1][2][3][4][5][6][7] use-after-free type confusion flaws in the kernel for both read and write primitives. Avoid having a user-controlled size cache share the global kmalloc allocator by using a separate set of kmalloc buckets. Link: https://blog.hacktivesecurity.com/index.php/2022/06/13/linux-kernel-exploit-development-1day-case-study/ [1] Link: https://hardenedvault.net/blog/2022-11-13-msg_msg-recon-mitigation-ved/ [2] Link: https://www.willsroot.io/2021/08/corctf-2021-fire-of-salvation-writeup.html [3] Link: https://a13xp0p0v.github.io/2021/02/09/CVE-2021-26708.html [4] Link: https://google.github.io/security-research/pocs/linux/cve-2021-22555/writeup.html [5] Link: https://zplin.me/papers/ELOISE.pdf [6] Link: https://syst3mfailure.io/wall-of-perdition/ [7] Signed-off-by: Kees Cook <keescook@chromium.org> --- Cc: "GONG, Ruiqi" <gongruiqi@huaweicloud.com> Cc: Xiu Jianfeng <xiujianfeng@huawei.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Kent Overstreet <kent.overstreet@linux.dev> Cc: Jann Horn <jannh@google.com> Cc: Matteo Rizzo <matteorizzo@google.com> --- ipc/msgutil.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)