<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/rss.xsl.xml"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
    <title>Changes in task_kfunc.c</title>
    <description></description>
    <language>en</language>
    <copyright>Copyright 2015</copyright>
    <generator>Java</generator><item>
        <title>f987a640 - selftests/bpf: Add tests for bpf_task_from_vpid() kfunc</title>
        <link>http://172.16.0.5:8080/history/linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c#f987a640</link>
        <description>selftests/bpf: Add tests for bpf_task_from_vpid() kfuncThis patch adds test cases for bpf_task_from_vpid() kfunc.task_kfunc_from_vpid_no_null_check is used to test the case wherethe return value is not checked for NULL pointer.test_task_from_vpid_current is used to test obtaining thestruct task_struct of the process in the pid namespace based on vpid.test_task_from_vpid_invalid is used to test the case of invalid vpid.test_task_from_vpid_current and test_task_from_vpid_invalid will runin the new namespace.Signed-off-by: Juntong Deng &lt;juntong.deng@outlook.com&gt;Link: https://lore.kernel.org/r/AM6PR03MB5848F13435CD650AC4B7BD7099442@AM6PR03MB5848.eurprd03.prod.outlook.comSigned-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;

            List of files:
            /linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c</description>
        <pubDate>Mon, 14 Oct 2024 09:25:53 +0000</pubDate>
        <dc:creator>Juntong Deng &lt;juntong.deng@outlook.com&gt;</dc:creator>
    </item>
<item>
        <title>63ae8eb2 - selftests/bpf: Add CO-RE relocs kfunc flavors tests</title>
        <link>http://172.16.0.5:8080/history/linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c#63ae8eb2</link>
        <description>selftests/bpf: Add CO-RE relocs kfunc flavors testsThis patch adds selftests that exercise kfunc flavor relocationfunctionality added in the previous patch. The actual kfunc definedin kernel/bpf/helpers.c is:  struct task_struct *bpf_task_acquire(struct task_struct *p)The following relocation behaviors are checked:  struct task_struct *bpf_task_acquire___one(struct task_struct *name)    * Should succeed despite differing param name  struct task_struct *bpf_task_acquire___two(struct task_struct *p, void *ctx)    * Should fail because there is no two-param bpf_task_acquire  struct task_struct *bpf_task_acquire___three(void *ctx)    * Should fail because, despite vmlinux&apos;s bpf_task_acquire having one param,      the types don&apos;t matchSigned-off-by: Dave Marchevsky &lt;davemarchevsky@fb.com&gt;Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;Acked-by: David Vernet &lt;void@manifault.com&gt;Link: https://lore.kernel.org/bpf/20230817225353.2570845-2-davemarchevsky@fb.com

            List of files:
            /linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c</description>
        <pubDate>Thu, 17 Aug 2023 22:53:53 +0000</pubDate>
        <dc:creator>Dave Marchevsky &lt;davemarchevsky@fb.com&gt;</dc:creator>
    </item>
<item>
        <title>f85671c6 - bpf: Remove now-defunct task kfuncs</title>
        <link>http://172.16.0.5:8080/history/linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c#f85671c6</link>
        <description>bpf: Remove now-defunct task kfuncsIn commit 22df776a9a86 (&quot;tasks: Extract rcu_users out of union&quot;), the&apos;refcount_t rcu_users&apos; field was extracted out of a union with the&apos;struct rcu_head rcu&apos; field. This allows us to safely perform arefcount_inc_not_zero() on task-&gt;rcu_users when acquiring a reference ona task struct. A prior patch leveraged this by making struct task_structan RCU-protected object in the verifier, and by bpf_task_acquire() touse the task-&gt;rcu_users field for synchronization.Now that we can use RCU to protect tasks, we no longer needbpf_task_kptr_get(), or bpf_task_acquire_not_zero(). bpf_task_kptr_get()is truly completely unnecessary, as we can just use RCU to get theobject. bpf_task_acquire_not_zero() is now equivalent tobpf_task_acquire().In addition to these changes, this patch also updates the associatedselftests to no longer use these kfuncs.Signed-off-by: David Vernet &lt;void@manifault.com&gt;Link: https://lore.kernel.org/r/20230331195733.699708-3-void@manifault.comSigned-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;

            List of files:
            /linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c</description>
        <pubDate>Fri, 31 Mar 2023 19:57:32 +0000</pubDate>
        <dc:creator>David Vernet &lt;void@manifault.com&gt;</dc:creator>
    </item>
