Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp638126pxb; Tue, 9 Feb 2021 08:51:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfW028jHTwIns+gZLTDxGJd+m0ATX1NmFsJ1bZZNMEBWbdx0gRbQ4yRsRB9LdN7aeDf+59 X-Received: by 2002:a05:6402:3070:: with SMTP id bs16mr23427550edb.22.1612889476551; Tue, 09 Feb 2021 08:51:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612889476; cv=none; d=google.com; s=arc-20160816; b=XNRkdhS4+XBWT4Jmzgs84GEXJavftBsKX4Ie0RJ1qfDzASx4DmRKA6zpWKpjoqi9LF fQvYxdsiO/Ey7joSXW+GljACLgFehoJB0AestjEIyyi3qMypcJ32jFV6x2DNoMptyaoC ZuLK7yoWXcpHM4uRCGNIlsvQqkONSoic+lcmPHvf8EIWTkGVQvoRgGx67pAiYG73Wjvs PlAdyuu/OA5FLyIgEtC47Jh6X+jzgn3To4e/n5p7gdsc2QRsrbLCR/pwqK1IixvXCKjG CnP3y20twQYlDkhjA/byIUpt9jnrwsc0dcYPuAcvAC3LWV4r2Hs6mq8XX/NLspcoMraW 4sIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ucw59OKhM9Q+zWkYzS3DfxjYeaWxtahJyWWZM+ZSxcs=; b=yOidLwUCgPzWJOjaL+AJC3R40IcKdXYYXRziCTCCxsMXo0euTmdUCEz+uzvevgLHSm OuFXc/eLF4727LK5x5zpn6vDltcU/cJlrfepNIBi1FDDQrEj4WqTS2MBpQy1zL2MvT9q JQ5YsIP76iIGoFB9JQ10IOF8gu5BrnVoWmG6ZmaWgjxr8tteqKrp7vX4AuDfHYpfL80N Rv8ZFfuG9nXG4eBu64HwPld3RwGlyCbGp1jZbw50WoRLo026ZpYr5sTBUKgcLgOEYIhi ulz7dkFjnec+pID0Cw5yW1TaHn08PCweLoqldA/tLds805d1A5wIEBWU3tMxyPJX80+I kmOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CksqofXN; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w20si14909879edi.528.2021.02.09.08.50.53; Tue, 09 Feb 2021 08:51:16 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=CksqofXN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233015AbhBIQsX (ORCPT + 99 others); Tue, 9 Feb 2021 11:48:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232897AbhBIQqe (ORCPT ); Tue, 9 Feb 2021 11:46:34 -0500 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 540FDC0613D6; Tue, 9 Feb 2021 08:45:53 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id f2so23217875ljp.11; Tue, 09 Feb 2021 08:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ucw59OKhM9Q+zWkYzS3DfxjYeaWxtahJyWWZM+ZSxcs=; b=CksqofXNoheIa9e1LmljJyAtF5mIk/2VO9Knc5og6IIcHV3s+qa62XPGPBZbukFUc3 llf8VuBHfG4uQkV4ZcWZTsHju69yHLidkySv9wacWjQUlssJMOqjXvNdtJUBoednu1Em qryZm5jdr0AZY7z/ZooZKOUUZMFrsLLnAPUwW7yntjouTNDO1FDSE/KCQE0DI2KMkkCr Tfeio6TdlWhCWmxpkNL/dYuGvhFgaKZsFK3jafISWZf/9oawVz69aoT2/qljhF5wCSPW XJT418JirCZ6+xQkOQzuwqEFDZV9jSRUVJ9wd2TkG2xLjLpUlU+NISXqT/pBPsi09kEj qcgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ucw59OKhM9Q+zWkYzS3DfxjYeaWxtahJyWWZM+ZSxcs=; b=Ig1Zv+kXU53r0PZAnW0YsMO8j7NcbBlS7f28ifoIg2ADcMdYXQCxZ/kEMa9eEGHLxP 8qMG/f+ln5pgHdoiXuY4DiOs2SJNZJXN/ekIIFDd7dbm2aE75pPFYOKNxRhVpfJ4HYDV lpRnWG+jg9xpRtdHlTaOb7TNE8cozMLCCiAkiejY8+cqd6yo5Ruprp3FJyjE3+fQqysS uUmC7LK4CpZy7yJ9Pwt8ZAvD1QlXMInK5ujJDFewKmBcYt1wFtNnx9d95na3ET5glyYZ vCH2xk3ARf//tTpIeY0sSx+3gHZDQq3SmzoFvoOwJu3CuIT+YRiyUN6zOCwlzS0a60cf ijWg== X-Gm-Message-State: AOAM532gKEWCB++J4pwvv6SFGGRBzaE6UJhGtuitcqwEm6jWMq7lsNGK FOBS5haMaZbyZkl/hEkj1HC1ZreRXPnZefGJ0QE= X-Received: by 2002:a2e:3507:: with SMTP id z7mr14328131ljz.32.1612889151851; Tue, 09 Feb 2021 08:45:51 -0800 (PST) MIME-Version: 1.0 References: <20210207104022.GA32127@zn.tnic> <20210207175814.GF32127@zn.tnic> <20210207224540.ercf5657pftibyaw@treble> <20210208100206.3b74891e@gandalf.local.home> <20210208153300.m5skwcxxrdpo37iz@treble> <20210208111546.5e01c3fb@gandalf.local.home> <20210209094953.65d2f322@gandalf.local.home> In-Reply-To: <20210209094953.65d2f322@gandalf.local.home> From: Alexei Starovoitov Date: Tue, 9 Feb 2021 08:45:40 -0800 Message-ID: Subject: Re: [GIT PULL] x86/urgent for v5.11-rc7 To: Steven Rostedt Cc: Miroslav Benes , Peter Zijlstra , Josh Poimboeuf , Linus Torvalds , Borislav Petkov , Dave Hansen , x86-ml , lkml , Alexei Starovoitov , live-patching@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 9, 2021 at 6:49 AM Steven Rostedt wrote: > > On Tue, 9 Feb 2021 09:32:34 +0100 (CET) > Miroslav Benes wrote: > > > powerpc has this > > > > static inline unsigned long klp_get_ftrace_location(unsigned long faddr) > > { > > /* > > * Live patch works only with -mprofile-kernel on PPC. In this case, > > * the ftrace location is always within the first 16 bytes. > > */ > > return ftrace_location_range(faddr, faddr + 16); > > } > > > > > > I suppose the trivial fix is to see if it points to endbr64 and if so, > > > > increment the addr by the length of that. > > > > > > I thought of that too. But one thing that may be possible, is to use > > > kallsym. I believe you can get the range of a function (start and end of > > > the function) from kallsyms. Then ask ftrace for the addr in that range > > > (there should only be one). > > > > And we can do this if a hard-coded value live above is not welcome. If I > > remember correctly, we used to have exactly this in the old versions of > > kGraft. We walked through all ftrace records, called > > kallsyms_lookup_size_offset() on every record's ip and if the offset+ip > > matched faddr (in this case), we returned the ip. > > Either way is fine. Question is, should we just wait till CET is > implemented for the kernel before making any of these changes? Just knowing > that we have a solution to handle it may be good enough for now. I think the issue is more fundamental than what appears on the surface. According to endbr64 documentation it's not just any instruction. The cpu will wait for it and if it's replaced with int3 or not seen at the branch target the cpu will throw an exception. If I understood the doc correctly it means that endbr64 can never be replaced with a breakpoint. If that's the case text_poke_bp and kprobe need to do extra safety checks.