Received: by 10.192.165.148 with SMTP id m20csp84465imm; Wed, 9 May 2018 09:09:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpcJAJ5xkMWQnJQcSz+K/zSMBsJ7/N6zjcKXFsFAf9EAc2Is+9N0aWkXRqwjkW+p2sHJtFr X-Received: by 2002:a63:2b46:: with SMTP id r67-v6mr35652342pgr.89.1525882172343; Wed, 09 May 2018 09:09:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525882172; cv=none; d=google.com; s=arc-20160816; b=fLUJF33b0z375z+DsgLrRhsvdKrTPSmWfhybF+IsB81OWeE1u0G+vkqNg2UUBUs7FT 7T4TXk4DugBPFn4frRsfnzEg3eFULLPfA84vfWaMrCE+7z0j1bNfzkt5QpJWUt60i3nF olsM33RbcmQbdP9hrqqfxqt2N7LonnCYwecYvqFo1iFnUJhQ3CvPTj3MKgoczLxjKztn z7KF0SQPhXzHasFB6s3BQNnuWur55L6rPuwMnwWbF9mkXGRKqvJH9+GOQGYFJy/WHGn3 yONhAEmWTeXnLE5pQKfi5G+WKo46Xq+1Ee8nQJKl1CbB8DpYKEJ8oiTlE7GXy7ZbL/nE T8/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=QDx3KDvhZK3etHsvrUq3vo07wDqsANRrNbIqAtP1jWw=; b=q8rPQSCp6rWY6uRqaL2kieNW3TJKTh6R1fb2qEpxNimSlg8jXVkoyA4ebqEgxC4j2E XAm7QKlPpjtJ4QEWvaMtSBCJdahpg+TJa2BOoPFdNmXjJcDI5EXB5s8N1VlomgSm03hi CKHO106VwhYGAvFo8r9e6M3637boBQNSkFy1udRnGiwmc78RW6JZP4BMDF4Akv7pvg1i 7dNGaXcm2su4Q1+V5E42tLPRPpNUsGd6eh91uiHU+pbt4jV+WjMCIM9z4v5CKvvaQuR5 uwArc6wy50o80kzUzLU9749d2TovUb0rmFxlmD18JvWj2FbyBwIJAxTs2VoV+aMhQaG+ SpbA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17si27369196pfj.10.2018.05.09.09.09.17; Wed, 09 May 2018 09:09:32 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935452AbeEIQI2 (ORCPT + 99 others); Wed, 9 May 2018 12:08:28 -0400 Received: from mail-pl0-f42.google.com ([209.85.160.42]:34553 "EHLO mail-pl0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933409AbeEIQI1 (ORCPT ); Wed, 9 May 2018 12:08:27 -0400 Received: by mail-pl0-f42.google.com with SMTP id ay10-v6so4571916plb.1 for ; Wed, 09 May 2018 09:08:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QDx3KDvhZK3etHsvrUq3vo07wDqsANRrNbIqAtP1jWw=; b=hV1pCn7AoNwehjL88xhd11bL37Ey5qB7mavL58+tiMN3kK9QsYT2ySEHPpHyGisIw7 WksgnRIUTo8kjzlSMrZLPPHAuvY0tEWpJhgm5SiXUcejAFtampZKl9SF3GsjnSeAaayI 2W3/lnp1YRwX2m0sWh1UHjgO4XBQ06wRrGe5Kvm7ci8XwDRC10L2k5wE0/5BApGwgzO6 PiR6sD5vrr8OXyEkFEq3WoqTXV27WeS7TH8KgYh/Up3hDJL5Zeotbdm6aMXu5xYXALr2 QJng9DjsD/v6E/q47kSuBfyLr4FRaE78hhGUx4tjoBaouxG0OkwP2pLHeiKBHylGAirH Hp8A== X-Gm-Message-State: ALQs6tDJ4ijD9XFb70dfSAFbaxiXshakXtCa+3rK+A/0PSZxvCYXWwh7 4paSYo9uq4+K91yV2Irc+wTARQ== X-Received: by 2002:a17:902:aa04:: with SMTP id be4-v6mr46115024plb.20.1525882106774; Wed, 09 May 2018 09:08:26 -0700 (PDT) Received: from localhost.localdomain ([68.177.129.82]) by smtp.gmail.com with ESMTPSA id p84sm30764451pfi.66.2018.05.09.09.08.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 09:08:25 -0700 (PDT) Subject: Re: [RFC][PATCH 00/13] Provide saturating helpers for allocation To: Kees Cook , Matthew Wilcox Cc: Rasmus Villemoes , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel-hardening@lists.openwall.com References: <20180509004229.36341-1-keescook@chromium.org> From: Laura Abbott Message-ID: <4baffc55-510e-96d3-3487-5ea09f993a0c@redhat.com> Date: Wed, 9 May 2018 09:08:24 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180509004229.36341-1-keescook@chromium.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/08/2018 05:42 PM, Kees Cook wrote: > This is a stab at providing three new helpers for allocation size > calculation: > > struct_size(), array_size(), and array3_size(). > > These are implemented on top of Rasmus's overflow checking functions, > and the last 8 patches are all treewide conversions of open-coded > multiplications into the various combinations of the helper functions. > > -Kees > > Obvious question (that might indicate this deserves documentation?) What's the difference between kmalloc_array(cnt, sizeof(struct blah), GFP_KERNEL); and kmalloc(array_size(cnt, struct blah), GFP_KERNEL); and when would you use one over the other? Thanks, Laura