Received: by 10.223.185.116 with SMTP id b49csp1028683wrg; Wed, 14 Feb 2018 10:28:16 -0800 (PST) X-Google-Smtp-Source: AH8x224dau1eFAPL7xlKYLtGaTunV+1/c5TGO/fDrNZn9i2u8KFvil2PI9xGsR6rwTXgPQ9fIs2H X-Received: by 10.167.130.193 with SMTP id f1mr95312pfn.241.1518632896429; Wed, 14 Feb 2018 10:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518632896; cv=none; d=google.com; s=arc-20160816; b=d5oVhYAlQLC0YFv/wn0nsjhW2VxDgdRocNtZn3MVQZrZk3b5O1/JcHPr15B6ZWbwLX lB2pYefDLVUxebfsY7TZS98efVWYmUGlDW9hY1JZGa9ICt4HbSHxsV8wHkF0vJgV4Rig 9NK6VYE6J6mVfNcYvqQXgbURhc3lzck3Olz7QSIaVe5eofmnj46sGYXc/53kbSXt/I6N TYwGga4A/jahGgN26ad0RBJS6dTbCNeucmangMIbAtqZQQB6ehG3zvOGQFCAi0TUMJFz CgQPqbIr/d6smv1sQbKr9y86kaJcYsojWEpzbfDszKVdefFmu9f79D1/fYX4dVVQyvlT zAiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=8EvrJzML4QbyIGOABtDwyZ9IvULxh4uqpwPOtxh3Av8=; b=D2q8vdF7KuMHYjVyTRNOpmCNvrYs7xAx3AnTa4LgSGYNBoBk64wB5vtIrWjYf+UC8I Kkc3EG0H/g4DGBy29JjmMrGvNRIEHqylx4KM15C2cC9fE5sFZAip+lOw6FwUWG41QZy+ UVAVUR/dCxGio1kHtzgkG1kk7KM5y9irWV0/CVGvh4Z/Gm8rVT8Saz6JhllBdUMatINS eQX21Rx3BWMecF5VW7UteoXbTW2ucTrIUJA1SijS1nyGlIiHvZV9PHM7yKkbxbuejlQz UjKlQWaM0MC401vZWgAnDOmjWuSLgYLA8jnsrNUFnTq+D333KvMZ6nEnrI4ZYMbpRs5k 2/ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=D9CmX33+; 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 14si4385889pfi.158.2018.02.14.10.28.01; Wed, 14 Feb 2018 10:28:16 -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=D9CmX33+; 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 S1162081AbeBNS0a (ORCPT + 99 others); Wed, 14 Feb 2018 13:26:30 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:58538 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161914AbeBNS0Z (ORCPT ); Wed, 14 Feb 2018 13:26:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8EvrJzML4QbyIGOABtDwyZ9IvULxh4uqpwPOtxh3Av8=; b=D9CmX33+PWuJ7YS+rBGAUjXf5 vLiYPId/HimQP4TkPQMKVQq7AUwhIXN2NRxw7O3WK4UFplodw8OjBdA2LR0q9pJj41CIQ0qHYfcFA rX1LoVIyNISiId9MSCQb+DBK+iiSiQkcnzySwLC2PEwuw5XNJcQIPIrq9OP0+Xr9/X+bKSmVRrqG3 Oyj8GcPCIxDvaUxZv9UGUubAcBXFGqwGvuGJzSRD2OPJ49M2w44T94WQ9bj5GFJWC86U4yWL0zhKW 0ZveNWbTFdDIYvR6qvtEi1UthGIDWr48dEz7s/vISzxnYyCYBNYxIFgcq//9z4ca7uEokAn542F+u lzzCOUA4Q==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1em1l8-0003sH-Nc; Wed, 14 Feb 2018 18:26:22 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-mm@kvack.org, Kees Cook , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH 0/2] Add kvzalloc_struct to complement kvzalloc_array Date: Wed, 14 Feb 2018 10:26:16 -0800 Message-Id: <20180214182618.14627-1-willy@infradead.org> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox We all know the perils of multiplying a value provided from userspace by a constant and then allocating the resulting number of bytes. That's why we have kvmalloc_array(), so we don't have to think about it. This solves the same problem when we embed one of these arrays in a struct like this: struct { int n; unsigned long array[]; }; Using kvzalloc_struct() to allocate this will save precious thinking time and reduce the possibilities of bugs. Matthew Wilcox (2): mm: Add kernel-doc for kvfree mm: Add kvmalloc_ab_c and kvzalloc_struct include/linux/mm.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ mm/util.c | 10 ++++++++++ 2 files changed, 61 insertions(+) -- 2.15.1