From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D03BB654; Mon, 4 Mar 2024 10:42:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709548922; cv=none; b=oDjE3z+mzAp9fUksX55Y5LiW2D5gVfM+FjopVsxCImM2y0hMnsP51bYfhtbncpIzsnYyq43VSqrAil5kLRUdDnwCQLTHL4IDFDpb0+gV8EUZ1rXhqP6jndNZFpEDgh1BJrFhkLCI2WJOiBLjey2l4NOJxrU6OmVnfJap0is736A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709548922; c=relaxed/simple; bh=+JybKZUAmD1s3bmTrSchyai48XNikWXuRgLyxam6z0o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UFyCVeXq52cF+X2HPFYVd5B8ommW2vmluxxr4O/Mjrtq374XVGyIllfARS29GMrB7DSv+FIHpBhSgX6XQVZFDQLHA2TrPxNWgpzdQHJW3RMbat6EeiTI3W4GSOcq1vKgv/pVPlsiyqRt5OGwqeljGaINt8qHk9yDXs3im7bvqpM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ltERCB8y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ltERCB8y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DA83C433C7; Mon, 4 Mar 2024 10:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709548922; bh=+JybKZUAmD1s3bmTrSchyai48XNikWXuRgLyxam6z0o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ltERCB8yAa0AMPJEpgzQS9Mbx+MMdX4t6PVSu/3nf+AZxPeRfx0+1DMY//JNr6jdF tHg/7M9hFnV/Jln+GGOrzBNYQGeYgWaCN5MUeTJUQJ4E6ijEOJPByuThwLfpXCPeDg OG3QZo2Gi3pZnIsOzs0Uil3poHWRtMmE+7WWYpTY= Date: Mon, 4 Mar 2024 11:41:46 +0100 From: Greg KH To: Rui Qi Cc: bp@alien8.de, mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com, jpoimboe@redhat.com, peterz@infradead.org, mbenes@suse.cz, stable@vger.kernel.org, alexandre.chartre@oracle.com, x86@kernel.org, linux-kernel@vger.kernel.org, yuanzhu@bytedance.com Subject: Re: [PATCH v2 0/3] Support intra-function call validation Message-ID: <2024030438-dropout-satisfy-b4c4@gregkh> References: <20240228024535.79980-1-qirui.001@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240228024535.79980-1-qirui.001@bytedance.com> On Wed, Feb 28, 2024 at 10:45:32AM +0800, Rui Qi wrote: > Since kernel version 5.4.217 LTS, there has been an issue with the kernel live patching feature becoming unavailable. > When compiling the sample code for kernel live patching, the following message is displayed when enabled: > > livepatch: klp_check_stack: kworker/u256:6:23490 has an unreliable stack > > Reproduction steps: > 1.git checkout v5.4.269 -b v5.4.269 > 2.make defconfig > 3. Set CONFIG_LIVEPATCH=y态CONFIG_SAMPLE_LIVEPATCH=m > 4. make -j bzImage > 5. make samples/livepatch/livepatch-sample.ko > 6. qemu-system-x86_64 -kernel arch/x86_64/boot/bzImage -nographic -append "console=ttyS0" -initrd initrd.img -m 1024M > 7. insmod livepatch-sample.ko > > Kernel live patch cannot complete successfully. > > After some debugging, the immediate cause of the patch failure is an error in stack checking. The logs are as follows: > [ 340.974853] livepatch: klp_check_stack: kworker/u256:0:23486 has an unreliable stack > [ 340.974858] livepatch: klp_check_stack: kworker/u256:1:23487 has an unreliable stack > [ 340.974863] livepatch: klp_check_stack: kworker/u256:2:23488 has an unreliable stack > [ 340.974868] livepatch: klp_check_stack: kworker/u256:5:23489 has an unreliable stack > [ 340.974872] livepatch: klp_check_stack: kworker/u256:6:23490 has an unreliable stack > ...... > > BTW,if you use the v5.4.217 tag for testing, make sure to set CONFIG_RETPOLINE = y and CONFIG_LIVEPATCH = y, and other steps are consistent with v5.4.269 > > After investigation, The problem is strongly related to the commit 8afd1c7da2b0 ("x86/speculation: Change FILL_RETURN_BUFFER to work with objtool"), > which would cause incorrect ORC entries to be generated, and the v5.4.217 version can undo this commit to make kernel livepatch work normally. > It is a back-ported upstream patch with some code adjustments,from the git log, the author also mentioned no intra-function call validation support. > > Based on commit 6e1f54a4985b63bc1b55a09e5e75a974c5d6719b (Linux 5.4.269), This patchset adds stack validation support for intra-function calls, > allowing the kernel live patching feature to work correctly. > > Alexandre Chartre (2): > objtool: is_fentry_call() crashes if call has no destination > objtool: Add support for intra-function calls > > Rui Qi (1): > x86/speculation: Support intra-function call validation > > arch/x86/include/asm/nospec-branch.h | 7 ++ > include/linux/frame.h | 11 ++++ > .../Documentation/stack-validation.txt | 8 +++ > tools/objtool/arch/x86/decode.c | 6 ++ > tools/objtool/check.c | 64 +++++++++++++++++-- > 5 files changed, 91 insertions(+), 5 deletions(-) All now queued up, thanks! greg k-h