From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 2989E4302FC for ; Wed, 12 Aug 2026 11:12:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786533130; cv=none; b=LA0SefuYE+icPry7TdpzTRzeozeIDdtyJ7815dluC8zfMJfNRk5upPCQgtKmpgvDn5eM55xqs0+caNstdXwZY7TUpD70FyJnkB/tiRLfAqkCoDunuUCQ74jHbbw+WdFLCGc2IbPBxE+5rOy8mTQ2muye0kHWZmaYauBO3PqeLUY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786533130; c=relaxed/simple; bh=OGxckeJmWrizXAHqZWRfuMMkJcH1fqycD1u6bjgSYRQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=J+fC3n6wzXgVz4Zdc+8DvvzDjWraqFe7Y2gcvQItnoOm6iwGmFfb3K7Xik50dgm2+f5t2eYj5bZMLB5Tfss+AExh1c2qUfGgA0c9M8sG+ZVFrEr6UcUuOG+7w4UJ3hCFvA7v3Y8Ra+JL5WrkbSqDerRxOH50tV920GCskiCaimg= 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=RzgD/hKB; arc=none smtp.client-ip=209.85.128.51 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="RzgD/hKB" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4953e04ef16so7762615e9.2 for ; Wed, 12 Aug 2026 04:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786533127; x=1787137927; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=OLpqRHzThXr7YoPCHJa6pbt4R/oii9J/OGrNuRU8D5k=; b=RzgD/hKBvaQHmUpFWk9m4S9hMEd0JE1OHzw6WvyZ+GEV3LWCEeo7+hgG9TohAe+50X bBp3cOF/2SV8RjQqsVkjvOdoMjK9fQFyQZn2zzKTx6DG4R9P977ipiv+nKKcMbtnWuvT /5IqbjbPMRq0GFDD9IE31lNsdGN/M2gwRUCKub4v9+A9QW4vOLCtJkegrks4/MfF4wfy ZuXEjPhb6AoDOTNxpDdNrxyfckUhklR1GjdOk4MT+1AEoEalG54p6MAkrfs6fNMR27uL YyJ8+R0xS/WSBpkBqWwuIBKmR1NfR/ty37glSIRduaz7wmSwQybMBAQUPJwbf0GEPXRn DH7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786533127; x=1787137927; h=content-transfer-encoding:mime-version: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=OLpqRHzThXr7YoPCHJa6pbt4R/oii9J/OGrNuRU8D5k=; b=Js/4vzlt8b2HpoAGfL+gJyCCEdsrZUXzOH0M7EM6ytu3ftHU02oUX6rSZph2i8xKqk UmvFyaeQZfDuXDJT+9wr8kZihFaodt+NaqG1be1k6TQQyeF49egjITQETzOVlCNyDQDs zlwS0s7nshRhUo+pD+JVUhgFl7ss7TqWSpPA8CAocaPX/LWh/1GTbw33rBgEhq0yWyzl ARdPCFCUTImcCevbBHXU4/hIK/5KFemT+6FHfMI3Dabx3QfevxYiYlp0cvQmvpZhb77I +Blk4SH8T0DmBPjsCoQneFok9UMIaYdJgrhKa+IFYK3W1RmMUQYyruQF1pea0BBO+J3q 7BNw== X-Gm-Message-State: AOJu0YzMCSjZ43PsXtQ7MnBBjf5JYN5fNLk2gekj6eBmRYROMtXUoNZB Byhzv4Xsud2X3ITauDZKB03dmu9+Jc/bUo6p+vzanRM/XI2nm+Hj038OkJLNcNhX X-Gm-Gg: AR+sD100N6pnY0SDlPvyfBHSFCzhw13Q1ZPaJJqJ2/q/tTz/OFZFOEn2ljz5Q+8KmlW VheSmOOXVHk85VOKqoPkNoIzNKJrl9+D+2G3YgjqxFURJi2KBHxhVbezbCG+mtYseqYCEWWUhCw ifxj2kmfs4uMIm5qCJ10rN+i9Tv72yU0GDX641kDIPf3Hrfgxsi49gjWKsEbRC8Whwl1Eb3Gr0q tvd4X0Rsb88jGoVPvdACWc9ZRW7qGUM77MFlIoxMyyJTwL9xvZiLvr7cmgisQeC5kBrs4LvogmD ThG727C2G7YPRN86zMOU9iiwxHM6opkp5D/6tJB2DQ8freJNo/fyCnT0Mo1rZf0HlyiDnDILuDA 9w/tD47xQOWq9FwmC2pbBDZNR8zeYlkW6quJrTcDFh7G6Rf9g7XwTECnmisT3k/rjcirwP591/a 6cUtx+ntpjgnPZ6pqLwp3MdhQNqnQ+PtaWSM1qv1y1c9EcsxeQHovjX2f652HpgJE6g0sj11AYB UO2 X-Received: by 2002:a05:600c:4fc5:b0:499:76c5:5855 with SMTP id 5b1f17b1804b1-4997c15fc13mr42107915e9.16.1786533127011; Wed, 12 Aug 2026 04:12:07 -0700 (PDT) Received: from dell-desktop ([2a02:587:4b5e:1100:7303:647d:7cc4:8552]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4997c9417bcsm54830855e9.4.2026.08.12.04.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 04:12:06 -0700 (PDT) From: Anastasios Papagiannis To: bpf@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, akpm@linux-foundation.org, david@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, kpsingh@kernel.org, matt@bobrowski.net, song@kernel.org, tasos.papagiannnis@gmail.com Subject: [PATCH bpf-next 0/3] bpf: Add user memory access kfuncs for linux_binprm Date: Wed, 12 Aug 2026 14:11:37 +0300 Message-ID: <20260812111140.7762-1-tasos.papagiannnis@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit During exec, argument and environment strings are copied into the new address space held by struct linux_binprm before that address space is installed on the task_struct. Existing eBPF user memory helpers only support reading from the old address space (i.e. current process) and for this reason programs cannot access these strings from the bprm_check_security LSM hook. This series adds two sleepable BPF kfuncs for copying bytes or NUL-terminated strings from the address space held by struct linux_binprm. This allows BPF LSM programs to inspect exec arguments before allowing the exec to continue. The series also adds selftests covering both kfuncs. Anastasios Papagiannis (3): mm: Add copy_remote_mm_str() bpf: Add user memory access kfuncs for linux_binprm selftests/bpf: Test linux_binprm user memory kfuncs fs/bpf_fs_kfuncs.c | 112 ++++++++++++++++++ include/linux/mm.h | 2 + mm/memory.c | 25 +++- mm/nommu.c | 25 +++- .../bpf/prog_tests/copy_from_user_bprm.c | 52 ++++++++ .../selftests/bpf/progs/copy_from_user_bprm.c | 74 ++++++++++++ 6 files changed, 288 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/copy_from_user_bprm.c create mode 100644 tools/testing/selftests/bpf/progs/copy_from_user_bprm.c base-commit: 07cb86aa50816b070b99c89bf948762ef035a1f2 -- 2.55.0