Received: by 10.192.165.148 with SMTP id m20csp1146828imm; Wed, 25 Apr 2018 13:22:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx49A/4ZMX6EWCqeaNPGnYGQwPbqMpiuGbQH68NUTIaidps1/KHwwW4XO3vgeLr5g7lYcCBzf X-Received: by 10.98.67.141 with SMTP id l13mr29169502pfi.166.1524687731163; Wed, 25 Apr 2018 13:22:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524687731; cv=none; d=google.com; s=arc-20160816; b=qomuMb/aamOZY9/YpG9EJGCGjf0v/61SbqAyDSyeMkVXjq0TnAKtm3qlUIYYdO+z96 WudTNwK4lgR7CVLaCOybmMSaqK6vHHvbBBAceaCyZoAtUdZYd2TrcMazmoig4PO7Z6gA mlrYYSSeBnuKeEHS2vDMStLKdnmqBsvsEJ55bFtQta5Jh5QyDOlo1oHER5T1oQeiHuC2 47wcUEPJQiH5litgFhzEn3fVP8yfUboengHzt8c36z8qRwnkcf0TO747H+4HmeHXRLWb IraOKm8mqeWjIpjtUSGYZYRCVb6gCzmG7JCsAPSFi2gQ9K25nUDnQeMEXjXHipnOkdv1 EJeQ== 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:dkim-signature :arc-authentication-results; bh=l6cg8hJNcKAm+Rgw0U5LH4Sue55kA2zLnBS0tVqqj3o=; b=bpgzzAlDybVBlY67TMTKqQEPgfphdFO7yAk3PKEn3J0mgxp8dyf/vD6r6e5T223xt+ dCIdF5PHBE2q8BY9vJj2PQ2WuIJ9TAlmvxfbSsZuLkcmUBqjwn7dBsSOXyw8sIYlWudO Ncme0I0WAOsdSiS1zPSaWgGCs8d1b33J3L2BIdc8yR6IwfG3L3G1KYdXjAkDuLjq8MQC DvoMAGSmS2QdAUxFrGKc064Ou70xVM1LBzeIDo69QfL06DYH5CF2LGasegKyjlUpV2bm +A0O9N9fLiqx1wfbLeGD5zI7GAOL8sKE1GAkr/8ePPz+pXiRBtRug3ZYVvn/KBUi12UG 6YRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=hW1bksQj; 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 i64si14235121pgc.323.2018.04.25.13.21.55; Wed, 25 Apr 2018 13:22:11 -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=hW1bksQj; 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 S1753346AbeDYUUw (ORCPT + 99 others); Wed, 25 Apr 2018 16:20:52 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38156 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750968AbeDYUUt (ORCPT ); Wed, 25 Apr 2018 16:20:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To: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=l6cg8hJNcKAm+Rgw0U5LH4Sue55kA2zLnBS0tVqqj3o=; b=hW1bksQjt54zQuSJpdNNHP22F iMZqQ7xCsRi06lGmf554IJN6ee2Yp2Ad0DUepsOtfrUwe7yoaAFrOK++/SdFIu2e2AxnfEJcXx2Oc 4/ewtxhe1gtmfEq9tRzzWX+QUD2DT/lQkEVkVnBFAohfFllZtAuFFn28GwpVR61ga+NaMA3ypF+4q 3vBIwT5JvqtP2IJCRQVI39D6KQOWg01p0ZuCRLkqLnXUQGSAK14HB41sHnNq5zLYUPdH1s9uN2xhY DGFy2kI/V6YSmX8bq3gEH3BjkEnbCctxTZ3QTBn2DuLvg6flmW9mSTCuEMolxQjofah8cF7+lZl5k 6NqHPlRSg==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBQuB-0005Tr-6e; Wed, 25 Apr 2018 20:20:43 +0000 Subject: Re: [PATCH v4] fault-injection: introduce kvmalloc fallback options To: Mikulas Patocka , Michal Hocko Cc: Matthew Wilcox , David Miller , Andrew Morton , linux-mm@kvack.org, eric.dumazet@gmail.com, edumazet@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, dm-devel@redhat.com, Vlastimil Babka References: <20180421144757.GC14610@bombadil.infradead.org> <20180423151545.GU17484@dhcp22.suse.cz> <20180424125121.GA17484@dhcp22.suse.cz> <20180424162906.GM17484@dhcp22.suse.cz> <20180424170349.GQ17484@dhcp22.suse.cz> <20180424173836.GR17484@dhcp22.suse.cz> From: Randy Dunlap Message-ID: <1114eda5-9b1f-4db8-2090-556b4a37c532@infradead.org> Date: Wed, 25 Apr 2018 13:20:39 -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: Content-Type: text/plain; charset=utf-8 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 04/25/2018 01:02 PM, Mikulas Patocka wrote: > > > From: Mikulas Patocka > Subject: [PATCH v4] fault-injection: introduce kvmalloc fallback options > > This patch introduces a fault-injection option "kvmalloc_fallback". This > option makes kvmalloc randomly fall back to vmalloc. > > Unfortunatelly, some kernel code has bugs - it uses kvmalloc and then Unfortunately, > uses DMA-API on the returned memory or frees it with kfree. Such bugs were > found in the virtio-net driver, dm-integrity or RHEL7 powerpc-specific > code. This options helps to test for these bugs. > > The patch introduces a config option FAIL_KVMALLOC_FALLBACK_PROBABILITY. > It can be enabled in distribution debug kernels, so that kvmalloc abuse > can be tested by the users. The default can be overriden with overridden > "kvmalloc_fallback" parameter or in /sys/kernel/debug/kvmalloc_fallback/. > > Signed-off-by: Mikulas Patocka > > --- > Documentation/fault-injection/fault-injection.txt | 7 +++++ > include/linux/fault-inject.h | 9 +++--- > kernel/futex.c | 2 - > lib/Kconfig.debug | 15 +++++++++++ > mm/failslab.c | 2 - > mm/page_alloc.c | 2 - > mm/util.c | 30 ++++++++++++++++++++++ > 7 files changed, 60 insertions(+), 7 deletions(-) > > Index: linux-2.6/Documentation/fault-injection/fault-injection.txt > =================================================================== > --- linux-2.6.orig/Documentation/fault-injection/fault-injection.txt 2018-04-16 21:08:34.000000000 +0200 > +++ linux-2.6/Documentation/fault-injection/fault-injection.txt 2018-04-25 21:36:36.000000000 +0200 > @@ -15,6 +15,12 @@ o fail_page_alloc > > injects page allocation failures. (alloc_pages(), get_free_pages(), ...) > > +o kvmalloc_faillback kvmalloc_fallback > + > + makes the function kvmalloc randonly fall back to vmalloc. This could be used randomly > + to detects bugs such as using DMA-API on the result of kvmalloc or freeing > + the result of kvmalloc with free. > + > o fail_futex > > injects futex deadlock and uaddr fault errors. > @@ -167,6 +173,7 @@ use the boot option: > > failslab= > fail_page_alloc= > + kvmalloc_faillback= kvmalloc_fallback= > fail_make_request= > fail_futex= > mmc_core.fail_request=,,, > Index: linux-2.6/lib/Kconfig.debug > =================================================================== > --- linux-2.6.orig/lib/Kconfig.debug 2018-04-25 15:56:16.000000000 +0200 > +++ linux-2.6/lib/Kconfig.debug 2018-04-25 21:39:45.000000000 +0200 > @@ -1527,6 +1527,21 @@ config FAIL_PAGE_ALLOC > help > Provide fault-injection capability for alloc_pages(). > > +config FAIL_KVMALLOC_FALLBACK_PROBABILITY > + int "Default kvmalloc fallback probability" > + depends on FAULT_INJECTION > + range 0 100 > + default "0" > + help > + This option will make kvmalloc randomly fall back to vmalloc. > + Normally, kvmalloc falls back to vmalloc only rarely, if memory > + is fragmented. > + > + This option helps to detect hard-to-reproduce driver bugs, for > + example using DMA API on the result of kvmalloc. > + > + The default may be overriden with the kvmalloc_faillback parameter. overridden kvmalloc_fallback > + > config FAIL_MAKE_REQUEST > bool "Fault-injection capability for disk IO" > depends on FAULT_INJECTION && BLOCK -- ~Randy