Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp823239lqp; Thu, 23 May 2024 00:31:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXn3hTdDi4A9ktFyVQFgNc2biGoVqiNhA3pbJHCTX0UOz1bhYhfW44uKlp55Yv6e/LqoCYb7eAssQrA8dgHUMxbT0GvY8/qrQntuoNiXQ== X-Google-Smtp-Source: AGHT+IHmLjWcvEl2nzVMTLpUTf2IPjDjRFnHXjEQPjveeGC1BQFrSkFces9BlTrxkq0oOKnDaFLM X-Received: by 2002:a05:6358:2820:b0:185:feb9:7dc2 with SMTP id e5c5f4694b2df-19791f1f2b0mr390456055d.16.1716449477290; Thu, 23 May 2024 00:31:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716449477; cv=pass; d=google.com; s=arc-20160816; b=lghvjVS9Fz5w/JOBRqDWgnXeBCwnq7MzDVHDg7fmzfwwt0X+Ui/jNEQIXKhTf58sWf T+g2Zpx6c2T2z3PBdk69T3aVZP3uLRu+OKbm1A7ayKxW1OnmUhvnv1MGJgMSxPe304B0 WOm+JUuqhMva2v5UrpyUO2r2nz3heb3poKE+lsyBtTQUs9h3yfUx9j8hnjoiiSnEtS1v 8ahjdZBFW82f1XtrcBLmMsVOFb6qMRqhbwEKsIpquOxit+E1gwSLH3bj9qaqDNbCZVuo t5/oQRYuqhvmHz+Izm6fLebXdn5WQlhwoek8cIoFC0XZt3qB/snghsT6kX3HxPRZxWIh rReg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=VXofB/MrwbBei8swbKQAdzf6vUd6YCUPSlTpcTrnuI8=; fh=bV+HvN2cIec1C4YXNeVy3Z+LHa3VpygqRCvdT2IN0Yk=; b=fCQuoPFXjIZy6Ig6r4lFb1pC+HW1uTFt4CfMs5b38neDmgaKc7vTBfohbD1a2Cqzun qYPyZNuXxwSm8qmjApcl/rSW1saxK2nBW3jL1y6Fauz1KMFilSJiaoJqSD5RKM11Ua/d BhIJ2OOVM0waWv1LniwUXu6eiMSUF6zYrwDCmDmrs79wuO+Rdi2Tg1S0Y5uZmGiDlvOh j9QFWcko0w8alY8vevD75uHrl4nK4Y2pT5Ljl8tgdDaPB+P+RDbFGO5cxMV/Ai/YmAu+ Hxs1vmHspgV/6K42rpB5MbIEZHT+5jZP6kc2ILiXvcGQNBWlDBW+KrQ2uhzDiTF1+1a6 FXMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=PYYckYVX; dkim=pass header.i=@suse.com header.s=susede1 header.b=IvK9V8R3; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-187094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187094-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b1ba65si4601713b3a.226.2024.05.23.00.31.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 00:31:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=PYYckYVX; dkim=pass header.i=@suse.com header.s=susede1 header.b=IvK9V8R3; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-187094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187094-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DE4D0281B48 for ; Thu, 23 May 2024 07:31:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B826013C9D4; Thu, 23 May 2024 07:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="PYYckYVX"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="IvK9V8R3" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CCA413B284; Thu, 23 May 2024 07:31:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716449469; cv=none; b=E8NHHvrJx3b2OWbxbT+nRCOLxNMi9HwfA/nO6vOJr8WfJTOCiNdHkctjBbYrLmfun1iQjg4AmQi1LKr2N+l+gEWBiIT3lUmO+THEEV+i9j9pguSDiD1ENC6pH7A9aVZYQgtip2lLu0mXNLfDggm3ZhAPOuzPJswVZ7tSqPtdico= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716449469; c=relaxed/simple; bh=E6KSMHkcFqMBfxwvW0aqU0sxVmzpbZ2ANCBUp28KRoI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kZBgXFtEvBWhKJ38IG2epV4hlEEQ+7/qIvF+p/k/Z6RHDITQrCBkvcz03oE9QnlBka8pcP0q518UzvvFm7WKuNO/uXxn+crDj4Hxnej72cX/n0DzsgJscHuZCWqE5e2R9pTrj95kj6O9cN95pg0OHfxcBw/mkZW+JkIEIoe0nzw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=PYYckYVX; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=IvK9V8R3; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5A207221BE; Thu, 23 May 2024 07:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1716449461; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VXofB/MrwbBei8swbKQAdzf6vUd6YCUPSlTpcTrnuI8=; b=PYYckYVXkrSJAlsjvASJofbHz9wflc/AaIh5IEXIF568ssr4dNvTsd7gDBcw5omcxPs2vh MtNKZxT0F2l13DKq/xNE3xwrvMYye/zwOraPNajynCzrenmlYTndD1+Jds6dlWyDR2xDMS 0iAnOJPcWDA3J1X9cN+CmNGLhIHZFmw= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1716449460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VXofB/MrwbBei8swbKQAdzf6vUd6YCUPSlTpcTrnuI8=; b=IvK9V8R38dhZDQYWTBxFFJai+li2mt6n1f9i5aMy9D1ZFHZv1MDfuk/cRosCnhCeMhOopp ACOBVD/7U2zad7eXDKdKZHM2IPaXDBroqcXW7L3XatC4HrBgc2QMQNjcPwJFGyM5qozDwn LMOxfW8UXw2ac2xUYKNkEnWTUZqwfi8= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 376CB13A6C; Thu, 23 May 2024 07:31:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id BzjTCrTwTmZhRwAAD6G6ig (envelope-from ); Thu, 23 May 2024 07:31:00 +0000 Date: Thu, 23 May 2024 09:30:59 +0200 From: Michal Hocko To: Oscar Salvador Cc: Peter Xu , cve@kernel.org, linux-kernel@vger.kernel.org, linux-cve-announce@vger.kernel.org, Greg Kroah-Hartman Subject: Re: CVE-2024-36000: mm/hugetlb: fix missing hugetlb_lock for resv uncharge Message-ID: References: <2024052023-CVE-2024-36000-cfc4@gregkh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Flag: NO X-Spam-Score: -3.80 X-Spam-Level: X-Spamd-Result: default: False [-3.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; MISSING_XM_UA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] Let me add Oscar, On Tue 21-05-24 15:38:45, Peter Xu wrote: > On Mon, May 20, 2024 at 05:14:58PM +0200, Michal Hocko wrote: > > Peter, > > Hi, Michal, > > > does b76b46902c2d ("mm/hugetlb: fix missing hugetlb_lock for resv > > uncharge") really have any security implications? I fail to see any but > > UFFD is not really my area so I might be missing something very easily. > > AFAIU that issue wasn't userfault specific, but a generic issue for hugetlb > - I believe that can also trigger in other paths whoever try to call > alloc_hugetlb_folio(), and UFFDIO_COPY is one user of it. > > I looked at that and provided a fix only because the report originated from > the uffd report, so Andrew normally pointing those to me, and since I > looked anyway I tried to fix that. OK, I see. Thanks for the clarification. > Here in general what I can see is that the lock is needed since this > commit: > > commit 94ae8ba7176666d1e7d8bbb9f93670a27540b6a8 > Author: Aneesh Kumar K.V > Date: Tue Jul 31 16:42:35 2012 -0700 > > hugetlb/cgroup: assign the page hugetlb cgroup when we move the page to active list. > > That commit mentioned that we rely on the lock to make sure all hugetlb > folios on the active list will have a valid memcg. However I'm not sure > whether it's still required now (after all that's 2012..), e.g., I'm > looking at hugetlb_cgroup_css_offline(), and hugetlb_cgroup_move_parent() > looks all safe to even take empty memcg folios with the latest code at > least: > > /* > * We can have pages in active list without any cgroup > * ie, hugepage with less than 3 pages. We can safely > * ignore those pages. > */ > if (!page_hcg || page_hcg != h_cg) > goto out; > > In short, I don't know any further security implications on this problem > besides LOCKDEP enabled. But I don't think I fully understand the hugetlb > reservation code, so please just take that with a grain of salt. E.g., > right now we do the hugetlb_cgroup_uncharge_folio_rsvd(), then could it > happen that this folio will still be used finally and got injected into the > pgtables (after all, alloc_hugetlb_folio() will still return this folio to > the caller with a success), and would that be a problem if this folio has > its _hugetlb_cgroup_rsvd==NULL? That looks like another question besides > this specific problem, though.. Oscar, could you have a look please? -- Michal Hocko SUSE Labs