From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2519C2D0A8 for ; Sat, 26 Sep 2020 17:15:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FF4A20789 for ; Sat, 26 Sep 2020 17:14:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alien8.de header.i=@alien8.de header.b="aIHN0152" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729232AbgIZRO5 (ORCPT ); Sat, 26 Sep 2020 13:14:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbgIZRO4 (ORCPT ); Sat, 26 Sep 2020 13:14:56 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93BACC0613CE for ; Sat, 26 Sep 2020 10:14:56 -0700 (PDT) Received: from zn.tnic (p200300ec2f1c25001c55400185a26885.dip0.t-ipconnect.de [IPv6:2003:ec:2f1c:2500:1c55:4001:85a2:6885]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id EB5C31EC03EA; Sat, 26 Sep 2020 19:14:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1601140493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=FRmt1ZU323p3kg9TO7fbBge69StpQX8q8Foc3zlvE2s=; b=aIHN0152CmLZsWu2iozBNysrRKNTdF6YDMpRt6q0ui+4bF8LTMKwskGMQ7ViSwQmkMqAtv MVXcqTc89G6OUmKeRdTFIETBv5kXpcYhluoSww+A7/JzJlG2vvhygmTTYdZw8gRLgEXf34 0bFMOAwS5Uob0+Nm6gwewS6r+A26kVg= Date: Sat, 26 Sep 2020 19:14:51 +0200 From: Borislav Petkov To: Nick Desaulniers Cc: Dmitry Vyukov , Josh Poimboeuf , syzbot , Arnaldo Carvalho de Melo , Alexander Shishkin , "H. Peter Anvin" , Jiri Olsa , LKML , Mark Rutland , Ingo Molnar , Namhyung Kim , Peter Zijlstra , syzkaller-bugs , Thomas Gleixner , the arch/x86 maintainers , clang-built-linux Subject: Re: general protection fault in perf_misc_flags Message-ID: <20200926171451.GB22089@zn.tnic> References: <20200921221336.GN5901@zn.tnic> <20200923090336.GD28545@zn.tnic> <20200923103431.GF28545@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 25, 2020 at 05:32:14PM -0700, Nick Desaulniers wrote: > Boris, one question I have. Doesn't the kernel mark pages backing > executable code as read only at some point? Yes, I added some debug output: [ 562.959995][ T1] Freeing unused kernel image (initmem) memory: 2548K [ 563.672645][ T1] Write protecting the kernel read-only data: 137216k [0xffffffff81000000:0xffffffff89600000] and perf_misc_flags() is well within that range: ffffffff810118e0 : [ 566.076923][ T1] unused kernel image (text/rodata gap): [0xffffffff88608000:0xffffffff88800000] [ 567.039076][ T1] unused kernel image (rodata/data gap): [0xffffffff8941d000:0xffffffff89600000] [ 568.205550][ T1] Freeing unused kernel image (text/rodata gap) memory: 2016K [ 569.277742][ T1] Freeing unused kernel image (rodata/data gap) memory: 1932K We also have this debug option which I enabled: [ 570.598533][ T1] x86/mm: Checked W+X mappings: passed, no W+X pages found. so that looks ok too. > If that were the case, then I don't see how the instruction stream > could be modified. I guess static key patching would have to undo that > permission mapping before patching. Yap, and I still have no clue about the mechanism which would lead to this corruption. > You're right about the length shorter than what I would have expected > from static key patching. That could very well be a write through > dangling int pointer... Right. Lemme try to setup one of my test boxes to run syzkaller and see how far I can get. But don't hold your breath... -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette