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=-2.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham 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 D8CACC04A6B for ; Fri, 10 May 2019 04:32:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A698E217F5 for ; Fri, 10 May 2019 04:32:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OFGOE2Nw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726930AbfEJEcG (ORCPT ); Fri, 10 May 2019 00:32:06 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43684 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbfEJEcG (ORCPT ); Fri, 10 May 2019 00:32:06 -0400 Received: by mail-pl1-f196.google.com with SMTP id n8so2192650plp.10; Thu, 09 May 2019 21:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xvneL+tleAZug+cm73ok0sRVVSDLg417J9gTpEjzm0Y=; b=OFGOE2NwOn/bcY8miPOcXwpkHA80Ku8G4fyzOGykVhmR/QDaMsnCcwbIDimS7JTF5x gvMg+htASqUGwslWKLMbU1xXdsQaVUcA/xPqXJ0j45BYvpJ3onYF5mDvzaoz3gA3C77B ++l12pVN+QFnZjgx39cid1yMH+P3KT0xaTRuupjJwhqpQ78pa3bVqh+Gj22blHzFubzH YtdQ7BQvuXX8czCJXHl9ref8MygU9ec9G0beZY9SNC55RzYgkGmMTDmHFBliUjOnie/Y rT9nhRDFk346t/w2nxRdrAq6xrkYiBzWcghocJe6EOAGwJeDfMlTeLC4nNAuKqMZeMcw bPpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xvneL+tleAZug+cm73ok0sRVVSDLg417J9gTpEjzm0Y=; b=Y0UEUUxtaCQH2cnMxENfztawyFlKdgExduujyJU56aewSxayhN6h2+Iik42pZ4fYfL G0USklTwMFTE7STym7HUymEKZ51r+7KgYpQUhl96Poao7bgbSIx+gaie83KPEenjx2i/ u4fCjXrxKqHoJnIpD/9lYMHtE/dTxHElFr/wl5UnIvlIydVIgF7vTwTuA0fuei6V+www 9MQrgRc6sqiPzieAZ9uWCMSpjV5GU63lnIysNmRiQ1x1fL5Z1WI6UC0GdV+UbrZWVZFu 7oWzQ4bYZnr+1U383eFNEKF4Y85JTOfw3n5h729ZM9fRvBhR7bLq9++uMTQa5Lx4icr7 hJtQ== X-Gm-Message-State: APjAAAX6vavaKS69kYb9/SY2+CDXGY43dwl+lDR2ITe7EpIbVcCsCRPz iBW8A0K2e2ZGorGmiM7w1zY= X-Google-Smtp-Source: APXvYqzCVqQG81jyDsA4pwg3oVltor0yDbhImtQRMizI91ol50Lus0a+020M12H8AeI0dti/GS3zRA== X-Received: by 2002:a17:902:10c:: with SMTP id 12mr10524545plb.61.1557462725544; Thu, 09 May 2019 21:32:05 -0700 (PDT) Received: from localhost ([39.7.15.25]) by smtp.gmail.com with ESMTPSA id y17sm5555133pfb.161.2019.05.09.21.32.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 May 2019 21:32:03 -0700 (PDT) Date: Fri, 10 May 2019 13:32:00 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Linus Torvalds , Andy Shevchenko , Rasmus Villemoes , "Tobin C . Harding" , Michal Hocko , Sergey Senozhatsky , Steven Rostedt , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Russell Currey , Christophe Leroy , Stephen Rothwell , Heiko Carstens , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Martin Schwidefsky Subject: Re: [PATCH] vsprintf: Do not break early boot with probing addresses Message-ID: <20190510043200.GC15652@jagdpanzerIV> References: <20190509121923.8339-1-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190509121923.8339-1-pmladek@suse.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (05/09/19 14:19), Petr Mladek wrote: > 1. Report on Power: > > Kernel crashes very early during boot with with CONFIG_PPC_KUAP and > CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG > > The problem is the combination of some new code called via printk(), > check_pointer() which calls probe_kernel_read(). That then calls > allow_user_access() (PPC_KUAP) and that uses mmu_has_feature() too early > (before we've patched features). With the JUMP_LABEL debug enabled that > causes us to call printk() & dump_stack() and we end up recursing and > overflowing the stack. Hmm... hmm... PPC does an .opd-based symbol dereference, which eventually probe_kernel_read()-s. So early printk(%pS) will do printk(%pS) dereference_function_descriptor() probe_kernel_address() dump_stack() printk(%pS) dereference_function_descriptor() probe_kernel_address() dump_stack() printk(%pS) ... I'd say... that it's not vsprintf that we want to fix, it's the idea that probe_kernel_address() can dump_stack() on any platform. On some archs probe_kernel_address()->dump_stack() is going nowhere: dump_stack() does probe_kernel_address(), which calls dump_stack(), which calls printk(%pS)->probe_kernel_address() again and again, and again. -ss 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=-2.0 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable 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 DF584C04A6B for ; Fri, 10 May 2019 04:33:36 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2702A217F5 for ; Fri, 10 May 2019 04:33:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OFGOE2Nw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2702A217F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 450clx2lbmzDqRq for ; Fri, 10 May 2019 14:33:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=sergey.senozhatsky.work@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OFGOE2Nw"; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 450ckN0n7hzDqCt for ; Fri, 10 May 2019 14:32:08 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id x15so2186027pln.9 for ; Thu, 09 May 2019 21:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xvneL+tleAZug+cm73ok0sRVVSDLg417J9gTpEjzm0Y=; b=OFGOE2NwOn/bcY8miPOcXwpkHA80Ku8G4fyzOGykVhmR/QDaMsnCcwbIDimS7JTF5x gvMg+htASqUGwslWKLMbU1xXdsQaVUcA/xPqXJ0j45BYvpJ3onYF5mDvzaoz3gA3C77B ++l12pVN+QFnZjgx39cid1yMH+P3KT0xaTRuupjJwhqpQ78pa3bVqh+Gj22blHzFubzH YtdQ7BQvuXX8czCJXHl9ref8MygU9ec9G0beZY9SNC55RzYgkGmMTDmHFBliUjOnie/Y rT9nhRDFk346t/w2nxRdrAq6xrkYiBzWcghocJe6EOAGwJeDfMlTeLC4nNAuKqMZeMcw bPpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xvneL+tleAZug+cm73ok0sRVVSDLg417J9gTpEjzm0Y=; b=BvyiMWxrdLWn6jZQibBWdPfEPRPSLsvKd+3m8JwyjSgsQ44GUlGFv0KdnG2ITuoDyB 6pa+TNISdOZRsCQUVg75SPXfqh+gsNLBNGBOUXqOec9lRpCcO0SRQ4AwXvssgtHe//V1 3ZDqowuBkKLMqiiK9uBXv3sCOzDuYgaSfFftmNM93JYV/O9vT37GRibv3NRF0U515+tY BYetMuE0yX4Rshpk2+HvjZVKUufcdj5tBInB+HOwwZG/bPWlxnU6j2fWMOxPfy3cNaAm 7Mmr4tn0HmSAeBoIG304Y/wfsYtH9KvxBGAkyiCrfMxNtF0IfTOJ69w7jpUuk4p1sDCe AFaw== X-Gm-Message-State: APjAAAWZxEq11kc7BFK2nEZ3r+ol4w6OFJUELiiB3ecHvhDBBR8r7HyY GjJgMjEcf/bY//gH4/LCG1o= X-Google-Smtp-Source: APXvYqzCVqQG81jyDsA4pwg3oVltor0yDbhImtQRMizI91ol50Lus0a+020M12H8AeI0dti/GS3zRA== X-Received: by 2002:a17:902:10c:: with SMTP id 12mr10524545plb.61.1557462725544; Thu, 09 May 2019 21:32:05 -0700 (PDT) Received: from localhost ([39.7.15.25]) by smtp.gmail.com with ESMTPSA id y17sm5555133pfb.161.2019.05.09.21.32.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 May 2019 21:32:03 -0700 (PDT) Date: Fri, 10 May 2019 13:32:00 +0900 From: Sergey Senozhatsky To: Petr Mladek Subject: Re: [PATCH] vsprintf: Do not break early boot with probing addresses Message-ID: <20190510043200.GC15652@jagdpanzerIV> References: <20190509121923.8339-1-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190509121923.8339-1-pmladek@suse.com> User-Agent: Mutt/1.11.4 (2019-03-13) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Sergey Senozhatsky , Heiko Carstens , linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Rasmus Villemoes , linux-kernel@vger.kernel.org, Steven Rostedt , Michal Hocko , Sergey Senozhatsky , Stephen Rothwell , Andy Shevchenko , Linus Torvalds , Martin Schwidefsky , "Tobin C . Harding" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On (05/09/19 14:19), Petr Mladek wrote: > 1. Report on Power: > > Kernel crashes very early during boot with with CONFIG_PPC_KUAP and > CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG > > The problem is the combination of some new code called via printk(), > check_pointer() which calls probe_kernel_read(). That then calls > allow_user_access() (PPC_KUAP) and that uses mmu_has_feature() too early > (before we've patched features). With the JUMP_LABEL debug enabled that > causes us to call printk() & dump_stack() and we end up recursing and > overflowing the stack. Hmm... hmm... PPC does an .opd-based symbol dereference, which eventually probe_kernel_read()-s. So early printk(%pS) will do printk(%pS) dereference_function_descriptor() probe_kernel_address() dump_stack() printk(%pS) dereference_function_descriptor() probe_kernel_address() dump_stack() printk(%pS) ... I'd say... that it's not vsprintf that we want to fix, it's the idea that probe_kernel_address() can dump_stack() on any platform. On some archs probe_kernel_address()->dump_stack() is going nowhere: dump_stack() does probe_kernel_address(), which calls dump_stack(), which calls printk(%pS)->probe_kernel_address() again and again, and again. -ss