Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp85025yba; Thu, 11 Apr 2019 22:39:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwW5kSHPF7AFiLfy19ZANWpEgPc8rjHHeqdUv8CUPdZfwFDRFsGldiGroxPkxTQm5lcqN9m X-Received: by 2002:a17:902:2702:: with SMTP id c2mr36015351plb.37.1555047576252; Thu, 11 Apr 2019 22:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555047576; cv=none; d=google.com; s=arc-20160816; b=GGMwFHisR5R+Xq9XHROS+WSNjo+pXA3aLa9V9866+Xba6BD54Jqs41FiY6/JjAZkdJ tsrZBE8jrrb8CDN5l78sA9reQbxQ3b8Nafa5yVd9GEag5t3mr7KTuh9OyM+PtNmtjgfH +2o6Kzv3q+vonYaMehX40mATED8XUxBBjHKkTbd6Y3SPH1icRq/41ms8wwuq3/AoD03D +UcP7x1P2P+iFksQbZAIrwBHT+wcRozk5rKF0UatyIPFcHmAHYjPsSJM8SmCPDgHsq2h C8TluA+7TH1vuA5BYC/KZoEQWN3REcz0CpCDn7udwPX7GhBhKiKA786AcqIR6/ZIwDpa 711g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=xHEBZHc0l3bFwYTk5fYReti+5FO3ym176CcS7WgDG0U=; b=LEOkH4BJ4hsbeRK2YV0LUF/I9QFamasqXcgNNNf/mNUUAM08JQNw3kG8tMXMiQos1D aC0wKn+PUAx36eJYeWgtCkzGWaoBgnGfYlfEZ8DHiEVNIqnO2ScyfUh0WovDXslKVaX7 /i7opyMhneguWPVdz25Tt2LKFglc3ICQz5othoHoV8zHBMFpAiXgSl5hY8e+ey3+Kom/ wqy1ewnl74ET6ahc7lgTmFkDF6nXjBszXJdRo7ZfIOheokCShHmgz9uI0VDqkWw6PXZh BPGlH4MVvax3qhZLZH22kF1QBVNqtaoES6QGjnvJjdu6YXrrf5eeslzknwL9iZJlnwoC aQvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LHFiCjiF; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9si36216901pfo.173.2019.04.11.22.39.20; Thu, 11 Apr 2019 22:39:36 -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=pass header.i=@google.com header.s=20161025 header.b=LHFiCjiF; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726685AbfDLFip (ORCPT + 99 others); Fri, 12 Apr 2019 01:38:45 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:54548 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbfDLFip (ORCPT ); Fri, 12 Apr 2019 01:38:45 -0400 Received: by mail-it1-f196.google.com with SMTP id a190so5343519ite.4 for ; Thu, 11 Apr 2019 22:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xHEBZHc0l3bFwYTk5fYReti+5FO3ym176CcS7WgDG0U=; b=LHFiCjiFfNyVsrihH6WNLeRGo+81LhYX8qh+9xuxZEdr8ykj1kYG4C/o0XWeNKfsgv DRGEzr6lPVkVkg5zWDc0aXsK2jpqGe6PpWKNOYKMpZM2CrseqPL247swdESteWd2hSHo cNJsfIF5nwptLD2oX6E/kCtH25o9rBVPyeBkb3aqFV4FOVA7ufSpLWO82GSDEV/EfTK4 PDPF+FdGNQFh/AKt0iTNuLk8v1wrx0L/yfjRp+8d4W/TTGcS2Hg+Mu1w+lahE8WaLseQ zJPPEfG6JyEDjjLV9qONfzpDxJp6GHicJ28d2qi3fseOaxEO8bVwUMUzeKBRBup/iW/u 1+SQ== 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=xHEBZHc0l3bFwYTk5fYReti+5FO3ym176CcS7WgDG0U=; b=DDlZB+1PMSsspx2il+KAVlZrayxJKTxnZcYdhQzgwViSz3J4uxg6zv4HSIjN/+t40z mL9eOAJ+P/thKoWDFykYoMyknBkPGExb7IgTvNZ0nsNUG8QdQLuAAc3lAyLgaQWkbzbq 2g/L3CjWwoD7M3u4jNvtr9G2gyYjo1VNt79hkezR/M562xvOmAQMtHR3Tty5C7hU8oOD fC3ChyNANWrTHLkQcfCIDcgUBXz2UP8b2oPaPCQ4ybdyMFBOVfMmGDhRq7ZjWllbbDjq RLH9vT98SDvDRHqUyJxTbYot+WDiXALDSIn+tpHF9a/XMKjLvCNYMbWBNQeijYmychTQ k5yg== X-Gm-Message-State: APjAAAXH8brhZR318YWnfAT1sm/iwEX7f3WoG4qf3rFQ6BsJ9v05kBMY Nhe1uM+Cg6NpnvXjcaLPlXWI3FGFv2AMGMr7sHfZyQ== X-Received: by 2002:a02:6553:: with SMTP id u80mr38602190jab.51.1555047523884; Thu, 11 Apr 2019 22:38:43 -0700 (PDT) MIME-Version: 1.0 References: <20190411192607.GD225654@gmail.com> <20190411192827.72551-1-ebiggers@kernel.org> In-Reply-To: From: Dmitry Vyukov Date: Fri, 12 Apr 2019 07:38:32 +0200 Message-ID: Subject: Re: [PATCH] crypto: testmgr - allocate buffers with __GFP_COMP To: Kees Cook Cc: Eric Biggers , Rik van Riel , Matthew Wilcox , linux-crypto , Herbert Xu , Geert Uytterhoeven , linux-security-module , Linux ARM , Linux Kernel Mailing List , Laura Abbott Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 11, 2019 at 10:32 PM Kees Cook wrote: > > On Thu, Apr 11, 2019 at 12:31 PM Eric Biggers wrote: > > > > From: Eric Biggers > > > > This is needed so that CONFIG_HARDENED_USERCOPY_PAGESPAN=y doesn't > > incorrectly report a buffer overflow when the destination of > > copy_from_iter() spans the page boundary in the 2-page buffer. > > > > Fixes: 3f47a03df6e8 ("crypto: testmgr - add testvec_config struct and helper functions") > > Signed-off-by: Eric Biggers > > Reviewed-by: Kees Cook > > > --- > > crypto/testmgr.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/crypto/testmgr.c b/crypto/testmgr.c > > index 0f6bfb6ce6a46..3522c0bed2492 100644 > > --- a/crypto/testmgr.c > > +++ b/crypto/testmgr.c > > @@ -156,7 +156,8 @@ static int __testmgr_alloc_buf(char *buf[XBUFSIZE], int order) > > int i; > > > > for (i = 0; i < XBUFSIZE; i++) { > > - buf[i] = (char *)__get_free_pages(GFP_KERNEL, order); > > + buf[i] = (char *)__get_free_pages(GFP_KERNEL | __GFP_COMP, > > + order); > > Is there a reason __GFP_COMP isn't automatically included in all page > allocations? (Or rather, it seems like the exception is when things > should NOT be considered part of the same allocation, so something > like __GFP_SINGLE should exist?.) It would be reasonable if __get_free_pages would automatically mark consecutive pages as consecutive. When these should not be considered part of the same allocation? Is it possible to free them separately? Will that BUG with __GFP_COMP mark? I understand that there can be a weak "these are actually the same allocation, but I would like to think about them as separate". But potentially we can ignore such cases. > -Kees > > > if (!buf[i]) > > goto err_free_buf; > > } > > -- > > 2.21.0.392.gf8f6787159e-goog > > > > > -- > Kees Cook