Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2450pxv; Wed, 21 Jul 2021 13:54:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztjGI4+gpHsqSbqumyWECMNxAtA40MbgnsEHiGGV04XgZd+vLfG5ulmYfWy8JQUAraX/DE X-Received: by 2002:a92:dc8a:: with SMTP id c10mr15579600iln.48.1626900849306; Wed, 21 Jul 2021 13:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626900849; cv=none; d=google.com; s=arc-20160816; b=V5WvesEXGkwZgR9dpYoZBTBS7TNYosVo06EgJlxV7Uq6HnFYCa3FGrMYeV/M1Hc1BI wZ3/OQuCMyS8OkZmexX/8rfWxWdaC8PKDwM9ourwfk2Vj+YTyO/gQsTSkmbJFDdMddpL XjDGFgT0WSZxehEYNOe5h7ds80jxpiX0bULsw8C+MgYczoPOObVVZHIARyDqohBffv4U VRJbtJUjyEWW4giIcQv+hVB8OOCRvl0V2T1xf0iz/EYG6UpiTW4k44+W9cDoP1fpFwB5 Xan+8k7PlrTsI/JvsBu46BvC0uJAqQiOBK12PxzWLg05r+Y18gZ9Nt2r5lP2eiY6rdZG yozw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=wHmWOsRJBltjYo7lCFhKzzQm+gRr0aziJWNnsm+aX04=; b=wgEOMthLKlulQ6/E3vrCcT2dYbXcKMQO8xSFbX1kNYSLG1s4S3zWFXD8YP+XwkJf9x jWW+g0v0K0M4aZeAU0A+LrH0mwQpHyBWPndO2gUHfXFsRR+Hrse2p1MS5p9Bd8jH9akS UMHoqZB5G0BfL2GIVzyhIztSMn8VaDahIMSV37g2JzKoY78RbRFQuj637QQWW+N74rfS qlbiN5GdlmKhrFo3dhMZ0Lv1fV8CO1LinwbvpZgbdIX4zc18urMrbhoCmRco/LZId0di Hzhwk5Xe9NA6oXjvPeZejI7V+ggpdLaHO+jpllMIVm/n79/12byCv3qaiWP0MGFJs0ST fW/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=AKrRqb6Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si26496864jaq.116.2021.07.21.13.53.57; Wed, 21 Jul 2021 13:54:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=AKrRqb6Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229597AbhGUUGI (ORCPT + 99 others); Wed, 21 Jul 2021 16:06:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbhGUUFw (ORCPT ); Wed, 21 Jul 2021 16:05:52 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C4EEC061575 for ; Wed, 21 Jul 2021 13:46:28 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id b26so5164523lfo.4 for ; Wed, 21 Jul 2021 13:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wHmWOsRJBltjYo7lCFhKzzQm+gRr0aziJWNnsm+aX04=; b=AKrRqb6ZSHyas0lTpEb/OJQ4sS90yqcnp66+16rXaoYcS9JZ1Ft4L/FV31nBUbXqRd ZQVTk8nuT1MLONhdGXvRXJ1/SOVPhaYqRU4JWvyDLFp4E9MvKBl2qDDX/cMEYMIktlX+ 4w9O+vfJH3cBANYWYhDUgZS5akjmCFNy7wctk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wHmWOsRJBltjYo7lCFhKzzQm+gRr0aziJWNnsm+aX04=; b=oHtIROqFHhCSYFcRg9K4OiK/G7UZHndyF2qxqAgPIJ1BLvo51pQEVHSp8Z3csv5e8n jIuFm2Ex5nwop9amyt8NB5DF6BxNUL2EpawLc9PX1zDCNi5iYXGW9rbphmAcQtZVEVh9 GFXd8Y/MqIp8ZRGmwx0KnehAxxSHKQxw3inG8pZD5T825GUTHONLr40J4wizgjH7rQHc 5sGh7xqUlqNwf061LEyb7jgceCLkAu//9TzFOtlPtbwW2tPt9EohokaCHJGeBzNE4t31 y+xB339qK1BCSN1TYoKMKWQO+wIdsdksvKMzznnuKMLCV1BSRdssxNMxMXWrepkn8TTA vCLg== X-Gm-Message-State: AOAM531QSQjlXT+hzsr7tSvg06WX+V9J0xEcFC/wN8CG6Ks3twXs69b0 uE1DHoAb7CBAIuCjhISW7KunQBIg2W/EwmKQ X-Received: by 2002:a05:6512:3697:: with SMTP id d23mr27344232lfs.552.1626900386416; Wed, 21 Jul 2021 13:46:26 -0700 (PDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com. [209.85.208.176]) by smtp.gmail.com with ESMTPSA id k21sm2822879lji.107.2021.07.21.13.46.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Jul 2021 13:46:26 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id h9so4670407ljm.5 for ; Wed, 21 Jul 2021 13:46:25 -0700 (PDT) X-Received: by 2002:a2e:90cd:: with SMTP id o13mr16148707ljg.465.1626900385724; Wed, 21 Jul 2021 13:46:25 -0700 (PDT) MIME-Version: 1.0 References: <20210721184131.2264356-1-willy@infradead.org> In-Reply-To: <20210721184131.2264356-1-willy@infradead.org> From: Linus Torvalds Date: Wed, 21 Jul 2021 13:46:09 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm: Make kvmalloc refuse to allocate more than 2GB To: "Matthew Wilcox (Oracle)" Cc: Al Viro , Qualys Security Advisory , Eric Sandeen , Linux-MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 21, 2021 at 11:42 AM Matthew Wilcox (Oracle) wrote: > > It's generally dangerous to allocate such large quantities of memory > within the kernel owing to our propensity to use 'int' to represent > a length. If somebody really needs it, we can add a kvmalloc_large() > later, but let's default to "You can't allocate that much memory". I really think that without the WARN_ON_ONCE(), this is just moving that failure point from a known good place ("we know this must not succeed") to a possibly bad place ("this might cause silent and hard-to-understand failures elsewhere"). IOW, in seq_buf_alloc() there's no need to warn. It's clear that a bigger allocation can never be valid. But in kvmalloc(), it needs to warn, because if it ever triggers we need to check what triggered it. So this is not just moving code from one place to another equivalent one. Linus