Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp524553ybi; Fri, 7 Jun 2019 12:01:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqygFloak5xrWTJbFX/fxaipYzTPHPvUDDYQml1MujGc50/KJLGrpq0+1V4Lf/TM8QQy0+/F X-Received: by 2002:a63:5726:: with SMTP id l38mr4635301pgb.344.1559934081788; Fri, 07 Jun 2019 12:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559934081; cv=none; d=google.com; s=arc-20160816; b=x5BGTZqerjAtU9odwo++FAdR4EgB7U0Xoil6zyojBHt3BzFt95CLA1gSOglHLT4hzd cCHHWl+/ou48tCrLnMj0KUcIzuqz0MLdVB33nXf4hDhx68ElNI21ftCdyjrzD3vinoSC 3V7rRWPNjma+zktzXtIbWTvs9Yhj7stKaUXiIO9LVKTlraU5B1o3kC04ETqQx1/Mx7Ij CB4YMLg7XHrk+eXWO+qLh8YKjGRgA88Tj/TG+rQ459oi8qt1mbX8WxpLe2Hg/45CnvHl ndaFG84U6onqntJOf0QU1FkQo1GUUeRRN8NlZUtKmUui6g3lymyn0dLyW7drGHwutc8Y rwTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=RdV7PbyVkSYhNsrYGZ8E6Uu22GQTdcJL5heT1Y0FTF4=; b=yZQpzW7xzSq2f3Rwg8jkBJndunwWMXugxphalQsNX56EWOvGemUR1AzLSHO+EF5Vs8 Sci1crRgXdrsEqK4FYDPSSK7r2nLqzXVnXIvZH1sPPAxa6u8HlM+xXTnDWg8/hHP2fN8 EMyrZAl3xl6ool7L1qdX61piUSY6edw0hPEDCpJfCwNqr9CF1wvWljRSVyBnsmQWXMpN FLhimosEqozc+3ssDhavXlNYyHbkXcdQQD7KRD7d8BGXibbWiJhsvgm3BsTGSJJeSy+5 HCSyiOb9V363mkYz0ljNCyYslk91RGC8Te66lddKi0uJBciwDilLl/3KiCNkx93bJM7b X5Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=ouhlv+Sd; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si3052929pfo.144.2019.06.07.12.01.05; Fri, 07 Jun 2019 12:01:21 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=ouhlv+Sd; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730873AbfFGSKW (ORCPT + 99 others); Fri, 7 Jun 2019 14:10:22 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37727 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730442AbfFGSKW (ORCPT ); Fri, 7 Jun 2019 14:10:22 -0400 Received: by mail-pf1-f196.google.com with SMTP id 19so791411pfa.4 for ; Fri, 07 Jun 2019 11:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=RdV7PbyVkSYhNsrYGZ8E6Uu22GQTdcJL5heT1Y0FTF4=; b=ouhlv+SddShDf250mCEoGIo+nD3wsUaOV8r6iUvcyecJcT9BKaJsjGfcoib34GTjau JT5IqYoZJKDp2aMvAewcsfHqE4lEpdXwGIHjhGdrKrf0uwHZZKeEEigdG3cDgaaAnFAY Dt4tvCwXwQVTsAAwmNAey4AC4Wkam2ift6+jrAqcVRj3A2yqKNbXd4qU6pJGq+rbtUDf grmNyW+aaCuftmbdxMy23ItA3gtc+ssc26qODc9ED7fBm8jugx5GV203valW3JNmy2Sa 1IDqY79wev5+F+rHZhr9eVmJKKN0bc3xldGbeyc6vrZyuzzGdh56q4HtSump1b8J1lNc YJGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=RdV7PbyVkSYhNsrYGZ8E6Uu22GQTdcJL5heT1Y0FTF4=; b=rd545R3l5f5G0iqdWoBZnLnhDGJxbiN6yjshC0oKFVok/nDEtkDDRwuHdb+ZT2NYcE jBrKLIQsMtV7DteDDtYLJxahbbGfhY1ojXK5/Av8hETNipBXN55jk3pLhc2uNAjK42Z6 KhbRcYJKdzG+aFyqLFbIHIHXhMP2+ceGKr/ZuUWYd/iBZ9gOQZUoEUMUrZp1N5xXeSE/ uIAY6pf96gmwutWuPqXp8DIuwxSWC2BBbCREPTfDKcKKyFvfmBx+SQIJLhJOo+zE9XCM ZxmrKl4/laNo6UINn7SiOSzGoSUt/lgq0ItqRVRgX/InouMmAilhAtkCCwag2Iok7RJE xuMw== X-Gm-Message-State: APjAAAXVSNF9WwZ49sK6AHtFsLPE0e5utzN8GclJK9oEaoopRrJ+Ff0J nQbgd//IIGYxOhVYZAYJ1P2ewg== X-Received: by 2002:aa7:9f1c:: with SMTP id g28mr37489871pfr.81.1559931021677; Fri, 07 Jun 2019 11:10:21 -0700 (PDT) Received: from ?IPv6:2600:1012:b044:6f30:60ea:7662:8055:2cca? ([2600:1012:b044:6f30:60ea:7662:8055:2cca]) by smtp.gmail.com with ESMTPSA id j14sm2905412pfe.10.2019.06.07.11.10.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Jun 2019 11:10:20 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 08/15] x86/alternatives: Teach text_poke_bp() to emulate instructions From: Andy Lutomirski X-Mailer: iPhone Mail (16F203) In-Reply-To: <20190607173427.GK3436@hirez.programming.kicks-ass.net> Date: Fri, 7 Jun 2019 11:10:19 -0700 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 , "H. Peter Anvin" , Nadav Amit , Rasmus Villemoes , Edward Cree , Daniel Bristot de Oliveira Content-Transfer-Encoding: quoted-printable Message-Id: <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> To: Peter Zijlstra Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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. >>=20 >> Hm, actually it doesn't restores randome text, since the first byte >> must always be int3. As the function name means, it just unoptimizes >> (jump based optprobe -> int3 based kprobe). >> Anyway, that is not an issue. With this patch, optprobe must still work. >=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. >=20 I am surely missing some kprobe context, but is it really safe to use this m= echanism to replace more than one instruction?=