From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA104233926 for ; Sun, 23 Aug 2026 05:00:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787461235; cv=none; b=k67cfpRoxM4+k4FqWUZOiCpB6o5WVs8/vh0yDZnMhelg5vqwtcbBAT2fyDd66d48RQj0ciCoa5vx3Lk/98aQSrUrQUqdUPdql28nQsJMEhLnu7VQQqhxgCcWtbRlcerrE78+Un98GriD64bhuY7JWe+YWkBOT4Dkcw00Oxsrtj8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787461235; c=relaxed/simple; bh=KBVhPHwGh7gCHrsssphUSdeOdVh3Sr96NStd12N7L0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T1e/U5zXTy2PS6EheI0CKdtskmBjJTjEcp+ZJuC30Fpkir61S2URQ9RVVWQ1SfBn93WZZz9DszWlrJ6dGHJfw8RY5MMz27SmIg31e7pvQVxgAMYPPfxrM3/066oFZtETz6O9GP+1mAhRicY8/CF1E7KaeS32UPx+jgUOIUVJmAU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KQ9sZZ98; arc=none smtp.client-ip=209.85.216.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KQ9sZZ98" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-383cb94f742so2451713a91.3 for ; Sat, 22 Aug 2026 22:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787461234; x=1788066034; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KBVhPHwGh7gCHrsssphUSdeOdVh3Sr96NStd12N7L0I=; b=KQ9sZZ98eIm9D9hR1Gnm/gZW8oC3J9L8jwvKC05kUIPFhNpTRijN8CP6rGGnH27iDF 7gGep+0BwLhmq5bX+1O9HpWkvXjTcUQ1ixutZ7cp3cWlbvkakq5NCKOSnANGN0UgQ2Cp XJD6mh4gj3GW7l+HJaeG+wPMioz9Ubb1y3hzpXsIGzgBLXjlSLcSZO8+kJj+7TaBmPt0 fY9CdhzcBxmJbwiygGq0SHjHeq+cU4Y7UTcjI01H+LL3qCbgNJzZ+GTLIRmx2xQZSoyu tAbvUSJUfAe9JJ4YYMsNaeeT3r9n9XxTNFdHvcpeJpbQRs0iBhT/6V+wFWtIyfCDifhx o9Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787461234; x=1788066034; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=KBVhPHwGh7gCHrsssphUSdeOdVh3Sr96NStd12N7L0I=; b=skKonXcAV479c+YpnvPAF1518OJMSQK6l48jqS2Nylg6lVEuUhAZTCDSm18x/RrOdQ t08bfVYgplWyLuRa4B+YMLnn1FTX/SsITM96HAizbqmEtAamfSO99maeUnLKVVYIzX+K 1EkTB6sWdKra2Ame/88xmfoPojwdokWzdraoiod0QKHiW3fqr4oZ/QEr4ZlOAbrLIn6T 3WZSILDj+IV84TxYFyuzxb2BIqfRnDJhmeCRENA2H482S0Hf2OykzuOhGeWGyGiuDrk7 +0XQEsg0m32xIYNIGhKD6gOkxsBELUiRF9CAlTX+1SWc1Fe7ac/lwYIMGfghVBi5bffs /rFw== X-Forwarded-Encrypted: i=1; AHgh+RoGXNaA+LOFC35jMhTeiNty3uvabe0274c0aVLcXf+IRR3mLU1FM2agL/q0tcAydUHSj+3BRFhCu5VZYBA=@vger.kernel.org X-Gm-Message-State: AFuF++neszva9mlKzQQCI98zFxgsXz2/01/W70rpDjdVdY7JkUj4HW4d UK2B0cZU+4Sl3oDEsKk6ZXR89orDinTPUfvMysiDrRtiLuwYAcFSupfA X-Gm-Gg: AR+sD10oFAfvecB7tejOoEhlhO792VS/pUsPsdCgEWRDBL3U/guwm9lP/4xJ9fERTgD XFgyV0e858Zh2hmJQnddns+h48CjQTUHATmhAP/ku1dU5cQjHGCQ3rnTg0GtEPGLOyATDyXZH6Q SGJ4KsvkM5baG7B+8T46yeUfFiIX5yXuiCYBVmXAtv9d18u6okXiR4vOmqDL/dOMSxhMtBi6oNd bImB0TBpuKwOtciY6dp9xByA7kahjEyekTEiVsP1IUJZMd6MaF4ERTve4uKJnVzs8mON5TfNqKY +uQbHuuMLek3MYA8TbY7HmhFSseFcEHP1smJ6iFtkGK+I0+aKgKyA7bxg2dNQejS4UV7Yx5U8mu 1Hn5Z1GBsNT59O2HwYpWinyxpmyvJZ9tVVt3RDkXe/G3t1e4yHooq6gGjDUrudC6ZW9S2x7ZVBZ JbJHKlIRzP1UIzujr7xxbM63yYQMLO6Pgf2aqWKZZXY1yTTMJpsBOtBfXM44vAJn5B6TluMj67c FUL277/K4ePDQGr07VSo2MclBBeI9bwUw== X-Received: by 2002:a17:90b:1f8d:b0:38c:a59b:5189 with SMTP id 98e67ed59e1d1-395df67778fmr16884913a91.15.1787461233876; Sat, 22 Aug 2026 22:00:33 -0700 (PDT) Received: from Harrys-Laptop.hitronhub.home ([2407:4d00:6c05:13e8:edcf:d188:51c8:54cc]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-395e42cc144sm4731547a91.0.2026.08.22.22.00.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 22 Aug 2026 22:00:33 -0700 (PDT) From: Harry Hsu To: pmladek@suse.com Cc: jpoimboe@kernel.org, jikos@kernel.org, mbenes@suse.cz, joe.lawrence@redhat.com, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] livepatch: Fix stack check for aliased old_func Date: Sun, 23 Aug 2026 13:00:29 +0800 Message-ID: <20260823050029.35979-1-x90613@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Fri 2026-08-21 17:27:10, Petr Mladek wrote: > This might fix klp_check_stack_func() for A. But not for B. B won't > be the last entry so that klp_check_stack_func() would use > the list_next_entry() and will check for A on stack instead of > the original function. > > Another _big problem_ is in klp_ftrace_handler(). It would use A > in PATCHED state and B in UNPATCHED. But it is not clear whether > A or B should be used in the PATCHED state. And it should use > the original code in UNPATCHED state. > > IMHO, we must catch this situation when preparing livepatches > and when enabling the livepatch. A single livepatch must never > create two entries on any ops->func_stack. > > IMHO, we should catch the duplicate (aliased) entries in > klp_init_object_loaded() and return -EINVAL when they are found. > > I do not see any other solution. We could not decide which > struct klp_func should be used for the redirection when > more of them point to the same original function. You're right, thanks for pointing this out. list_is_last() only patches over the stack-check symptom for A and still leaves B wrong, and it does nothing for the klp_ftrace_handler() ambiguity you describe - there's really no sound way to pick between A and B once they're both live entries backed by the same old_func. Rejecting the duplicate at load time is the right fix. I'll send a v2 that detects aliased old_func addresses within the same klp_object in klp_init_object_loaded() and returns -EINVAL when found, instead of touching klp_check_stack_func(). Thanks, Harry