Received: by 10.223.176.5 with SMTP id f5csp2303985wra; Thu, 8 Feb 2018 11:43:38 -0800 (PST) X-Google-Smtp-Source: AH8x2276Wbxy1HpMd3gnr7UXrnLXUTDNxycjz0I3EM5bDZYg+IhqCrg0qfiJpHiuSZMcFp2Fc0jG X-Received: by 2002:a17:902:be06:: with SMTP id r6-v6mr125728pls.448.1518119018762; Thu, 08 Feb 2018 11:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518119018; cv=none; d=google.com; s=arc-20160816; b=geBJCnZpxpZUtNCBK0Cz2yRnKGlS/rH4SNaiP9hVeI5UJeaZ7yEvItdPXDW3Bw2Yel oEzPnL5aJyHp2VRg4oP9yWOOjB9XpnX0XQ1OZBqWucMOX1eQeOoz4Sx4tbpL2b9lgel5 v+Ye5QuC2AmwzvQPwJkNMa6oAGwlR2q79BuHA+XksFFjkLPwsBvyuv97afoB3nZ3UckZ iPlpDY1MG5QPelhVo+JD8u2PBmr0HzkuFKBKZ7fLtr+uwMibtM8KTYMIGv1fjS3x0KAT 8bOU07zpWWLkbQnXDO3CgMvd2rlkNXRS+aMqRcQi5HwCEJ5BBB5brpObXNcPl1nHMFfn 5m1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=+ZtWX9IVq45x1+pYxShvjfDPDtTuvfex0fzIsv69hFk=; b=J305718SFDeE9OxFpVNfd1fc5BE6/pgwema1+9fGqw17zbH/D2Vp3k05G31bLnyMcs 3ULpa5/z4zwYK4TNZUg9y31S5sjUve8iX3kV0cEg+zaoe2PV8ILJRljzIuFVL2P51PeN bqe66wAUFuissgFWOo88yYekDxrkBm17egBoYu/x48lSacNQeI3OpD+I/U71Q/8fTiud 8GQQ3eBsnrtE6wTgCkc6/bfJLnXcbuXdI0mFuIzlSXduGzvkYs8nQIIZJLBXfHDnOES0 0I+u4/NDbGQQbVzGQrRaCAl2dfdBQZHd70jk2F8Gv+/J+CCZDM2DugosklhipOEX4Xtv 5y5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Og83/0Y6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j19si410232pfh.377.2018.02.08.11.43.22; Thu, 08 Feb 2018 11:43:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Og83/0Y6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752223AbeBHTmj (ORCPT + 99 others); Thu, 8 Feb 2018 14:42:39 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:52669 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751700AbeBHTmi (ORCPT ); Thu, 8 Feb 2018 14:42:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+ZtWX9IVq45x1+pYxShvjfDPDtTuvfex0fzIsv69hFk=; b=Og83/0Y6eeZH9tgGmGRleibPh gjPwO/7a9MIjoMiBArMZQDPfI7ItK4coPgyxr/TCCTHy+fZ5dd4PZBDegLcFoCWqZPSK/frNjdyIb FWt4Ix4uogm7IHvQhaGpIc9ANG3vLAhdrr4ghhS7+g9JeaFzPC2Ur+BfQsyNhkN4ZmO31t638C3Dm LG/M6PbpyiuM1C6FLuxvQAOAso1dSh02QcNKeuwkdjXnbmYJmP/kL4ifOjwubGfUSyGYQW+rXVV0Q mi9RjaNxI37kIZVx2naguQw7/flR7ygYAFa0cQ4rD6xCXvfc7f0ZXAXyR4H/gHRWku66iTo5sL3h8 oL3RerIaw==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1ejs5b-0004Af-VK; Thu, 08 Feb 2018 19:42:35 +0000 Date: Thu, 8 Feb 2018 11:42:35 -0800 From: Matthew Wilcox To: Daniel Micay Cc: Jann Horn , linux-mm@kvack.org, Kernel Hardening , kernel list , "Kirill A. Shutemov" Subject: Re: [RFC] Warn the user when they could overflow mapcount Message-ID: <20180208194235.GA3424@bombadil.infradead.org> References: <20180208021112.GB14918@bombadil.infradead.org> <20180208185648.GB9524@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 08, 2018 at 02:33:58PM -0500, Daniel Micay wrote: > I don't think the kernel can get away with the current approach. > Object sizes and counts on 64-bit should be 64-bit unless there's a > verifiable reason they can get away with 32-bit. Having it use leak > memory isn't okay, just much less bad than vulnerabilities exploitable > beyond just denial of service. > > Every 32-bit reference count should probably have a short comment > explaining why it can't overflow on 64-bit... if that can't be written > or it's too complicated to demonstrate, it probably needs to be > 64-bit. It's one of many pervasive forms of integer overflows in the > kernel... :( Expanding _mapcount to 64-bit, and for that matter expanding _refcount to 64-bit too is going to have a severe effect on memory consumption. It'll take an extra 8 bytes per page of memory in your system, so 2GB for a machine with 1TB memory (earlier we established this attack isn't feasible for a machine with less than 1TB). It's not something a user is going to hit accidentally; it is only relevant to an attack scenario. That's a lot of memory to sacrifice to defray this attack. I think we should be able to do better.