Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1162253ybe; Thu, 5 Sep 2019 11:14:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwT5CAokZkYZOAAaY+MM89DAK5AQI62Plyp6IZtR1/Ks2J8r+6mu3pwOxyRgLls4hQ82wt X-Received: by 2002:a17:90a:2e08:: with SMTP id q8mr5467389pjd.43.1567707256377; Thu, 05 Sep 2019 11:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567707256; cv=none; d=google.com; s=arc-20160816; b=aIx3Ou53HYkB2Gn/1wEIRzoherygp5xaa9VUPg6+D34no+gZDZP9gUVLF9/6bOBpu+ OCGXyNfiRz4bpz28M3QFK2l5IcE5c2944UovNiGvWuxijt+XTTgPIP1GCWHRpy0bn/t3 EGsCimNvpZ4smcDicrJ1mNnR9ei7J5Xbi0om9/XjML0wQvDefUgCfsiUGz2LvYdx7gVZ KgHZqm+C4Ukbz+sPpaeMfpMULWzXk+piX0ddtHBtYpeju4148MjyoVXMGoOU8yt8TYVN djY0a45yG1U3oBZZJkCuKTK0mlrH+Wo86YZ6GOO9F6KE5Nsm5NXXxw54Uz7+sEz1SYv1 SK3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=vN9qA/473lp+QyEgBGCLMUCErKc0yHg1uYMVMBJUEEM=; b=oQX56pV+6IK4uyNc8PQdBYmYvLRXJGNhiIdrkKdAKHoS3bLEykqRFZQYnOZGFaWGLq uirN96nHJLqtpyURenXVIZHcdeLdKtXzYuwFtXX0BAJBK9Ezhxa9dk84dIdd4mF8jYQC uXx4dOBMbHLJtNQpmDxt65k6PUDgF8Gr9vW1YyO/k+mKrD1Oz7899fiAIok4/2OPX59w zwY/IzxZgrUTt+CjzZRBleKK0/Z+H0Hso91LgQVVXhARcvjG3G3wvemcrUSe98wXyvef UptkdtwWXeDEyfdA8xoJTofLPGYi9Vv/xARuQonADLPd4c8ygqh287CoSkZlIIfDfyFX jllA== ARC-Authentication-Results: i=1; mx.google.com; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y187si2368684pgb.480.2019.09.05.11.13.58; Thu, 05 Sep 2019 11:14:16 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389348AbfIEO2Q (ORCPT + 99 others); Thu, 5 Sep 2019 10:28:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48552 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727914AbfIEO2P (ORCPT ); Thu, 5 Sep 2019 10:28:15 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A34FB8980EA; Thu, 5 Sep 2019 14:28:15 +0000 (UTC) Received: from treble (ovpn-120-170.rdu2.redhat.com [10.10.120.170]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23EEB100033E; Thu, 5 Sep 2019 14:28:12 +0000 (UTC) Date: Thu, 5 Sep 2019 09:28:09 -0500 From: Josh Poimboeuf To: Petr Mladek Cc: jikos@kernel.org, Joe Lawrence , Miroslav Benes , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: [RFC PATCH 2/2] livepatch: Clear relocation targets on a module removal Message-ID: <20190905142809.bpalx7wmihkvavxy@treble> References: <20190826145449.wyo7avwpqyriem46@treble> <5c649320-a9bf-ae7f-5102-483bc34d219f@redhat.com> <20190904084932.gndrtewubqiaxmzy@pathway.suse.cz> <20190905025055.36loaatxtkhdo4q5@treble> <20190905110955.wl4lwjbnpqybhkcn@pathway.suse.cz> <20190905130832.dznviqrrg6lfrxvx@treble> <20190905131502.mgiaplb3grlxsahp@treble> <20190905135259.7obdymb7c2wdgafw@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190905135259.7obdymb7c2wdgafw@pathway.suse.cz> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Thu, 05 Sep 2019 14:28:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 05, 2019 at 03:52:59PM +0200, Petr Mladek wrote: > On Thu 2019-09-05 08:15:02, Josh Poimboeuf wrote: > > On Thu, Sep 05, 2019 at 08:08:32AM -0500, Josh Poimboeuf wrote: > > > On Thu, Sep 05, 2019 at 01:09:55PM +0200, Petr Mladek wrote: > > > > > I don't have a number, but it's very common to patch a function which > > > > > uses jump labels or alternatives. > > > > > > > > Really? My impression is that both alternatives and jump_labels > > > > are used in hot paths. I would expect them mostly in core code > > > > that is always loaded. > > > > > > > > Alternatives are often used in assembly that we are not able > > > > to livepatch anyway. > > > > > > > > Or are they spread widely via some macros or inlined functions? > > > > > > Jump labels are used everywhere. Looking at vmlinux.o in my kernel: > > > > > > Relocation section [19621] '.rela__jump_table' for section [19620] '__jump_table' at offset 0x197873c8 contains 11913 entries: > > > > > > Each jump label entry has 3 entries, so 11913/3 = 3971 jump labels. > > > > > > $ readelf -s vmlinux.o |grep FUNC |wc -l > > > 46902 > > > > > > 3971/46902 = ~8.5% > > > > > > ~8.5% of functions use jump labels. > > > > Obviously some functions may use more than one jump label so this isn't > > exactly bulletproof math. But it gives a rough idea of how widespread > > they are. > > It looks scary. I just wonder why we have never met this problem during > last few years. Who knows what can happen when you disable jump label patching. Sometimes it may be harmless. A panic is probably the worst case. There may be other fail modes which are harder to detect. > My only guess is that most of these functions are either in core > kernel or in code that we do not livepatch. This is definitely not the case. We recently introduced jump label checking in kpatch-build, and it complains a lot. The workaround is to replace such uses with static_key_enabled(). -- Josh