<item>
        <title>d02c48fa - bpf: Make struct task_struct an RCU-safe type</title>
        <link>http://172.16.0.5:8080/history/linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c#d02c48fa</link>
        <description>bpf: Make struct task_struct an RCU-safe typestruct task_struct objects are a bit interesting in terms of how theirlifetime is protected by refcounts. task structs have two refcountfields:1. refcount_t usage: Protects the memory backing the task struct. When   this refcount drops to 0, the task is immediately freed, without   waiting for an RCU grace period to elapse. This is the field that   most callers in the kernel currently use to ensure that a task   remains valid while it&apos;s being referenced, and is what&apos;s currently   tracked with bpf_task_acquire() and bpf_task_release().2. refcount_t rcu_users: A refcount field which, when it drops to 0,   schedules an RCU callback that drops a reference held on the &apos;usage&apos;   field above (which is acquired when the task is first created). This   field therefore provides a form of RCU protection on the task by   ensuring that at least one &apos;usage&apos; refcount will be held until an RCU   grace period has elapsed. The qualifier &quot;a form of&quot; is important   here, as a task can remain valid after task-&gt;rcu_users has dropped to   0 and the subsequent RCU gp has elapsed.In terms of BPF, we want to use task-&gt;rcu_users to protect tasks thatfunction as referenced kptrs, and to allow tasks stored as referencedkptrs in maps to be accessed with RCU protection.Let&apos;s first determine whether we can safely use task-&gt;rcu_users toprotect tasks stored in maps. All of the bpf_task* kfuncs can only becalled from tracepoint, struct_ops, or BPF_PROG_TYPE_SCHED_CLS, programtypes. For tracepoint and struct_ops programs, the struct task_structpassed to a program handler will always be trusted, so it will always besafe to call bpf_task_acquire() with any task passed to a program.Note, however, that we must update bpf_task_acquire() to be KF_RET_NULL,as it is possible that the task has exited by the time the program isinvoked, even if the pointer is still currently valid because the mainkernel holds a task-&gt;usage refcount. For BPF_PROG_TYPE_SCHED_CLS, tasksshould never be passed as an argument to the any program handlers, so itshould not be relevant.The second question is whether it&apos;s safe to use RCU to access a taskthat was acquired with bpf_task_acquire(), and stored in a map. Becausebpf_task_acquire() now uses task-&gt;rcu_users, it follows that if the taskis present in the map, that it must have had at least onetask-&gt;rcu_users refcount by the time the current RCU cs was started.Therefore, it&apos;s safe to access that task until the end of the currentRCU cs.With all that said, this patch makes struct task_struct is anRCU-protected object. In doing so, we also change bpf_task_acquire() tobe KF_ACQUIRE | KF_RCU | KF_RET_NULL, and adjust any selftests asnecessary. A subsequent patch will remove bpf_task_kptr_get(), andbpf_task_acquire_not_zero() respectively.Signed-off-by: David Vernet &lt;void@manifault.com&gt;Link: https://lore.kernel.org/r/20230331195733.699708-2-void@manifault.comSigned-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;

            List of files:
            /linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c</description>
        <pubDate>Fri, 31 Mar 2023 19:57:31 +0000</pubDate>
        <dc:creator>David Vernet &lt;void@manifault.com&gt;</dc:creator>
    </item>
