From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 88331184 for ; Fri, 23 Jan 2026 16:28:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769185721; cv=none; b=kQ6D6pJNgAU7ne4aznSE2r2xGQW7ltr7ycmhUuwd0A2k7okJRLR6/OgJzHvAGfeYW4wp0vFZX8kOVJNW3QX1xkqI8kh6PpLTmy+KbWm++CZECKsxDJsaZ+0IzBW6713gw5rITpOJ07AAWQJaQ9C73d2WePzmpOH20MYtbPtFhcE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769185721; c=relaxed/simple; bh=ojtsfNCk0TQce85vSVCnHOTJK97VmGyljT4hKsA0Knc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RKZ9nH1TcMiuyWgIY2IlveVDokZdcoSghdRqstrY0FfC1+xe1IA9OTDgunVIWD7wnpo/FsJ7ntB5+c+Vyp+0N9uLCO0JKqrgrWu59UnPbgpItKzIwOKVqMwBeImaDhiVDHaAAuE6MzAsfz3UZlE0BDb0fG6YPEdMvngjj8IqCx4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sT5f2cYi; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sT5f2cYi" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-34c43f8ef9bso3102940a91.1 for ; Fri, 23 Jan 2026 08:28:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769185720; x=1769790520; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=he8XloOOWPSaOui0O7oaErIAKoE6NnMdJNO0Fc3CGTs=; b=sT5f2cYiHDlPz4t/TYQZO2rKcKlOWE2TekSgMSOg70/hSrxDdReCv+6sh6nkmoTFCA +UMsCgn+kkX4Yfo0wSyCWxzdRQkSlbbXq6r+w3coj3yqrqPSLLj4BEW9N1woaYVZDCsh wnqC1fLlsWQTBy7XmfEILkCV0XUFKjr87yis5EtsJjXeD95GDEN9AX7FkAJfVJfliYFg kHrPJuMqdDvsvN9dJWPJC3js02aPyXvGRIZwMK6Rmbet1+TLx0xUnNFlH9FGDGdx5iOA 8ykL7QrJwv0mKpsmS0uvheCV8JFGJDlNtNYF+j36eGi6FoPF+th3qh7iSt30Gl7JgGLu j2Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769185720; x=1769790520; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=he8XloOOWPSaOui0O7oaErIAKoE6NnMdJNO0Fc3CGTs=; b=cbmNM8fH0eKsHikHOP2wcU0+TQ78SjrDZBV+2vj5WB5uoVp6l9eWxa/jOMqrxWrZ7A 3Ncf7fAf9A/ynS9LMMvTjyr1WFbh0cMd/Cc/YipHck/cbMzeFF6JelqhXeuOpU2aSJ/P ViLf1dGeMQWRxcwHzpIeXw4Qo9Oi7BK0PvvlxaNqBkvwFqM9FXy9YWyqLkyozvbvrZZv frzVAM/UUhtYTPZZv9854DrMypgPDQZIV1vlolBtCuXi3H+WohQ0ues2bG45tPmSxqV5 7wsmPYh58najM64KevgNhCfgPCe2cjN7hrQFCD0LatruVHUjGrwdddyTwX/u88Wihi42 c4QA== X-Forwarded-Encrypted: i=1; AJvYcCWFsG7IFOsqwTrIpQWe8gssKrA2BbL1NOvi+o9sHAmKco6Q06m60zT1jQcJEnrQr4cqIptrxiODfORL4Vw=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5wia1fhziRI5IviiXK7Rpy9ABKj3lHKQQzeDGbh5uPVmBVCD0 UX4SswyZb5MrH+cFBNz73ntFj67EyrOnWWQggJ1l8WSMkNEzsXfeux/SeR0YPhoFDz1FwxvBfAa j7McHzw== X-Received: from pjbqo8.prod.google.com ([2002:a17:90b:3dc8:b0:352:c99c:60b2]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:384f:b0:32e:2fa7:fe6b with SMTP id 98e67ed59e1d1-3536acf4d36mr2783154a91.14.1769185719797; Fri, 23 Jan 2026 08:28:39 -0800 (PST) Date: Fri, 23 Jan 2026 08:28:38 -0800 In-Reply-To: <6752311d-f545-4148-a938-5c9690c31710@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260122053551.548229-1-zhiquan_li@163.com> <6752311d-f545-4148-a938-5c9690c31710@163.com> Message-ID: Subject: Re: [PATCH] KVM: selftests: Add -U_FORTIFY_SOURCE to avoid some unpredictable test failures From: Sean Christopherson To: Zhiquan Li Cc: pbonzini@redhat.com, shuah@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 23, 2026, Zhiquan Li wrote: >=20 > On 1/23/26 01:21, Sean Christopherson wrote: > > Is this needed for _all_ code, or would it suffice to only disable fort= ification > > when building LIBKVM_STRING_OBJ? From the changelog description, it so= unds like > > we need to disable fortification in the callers to prevent a redirect, = but just > > in case I'm reading that wrong... >=20 > Thanks for your review, Sean. >=20 > Unfortunately, disabling fortification only when building LIBKVM_STRING_O= BJ is > insufficient, because the definitions of the fortified versions are inclu= ded by > each caller during the preprocessing stage. I=E2=80=99ve done further in= vestigation and > found the off tracking since compilation stage with the GCC =E2=80=9C-c -= fdump-tree-all=E2=80=9D > options: >=20 > I found memset() is replaced by __builtin___memset_chk in > x86/nested_emulation_test.c.031t.einline phase by compiler and kept to th= e end. > At last, __builtin___memset_chk was redirected to __memset_chk@plt at GLI= BC in > linking stage. >=20 > As a perfect reference substance, guest_memfd_test, which invokes memset(= ) in > guest_code() as well. I replayed the same steps and found memset() is re= placed > by __builtin___memset_chk in guest_memfd_test.c.031t.einline phase, but, = it was > redirect to __builtin_memset in guest_memfd_test.c.103t.objsz1 phase aft= er the > compiler computing maximum dynamic object size for the destination. Even= tually, > __builtin_memset was redirected to memset at lib/string_override.o in lin= king stage. >=20 > Whatever, the KVM selftests guest code should not reference to the fortif= ied > versions of string functions, let=E2=80=99s stop it at the beginning to a= void the > compiler dancing :-) Indeed, disabling fortification for all code may se= em > overly aggressive. Nah, that'll just turn into a game of whack-a-mole, and likely with extreme= ly random moles :-) I verified the original patch fixes my problematic setup, I'll get it queue= d up. Thanks!