Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp217357imu; Tue, 15 Jan 2019 20:17:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Y2yVWVOob1po2JqibVX57U5xSF2AHxfypcHiMZrYqgSY+FG50hzbNQFM3ToIWt/q/pPKO X-Received: by 2002:a63:160d:: with SMTP id w13mr7111038pgl.43.1547612269304; Tue, 15 Jan 2019 20:17:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547612269; cv=none; d=google.com; s=arc-20160816; b=H+nI7tLCMTBGd0YdPC3aihj19/XjYKDbO58pf5ye7lZ1CDSsxeEPutElBS5HsARKZX gWLNxNdPUyfJ8JtHR7ExNkyS2xIq1+meSelwHyxsPoBS5umBa6JQ8lJkPEDmxjkFHIyZ qh7wD290IAH2as5K3Cc8b4iqb3Thtq9bzefFUcORnvstyftMh43t40G1M+XbFMDL4//s rE5dehVd7N4d37mpPNylWT7HhMYpA/jD5bKmPB//wToOx0l8wnX16aZ7nQC3xvB120mQ cTxKUIIFRiuajVMbGhlNvteSPzPQE8JmU8QUHfn3KhgKs1khenUKsNp7+pygdouF9Rvw G9Wg== 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; bh=MCvx5dBJWlgSiaXvtZOFQWj9OJqRKMyrVgbfZuB0FIY=; b=JlzqyCh9Eap70yVol8aFJ52CnI1WqDWiMdCmuK5h/3aQCPPvn2uYVcD7iPBZcB8v5E 9GDm5VkLIQwwp+veZvRrHbWHQlDgG5WgrImW0VcfnQh8/O7JR8zv6DUgh/+ip7gfZ0AN sWiIfcQNuHpT/5Mc9lMWOaH710K0V6pbrQ4jNsdeOE+XXK6aS8+ZhglhbNNPwP1KuxDU xWee5REhvBA9zrl7LrvAWDwv1ZyaNz07QsbrB0tODDmU2cEYHPGxpNmstFN0Xs1x3njq 7y+AT3BPhgb5+GDizOrR8JXet716cjzlnVQjJZG7Ni+bKB/p41O9sEtLuv7JiSwpc4pv 6AVA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w11si5416156pfk.210.2019.01.15.20.17.33; Tue, 15 Jan 2019 20:17:49 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730373AbfAORY7 (ORCPT + 99 others); Tue, 15 Jan 2019 12:24:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:54032 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728736AbfAORY7 (ORCPT ); Tue, 15 Jan 2019 12:24:59 -0500 Received: from [172.16.25.12] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gjSSP-0004cU-Nd; Tue, 15 Jan 2019 20:24:57 +0300 Subject: Re: [PATCH v2] page_poison: play nicely with KASAN To: Qian Cai , akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <2e46c139-70d3-dc86-28c9-a9f263651b57@virtuozzo.com> <20190114233405.67843-1-cai@lca.pw> From: Andrey Ryabinin Message-ID: <3a2aefb4-f108-5354-ddb9-7a35d8e0b3f2@virtuozzo.com> Date: Tue, 15 Jan 2019 20:25:20 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190114233405.67843-1-cai@lca.pw> 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 1/15/19 2:34 AM, Qian Cai wrote: > KASAN does not play well with the page poisoning > (CONFIG_PAGE_POISONING). It triggers false positives in the allocation > path, > > BUG: KASAN: use-after-free in memchr_inv+0x2ea/0x330 > Read of size 8 at addr ffff88881f800000 by task swapper/0 > CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc1+ #54 > Call Trace: > dump_stack+0xe0/0x19a > print_address_description.cold.2+0x9/0x28b > kasan_report.cold.3+0x7a/0xb5 > __asan_report_load8_noabort+0x19/0x20 > memchr_inv+0x2ea/0x330 > kernel_poison_pages+0x103/0x3d5 > get_page_from_freelist+0x15e7/0x4d90 > > because KASAN has not yet unpoisoned the shadow page for allocation > before it checks memchr_inv() but only found a stale poison pattern. > > Also, false positives in free path, > > BUG: KASAN: slab-out-of-bounds in kernel_poison_pages+0x29e/0x3d5 > Write of size 4096 at addr ffff8888112cc000 by task swapper/0/1 > CPU: 5 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc1+ #55 > Call Trace: > dump_stack+0xe0/0x19a > print_address_description.cold.2+0x9/0x28b > kasan_report.cold.3+0x7a/0xb5 > check_memory_region+0x22d/0x250 > memset+0x28/0x40 > kernel_poison_pages+0x29e/0x3d5 > __free_pages_ok+0x75f/0x13e0 > > due to KASAN adds poisoned redzones around slab objects, but the page > poisoning needs to poison the whole page. > > Signed-off-by: Qian Cai > --- > Acked-by: Andrey Ryabinin