Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752454AbdLWMow (ORCPT ); Sat, 23 Dec 2017 07:44:52 -0500 Received: from mail-db5eur01on0129.outbound.protection.outlook.com ([104.47.2.129]:56224 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750810AbdLWMos (ORCPT ); Sat, 23 Dec 2017 07:44:48 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Subject: Re: linux/master crashes on boot with KASAN=y To: Jakub Kicinski , Andy Lutomirski Cc: Thomas Gleixner , Ingo Molnar , LKML References: <20171223000143.0af3366d@cakuba.netronome.com> From: Andrey Ryabinin Message-ID: <41c68406-ad05-1db7-b0dd-a2e616448ee1@virtuozzo.com> Date: Sat, 23 Dec 2017 15:41:27 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171223000143.0af3366d@cakuba.netronome.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [84.47.128.244] X-ClientProxiedBy: AM5PR0502CA0012.eurprd05.prod.outlook.com (2603:10a6:203:91::22) To VI1PR08MB2829.eurprd08.prod.outlook.com (2603:10a6:802:19::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 567e61e2-e3f0-499f-2b42-08d54a02f233 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060);SRVR:VI1PR08MB2829; X-Microsoft-Exchange-Diagnostics: 1;VI1PR08MB2829;3:Pem4Ld2jPf8I+QyDLf9yssvNvIJPBdr+40mW1I0zXODAOnk1c07iQErnCKRdPiHLNgKhw1rpkYpoLlrHV3DQUtQJY/M182RGDhCfYIaZFQnzHHy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xnAdI3c2c3czBkngQ53RzhcWms9KG2qk2Ae0X7ukkSwcpQgJUQMQVQw721OYdOIMcBACBjrnL8HbE3VCsFkbc4CnIYHTFzTtkMFz7899oZMDQg5TsbdJxS3YP6vDkm6DyubQC02n9mdH31sZCbXLchjC4FUs=;4:SE18zJ8PYlenHzdR6D3teH0GtzohpT/vijna/YTQVXUQBZmfOHYuqeGSfAHJ6bGwYL1y9i1AZOPZolsNkI57+9XlQJbJRt3qIiLBiZqV9uqKo0qYxBLKWfYR7ErvTBWNuI/kZMwzycSNHbHexYRXoBSpW2WruPxuT28FTaZP4FUeCSLpcpmGDDN86BqECBlW8Fq6SDryAeQFSeu+q4ZecuaTrK3QdwEgfDDwYeorAY8U4nzZjAB8wf2MqBg1HhLzi6OnzyzM5WdHkP5MrJRO/A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(10201501046)(3231023)(93006095)(93001095)(3002001)(6041268)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(6072148)(201708071742011);SRVR:VI1PR08MB2829;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:VI1PR08MB2829; X-Forefront-PRVS: 0530FCB552 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(39840400004)(376002)(39380400002)(396003)(366004)(346002)(24454002)(189003)(199004)(50466002)(65806001)(3846002)(6246003)(53936002)(230700001)(316002)(386003)(53546011)(6666003)(36756003)(2950100002)(25786009)(8936002)(16576012)(83506002)(229853002)(6486002)(86362001)(16526018)(54906003)(478600001)(58126008)(97736004)(110136005)(305945005)(81156014)(2906002)(81166006)(65826007)(106356001)(47776003)(77096006)(59450400001)(31696002)(52116002)(8676002)(65956001)(64126003)(23746002)(66066001)(7736002)(6116002)(31686004)(105586002)(68736007)(5660300001)(76176011)(4326008);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR08MB2829;H:[10.52.82.103];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;VI1PR08MB2829;23:qu1KwG/zfQwmXXJfhH202DSqHrZ/H4xoigiXZ?= =?Windows-1252?Q?stdocIOMYTtybc2Gbv/FQco7zYtQt/CZ5uKfFNvlTJ81Pi4Bj+Fot5S0?= =?Windows-1252?Q?2ju0uHyhzNa84Z/+ufOLVgBP4w1H4WAlZGnL/8arsWCimLjF5+XCbbUW?= =?Windows-1252?Q?7dLITdzpoBA9Bml1CepscTIJPK3Qy/3WWrCn3ujlzahWtMbOvic0vemU?= =?Windows-1252?Q?RCqhDchkPT3FT/uIXzJ3PvMZN6GyIAQCOFrpM6HESJ/DJpNDfeqWaycs?= =?Windows-1252?Q?FXpyI1ExmpwpnpKMIGN21jlms9SXOPpqCrZD1WCMTx2BXwQVrHTzNxN+?= =?Windows-1252?Q?mBqSLXWEFP9ON3WNYWFa6O5OCP1fRCQzMu3rNIaUlCrqmHR1UuQowu0U?= =?Windows-1252?Q?zwOYE6Wr7EDowUIjpQIudVdbRYAQlATPhefA5a/81HKa0LFiakhvx5N0?= =?Windows-1252?Q?Q9nA0UWsyLZVz/KJUDNDFRIOyNRiWLZO4F8x7S7jLXqekssqfPk6sEv0?= =?Windows-1252?Q?by8ip8WIEizKXptj6Awr/A4snruw/joIefKFTl2Bm7TMr6sGWzzAMQu/?= =?Windows-1252?Q?ep5yE7MS0x1XuqVlcLOMfKgv5TpoCr3jUW8mc+NEcqp4wl/+pATn+P5I?= =?Windows-1252?Q?KgokKBFgOP9t+GKGLL6M9ao5pKoLg4GGkGlO+62FyXWLCcM6VS+DOdMq?= =?Windows-1252?Q?3qtzvgJACr4ilBZ7qFNCbYJ/3ZZ2EA1fpt5S98jk4UDLbzb9adyLQKGK?= =?Windows-1252?Q?CadnhC7d6ETDS6V8E7AGywB+73AQXpaOAeEZ3Xs43GjOOnRi94o00yGG?= =?Windows-1252?Q?tH7SKRkXkou8NaOPFjGIqRvq0+2jWTn7/7VUS70FlvgUd0xdBQh9U8lQ?= =?Windows-1252?Q?BydVOkZVV7U+1WwC1NOmorv0wvB0b/Ye14V4rth6IKgjfYjZ/N1wwyHK?= =?Windows-1252?Q?DhNKGp2hrpvc3JdPiiS7wDn0LtUsTHBHVEFheBCL6bhpgJCJZhlLQ2qM?= =?Windows-1252?Q?y0rgyILIOkdZ/Tki4plP7A56KILjC5mqCY7vdnKMgo+DWz56fStcHH0q?= =?Windows-1252?Q?f+UaaPZEHc0cr+LqGOZYhiCv03wWXfd5wFoaI7pdRFND6Pu6RAdX3kAq?= =?Windows-1252?Q?FCcZNWlcW07Tcaiv2tRgmEVymA0vhC27/DD8fL1q5Wsm0ABWoidCwv7y?= =?Windows-1252?Q?/immh7+97cjdeiQnyiYTqKYWpWPXYdIiUTu3SCKeweTdDsXg+aOlsuX3?= =?Windows-1252?Q?x1R27WZZbZZtjomO2C5l+urtYC8vAVGGU8vO0utmvyc/ShzMDACwAS5X?= =?Windows-1252?Q?3VnvLPaXVk68ESNf9/LNlyeJaJjn4YROiGbA8rFl2adb7aiFiZAGOsda?= =?Windows-1252?Q?rLRSygrQzyJvvHQEfcTa1HptK2y0dRNxm1Q0NM0uXQr+6uLf0T5Dt6xb?= =?Windows-1252?Q?aoArIon1l5SCGHMT7Upr/yXZ0UiBboyjKKUtfaEig=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;VI1PR08MB2829;6:pFeOwt4v2cu29WOhHVN2/fr7OBocPwVwwyWVLIweyzhWh2PW13ywFZb0W3JemHPlztR1EF6z3SK9s7STcYUogbb7bqNJxRzVhymaG6Uf6PbCuB0bVwnqO5LQgm6Q9expY/oY9+uSQwaSNm812KjqZFi8LuPqNCdDV22jOhnZlAjUNVM1N7ePT139vXChzmi+/zstLNQvtz6vT9gChu1ZeADZYwYhqliwdZeZF49sjgK5Jtv8J0CwH5YWPdsfpg2yDwba93TQVV2bKzbuKnFvRoCFUWEV7GvFrM32SbgHZJoeip91K6eGeJ5yc9C1gGdu+cOjDj+UTCf5z7Zw0p02Cc18VZdAXYDFJg1hW0P8+mk=;5:P9OElJn5wUf97Dx5EKvTf1seHdUsLqzyst5TDNx5Lf3RBugIeoSUTaVIAx5m9W5QjWDWK8Ss3Pk0eRLTuENk4AF3+JBaLkGrm/EyyWZPZ6JWvvdSKt2jfH1zfNC8lfCBsiPoP1++3Qd71BbirKSNRPnz5HXCsnk+/Zidd9FHjv4=;24:/jW50p5DpXwd2aTo9PXIM+SQjRXerg+wP/e3zCZBJJ7u8zrhBztdl4wkQjjwwLoFADBiWhRGmrs3XAATJBD6qEuClEpBVuFZpSMGIfqEV6U=;7:NqbeAoNVjcTDizYJF75Ae0tFfvuKAQ70ePA/VcbBd9Pe94Sm0YD2z2F+4iGo/2qbvo6B0cLWNvmY0anF8GY+EGSxM4yaN+08axG+YKUVIMU3TtnSuSTfeYwYB/t+G6P/gEENplXtO8ZRRUzUQZvJKcIcuN0qXJraizMOmdo+kWQYiJP9ELKIkAWQAbK9HXd2NGlzmmDD6g7LP/aZYAhSGrN6gm41TSKfwPcT7aLxfclUeIfO7V840MyymUagoxPp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR08MB2829;20:BRk9YtsVMQZKQy70Imerq1HPKAh/kMkaVfyf1tgyDcadM5XtgEkrwkihhQk2/Kh8xIxd52pD5My7/UzytU5kXbdhqlwTsKjxKUNDYH8nHlOQyLuEJ/mOyzo0KPsKr8pdIzOF0/EEgoOzaSbNBCmAPQ1ClyYJsyjbh7+SegUy2d8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Dec 2017 12:44:45.1154 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 567e61e2-e3f0-499f-2b42-08d54a02f233 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2829 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2429 Lines: 68 On 12/23/2017 11:01 AM, Jakub Kicinski wrote: > Hi! > > I bisected a crash on boot to this: > > commit 21506525fb8ddb0342f2a2370812d47f6a1f3833 (HEAD, refs/bisect/bad) > Author: Andy Lutomirski > Date: Mon Dec 4 15:07:16 2017 +0100 > > x86/kasan/64: Teach KASAN about the cpu_entry_area Thanks. There is nothing wrong with this patch, it just uncovered older bug. The actual problem comes from f06bdd4001c2 ("x86/mm: Adapt MODULES_END based on fixmap section size") which is made kasan_mem_to_shadow(MODULES_END) potentially unaligned to page boundary. And when we feed unaligned address to kasan_populate_zero_shadow() it doesn't do the right thing. Could you tell me if the fix bellow works for you? --- arch/x86/include/asm/kasan.h | 8 ++++++++ arch/x86/include/asm/pgtable_64_types.h | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kasan.h b/arch/x86/include/asm/kasan.h index b577dd0916aa..0c580e4b2ccc 100644 --- a/arch/x86/include/asm/kasan.h +++ b/arch/x86/include/asm/kasan.h @@ -5,6 +5,14 @@ #include #define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL) +#ifndef KASAN_SHADOW_SCALE_SHIFT +# ifdef CONFIG_KASAN +# define KASAN_SHADOW_SCALE_SHIFT 3 +# else +# define KASAN_SHADOW_SCALE_SHIFT 0 +# endif +#endif + /* * Compiler uses shadow offset assuming that addresses start * from 0. Kernel addresses don't start from 0, so shadow diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index 6d5f45dcd4a1..d34a90d6c374 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h @@ -6,6 +6,7 @@ #ifndef __ASSEMBLY__ #include +#include #include /* @@ -96,7 +97,8 @@ typedef struct { pteval_t pte; } pte_t; #define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL)) #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE) /* The module sections ends with the start of the fixmap */ -#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1) +#define MODULES_END (__fix_to_virt(__end_of_fixed_addresses + 1) & \ + ~((PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT) - 1)) #define MODULES_LEN (MODULES_END - MODULES_VADDR) #define ESPFIX_PGD_ENTRY _AC(-2, UL) #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << P4D_SHIFT) -- 2.13.6