Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1617353ybk; Thu, 14 May 2020 13:31:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzShLepgkei1IYhkPVtNQ9kKMXqblxQwvf9EAyt1Fl2NABakmpsmnMY2P5ZFx4iqWR1X1ia X-Received: by 2002:a50:b286:: with SMTP id p6mr5715978edd.350.1589488275707; Thu, 14 May 2020 13:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589488275; cv=none; d=google.com; s=arc-20160816; b=ETnOKshIq1YOckE/kctt9ftyvxYeReIkzop1X2pF7pc1GIdxCYrXYUKleTT1YJzgtV 4uiTKAm2E6afYZEZLBFlyO9P0k+/AwwRCYBdXQ7dnetC8my93q8UNFpIoc6Y112WFHbe DpCXGIGnzUnSMd49ZoyYGZ85wqh+MlcC4JB+8GXNbZYZY9SoUzoPXxIAvXpzXSvWWmjb CFZQZW94RQslk+I2iLKRXJgD3hKCSeTBl0Ar7qFHVYhWFYW4Oafq1Y/pRpQrU5VMnCb2 cEhsu9IS55bJkmXDCspuFOdEVkUkFuEjoM7rAd/ilAuYrXqPDwMFZAyD1g4f2FVykaJF 6lFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=TSLa/dtbCyvxyN5oIuPfHoLuHt8yn4QjYXztKgqiblU=; b=AiWFb8oO6DpsKNdXiDa/ZWpj6aIIcfQ78k3j3wj1uckt+hoGrV3sb+kDRFVibVWiIq KFRrW90e3dPdNL9L2tbUT5DTCxZh7KfRkaQ8ncgied4LnCOdzOpw6gbP2rYJfrzNw8cR 32AYWsgK0DYUZAj8rB035hwJDlffduRTVd3TmdixTJJ7d/CgJQr5w72VXZk9oktyAXVc ajKK9M8E49cXkC0nJ5gcyPzr2qucB3Xvnz6+oOXc/Rcx4Q5sycruyti8HIFCKZ3GO4EH 9zV7WlGG2xtbim6gDEbLRznyrTiyd5RqTLj7uUeh6F70xfnm+4aCCHBfDIFjr7du8SVX RoLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q1nOj8P0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si2363185ejh.303.2020.05.14.13.30.50; Thu, 14 May 2020 13:31:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q1nOj8P0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726216AbgENU2x (ORCPT + 99 others); Thu, 14 May 2020 16:28:53 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:51441 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725975AbgENU2w (ORCPT ); Thu, 14 May 2020 16:28:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589488131; 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: in-reply-to:in-reply-to:references:references; bh=TSLa/dtbCyvxyN5oIuPfHoLuHt8yn4QjYXztKgqiblU=; b=Q1nOj8P07empx1mqkH3jer8hjP1Gw1AMekXFiyk+U+1PHYlBiojU9ZRNHxb27oCUtKtTUR dT3BLaU9WZ8Dl9ZFdLdC7RVBH1U2tSWzFCzp7kB28ZVgIrKuvykp447TY21rzqeyXMfbQv qWJMRiOiwS6K5JL5zORF75iPE4vQ/Wk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-258-qANUTNzSPaqn5qHUdJuQOg-1; Thu, 14 May 2020 16:28:47 -0400 X-MC-Unique: qANUTNzSPaqn5qHUdJuQOg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 52D641005510; Thu, 14 May 2020 20:28:45 +0000 (UTC) Received: from treble (ovpn-117-14.rdu2.redhat.com [10.10.117.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D31F1C933; Thu, 14 May 2020 20:28:42 +0000 (UTC) Date: Thu, 14 May 2020 15:28:39 -0500 From: Josh Poimboeuf To: Pavel Machek Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Miroslav Benes , Ingo Molnar , Andy Lutomirski , Dave Jones , Jann Horn , Peter Zijlstra , Thomas Gleixner , Vince Weaver Subject: Re: [PATCH 4.19 41/48] x86/unwind/orc: Prevent unwinding before ORC initialization Message-ID: <20200514202839.l2ztrqd4zff4e4as@treble> References: <20200513094351.100352960@linuxfoundation.org> <20200513094402.645961403@linuxfoundation.org> <20200513215210.GB27858@amd> <20200514194457.wipphhvyhzcshcup@treble> <20200514201340.GA14148@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200514201340.GA14148@amd> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 14, 2020 at 10:13:40PM +0200, Pavel Machek wrote: > > > > @@ -563,6 +560,9 @@ EXPORT_SYMBOL_GPL(unwind_next_frame); > > > > void __unwind_start(struct unwind_state *state, struct task_struct *task, > > > > struct pt_regs *regs, unsigned long *first_frame) > > > > { > > > > + if (!orc_init) > > > > + goto done; > > > > + > > > > memset(state, 0, sizeof(*state)); > > > > state->task = task; > > > > > > > > > > As this returns the *state to the caller, should the "goto done" move > > > below the memset? Otherwise we are returning partialy-initialized > > > struct, which is ... weird. > > > > Yeah, it is a little weird. In most cases it should be fine, but there > > is an edge case where if there's a corrupt ORC table and this returns > > early, 'arch_stack_walk_reliable() -> unwind_error()' could check an > > uninitialized value. > > > > Also the __unwind_start() error handling needs to set that error bit > > anyway, in its error cases. I'll fix it up. > > I did this in the mean time. It moves goto around memset, and I > believe that 8 in get_reg should have been sizeof(long) [not that it > matters, x86-32 is protected by build bug on.] > > Signed-off-by: Pavel Machek I already have the same memset patch (along with other error-handling fixes) which I'll be posting shortly once it runs through my testing. Since the sizeof(long) thing isn't really a bug, I'll make that change later, along with some other pending improvements I have. -- Josh