Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp606248ybi; Fri, 7 Jun 2019 13:32:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyo4b6MPyZXv40y5HYSj/pQIht7WplaL6bw/WQ79nWceLkX2M0EcMqJPaukoxwInX5UN0SD X-Received: by 2002:a65:4283:: with SMTP id j3mr4631551pgp.88.1559939549006; Fri, 07 Jun 2019 13:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559939548; cv=none; d=google.com; s=arc-20160816; b=fEj5PFImTCFHB617NMk+rvjoq8mdHRTb9ciq/irwTlMyArav1ZSKSyhzU2MjtBSsYI 2WsLGGLQF63Oi9a6KkYJIfz/SjLrfLjdSGi2LuRcwy08YADgw6gxARJtVEhoOHQcdS2U zVaLTVdxtdxPBZ8Xzy6DYTOj2kmOJ2jcCcQlk2wschil2AZTHGxCPc98WLLvzkhGprdP xyaRPwxh2HdAQVuUPVZ5dggQWiwyIUyPeFuPJNTZ9kG/W1V9I2XRHKOufpJZKFCTsbsx PlsZ2540a83Vtw/sQytyAaaioiOWy36aFW/Ct81e0zOTmP3hd9Pvi5EjPuQJWX+CcF4G pfcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date:dkim-signature:dkim-filter; bh=ne0jc3kRZK29kv4U15wWU4x86yG5oGXYcHvoXYZq1Qs=; b=MZEfFIlIz3K7Sf9Idr4DS5x/R9yjmwb0G5eHDAQkpYAKli4/L19L1vKWKuaSAx64W5 uki+SSXGbC/qYDZt+PMDyonFdOekSZtiW09EvD733BoRI+XmdjKHhhrOpumX6kwwLWg9 9AnRBBkvW5fN1+gmgEO/wPQZoJ5ZEACPPxuMsOdbSEaaZSacuNCE5y0mtkK/nNoQGDxu 6j2mRENBEfaVmTncT9SlwyR4LXpsomLvKM1a6r9H6RfYNdHyRIIV/iDIuVhsbeuRMXps Ph6EtY5lW3llDnpjk1fBHwonGEL+rWPj66WUO+MEPXtkaw1u9pHFAfeFThG0ljZQMU8N 3zfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@zytor.com header.s=2019051801 header.b=iVHpk3hZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 132si2907439pfu.263.2019.06.07.13.32.12; Fri, 07 Jun 2019 13:32:28 -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=fail header.i=@zytor.com header.s=2019051801 header.b=iVHpk3hZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730041AbfFGUYa (ORCPT + 99 others); Fri, 7 Jun 2019 16:24:30 -0400 Received: from terminus.zytor.com ([198.137.202.136]:57631 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729268AbfFGUYa (ORCPT ); Fri, 7 Jun 2019 16:24:30 -0400 Received: from [IPv6:2601:646:8600:3281:84b2:b0c:3049:ccfe] ([IPv6:2601:646:8600:3281:84b2:b0c:3049:ccfe]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id x57KMeeV2644168 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 7 Jun 2019 13:22:47 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com x57KMeeV2644168 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1559938972; bh=ne0jc3kRZK29kv4U15wWU4x86yG5oGXYcHvoXYZq1Qs=; h=Date:In-Reply-To:References:Subject:To:CC:From:From; b=iVHpk3hZET4fJNgfFIVgmGMF1UWexTvYsBix/DgxyFnREUMGcT2oXQjKaNIkTNT13 De/ERe0Uzu/XEwyteklpHdL+pxJKozBJawSBkStPLkMwyHZMs3kKz+iBidgDUGN489 9OQ1wSxnF7BktoeZ9jRa/DorFQGF5zvShAF8xJugKw9v9ENAKmEUUAGIqpPkFzRkvH +f0V8ICD1J1O11HJzVMgK/rB5tJBlrEwdCmElVarxTpIMllo+4lJyC86+YUFcTbvB+ g/AMo8H1SS2T9+7XZKRYrUPMWlOZucbXao4YEyuW4fJizIFXdgDH23z9qNupDAdU6s S0dUFxTop/aYw== Date: Fri, 07 Jun 2019 13:22:31 -0700 User-Agent: K-9 Mail for Android In-Reply-To: <3DA961AB-950B-4886-9656-C0D268D521F1@amacapital.net> References: <20190605130753.327195108@infradead.org> <20190605131945.005681046@infradead.org> <20190608004708.7646b287151cf613838ce05f@kernel.org> <20190607173427.GK3436@hirez.programming.kicks-ass.net> <3DA961AB-950B-4886-9656-C0D268D521F1@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH 08/15] x86/alternatives: Teach text_poke_bp() to emulate instructions To: Andy Lutomirski , Peter Zijlstra CC: Masami Hiramatsu , x86@kernel.org, linux-kernel@vger.kernel.org, Ard Biesheuvel , Andy Lutomirski , Steven Rostedt , Ingo Molnar , Thomas Gleixner , Linus Torvalds , Jason Baron , Jiri Kosina , David Laight , Borislav Petkov , Julia Cartwright , Jessica Yu , Nadav Amit , Rasmus Villemoes , Edward Cree , Daniel Bristot de Oliveira From: hpa@zytor.com Message-ID: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On June 7, 2019 11:10:19 AM PDT, Andy Lutomirski wr= ote: > > >> On Jun 7, 2019, at 10:34 AM, Peter Zijlstra >wrote: >>=20 >> On Sat, Jun 08, 2019 at 12:47:08AM +0900, Masami Hiramatsu wrote: >>=20 >>>> This fits almost all text_poke_bp() users, except >>>> arch_unoptimize_kprobe() which restores random text, and for that >site >>>> we have to build an explicit emulate instruction=2E >>>=20 >>> Hm, actually it doesn't restores randome text, since the first byte >>> must always be int3=2E As the function name means, it just unoptimizes >>> (jump based optprobe -> int3 based kprobe)=2E >>> Anyway, that is not an issue=2E With this patch, optprobe must still >work=2E >>=20 >> I thought it basically restored 5 bytes of original text (with no >> guarantee it is a single instruction, or even a complete >instruction), >> with the first byte replaced with INT3=2E >>=20 > >I am surely missing some kprobe context, but is it really safe to use >this mechanism to replace more than one instruction? I don't see how it could be, except *perhaps* inside an NMI have, because = you could have a preempted or interrupted now having an in-memory IP pointi= ng inside the middle of the region you are intending to patch=2E --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E