Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1752820lqg; Mon, 4 Mar 2024 02:43:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUUDJLKYXZ4JhKfhBNfHLIC8hz2y84adpoFNE+TOwvH4UZWf/M75nN5mSLrjcMQEporIuHnPPFUBNRSAIbZ2awenceViw2emSlh2KXirA== X-Google-Smtp-Source: AGHT+IFjgJgEVAuDcIGe4QSgHBuylVI08qd8ELi98D9zrTidPJASJNnDFOPwcCHRuH/bvBpDFGG5 X-Received: by 2002:a17:902:a58c:b0:1dc:696d:ec68 with SMTP id az12-20020a170902a58c00b001dc696dec68mr6397201plb.21.1709548990972; Mon, 04 Mar 2024 02:43:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709548990; cv=pass; d=google.com; s=arc-20160816; b=ckL+g7QoseIjEJbWZ/bDW5jcnX793wMcxx9lhH6CRiJY84XDs8THawIRmNs5h2h7EU Tx3jVJgArOoyaSICc8xdSHsTLoFH2kTC+oqwEPfkaFElLf4LYgTbpK0JuwKZ6mF2lnxs sWSc9lzOIjXjcMOyDVbuGWcNo8/qiBmpD3V/fqQFYBH1NFo2z4TfHZsNvIUct1dV+jso bmHei2ySlL3WMQqILnyXNUygYqAzM3c3EUBGjd+IL2bxLuQoKjKMPm5qhxqZkjLDiXnk U7AxbCqUFyKrXBim3FkJLCqV/NBrjr9lHwZGxMud0+uKCGPw4p5wKuXqaT5eVuToxRLU TYuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=anvPCbXhdM56asus3CG3dclc70QRG9GqO+fWTCShQ6U=; fh=1l/X9Q5ZzKuP8Xua5ctqqBeOWrwnJWrTGQlcTmrQK8g=; b=Z6H/80DJ8bRI8/EDtYJ1w6OxQsNptLIVtGXtb4EABkKkmfaC0pi1TL4baXTKTHXF6x E6n2kC2uYhPgwNiDtX4NS8nPM8jfAZCPw16B1pJWQ41iJcv0ZQyTR+E2vJdOobXmonZh 370Yh8n+EQKG6U7rjZqiuhn/AMkicwZj3mILMeMR9h+v67RUUiqW8V087exIT3DnHmzl 3PSFkAjQyF1hgWFdSoqQdTMEcijE6BoqC0wbIdX6lgkdiMf7OS58dd9AHqpJ4LCWAay8 w9zKOLD68fVhVkBaQY4dxUDyzgpVp3qJ/OuUOHN7XA9T3fD6bJZnTPq5QtSEWPtuq9N9 /PgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ltERCB8y; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-90447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n8-20020a170903110800b001dd10a1ee05si1602019plh.547.2024.03.04.02.43.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 02:43:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ltERCB8y; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-90447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 34E812823D0 for ; Mon, 4 Mar 2024 10:42:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14C1F374C1; Mon, 4 Mar 2024 10:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ltERCB8y" 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 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