From patchwork Fri Dec 2 13:41:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 9458949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B86460236 for ; Fri, 2 Dec 2016 18:14:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 027772840B for ; Fri, 2 Dec 2016 18:14:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9011285A2; Fri, 2 Dec 2016 18:14:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CEB82840B for ; Fri, 2 Dec 2016 18:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753572AbcLBSOf (ORCPT ); Fri, 2 Dec 2016 13:14:35 -0500 Received: from mail-db5eur01on0118.outbound.protection.outlook.com ([104.47.2.118]:6016 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750903AbcLBSOX (ORCPT ); Fri, 2 Dec 2016 13:14:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=VeZHXPP6o+vwmPpJinaCNwvhfWymeX0o2A8BwSYgVbw=; b=LZVyZcH09xo3OMR1nuxr8/4zYtBqZ5GKIR9ntCJhmMIhCo71mAP6DF5Rj9a6dPdZrrwCPUIzwo544FOUD523qZ/KzI7CMCm/tz1btyB0QzC+O05vO0Xi3BZJVg86kMz4Pt8Tr4NNk6M95Om3X334cw9i2sTu/aZQoleIs7L1YBw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Received: from [10.30.19.223] (195.214.232.10) by AM5PR0801MB2049.eurprd08.prod.outlook.com (10.168.158.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9; Fri, 2 Dec 2016 13:40:42 +0000 Subject: Re: [PATCH v2] x86/suspend: fix false positive KASAN warning on suspend/resume To: Josh Poimboeuf , Dmitry Vyukov References: <20161130231011.ofmbmevn3hqasetz@treble> <8f4c4a62-d912-0cd9-3462-8df20a868834@virtuozzo.com> <20161201145821.imkcgizo4thmiei2@treble> <20161201164551.52xlcftamleam6vq@treble> <20161201171306.swnvi4f2ezavloxd@treble> <20161201173438.bfe5eq23i6ezfxsq@treble> <20161201175611.gf63mwzomt4wrlxy@treble> <20161201203154.mwt5x736g7z6jh3o@treble> CC: "Rafael J. Wysocki" , Len Brown , Pavel Machek , , LKML , Peter Zijlstra , "Ingo Molnar" , Andy Lutomirski , Scott Bauer , "x86@kernel.org" , "Alexander Potapenko" , kasan-dev From: Andrey Ryabinin Message-ID: <5144d695-7ac4-f992-5239-91c772b0c121@virtuozzo.com> Date: Fri, 2 Dec 2016 16:41:09 +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: <20161201203154.mwt5x736g7z6jh3o@treble> X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: HE1PR03CA0018.eurprd03.prod.outlook.com (10.163.170.156) To AM5PR0801MB2049.eurprd08.prod.outlook.com (10.168.158.139) X-MS-Office365-Filtering-Correlation-Id: 29d153e9-1e01-408f-e16c-08d41ab8d0b4 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AM5PR0801MB2049; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB2049; 3:tOaBeKoiTsMrQt+Iqqosb5zf4u3tIlTmBQyQ85rTs0lGWnk2GpuFcCwHOwxTSPfTGEAckJc0disrrXsBEEI04sH40qlTZZ9WtyK5/wY0QFSeAhMwO8OdS8r/B5EuPoKnYi2lztw5uzUNydkOwuPD267/FRhWuyHC4/0hqA860FXFXx6R54se7Qq42VZPxTJM+jmHRVuM9r6erfeqoeJn4ZwUGd0WISDakcg6K8puovhdpBuMfUqXTRQwUA4fWRCw8FiSUHavoZRgB9kms6nCPw== X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB2049; 25:7a6dRQbNDm4wHGCTo3oW1b0fh3wmLbHWeJpptCCgfjbZd46o78GYXXA3AvTeaHtdtHSYYXNuKlJCtTmCl+wFoJNkqtQwkMdgUw+k61bxhwB2IOSk44iH42CUnVzeCCbJidaZPQG2CibBqI9vl9hLgsQtQ4ZCVX4DbhOG8D3uYZ5NX9m1kBCbAiflTItZEhq9zdDcKu5gwTZ2sGRfEOs95CKqKz0WuXCBOvYfp0TZdckIBsgSHxpLPkeCqchQ1+CDIlnE2N+FWWSGCWM4HM+8PBqHiQWonl7GjCfcaFTVpxZrZVM6YvIWw3vq31ilya0slIcM4BtGcLPvP8cW1JuLvzufD9wjQL3rQoz/kn0Ao6xcfK6cqXT3IwAGMxetV6FsFxs7XOQ1cb4SMsA/TRgJfIQO01YAMNxNro1vw8Pl/vyY8KZbhICuvOjWXtW1KJu7LRtCd6GOZlDXiv6KOLT2WhogZPTyMCJDHVI3I8SzRctZGj7tkosXKUTjO+hrPLh9onoipjrk3sanRwbfzCsxlF0/NH34gMMBeXmo3J5ib1IHtEDgiCg+BZ78Qr3S4SeBSuTeiY7Nz9iS0DUABwMcJuIYb/Zu5zpZgNLa0bqZ+mTHU+LVzwU4aS4B0SZnweKbApo/AyXYNezhVjUCwJ28EYw5tLnD1s7i4BcXMkfbZnKWVbeRErGhZn14fJ2n2gGorqhUEMFguWkZc8o+zvWMPNVV9+wQhb9aZdzgkdr3OAAU/dBjiWn38AH+00YhrNQZjd20KshvsfQkNfFr8SYp+hFsEbNKrZMqk3WH8jBShSpjKQwhRdE3v0ZNwFVENHf+RVIghRkmwY2B80eQ9BPHGA== X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB2049; 31:58xHs5AAXNeRwxdAwYznSUlHLlBBixw7HN0wEbcUEgsoKwOxhs3mrt7qDprFeHoVG8Iwf7i5CmJJW+n6nrULG3xYOCzMiShGQPhkAIOeUBtExhJ6kEB3d6HxOtDn1GPkt2MrqckBaO3F6bqNtjfkD50H3857lwPASkGFcKm7snGUECVHg4jR+tCW23luqZMsDzeF50sdKfJy+d+uF74/9LaHnRZfywEmbCzt2y3y8eWOmPGjQKag7cslQWGrkfgwqRKEjXpKlV1bpTdKdLTT7w==; 20:I+AKDWQr5DiOzPVFfGqg7a16uudqe5L+Q1G/CJHpJTr/6fuTRGJG6+7kQ/pj2Mw8IQCtYpPa6W6pFR02dVku2H4w1cAAoaM6fHSehFDkRXI6wGNlSEphbyW/aaQ/J0Ez30y4xIG3v6TwQYRpQwWWc09wf5uy1fFWbn2+4wfxy7k= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(2016111802025)(6043046)(6072148); SRVR:AM5PR0801MB2049; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB2049; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB2049; 4:9xTFRVyKbDZCBaiLg2to1LwWpjLBdgFOeFEGOccJjxf8LTZbb5vuc2vfjK8BiaStsM3jT6SiS1Egd0bAfnJozX9K1Gew31D37VMZx7yEdOgOb7SuqQXaQXYcRYSVE3h7hXJsFOBRybIOREcVBx+MYoGTqA4c5/wB0MlkRW/JKgsDmFyGtoSg3Nvzsd/AKaB8UMKGAIc91JvlNfn/NOWYvpuC9dIs0VXINPvP/eZMgOJty7f9mO3NLtoqOi/ZN9hLezM7tT3c6VA/voeuaQBWCJcvRxhj9YnLRy9hCkCqKcM6PkZR1VCGRvl3GSzHj3ABwNXUkbri9JsFeo/31l1vGFSyXf01RzLvGAYX/utNvdP0sIniTGON6Fhaz02vdHVQeBdwaMObVEYC9cwWFiIXr2/BMGiVjvRV//p6EyVFWTFzFo/jR45uyN9teJ1qbAwEYvb/AnciPpX+Q1Du/uibRWWSRORi3T/wZ5d/Ahuhv0zqckS4m7IXeS7obWS4AmhCFpGewXpnF6mIK0OCds05n2ID56o6avK3h4JsKbHJGgE2VycCWavo/huBf2ZT+cFez6iDdSBPL+pK0GsZPct7htfAqD6a/96fAcAO+2yqqOmCsqj+Nt23b2MGR5xmg4AE X-Forefront-PRVS: 0144B30E41 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6049001)(6009001)(7916002)(24454002)(189002)(377454003)(199003)(92566002)(68736007)(31686004)(65806001)(23676002)(66066001)(3846002)(65956001)(6116002)(65826007)(90366009)(47776003)(5660300001)(106356001)(7416002)(2906002)(230700001)(83506001)(4001350100001)(189998001)(15650500001)(93886004)(6666003)(38730400001)(8676002)(229853002)(86362001)(31696002)(76176999)(33646002)(81156014)(81166006)(305945005)(7846002)(42186005)(36756003)(4326007)(105586002)(50986999)(54356999)(64126003)(50466002)(5001770100001)(39410400001)(2950100002)(97736004)(77096006)(7736002)(6486002)(101416001)(39450400002)(733004); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5PR0801MB2049; H:[10.30.19.223]; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not design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nosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB2049; 7:G66bIMEkAwpSGDjzoBrWsQlUw0fEII8/N/vqaYT49oAp1M7bskHsDQFXLP6xowtMTarPALkldwho08NsQIGiyZhtiaX9bzKUK3y1hKg3WgmvVOZx0G4WoVPTQa72/mLB+RqOsEa7AaMywg6WX3dupOKrvLu9qC5Xs5eTdJ1GZ27t/s+FzHK0OmHbyMB94v5p0n//mHC+q0g8g7ewcfPjPXWNuNNsN9SqzbnoGDDRY5HgaRteEKH4zjf63DyEuGXt9gZ9KKv8TXhBks7JfQfbmfT7yVik8YHcDTPLXaBS5ecGHR9TZrOzbngum0XgryMMpo+nLt3UhGAKYxkCg6IQ0o5QiohGf9DHqlK3N6856eVa0k9BvwfzQAa9xhXB3R23fHuu4isQ/4b24swN7TbSFuC6hz0RcUDs6MNKrcEquhEpipedLMRnPI2nn7/V4JVuhEyGVUxqp94qUHBwuuZCuw==; 20:8RBF+1mvkcg22UIAR6God1X+CuBeX7XiWXIxgiTk7mFzwo/Kf5NPJgflU3jnAvD77ZzhXPfy+OxyB4+6OMgY/Amd9TqFRmoCLgHrwjxQvbh6eiwjKc1kBHkBX1ab3/DNIM/VI+HyqbdpAS5CdVAkzzqcqoMu0ffBYtUNXMSf05o= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2016 13:40:42.6407 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB2049 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 12/01/2016 11:31 PM, Josh Poimboeuf wrote: > arch/x86/kernel/acpi/wakeup_64.S | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S > index 169963f..1df9b75 100644 > --- a/arch/x86/kernel/acpi/wakeup_64.S > +++ b/arch/x86/kernel/acpi/wakeup_64.S > @@ -109,6 +109,22 @@ ENTRY(do_suspend_lowlevel) > movq pt_regs_r14(%rax), %r14 > movq pt_regs_r15(%rax), %r15 > > +#ifdef CONFIG_KASAN > + /* > + * The suspend path may have poisoned some areas deeper in the stack, > + * which we now need to unpoison. > + * > + * We can't call kasan_unpoison_task_stack_below() because it uses %gs > + * for 'current', which hasn't been set up yet. Instead, calculate the > + * stack range manually and call kasan_unpoison_shadow(). > + */ > + movq %rsp, %rdi > + andq $CURRENT_MASK, %rdi > + movq %rsp, %rsi > + xorq %rdi, %rsi > + call kasan_unpoison_shadow > +#endif > + Looks good, but in fact we can use kasan_unpoison_task_stack_below(). We just need to change it a little: With this we don't have to calculate stack range in assembly. --- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c index 70c0097..e779236 100644 --- a/mm/kasan/kasan.c +++ b/mm/kasan/kasan.c @@ -80,7 +80,9 @@ void kasan_unpoison_task_stack(struct task_struct *task) /* Unpoison the stack for the current task beyond a watermark sp value. */ asmlinkage void kasan_unpoison_task_stack_below(const void *watermark) { - __kasan_unpoison_stack(current, watermark); + void *base = (void *)((unsigned long)watermark & ~(THREAD_SIZE - 1)); + + kasan_unpoison_shadow(base, watermark - base); }