Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1475192imm; Fri, 29 Jun 2018 20:11:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKK1Cti64mCLGY/NrN55VLv449MstAAQn1fwojucwiTP7u2QoSKqxYayRXrM5zTuxiRr+61 X-Received: by 2002:a17:902:8308:: with SMTP id bd8-v6mr17456053plb.329.1530328282029; Fri, 29 Jun 2018 20:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530328282; cv=none; d=google.com; s=arc-20160816; b=GfpgurK5XnAKqWWFx03aEWp3meCDrGiry8WUUlyHmWg1JOO91HOHfDEXsLmLKMZVnr n3KeALorWino7+aEfzYsg97TIqDUP7dF8LhD1ddtGU423lfEg4/JCoHSTTzcCh4l0/ik l78ZweC7JB0Bcmfwp5pQ9sbaJ/tiDX63s54gwuJtA7D24MSJU0tuZTHIVWIw0+2EYPVr o8Okbeq7126ikxDFGMQPm29dsQESKAF1WdfwjR4Wun5xcgnvsUpjqmx5N7+ZwrWHH9fQ 9tpXVd4VdDN9ziwmjq5/DyCitMU5lOpg7+bhZiBlyJU5misNMjgY9PRsEZs7w77eBRH6 XaPQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=YXlXuc2FbjU0tIhe0jiPMJ32nfJogJRTixAK1m1PNaY=; b=abyqpNYN6sDmKzzs7t9ySEB8oEsnZw3/nL0e1Si24QoFnD2kN55I5gPAsYalO50sVA zEux1yLhhNcbuTy9xNJfVm6JVJ8BIVxur6IDBbuMnS3ppRZ9XNZ3y9fei1ZNwviXxIwM 3u5Zs7idZ0knimzPewxm2opgpwm/006geSFeuXgGQ8Txc/vt/P/wfDew59wcV1KSF3ZE RqQJGBaLt7+FxUaVc98D2b5uoNV0MXxGu76chLz+uld6ZnRiyLZWi2wXYOUKQY9M4X17 V0vmSvji8bkKN/A1Cp/+o6cVLpG3dCBhoIzqASwX3WEBrqYq1PDMXtq4PIEtl+J/VN9m H9Fw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a67-v6si9458220pla.177.2018.06.29.20.11.07; Fri, 29 Jun 2018 20:11:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936187AbeF3CdF (ORCPT + 99 others); Fri, 29 Jun 2018 22:33:05 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60366 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755609AbeF3CdC (ORCPT ); Fri, 29 Jun 2018 22:33:02 -0400 Received: from localhost.localdomain (c-24-4-125-7.hsd1.ca.comcast.net [24.4.125.7]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A94F0891; Sat, 30 Jun 2018 02:33:01 +0000 (UTC) Date: Fri, 29 Jun 2018 19:33:00 -0700 From: Andrew Morton To: Andrey Ryabinin Cc: david@fromorbit.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, dan.j.williams@intel.com, dvyukov@google.com, glider@google.com Subject: Re: [PATCH v2] kernel/memremap, kasan: Make ZONE_DEVICE with work with KASAN Message-Id: <20180629193300.0ae0f25880a800bd27952b15@linux-foundation.org> In-Reply-To: <20180629164932.740-1-aryabinin@virtuozzo.com> References: <20180625170259.30393-1-aryabinin@virtuozzo.com> <20180629164932.740-1-aryabinin@virtuozzo.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 29 Jun 2018 19:49:32 +0300 Andrey Ryabinin wrote: > KASAN learns about hot added memory via the memory hotplug notifier. > The devm_memremap_pages() intentionally skips calling memory hotplug > notifiers. Why does it do that? > So KASAN doesn't know anything about new memory added > by devm_memremap_pages(). This causes to crash when KASAN tries to > access non-existent shadow memory: > > BUG: unable to handle kernel paging request at ffffed0078000000 > RIP: 0010:check_memory_region+0x82/0x1e0 > Call Trace: > memcpy+0x1f/0x50 > pmem_do_bvec+0x163/0x720 > pmem_make_request+0x305/0xac0 > generic_make_request+0x54f/0xcf0 > submit_bio+0x9c/0x370 > submit_bh_wbc+0x4c7/0x700 > block_read_full_page+0x5ef/0x870 > do_read_cache_page+0x2b8/0xb30 > read_dev_sector+0xbd/0x3f0 > read_lba.isra.0+0x277/0x670 > efi_partition+0x41a/0x18f0 > check_partition+0x30d/0x5e9 > rescan_partitions+0x18c/0x840 > __blkdev_get+0x859/0x1060 > blkdev_get+0x23f/0x810 > __device_add_disk+0x9c8/0xde0 > pmem_attach_disk+0x9a8/0xf50 > nvdimm_bus_probe+0xf3/0x3c0 > driver_probe_device+0x493/0xbd0 > bus_for_each_drv+0x118/0x1b0 > __device_attach+0x1cd/0x2b0 > bus_probe_device+0x1ac/0x260 > device_add+0x90d/0x1380 > nd_async_device_register+0xe/0x50 > async_run_entry_fn+0xc3/0x5d0 > process_one_work+0xa0a/0x1810 > worker_thread+0x87/0xe80 > kthread+0x2d7/0x390 > ret_from_fork+0x3a/0x50 > > Add kasan_add_zero_shadow()/kasan_remove_zero_shadow() - post mm_init() > interface to map/unmap kasan_zero_page at requested virtual addresses. > And use it to add/remove the shadow memory for hotpluged/unpluged > device memory. > > Reported-by: Dave Chinner > Signed-off-by: Andrey Ryabinin > Cc: Dan Williams > Cc: Dmitry Vyukov > Cc: Alexander Potapenko No cc:stable? Which kernel version(s) do you believe need the fix? > include/linux/kasan.h | 13 ++- > kernel/memremap.c | 10 ++ > mm/kasan/kasan_init.c | 316 +++++++++++++++++++++++++++++++++++++++++++++++--- It's a surprisingly large amount of ode to do something which KASAN already does for hotplugged memory. How come?