Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6855612imm; Tue, 28 Aug 2018 02:06:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaJT0YdEt0WI7VFe17BLeHELNn1UpViZ4AIyY6kH92Kvv8jnBUNSs6WYTwJoPzfJJqVHkts X-Received: by 2002:a17:902:6808:: with SMTP id h8-v6mr652424plk.27.1535447200500; Tue, 28 Aug 2018 02:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535447200; cv=none; d=google.com; s=arc-20160816; b=Y0zci6FOVTwkPeRgWZ/lodNA8yOV0b6seItjzgTwnFbLStSyBWdnWh03/S6xaLZQgJ 7HtkV6P/t1HL06/Ks+rojtrOaDHT1ZWYgV07hFg2k57sYekrxL3BVEWa+By4Wge9L1Ul MA5rPEOtSFAqytWEUDrl6dYLZ+SYuONKGP5G3haKacB9sHDuBy1HbAoK54QyOEjEQoaN BRXJSWgmekdjJPrZwVxSHAHocRRK4aOTtDkLDAOc8E6iHkmQsqD+eNVeNPg8G8AuLLxC KJbinI/WlNDSm5pRPPQUxHD4zhZ0XOY1kaVQl4g6+1VVDJYGIuq3xfFmYVzu0eD8CzuE 5gIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=3WZE6BkZDoTMa/Jx+/0OVaWa4+4sKOa3rabUHerJCac=; b=V6mrt5EWdmuTAZ3E1uVE41axmTIvUTfWwXZ3khzacrAE/mbXqBpEcjNwoGGNYhW3Gu MHe2EJo/wHIFd/1EqQfah1yRqawFgc0TroW9U8Mt4OCNWl3s/gmGuQLmUpBA6VGEdZTw vLNdcLqbj3XtGNHYsobpjTqoW8idIY6k+A4GV/ywnqcSdnmMu7KcdG0WpNk4hDTWBSoh +E5Xiala1TDUh2beqzQdFcAE/QjguYjBDf29/UUVFDhx4yAmP/2l7eQx7HikeesLKU9T p0Cxy8ehIeNFXtjBTnficz34Su4H9JwX8bkL9YMiaZLkqZAbHq0K99h1IfWwi0XCS57j mvrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=ZthGvTyT; 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=pass (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 n2-v6si580580pgu.103.2018.08.28.02.06.24; Tue, 28 Aug 2018 02:06:40 -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; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=ZthGvTyT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727535AbeH1Mzc (ORCPT + 99 others); Tue, 28 Aug 2018 08:55:32 -0400 Received: from mail-eopbgr80094.outbound.protection.outlook.com ([40.107.8.94]:45507 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727025AbeH1Mzc (ORCPT ); Tue, 28 Aug 2018 08:55:32 -0400 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:X-MS-Exchange-SenderADCheck; bh=3WZE6BkZDoTMa/Jx+/0OVaWa4+4sKOa3rabUHerJCac=; b=ZthGvTyTW7rUjQyX9ucE2+Ey+ABedGX1RrVNrYJqwWU+LZwRF3M/92oMI+kGP1p7eGQau7i1hIvYLu6aarguPNV18MyYfHhJZQOMQrTF9AtlbYvuJLEvE0PprccsNvODMv51VmigOWE6xDrQF8eZ/FeiNrTan+iXgPMTRQnqqT0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Received: from [172.16.25.12] (185.231.240.5) by AM0PR08MB3249.eurprd08.prod.outlook.com (2603:10a6:208:5e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Tue, 28 Aug 2018 09:04:46 +0000 Subject: Re: [PATCH] x86/entry/64: wipe KASAN stack shadow in rewind_stack_do_exit() To: Jann Horn , Andy Lutomirski , the arch/x86 maintainers Cc: kernel list , Dmitry Vyukov , kasan-dev@googlegroups.com, Alexander Potapenko , Kees Cook References: <20180824235826.62741-1-jannh@google.com> From: Andrey Ryabinin Message-ID: <0897d173-6a30-09df-f16a-76322384fe0d@virtuozzo.com> Date: Tue, 28 Aug 2018 12:04:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180824235826.62741-1-jannh@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: AM4PR05CA0018.eurprd05.prod.outlook.com (2603:10a6:205::31) To AM0PR08MB3249.eurprd08.prod.outlook.com (2603:10a6:208:5e::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 197062af-42c8-4389-16e7-08d60cc54d8b X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)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zQshmen4jLfJthWQypDrefNcUKoQEx6m/G4ZwKduMcXtKF4pFQgT7hJFnkyPAPoNvDqPkYDuNmGHNoAQj+1vgwB9JVY/bcdXJJ6kGrKCwcCH2olj6PulBndpO2Lt4icXODcqBzjT5gh05SDuYGR9L+PeMKiTYb40ESWbHbsbJa32FKuYKoEHHxSBTqH8I65FKKZCQkVEqQHn+AnUfAWVRRHHkxxApA7XM5Wc2FcBrDw369ghEo96zIKByxvZWyaozGr0yloDO9l9nDs3HtChN2NTvjWT3l4wA6DRznkmn52bIQqCqiNeOB6IUbKFGgwpIF++wUO9FLcUdKRYbwExUJoZsZpIvy9uX/QQCuIgioazkviUSbe5jtG3Huc37gWQJyXXhH0UHaRN/HNn4cIIY3nJs+pI7u X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506)(166708455590820)(211936372134217)(153496737603132)(192278398808882); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201708071742011)(7699016);SRVR:AM0PR08MB3249;BCL:0;PCL:0;RULEID:;SRVR:AM0PR08MB3249; X-Microsoft-Exchange-Diagnostics: 1;AM0PR08MB3249;4:EjL17ofCKkp1bZLuVNaAigpfFtDwjSIjDUp3y43aPhK2cwF8uV4TU/QVtVvwDh+BH39hBNphuPB/yPUnqFYncjUqXI0EG3rV8LWoy4HneJHQx1nCfENR0UKGXu3ZPBx0xVHFjB7lC/1Fpfhn8xnAPzEGbxG293K4YmbAVUD33VCBinYGFDXrxshu6PRhSSjKtvzZbDq32dUG/jgKCZJMKznRi1xGi2QqhzLOEAI/8PWkrdZFqqiHReKXBdMbgcxOT2hK6sJTmlCuq5SXgmTZ3Jyshie5xn30hyrMcGYElskaptBJPaCqNztuPgqtG5tIJHTY95z62O2be7WYvTvOPiwidV55KdY4ujl7Nwvia/uPXcRcQUuBAUEKV0vFx7vFsL6lwNWqH8wb3LLlK9mB+XkNbWjA558xBz+L0ZZP58I8NWYXqnCcxlz8KCuXne5Tl6JMEEAj3GXi9ARBXwiuOw== X-Forefront-PRVS: 077884B8B5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(376002)(366004)(39850400004)(346002)(136003)(396003)(43544003)(189003)(199004)(23676004)(3846002)(16526019)(186003)(50466002)(316002)(14444005)(68736007)(64126003)(97736004)(229853002)(6306002)(47776003)(8936002)(66066001)(2906002)(65806001)(65956001)(486006)(2616005)(6486002)(386003)(11346002)(53546011)(77096007)(476003)(956004)(52116002)(5660300001)(76176011)(16576012)(26005)(52146003)(2486003)(446003)(65826007)(58126008)(6666003)(31696002)(53936002)(106356001)(966005)(110136005)(54906003)(36756003)(25786009)(230700001)(305945005)(4326008)(7736002)(6116002)(81156014)(8676002)(81166006)(478600001)(105586002)(31686004)(86362001)(6246003);DIR:OUT;SFP:1102;SCL:1;SRVR:AM0PR08MB3249;H:[172.16.25.12];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTBQUjA4TUIzMjQ5OzIzOkRQcUxOa2V4dUZBUEY2SjZFbFpuamNackg3?= =?utf-8?B?c0hhUGpJaFpOQlVNZ1R3NmRzN2U4UnNDbHV5RzlpK3ZIZ1czaWNESEVTdFB3?= =?utf-8?B?bVlVT2x5UnRpQk81ZnJtWDFDOEUxdmVTUm1MUXlaRGpxL25hdXUzQU9TTzR1?= =?utf-8?B?L1BVQ3Rhb1NCeWErR2RVWjRMUmt5S3NHMHpwSDRYeDVqNzV6TmZmTDU1OHli?= =?utf-8?B?N1NlMHYxN0VJTkZYOVZ2bWJyRUN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gg6g=;7:7CtRB8MFs4yG/DxPDPwsmtiZwnu3IUJChUH0GjAcg+RjoymMH1+f1S2EK/YYfEiFDuHp2eTyIzNhEeyWLP9LLTrQtpwtGxqEqqMaVQebB4lQzwRFMR+1rnKSmQXTM87sQE7L0TB35F+FMVtQ7684zWrwSHgMTgPonkCi1yeVI8L2MX9ry76YagIGUSU2DxWQEF0kdawkB9pa3KzAXyS/vfn2GZaICzLJCjOlFezzLN5o0z2zaCqqQdKpdH/Pz8gX SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM0PR08MB3249;20:i83TJUEQHSS+JHl474Ll9+3HvhSxloLEZPdeO0NtAI1542KTrVDbYMdz4KSGaglHdyJADKJtYEOpFZ35IGPCpTGtzEl1EYIj7wUsq8Nijzom3UCGg7O3EslInbpOyN+scogpmx0xzUMTQrX3pP5dxxKouAkXehJ9tBVoISz1NOU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2018 09:04:46.3581 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 197062af-42c8-4389-16e7-08d60cc54d8b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3249 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/25/2018 02:58 AM, Jann Horn wrote: > Reset the KASAN shadow state of the task stack when rewinding RSP. > Without this, a kernel oops will leave parts of the stack poisoned, and > code running under do_exit() can trip over such poisoned regions and cause > nonsensical false-positive KASAN reports about stack-out-of-bounds bugs. > > This patch is 64-bit only because KASAN doesn't exist on 32-bit. > > This patch does not wipe exception stacks; if you oops on an exception > stack, you might get random KASAN false-positives from other tasks > afterwards. This is probably relatively uninteresting, since if you're > oopsing on an exception stack, you likely have bigger things to worry > about. It'd be more interesting if vmapped stacks and KASAN were > compatible, since then handle_stack_overflow() would oops from exception > stack context. > > Fixes: 2deb4be28077 ("x86/dumpstack: When OOPSing, rewind the stack before do_exit()") > Signed-off-by: Jann Horn > --- > I have manually tested that an oops that previously triggered this bug > doesn't trigger it anymore. > > It would be possible to rewrite this assembly to use fewer instructions > in non-KASAN builds, but I think it's clearer this way. > > If anyone thinks that this thing should also be wiping exception stacks: > I did write some (entirely untested) code that should take care of that > (before realizing that it's rather unlikely to occur in practice because > vmapped stacks and KASAN are mutually exclusive), but I'm not sure > whether it's worth complicating this code for that. > In case anyone's curious how that would look: > https://gist.github.com/thejh/c91f9b4e3cc4c58659bb3cd056c4fa40 > > arch/x86/entry/entry_64.S | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S > index 957dfb693ecc..92d3ad5bd365 100644 > --- a/arch/x86/entry/entry_64.S > +++ b/arch/x86/entry/entry_64.S > @@ -1673,9 +1673,25 @@ ENTRY(rewind_stack_do_exit) > /* Prevent any naive code from trying to unwind to our caller. */ > xorl %ebp, %ebp > > + movq %rdi, %r14 > + > movq PER_CPU_VAR(cpu_current_top_of_stack), %rax > - leaq -PTREGS_SIZE(%rax), %rsp > + leaq -PTREGS_SIZE(%rax), %r15 > + > +#ifdef CONFIG_KASAN > + /* > + * Remove stack poisons left behind by our old stack. > + * Do this before updating RSP to avoid problems in case we get some > + * interrupt that is not handled on an exception stack before we're done > + * with the unpoisoning. > + */ > + movq %r15, %rdi > + call kasan_unpoison_task_stack_below > +#endif Why this has to be done in the rewind_stack_do_exit()? Are there any problems with calling the kasan_unpoison_task_stack(current) from oops_end(), before the rewind_stack_do_exit()? > + > + movq %r15, %rsp > UNWIND_HINT_FUNC sp_offset=PTREGS_SIZE > > + movq %r14, %rdi > call do_exit > END(rewind_stack_do_exit) >