Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758153AbcLAOjN (ORCPT ); Thu, 1 Dec 2016 09:39:13 -0500 Received: from mail-db5eur01on0134.outbound.protection.outlook.com ([104.47.2.134]:43660 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751758AbcLAOjL (ORCPT ); Thu, 1 Dec 2016 09:39:11 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Subject: Re: [PATCH] x86/suspend: fix false positive KASAN warning on suspend/resume To: Josh Poimboeuf , "Rafael J. Wysocki" , Len Brown , Pavel Machek , References: <20161129181300.GA29095@sbauer-Z170X-UD5> <20161130183507.syv3cdpp3hzxi77k@treble> <20161130190217.GA2756@sbauer-Z170X-UD5> <20161130231011.ofmbmevn3hqasetz@treble> CC: , , , , Scott Bauer , , Alexander Potapenko , Dmitry Vyukov , From: Andrey Ryabinin Message-ID: <8f4c4a62-d912-0cd9-3462-8df20a868834@virtuozzo.com> Date: Thu, 1 Dec 2016 12:05:34 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 In-Reply-To: <20161130231011.ofmbmevn3hqasetz@treble> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: HE1PR0101CA0022.eurprd01.prod.exchangelabs.com (10.168.141.160) To AM5PR0801MB2051.eurprd08.prod.outlook.com (10.168.158.141) X-MS-Office365-Filtering-Correlation-Id: 447f5136-68fe-4086-8a6c-08d419c92668 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:AM5PR0801MB2051; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0801MB2051;3:eTvPq7JC0Ad8Iqz1W9g5439ws+4d5cJdsMFsawKfUFgsVFZbkaIbYQst26mmyFxt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L0I6O3L5ZGjAZzIjsOOtqqyGlzWRLdVkMpISSYvB7tAqSe2cCJQf23QX4CuAdVjFXrHHinXY6ml9GblNpGHbKgIgl+TNzFJukWL377nC6DuT7k= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(20161123558021)(2016111802025)(6072148)(6043046);SRVR:AM5PR0801MB2051;BCL:0;PCL:0;RULEID:;SRVR:AM5PR0801MB2051; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0801MB2051;4:lANxo6doIeFgpI7gQXNniFur9FMnlD4o1Dgz4rXNqqpBE81PcsRBfhq821PkMV1D+4SrgPcqas2zZrI7UfWuE4gywVErzV1MGbiMJxT01f1eDPA1eDzfgJ7oMzWldWGxlN/DuEBNtGck0llYFmGevYcfZJKoK/yDJ2Ro00SB2/smnG8bcGFqAEh/qzo7HAHQpV7j6/kCa0n+FNNctOsznfT6/EUViJwlumsjzrE2ZfaDLCg1H7eyrbA5cZQESUHt9BK1vmqixszJv3rWD/RWc1mdg5zhnGeNDNWgdNp34dY4OhRCL3uIQOY0nX0HLHcrhGzSLxQA9VTmQCqZIg6DywlgPJx4Z6cOgxg30FsQ6/BQ+UfKJ+vJaO29BrAdAxx6Jg0BCJUZnNAZuTeMkHfvoj7o0LytpPG6cXgcq3DoO945JXwGBjNtJGtqR5aqBG5Ly/lo4J/fgr5KMEKuSObQ8QBmq787G/wSEXMwBAcKLvHWQobBUDr+5lgYr6DnhPfJ3MHm9MH/6RYEnDzwLnviTilFQts1edt/fRYhB11WECgK0bTj1yZ/0Iuk5rhm8gG5F0NloGbxXa5nzE5/HmAhvfFs3SdCbKYIaw7F/FMFAPVNIfBImulq7WxD+7/QujZQ8/MwMPyBdOLw/C+pkHCISOhJqMMksxbEJ5t9gARGf3f+CCSDntC06H+DsDbZl+qkf71ZMhC6idbjKOwaFAGKjQ== X-Forefront-PRVS: 014304E855 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(7916002)(189002)(24454002)(377454003)(199003)(23676002)(105586002)(15650500001)(50986999)(76176999)(54356999)(229853002)(38730400001)(36756003)(42186005)(3846002)(31686004)(68736007)(101416001)(106356001)(50466002)(2950100002)(6116002)(4001350100001)(5001770100001)(97736004)(6666003)(189998001)(4326007)(8676002)(81166006)(81156014)(92566002)(5660300001)(64126003)(2906002)(230700001)(93886004)(33646002)(7846002)(733004)(77096006)(6486002)(7416002)(65806001)(305945005)(65956001)(31696002)(7736002)(66066001)(86362001)(83506001)(39450400002)(39410400001)(47776003)(65826007);DIR:OUT;SFP:1102;SCL:1;SRVR:AM5PR0801MB2051;H:[10.30.19.223];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTVQUjA4MDFNQjIwNTE7MjM6VDhFdE5MRTVpbVRCcTdyQmRSTEhndlhP?= =?utf-8?B?cEgyMGZVY3lsTDk2K1BFamtYdjhIaVQvZUZ2R3pldGRyTFNsOUw0OXQ4TE5v?= =?utf-8?B?dEdFdVF1aU9RU1dWQjd2Vlo4NEc1ZHpHRW9kc1U2MzZzT3AxZUhNeU5hZldK?= =?utf-8?B?cHl2bDNMWUpxUXRZczNQa3BSUHNJWnI5U29WSXhmbWlna1BFaktxZVVBbEht?= =?utf-8?B?bnh1dUtqd0JBOERwMmh2QStqa3RRaWpnZzlvV0lMMWFZU0U4bWRaRDRTVjY3?= =?utf-8?B?NzFsYmRTbm5lZFFjMzNPZzhGV1lBWlRPeHhQZmQ4UW1kWGM5c3h1YytxUUtH?= =?utf-8?B?ZUQyNXBxbVdkQko1TjZaS0YwbmwzUkdGNnViODN4V25iKzNuZG9IUmo5SnZ0?= =?utf-8?B?QVkrQ1h1TFlCWGFtL3hz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1oEjw0jiIJmHJT64rbdeG8+x/9a1AxDnLTAnZQt9y+qwIraypuAkKs= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2016 09:05:07.2374 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB2051 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1345 Lines: 36 On 12/01/2016 02:10 AM, Josh Poimboeuf wrote: > Resuming from a suspend operation is showing a KASAN false positive > warning: > > KASAN instrumentation poisons the stack when entering a function and > unpoisons it when exiting the function. However, in the suspend path, > some functions never return, so their stack never gets unpoisoned, > resulting in stale KASAN shadow data which can cause false positive > warnings like the one above. > > Reported-by: Scott Bauer > Tested-by: Scott Bauer > Signed-off-by: Josh Poimboeuf > --- > arch/x86/kernel/acpi/sleep.c | 3 +++ > include/linux/kasan.h | 7 +++++++ > 2 files changed, 10 insertions(+) > > diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c > index 4858733..62bd046 100644 > --- a/arch/x86/kernel/acpi/sleep.c > +++ b/arch/x86/kernel/acpi/sleep.c > @@ -115,6 +115,9 @@ int x86_acpi_suspend_lowlevel(void) > pause_graph_tracing(); > do_suspend_lowlevel(); > unpause_graph_tracing(); > + > + kasan_unpoison_stack_below_sp(); > + I think this might be too late. We may hit stale poison in the first C function called after resume (restore_processor_state()). Thus the shadow must be unpoisoned prior such call, i.e. somewhere in do_suspend_lowlevel() after .Lresume_point.