<item>
        <title>7525daee - selftests/bpf: Use __failure macro in task kfunc testsuite</title>
        <link>http://172.16.0.5:8080/history/linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c#7525daee</link>
        <description>selftests/bpf: Use __failure macro in task kfunc testsuiteIn commit 537c3f66eac1 (&quot;selftests/bpf: add generic BPF program tester-loader&quot;),a new mechanism was added to the BPF selftest framework to allow testsuites touse macros to define expected failing testcases.This allows any testsuite which tests verification failure to remove a goodamount of boilerplate code. This patch updates the task_kfunc selftest suiteto use these new macros.Signed-off-by: David Vernet &lt;void@manifault.com&gt;Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;Acked-by: Yonghong Song &lt;yhs@fb.com&gt;Link: https://lore.kernel.org/bpf/20230120021844.3048244-1-void@manifault.com

            List of files:
            /linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c</description>
        <pubDate>Fri, 20 Jan 2023 02:18:44 +0000</pubDate>
        <dc:creator>David Vernet &lt;void@manifault.com&gt;</dc:creator>
    </item>
<item>
        <title>c0c852dd - bpf: Do not mark certain LSM hook arguments as trusted</title>
        <link>http://172.16.0.5:8080/history/linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c#c0c852dd</link>
        <description>bpf: Do not mark certain LSM hook arguments as trustedMartin mentioned that the verifier cannot assume arguments fromLSM hook sk_alloc_security being trusted since after the hookis called, the sk ref_count is set to 1. This will overwritethe ref_count changed by the bpf program and may cause ref_countunderflow later on.I then further checked some other hooks. For example,for bpf_lsm_file_alloc() hook in fs/file_table.c,        f-&gt;f_cred = get_cred(cred);        error = security_file_alloc(f);        if (unlikely(error)) {                file_free_rcu(&amp;f-&gt;f_rcuhead);                return ERR_PTR(error);        }        atomic_long_set(&amp;f-&gt;f_count, 1);The input parameter &apos;f&apos; to security_file_alloc() cannot be trustedas well.Specifically, I investiaged bpf_map/bpf_prog/file/sk/task alloc/freelsm hooks. Except bpf_map_alloc and task_alloc, arguments for all otherhooks should not be considered as trusted. This may not be a completelist, but it covers common usage for sk and task.Fixes: 3f00c5239344 (&quot;bpf: Allow trusted pointers to be passed to KF_TRUSTED_ARGS kfuncs&quot;)Signed-off-by: Yonghong Song &lt;yhs@fb.com&gt;Link: https://lore.kernel.org/r/20221203204954.2043348-1-yhs@fb.comSigned-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;

            List of files:
            /linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c</description>
        <pubDate>Sat, 03 Dec 2022 20:49:54 +0000</pubDate>
        <dc:creator>Yonghong Song &lt;yhs@fb.com&gt;</dc:creator>
    </item>
<item>
        <title>f471748b - selftests/bpf: Add selftests for bpf_task_from_pid()</title>
        <link>http://172.16.0.5:8080/history/linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c#f471748b</link>
        <description>selftests/bpf: Add selftests for bpf_task_from_pid()Add some selftest testcases that validate the expected behavior of thebpf_task_from_pid() kfunc that was added in the prior patch.Signed-off-by: David Vernet &lt;void@manifault.com&gt;Link: https://lore.kernel.org/r/20221122145300.251210-3-void@manifault.comSigned-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;

            List of files:
            /linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c</description>
        <pubDate>Tue, 22 Nov 2022 14:53:00 +0000</pubDate>
        <dc:creator>David Vernet &lt;void@manifault.com&gt;</dc:creator>
    </item>
<item>
        <title>fe147956 - bpf/selftests: Add selftests for new task kfuncs</title>
        <link>http://172.16.0.5:8080/history/linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c#fe147956</link>
        <description>bpf/selftests: Add selftests for new task kfuncsA previous change added a series of kfuncs for storing structtask_struct objects as referenced kptrs. This patch adds a newtask_kfunc test suite for validating their expected behavior.Signed-off-by: David Vernet &lt;void@manifault.com&gt;Link: https://lore.kernel.org/r/20221120051004.3605026-5-void@manifault.comSigned-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;

            List of files:
            /linux-6.15/tools/testing/selftests/bpf/prog_tests/task_kfunc.c</description>
        <pubDate>Sun, 20 Nov 2022 05:10:04 +0000</pubDate>
        <dc:creator>David Vernet &lt;void@manifault.com&gt;</dc:creator>
    </item>
</channel>
</rss>
