From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A4E763246EB for ; Mon, 18 May 2026 09:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097853; cv=none; b=VUewDFrw3nKQs2oOmfP/8RrSVjFtqP44RDW7YxFuO5h+rlJtV1OTXIr3J34feeOQVwdeRGZR+vVElw002n/qv3cMMQQTgb2rFjIIwWScjAPhWLrlInxKQWJAXAUzYx53aBYUBSeqDRB/5cVAVJY2qgVk9GqSDkZpm3QC/dUcDFE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097853; c=relaxed/simple; bh=IV1AOHFxFtPMDWIuw8YM0qfvmYEK6TUnKOoH3bZ1kc8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r9q+WgCWH5r/sM6qc6dvj73pAJd7U3YS4nkPNXZDi3FqYKPNkSdXabDn/jL/eA8oiYoSFhked2x9WWYDsO4L1jUj7iRHQnOwy2rzaagCoXopHOu7wu1mHG0Jd8iBlfV/NInfUnoN6vUFRYpztULLAVBOIkbKKjPja03MBGbz0Es= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Rbh0C5wX; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=o5rEHMOA; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Rbh0C5wX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="o5rEHMOA" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779097850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eoryIgzXF/oIa33zui9MlTduEZDwQ60Yge75gzlAI50=; b=Rbh0C5wXKorBFppJBF1BYLRhWQkZwOQEMIVdFCWM2Kn2Dwrrp41Zkqcl992JI4UK67ryLn fACK+stDxFS2SU2WxAU5EG1E8Fb/1EFQS7DalLfbGaGDFXi7cfa88KByGN0hGNe7v8cCbI 7QG94wVvIRMs/IQLOW7TlM54S+vJSWFMotOP3YpKv8m9REAeO7yT8TWv0sWb+gY3BWDdf7 sMpKtUa4t/YA9jyhHtIqsVs8lkwEScXj76SV+WA6ErBMwcMGTYt90qHaJdW42BHKJUXBi1 /Qu2v5ecWBTDC64Jg0elTTMifp+tCexQulStkjIPTQtIMB2sxWplaawuu/g7gw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779097850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eoryIgzXF/oIa33zui9MlTduEZDwQ60Yge75gzlAI50=; b=o5rEHMOAoSaZSnblbe7t66JQZ78Sna7tcTnG/RLzSjyNF+gFFT3fYLDOp4elRXN8kCqhgk /MROBOf8F8i5xOAg== Date: Mon, 18 May 2026 11:49:42 +0200 Subject: [PATCH v3 4/6] vdso/datastore: Explicitly prevent remote access to timens vvar page 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-Transfer-Encoding: 8bit Message-Id: <20260518-vdso-mlockall-v3-4-bf4f2af2b41f@linutronix.de> References: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> In-Reply-To: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Andy Lutomirski , Vincenzo Frascino , Thomas Gleixner Cc: Nam Cao , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, Andrew Morton , David Hildenbrand , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1779097846; l=1920; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=IV1AOHFxFtPMDWIuw8YM0qfvmYEK6TUnKOoH3bZ1kc8=; b=mwlMV5qGf3DE/o8vp+sBUofrQvPITNJqFDZVoJnzPQTMcKlAFbYvOBGJQCmc6tMj4QnN26AlC u26yl4VQgCzAWxB8PzMusFV3pN/RDkiGzXa7F7qJ7wmkjmw9xBU1Z9A X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The fault handler for the timens page does not have access to the target task and therefore can not be invoked remotely. Currently the handler relies on the fact that the vvar mapping is marked as VM_IO and VM_PFNMAP for which the mm core always prevents remote access. However the VM_IO and VM_PFNMAP flags are going to be removed. Add an explicit check to prevent remote access to the mapping. Signed-off-by: Thomas Weißschuh Tested-by: Nam Cao --- kernel/time/namespace_vdso.c | 7 ++----- lib/vdso/datastore.c | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/time/namespace_vdso.c b/kernel/time/namespace_vdso.c index 0d74d160eec9..5ac7b6a6d3a8 100644 --- a/kernel/time/namespace_vdso.c +++ b/kernel/time/namespace_vdso.c @@ -74,11 +74,8 @@ struct page *find_timens_vvar_page(struct vm_area_struct *vma) return current->nsproxy->time_ns->vvar_page; /* - * VM_PFNMAP | VM_IO protect .fault() handler from being called - * through interfaces like /proc/$pid/mem or - * process_vm_{readv,writev}() as long as there's no .access() - * in special_mapping_vmops(). - * For more details check_vma_flags() and __access_remote_vm() + * vvar_fault() protects this from being called through remote interfaces like + * /proc/$pid/mem or process_vm_{readv,writev}(). */ WARN(1, "vvar_page accessed remotely"); diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index f9a1f0fb7ccd..3381ccf9edb1 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -68,6 +68,9 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, { struct page *page, *timens_page; + if (unlikely(vmf->flags & FAULT_FLAG_REMOTE)) + return VM_FAULT_SIGBUS; + page = vdso_data_pages + vmf->pgoff; timens_page = find_timens_vvar_page(vma); -- 2.53.0