Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796061160; b=ml7hX7BoigV6MEi+tdPSS07Y1+PEYii3guiR07nugSVS4tHkTdfExSMN23MiPcVvUWJ6 RC7fLcQ6O/8Jgi5K5DRXoSGAC6acyVYMggc+SZczOVECKTfF1DXSbknIACc31jVcH5eo5 rQHvDueBwWP6/OSmzoyz90kXp0Z90O07pqrJJ1wVSXpTUM9rFXc/TYB29JNc1x6WrNbCg qm8VdoqZstwo+8r3DazM9Yhhdfd9ob6FbjUjCjTQZtNjK0I0nSJZs7/zJP7brzLnKhuh4 RJyhRixoJJi+Qf6kkP6jY3iah3f+omktgwYwUVRaSPMdH4e22qIGVhJd6phEf7LeXgw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796061160; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=cD2bZ+TLgId6kLJZSfPvOKDTv0T0bwYwX2jpQlTgtNg=; b=x2pBDzuzqkfCpAgmPCl4ADTThwekKNNAS4rs+P4LijJ/0f42bkk9fRSLdy4xMqloLhQ2 aA9XqEYUhhH7Rwmzg5QNiM+CWQeQG47Pb3vDT7DfaWWBDxV1BOYnFxpQeiOe7uDZQbnF4 P8FAPmaFCoXg4ZegkOET+laSF4/ipKjEnb6RojPLMCnKf2O1BGVj23ehn4q5PZM6wZBmq 0/0bDEJwCnmNnBckAW1Zmyl3xDJJpHfStPS6ObuCe6UDrra/5P1w5jMOv4bxot6j57h3A DGo3LbvIA6D0mF8zVI063qwb/3RSmt5d8ob4B0GcupeJE9Am6lJpPUCO7clFmn5wh5g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="zm70LMA/"; arc=none smtp.remote-ip=209.85.221.53 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 2070F606A31C for ; Mon, 30 Nov 2026 17:52:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2070F606A31C 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.a=rsa-sha256 header.s=20260707 header.b=zm70LMA/ Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-4aa5833c263so10453688f8f.2 for ; Mon, 30 Nov 2026 09:52:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796061158; x=1796665958; 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=cD2bZ+TLgId6kLJZSfPvOKDTv0T0bwYwX2jpQlTgtNg=; b=zm70LMA/Z8c7apqlifZ6q6JCvNQLpwtg/jknyXmZLrmuXVgxCoDa5RDzJJHPaHlwBn e6KZiJcoLHnZyh7yCYfu5+6aXS2rWfu0LWuzodEoFJfKEoAJVR/IiX+OyfKG+hGQcmZF /Ucvhg6c2IomejgGWMaago29zvyqtghXBitxrdiApAjJx+phUMupZjNOKZPUSHBkWzQT B5JtroX7wACDdGIur2XtdwSlPdHOrtCZCUwRVappetd8TuWYkcgfrZM1MiA+50zx4p46 brEiWJWEsLsMA3/eyeKhoKc9idJ8/3nfAjT8odogpdiCbomYo/4iOqA2hMsIpCKBcvxN E0Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796061158; x=1796665958; 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=cD2bZ+TLgId6kLJZSfPvOKDTv0T0bwYwX2jpQlTgtNg=; b=QULiunItjSjwSrSNoS9sVIU0Xpfy0b+RrC/gruZRVc0SNpQZooQLoIkV+UoqVcMhqR Nx0OfkWB3IPxhMifDhCwKxNNEdwFhktfcHoptqTwh29uve3RoqoD5IXUSUZqFuoHCAOw ebOS6P1gGLcamZJrP/dfk2nUR+g1l9rODXUSJb0VvmhdWLOsRj7J3Uby5H7KCW28fkyZ w3rVIH7Pbg4sJ6x3rX5JrcYHFHdRbtN+mWhTz3YUKLr+njDhF7GYV/DnSGYhvmFcCHaT wXWJUI26QbRDuAQfr/u20UcOy3/Lm2xNIwkYMhwAAC7XpZDaCA3T2LNDULC4+LX9cknK U+fw== X-Forwarded-Encrypted: i=1; AL+hErErDzdIRcarmIojGrnoG84amtr3/5jpoXYGSn2c3OvfYEnwHJQVRtUey4CtAiF7aRJ/ULc=@vger.kernel.org X-Gm-Message-State: APuU4Z/t5sbRK7Cs38OK1jLhiXfLUU3lJbA/XFudtUcn6Iwgyhqx4KlZ be9R6emjpMEg7XxaUgulObUPUeh7CD0cVhzT7P6bRPD04kEnJ05yCRDv X-Gm-Gg: AZFdTZdFHfLtGGB/Ew4yL1lu7SD+exap5g4MS41GtnY3FDFMXWBe7xZSuWMh8fYAwpg dZwRk7EHPoD90yF3ZbzJxQlVBOMfACAXt3TlJecDVC1xtx5H8oLyqYa1wB4sVGreDWkP9CW4CUf 0VEFvyxK2ovgBv7AwuM6AL8AIrm9NhTrHd+DRblvragDDGbVs+erFYbvw9/z+osieD+luW+pW+C ydlAb6TQcxqXXUudvfQaitOuAKeQwTYXivd60yRbSAJ5CR31a7qSb92S986GfZXXBEg0b+IKtKl V14/uoDWQ4aGhMhOBuqhHyhNUnYJlLv65uUIdBkqCKyugLP72HJO0xEnys1+ES5b5TpeFKcmkB8 NlUErSihluWp9Z1x1hwMdYjaiGSbjDkFI2qv066tcOyXrAbzQceGRnBfvDYxRsJQn/fWtddapjY zCZjDdfJUhUH++L9/A2kokjNHCd6aenJWWXquKc67D0R5/Bx0smiWk15DmZ34We6ZzXkkmM2eWL K1EMLpA1sNCcwlrsoQyfC7apcSgMNlkh6ihBZHKlbfQNkpWK8Y3Cdl7jnYK6iy45W49HI9deO23 6F230vAIUMgY9dVEgP7ThFzi6ySvNEMKaTr5gExHCnjoKXg= X-Received: by 2002:a05:6000:18a6:b0:48d:fd4d:7fbf with SMTP id ffacd0b85a97d-4abab5ea3a8mr70992626f8f.4.1796061158251; Mon, 30 Nov 2026 09:52:38 -0800 (PST) Received: from localhost.localdomain ([2a04:ee41:4:b2de:1ac0:4dff:fe0f:3782]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab9cf005f2sm55159452f8f.45.2026.11.30.09.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 09:52:37 -0800 (PST) From: Anton Protopopov To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Alan Maguire , John Fastabend , bpf@vger.kernel.org Cc: Anton Protopopov Subject: [PATCH v2 bpf-next 0/5] Tag fmod_ret functions that return ERR_PTR() Date: Mon, 30 Nov 2026 18:04:17 +0000 Message-ID: <20261130180425.150703-1-a.s.protopopov@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit With CONFIG_BPF_FMODRET_SCAN=y the build tags the functions that return errors, so that an fmod_ret program can attach to them. But it looks only at the functions that return an integer. This set tags the functions that return ERR_PTR() too. The verifier part of v1 (patches 1, 2, 3 and 5) is in bpf-next now. This is the resolve_btfids part. Patch 1 fixes a problem which is shared with the integer functions. A function may test a value with IS_ERR() and return it only if it is not an error: return IS_ERR(prev) ? NULL : prev; Such a function got a tag though it never returns an error pointer, and its callers check only for NULL. Now an error does not count once its register is compared with -MAX_ERRNO on the way to the return. This is a simple check and it loses a few real errors too: "if (IS_ERR(p)) return p;" when a constant error and another value meet in p before the test. In an arm64 vmlinux it untags 17 of the new functions and 16 integer functions. In an x86-64 vmlinux it untags 24 functions. Evaluating the branch on the compare would keep them, this can be done in a follow-up, but adds ~300-400 lines of code, so I've dropped it. Patch 2 tags the functions that return a pointer. Patches 3 and 4 skip functions which have the right tag, but whose callers break when a program skips them. Patch 3 skips the seq_file operations: seq_file calls ->stop() after ->start() failed, so ->stop() unlocks what a skipped ->start() did not lock. Patch 4 skips eight functions by name. Patch 5 tests the series. In an arm64 vmlinux built with clang this series tags 1263 functions which return a pointer: 14864 functions are tagged instead of 13617. v1 -> v2: - Drop the test of a declared function that returns a pointer (Alexei) - Do not count errors tested with IS_ERR() (Alexei) - Count any -EINPROGRESS which a function loads, so that a lost one does not make its -EBUSY a failure. 3 functions affected. - Do not tag the seq_file operations (Alexei) - Filter out a few functions by name (Alexei) v1: https://lore.kernel.org/bpf/20261125102810.699464-1-a.s.protopopov@gmail.com/ Anton Protopopov (5): resolve_btfids: Do not count errors translated to NULL resolve_btfids: Tag the functions that return ERR_PTR() resolve_btfids: Do not tag seq_file operations resolve_btfids: Do not tag functions whose callers break on a skip selftests/bpf: Test fmod_ret on functions that return a pointer tools/bpf/resolve_btfids/fmodret.c | 62 +++++++++++++++---- tools/bpf/resolve_btfids/fmodret_scan.c | 5 +- tools/bpf/resolve_btfids/fmodret_scan.h | 5 +- tools/bpf/resolve_btfids/text_flow.c | 12 +++- tools/bpf/resolve_btfids/text_flow.h | 3 + tools/bpf/resolve_btfids/text_insn.h | 1 + tools/bpf/resolve_btfids/text_mc.cpp | 9 ++- tools/bpf/resolve_btfids/text_mc.h | 4 ++ tools/bpf/resolve_btfids/text_mc_arm64.c | 6 ++ tools/bpf/resolve_btfids/text_mc_x86.c | 6 ++ .../selftests/bpf/prog_tests/fmodret_retval.c | 2 +- .../bpf/prog_tests/fmodret_untagged.c | 2 + tools/testing/selftests/bpf/progs/err.h | 5 ++ .../selftests/bpf/progs/fmodret_retval.c | 10 +++ .../bpf/test_kmods/bpf_testmod_retval.c | 2 +- 15 files changed, 113 insertions(+), 21 deletions(-) -- 2.43.0