Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2764915ybh; Mon, 5 Aug 2019 06:29:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPaHkz/DZxRsqLV40ELbYsh6uYcrAzBqLLnideOGL8Ch83oX5Vv3VP/lmzJxBttDUbvGAR X-Received: by 2002:a63:1b56:: with SMTP id b22mr19437120pgm.265.1565011796605; Mon, 05 Aug 2019 06:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565011796; cv=none; d=google.com; s=arc-20160816; b=HvYaAeqSZJnitg++P/IYVJmhEVfo91vNsa0Jr5FIfh0w2BO74TYwJU/fyk/c/3P9aR rEBNwJY+7U5xieFg7sw83t8oWXCWRs6mfTtiYy+EOorcQS3K3Ys1Q6MInRZHu4aBR7o5 LV1Q9aury7fDu9YtFtSC2DAvOEltHD4aZEyaay0Ndc8TXtxUPHp2dFtxZhVLpBJeilKg H2MMwCD462rstwnFRWfJV2QuNzD0mApme4S6HmZeRYiwk31TKrVChHKxrnsYjC339i3c Ffi6xfgRcRcw8F/e9lbpGdVHt0VdIKxb7z6QF5sIUnzHlyuoyHw/oYh5bhQr4vMGyBN5 ggqw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SSDp2uOC9hLXOE7I0jFR+XKDuk95Fp6FJVWwWfXSvrs=; b=T01CrmVSuS2tu/4imyvn63VihZ2R5ZajRljVQ5rmduiO2WqNBdLhoeycM3XfY4ncHu 8H3V0hOTgeYu2lmyeBSvcmKbiIbT9YE/FNVipi7x+g8Z5RENijBLMNQU17/qqZndcAFQ Bdkk1lbafi6G0gGiWfXNvPOaAi7uuY7lqDbswq9HTiHvnABCrWpuCJ5qqd6m2zxuCF5K gvgbZp07aUw9FJsB/fY6Gngdjw3Ph/7nUuTevJEeme+sBR3B+FVImAnmXPgPNXKGclQu hCjjiq4f1mX8oMa+oauIGors9fjQGooFitc7FWsFObwdTF+MmAvIgRCiynGdNuB7BYm6 1qag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pPfq6Cgg; 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 h38si26014671pgi.327.2019.08.05.06.29.41; Mon, 05 Aug 2019 06:29:56 -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=@kernel.org header.s=default header.b=pPfq6Cgg; 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 S1730769AbfHEN3K (ORCPT + 99 others); Mon, 5 Aug 2019 09:29:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:58594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730638AbfHENWP (ORCPT ); Mon, 5 Aug 2019 09:22:15 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F407A216B7; Mon, 5 Aug 2019 13:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565011334; bh=Y8QJsEx3iQGHlddjHTT8Du+dE5LcgvkKqSkfYJiQt9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pPfq6Cggo2i5uA/Viul/UNWQNqAm46KXnv0vdf4hn1zrRo0uMQuCdB/UT5hgGPIsK /bRquLo4OpfzMcM3VGc6M9Rltf8U1PzoSymDf2XZNMCkwqjmwuLIMxuHYmHVJJ9Oin fl+StO3Ix703OEnTlCb7L6sXk6TUKXuWyIMKScF8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Randy Dunlap , Rasmus Villemoes , Joe Perches , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.2 054/131] lib/test_overflow.c: avoid tainting the kernel and fix wrap size Date: Mon, 5 Aug 2019 15:02:21 +0200 Message-Id: <20190805124955.049639253@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124951.453337465@linuxfoundation.org> References: <20190805124951.453337465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 8e060c21ae2c265a2b596e9e7f9f97ec274151a4 ] This adds __GFP_NOWARN to the kmalloc()-portions of the overflow test to avoid tainting the kernel. Additionally fixes up the math on wrap size to be architecture and page size agnostic. Link: http://lkml.kernel.org/r/201905282012.0A8767E24@keescook Fixes: ca90800a91ba ("test_overflow: Add memory allocation overflow tests") Signed-off-by: Kees Cook Reported-by: Randy Dunlap Suggested-by: Rasmus Villemoes Cc: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- lib/test_overflow.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/test_overflow.c b/lib/test_overflow.c index fc680562d8b69..7a4b6f6c5473c 100644 --- a/lib/test_overflow.c +++ b/lib/test_overflow.c @@ -486,16 +486,17 @@ static int __init test_overflow_shift(void) * Deal with the various forms of allocator arguments. See comments above * the DEFINE_TEST_ALLOC() instances for mapping of the "bits". */ -#define alloc010(alloc, arg, sz) alloc(sz, GFP_KERNEL) -#define alloc011(alloc, arg, sz) alloc(sz, GFP_KERNEL, NUMA_NO_NODE) +#define alloc_GFP (GFP_KERNEL | __GFP_NOWARN) +#define alloc010(alloc, arg, sz) alloc(sz, alloc_GFP) +#define alloc011(alloc, arg, sz) alloc(sz, alloc_GFP, NUMA_NO_NODE) #define alloc000(alloc, arg, sz) alloc(sz) #define alloc001(alloc, arg, sz) alloc(sz, NUMA_NO_NODE) -#define alloc110(alloc, arg, sz) alloc(arg, sz, GFP_KERNEL) +#define alloc110(alloc, arg, sz) alloc(arg, sz, alloc_GFP) #define free0(free, arg, ptr) free(ptr) #define free1(free, arg, ptr) free(arg, ptr) -/* Wrap around to 8K */ -#define TEST_SIZE (9 << PAGE_SHIFT) +/* Wrap around to 16K */ +#define TEST_SIZE (5 * 4096) #define DEFINE_TEST_ALLOC(func, free_func, want_arg, want_gfp, want_node)\ static int __init test_ ## func (void *arg) \ -- 2.20.1