From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796167321; b=tzASHdoY6r9LvLXiNdNAsWOqrFuAvFkxlfsChQMGeznAIHlYmL0m+sDe9Yzd0UBJYkPt uJDbthYzo3F2dVNqPyxeK/ZXQgBg9np83DfjXb15Z6hNs6rc0X/xXigQKXZwnu9AFoGdq sxlAPmabHy3rfoU1EJiPsLchJceBlnFXTsVrWuWjIcuD0wf7VnAEal55vKdNBzOOw4C9/ c/aynvDMJPI1WY/JUT6ixCMnjAVIHmPq2ghmKj4jNxXhB7T4kVArjmMV/SGYQTPW79D3e hAbYfLHefc7t3vj7IIyftwh8WgHm3YG6sqz7aUElqJ1scurR7Z3KoKMGB1KIJeKQW9A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796167321; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=tvyXfNhWP6jHdyR1H5frAeHBelxdtyj0zNsr2TEWbRU=; b=mvnX7wlLJ27j1KWTt87mkXHHUZF/AOGuVmdkaqkK69EIFSmJ3i2YFrXPV+8eLgPYk03l yxt4H58CziXDT0E9a31/QhgbetgooTI9Lkd8tfofTW0FlhSw64eFAihuhdDZAz17h1z+j bctrS/2+ehz+FjLwe4FJTB5vM7f5XlsD4MtVZPI8fI4Ec8NVpB7lhxPD5Nzr8WOj51R7K KTrFkK9xZnMJoIEdbNnC4xCl7p3aej1zQusPaFmWjihGbdAIKgeJ6l3Cpduuho6BvglWi uzhJz4Bdu3iUBQQArteewxGoQMhpZn3z2Djop48OF0MpXwpYk5Zs8VHY6/igJiFJIHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=ahE6cxZo; arc=none smtp.remote-ip=74.125.82.197 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B45F360A261F for ; Tue, 1 Dec 2026 23:22:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B45F360A261F 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--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=ahE6cxZo Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-386a0f79047so13714824eec.1 for ; Tue, 01 Dec 2026 15:22:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796167320; x=1796772120; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=tvyXfNhWP6jHdyR1H5frAeHBelxdtyj0zNsr2TEWbRU=; b=ahE6cxZoLw+NQveiJ3THmc8IK8M4Ip/tKkNA/FSmZ2MIsJ1E6aQRMXixun5Yn8FvAC OtBXlXpyHXOA+BKAwmMoApI0EevmdXVvqx5DEA0ghC2XCVdnlyoYJXgFQ/OWUHKWyxFN vnyyGS7Usl+3piFQlNFPhzqyLuRqxoI+gxTzH26KuIF2z+2yAchUnL2E+mpaeS/LqElP XO6qQAsSYAnfEw22qBMVkC6GuvYX0bA5CzY6KhQ/oDFbTPDy/6nVDKNwyZT/TjAE0sTr Ik0xToJh5AQrLkigjfFZ7ZC7AZy24yDYShGtpPxEOzhoSgvKuGuFNSmKvN3T6vglLURI fORQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796167320; x=1796772120; h=content-type: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:content-type; bh=tvyXfNhWP6jHdyR1H5frAeHBelxdtyj0zNsr2TEWbRU=; b=08xkfYEPdBpLjLG2A+cFGVcjg57T+R10g64Lz+ay4LglFz8/jWoHlJbPFX41m/gftw QjoFbewq0XCDL1OEGq2Jg1+ZStS0uo4eaD0/tAKYfwR5IQC1To+AuXpTkQUG2SlOrrx4 F4JQo38NCq8GSS8U8HhwUEy/OUJbQk9FjA9ujvkC5Q4znCzfJs6p+xTxGA7Me/jsZTIn 7Najflnsn/3jLfWILIUkLigdU2gTtHkNmVA0fhjERan0ToG+WALRKv+UAVHHdjyS0aDd dnUAHGJK92X6QeAieLD4TI3CntTG8Dgp4BsZmVTTBS1WEmqlCmLKiGV8LZKYqA4AzR6B Cfzg== X-Forwarded-Encrypted: i=1; AL+hErEdROyYCXjg3okjAKHlacRTmpFZdiL0CSS7Q/5DNh0kZzSqZnkT4dw2ra4g1yIPvUXeRMM=@vger.kernel.org X-Gm-Message-State: APuU4Z8GEP9zbN5exSvulhJp4daPsxKd5a1jNan0dhBIa5L7UD2l6lWA 82m2aTl4gXmI65aYXMcIVhc6gpwjZMLpqJXr1VDaPMA122Yy2taJmicA4NBw34BXf3PXq/2duax IF45Un66Lxw== X-Received: from dycnr28-n2.prod.google.com ([2002:a05:7300:e9dc:20b0:386:33c7:a7cb]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:8954:10b0:387:3203:ace4 with SMTP id 5a478bee46e88-3873203b0b7mr198236eec.18.1796167319675; Tue, 01 Dec 2026 15:21:59 -0800 (PST) Date: Tue, 1 Dec 2026 15:21:15 -0800 In-Reply-To: <20261201232116.1988791-1-irogers@google.com> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261201232116.1988791-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261201232116.1988791-16-irogers@google.com> Subject: [RFC PATCH 15/16] perf aslr: Anonymize sampled host_ip values From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Sean Christopherson , Paolo Bonzini Cc: Marc Zyngier , Alexei Starovoitov , linux-perf-users@vger.kernel.org, kvm@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Ian Rogers Content-Type: text/plain; charset="UTF-8" Include PERF_SAMPLE_HOST_IP in ASLR_SAMPLE_MASK and remap sampled host_ip addresses against the host machine in aslr_tool__process_sample() so anonymized perf.data files do not leak raw host hypervisor virtual addresses. Signed-off-by: Ian Rogers --- tools/perf/util/aslr.c | 32 ++++++++++++++++++++++++++++++++ tools/perf/util/aslr.h | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/aslr.c b/tools/perf/util/aslr.c index e365f807b021..ec2c0989e19d 100644 --- a/tools/perf/util/aslr.c +++ b/tools/perf/util/aslr.c @@ -1109,6 +1109,38 @@ static int aslr_tool__process_sample(const struct perf_tool *tool, if (orig_sample_type & PERF_SAMPLE_CODE_PAGE_SIZE) COPY_U64(); /* code_page_size */ + if (orig_sample_type & PERF_SAMPLE_HOST_IP) { + u64 remapped = 0; + + if (CHECK_BOUNDS(1, 1)) { + ret = -EFAULT; + goto out_put; + } + if (sample->host_ip) { + struct machine *host_machine = &aslr->machines.host; + struct thread *host_thread; + u8 host_cpumode = PERF_RECORD_MISC_USER; + + if (aslr_tool__preload_kernel_maps(host_machine) < 0) { + ret = -ENOMEM; + goto out_put; + } + host_thread = machine__findnew_thread(host_machine, sample->pid, + sample->tid); + if (!host_thread) { + ret = -ENOMEM; + goto out_put; + } + if (machine__kernel_ip(host_machine, sample->host_ip)) + host_cpumode = PERF_RECORD_MISC_KERNEL; + remapped = aslr_tool__remap_address(aslr, host_thread, + host_cpumode, sample->host_ip); + thread__put(host_thread); + } + out_array[j++] = remapped; + i++; + } + if (orig_sample_type & PERF_SAMPLE_AUX) { u64 size; diff --git a/tools/perf/util/aslr.h b/tools/perf/util/aslr.h index 9cc14f0263db..8850511a4a43 100644 --- a/tools/perf/util/aslr.h +++ b/tools/perf/util/aslr.h @@ -26,7 +26,8 @@ PERF_SAMPLE_CGROUP | \ PERF_SAMPLE_DATA_PAGE_SIZE | \ PERF_SAMPLE_CODE_PAGE_SIZE | \ - PERF_SAMPLE_AUX) + PERF_SAMPLE_AUX | \ + PERF_SAMPLE_HOST_IP) struct perf_session; struct perf_tool; -- 2.56.1.915.g69d5ec7298-goog