Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp158768ybm; Mon, 20 May 2019 13:48:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqykoDMWKK14QyX0gs3lFR+A5qn7r/5T3K7i1qFeI+U23GFnvWY6GLyAF8oTLpgach6VpEDF X-Received: by 2002:a63:a55:: with SMTP id z21mr77725223pgk.440.1558385283950; Mon, 20 May 2019 13:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558385283; cv=none; d=google.com; s=arc-20160816; b=l18z3JbH1EvaG7Qq4Z6zbQLBL15MkGmd+yLXg4IlxQ550MPoJ13lB2Bbw3PjGiyyVm pp5wRDnksOBroaMm7aIW1Tg1mubK1Oa+0HOT5r04J7tHhVwfYScp3xLjLaigGOxZtvku 2uVMCAYXYKjPTjYeTIOimshjonszceFQsei0G/yuNYbugBDiOHHMvm8mFeKpAQq1wvVP ifl9Wom5RVatLSSGnuUK+1c3AFcr7oLmmlJulbuo3Hfbae1SxCXJ/4Lo6KvzFQ476e1s YG22VfMhEcPSULBhg9lBXd2gCVal3850g+wAuUbRe34YkIk70ewap5beYzC2Tg2JpOMC WNqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject; bh=x/2qXi6LBc0cly4sEVoPuZ8J1hP3/bja/BDUDcV/mhI=; b=B1IOZ0wi4C2oQ+biggcT8oxxEBJlUET8Nnv/OM8SP4ZinIDkdzLGUiYD6CReYXWk08 KjD8R0HSvf3aMBaWZVsiUGILoNQmPDDoVzE9zXfun2BnHxTB9EWJlWv8xgr+JnhzKYRZ RjTLUWKQg9Kjf0KTQLFhrpGddEDo6YwSX1HpWLKFyXF8NWWOfmbBFhmb/0EIj0e75urt oGTXZbpmt2N8pltWn2xXkQwi6w/6b1G3jc4SuxUc8t1ltA0UKTP8YlvSBi5pX+9Irxzz hCkURZqWa2/pZPA4aDKEzXozC97O74LEdbFWL854Cz7uXq1BdOnTyqf8LbrhJtnTtcDB JJEw== 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 d186si18989204pgc.311.2019.05.20.13.47.48; Mon, 20 May 2019 13:48:03 -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 S1726187AbfETUqo (ORCPT + 99 others); Mon, 20 May 2019 16:46:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55612 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbfETUqo (ORCPT ); Mon, 20 May 2019 16:46:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA32428DE; Mon, 20 May 2019 20:46:38 +0000 (UTC) Received: from [10.18.17.208] (dhcp-17-208.bos.redhat.com [10.18.17.208]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B56F65C644; Mon, 20 May 2019 20:46:36 +0000 (UTC) Subject: Re: Oops caused by race between livepatch and ftrace To: Johannes Erdfelt , Josh Poimboeuf , Jessica Yu , Jiri Kosina , Miroslav Benes , Steven Rostedt , Ingo Molnar , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190520194915.GB1646@sventech.com> From: Joe Lawrence Message-ID: <90f78070-95ec-ce49-1641-19d061abecf4@redhat.com> Date: Mon, 20 May 2019 16:46:36 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190520194915.GB1646@sventech.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 20 May 2019 20:46:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ fixed jeyu's email address ] On 5/20/19 3:49 PM, Johannes Erdfelt wrote: > [ ... snip ... ] > > I have put together a test case that can reproduce the crash using > KVM. The tarball includes a minimal kernel and initramfs, along with > a script to run qemu and the .config used to build the kernel. By > default it will attempt to reproduce by loading multiple livepatches > at the same time. Passing 'test=ftrace' to the script will attempt to > reproduce by racing with ftrace. > > My test setup reproduces the race and oops more reliably by loading > multiple livepatches at the same time than with the ftrace method. It's > not 100% reproducible, so the test case may need to be run multiple > times. > > It can be found here (not attached because of its size): > http://johannes.erdfelt.com/5.2.0-rc1-a188339ca5-livepatch-race.tar.gz Hi Johannes, This is cool way to distribute the repro kernel, modules, etc! These two testing scenarios might be interesting to add to our selftests suite. Can you post or add the source(s) to livepatch-test.ko to the tarball? > The simple patch of extending the module_mutex lock over the entirety > of klp_init_object_loaded fixes it from the livepatch side. This > mostly works because set_all_modules_text_{rw,ro} acquires module_mutex > as well, but it still leaves a hole in the ftrace code. A lock should > probably be held over the entirety of remapping the text sections RW. > > This is complicated by the fact that remapping the text section in > ftrace is handled by arch specific code. I'm not sure what a good > solution to this is yet. A lock or some kind of referencing count.. I'll let other folks comment on that side of the bug report. Thanks, -- Joe