Received: by 10.213.65.68 with SMTP id h4csp211336imn; Mon, 26 Mar 2018 19:33:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELsRcxVbY2LW79lL/dMtcv6ymp6CJr3anRvG4iBpmZsFwvDLhbvU5wXFzfjKoKmjKUtvyb1k X-Received: by 2002:a17:902:8490:: with SMTP id c16-v6mr32876638plo.132.1522118002985; Mon, 26 Mar 2018 19:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522118002; cv=none; d=google.com; s=arc-20160816; b=JuVxP5Fwdcjbb6gWHKbQBeTaZlTu3AkBJt5qTHZpsuyY4V2z8vt1BatKxYgcwN3ZNg KVUn9etPj0uF+jy8zBYBhg5FkaV7lIw1OwndZphaxoeCesIEmdyOcjXQNh3BPWAOCkWL Fr1mIBye9Di9eSYmcryknITHgo/OhubUMvufG6jSCs2i3wBh83AuqQgBAyNWNwWVEvmG PszyvW347oJ7g18kxO9v4Hq8v9BjPMolEtPxHdhClxItdJv+0n/3KWEQ4i1C7Al3Tdgq XOyPWaGk16y3S2X2tjgpfSqer2CrNvU/Nn8PeN316/xOQKaublA683NSEE10Eo9nMVKJ hqSg== 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=7WqbcKf8FKJ/scg3+a7Sbgdmx/BCtGikxql+C04k5Uc=; b=R2BJPjcAUrm4SxSN1yJ+gfawTt87hO+WxytdEbSJUl0ur6jmUxt8Lxm/D1NlLcJ/Xp tdJ+JuWCfCJadpM7DyO99yDjodX0gfg1uRXMjkzukS05fYPjFLDC/SgM34QppOyJDfxi fAc3lz/prTE0YDjGlU/kHKChN8bnrxUdDtaA2W1oYscPw3fhStOBtDs2CFDEUIowKXft whV5WDCwJT3D83ABkTaWKDckIvjmX++aLPOTV3nBb1cGojMqC8Mu2RqK3DknvUBYlwOT XTO2Zo+rldNqz3AHMNx1rZbMiEWLts+3SS8WRyu9Qt5azkYiROavWSxO4O577QkD0lnt 9LsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=pzH8LKYR; 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 k4-v6si185297pll.176.2018.03.26.19.33.08; Mon, 26 Mar 2018 19:33:22 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=pzH8LKYR; 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 S1752582AbeC0CbS (ORCPT + 99 others); Mon, 26 Mar 2018 22:31:18 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:53908 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752559AbeC0CbQ (ORCPT ); Mon, 26 Mar 2018 22:31:16 -0400 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=7WqbcKf8FKJ/scg3+a7Sbgdmx/BCtGikxql+C04k5Uc=; b=pzH8LKYRdutbpK7gsmMovGE7w aILBw8OrGTmiO+bPHMwe/98UTkYKIEWV9qB3b+F/n/wOoyR39X8RFantmOMphH0SH8e3wMJtCqVEV jUWaPk1JIa9eMkmDDEg9Vlw0nU6FSJHEcMw5Yp4mY06UVGlJHoBj63Jb1NKJsiGWrwFys+HqmScID OeFAXYyOQIZN/Bs2W6SKzTdemFSbKE3beVANl5FjV0mIk0BHy0TDU2urCHl7OhxarZWAp3MDmjCAk Sx3WzjQFHZPxKLHESNF2oN0k6obQxyImnyyfEQBPqvTXPL11XFBzfrtH6iLlI8A3/aHIMI4tiRYrb rSbFc2yvg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0eOE-0007Wf-Tf; Tue, 27 Mar 2018 02:31:10 +0000 Date: Mon, 26 Mar 2018 19:31:10 -0700 From: Matthew Wilcox To: Igor Stoppa Cc: keescook@chromium.org, mhocko@kernel.org, david@fromorbit.com, rppt@linux.vnet.ibm.com, labbott@redhat.com, linux-security-module@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, igor.stoppa@gmail.com Subject: Re: [PATCH 3/6] Protectable Memory Message-ID: <20180327023110.GD10054@bombadil.infradead.org> References: <20180327015524.14318-1-igor.stoppa@huawei.com> <20180327015524.14318-4-igor.stoppa@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180327015524.14318-4-igor.stoppa@huawei.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 27, 2018 at 04:55:21AM +0300, Igor Stoppa wrote: > +static inline void *pmalloc_array_align(struct pmalloc_pool *pool, > + size_t n, size_t size, > + short int align_order) > +{ You're missing: if (size != 0 && n > SIZE_MAX / size) return NULL; > + return pmalloc_align(pool, n * size, align_order); > +} > +static inline void *pcalloc_align(struct pmalloc_pool *pool, size_t n, > + size_t size, short int align_order) > +{ > + return pzalloc_align(pool, n * size, align_order); > +} Ditto. > +static inline void *pcalloc(struct pmalloc_pool *pool, size_t n, > + size_t size) > +{ > + return pzalloc_align(pool, n * size, PMALLOC_ALIGN_DEFAULT); > +} If you make this one: return pcalloc_align(pool, n, size, PMALLOC_ALIGN_DEFAULT) then you don't need the check in this function. Also, do we really need 'align' as a parameter to the allocator functions rather than to the pool? I'd just reuse ARCH_KMALLOC_MINALIGN from slab.h as the alignment, and then add the special alignment options when we have a real user for them.