summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/bin/stackcollapse-record
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2019-06-23 14:27:17 +0300
committerChristian Brauner <christian@brauner.io>2019-06-24 15:52:54 +0200
commit9014143bab2f3bc0b9e5db3bc8d00e2a43e50fbd (patch)
treed74f92ce4c3467e485a0097a1c8f5a7be484c206 /tools/perf/scripts/python/bin/stackcollapse-record
parent4b972a01a7da614b4796475f933094751a295a2f (diff)
downloadkernel-9014143bab2f3bc0b9e5db3bc8d00e2a43e50fbd.tar.gz
fork: don't check parent_tidptr with CLONE_PIDFD
Give userspace a cheap and reliable way to tell whether CLONE_PIDFD is supported by the kernel or not. The easiest way is to pass an invalid file descriptor value in parent_tidptr, perform the syscall and verify that parent_tidptr has been changed to a valid file descriptor value. CLONE_PIDFD uses parent_tidptr to return pidfds. CLONE_PARENT_SETTID will use parent_tidptr to return the tid of the parent. The two flags cannot be used together. Old kernels that only support CLONE_PARENT_SETTID will not verify the value pointed to by parent_tidptr. This behavior is unchanged even with the introduction of CLONE_PIDFD. However, if CLONE_PIDFD is specified the kernel will currently check the value pointed to by parent_tidptr before placing the pidfd in the memory pointed to. EINVAL will be returned if the value in parent_tidptr is not 0. If CLONE_PIDFD is supported and fd 0 is closed, then the returned pidfd can and likely will be 0 and parent_tidptr will be unchanged. This means userspace must either check CLONE_PIDFD support beforehand or check that fd 0 is not closed when invoking CLONE_PIDFD. The check for pidfd == 0 was introduced during the v5.2 merge window by commit b3e583825266 ("clone: add CLONE_PIDFD") to ensure that CLONE_PIDFD could be potentially extended by passing in flags through the return argument. However, that extension would look horrible, and with the upcoming introduction of the clone3 syscall in v5.3 there is no need to extend legacy clone syscall this way. (Even if it would need to be extended, CLONE_DETACHED can be reused with CLONE_PIDFD.) So remove the pidfd == 0 check. Userspace that needs to be portable to kernels without CLONE_PIDFD support can then be advised to initialize pidfd to -1 and check the pidfd value returned by CLONE_PIDFD. Fixes: b3e583825266 ("clone: add CLONE_PIDFD") Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Christian Brauner <christian@brauner.io>
Diffstat (limited to 'tools/perf/scripts/python/bin/stackcollapse-record')
0 files changed, 0 insertions, 0 deletions
8fef775baa341a0f5d960becd248b11'>treewide: Use fallthrough pseudo-keywordGustavo A. R. Silva 2020-08-10Merge tag 'gfs2-for-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs...Linus Torvalds 2020-08-07gfs2: Never call gfs2_block_zero_range with an open transactionBob Peterson 2020-07-16treewide: Remove uninitialized_var() usageKees Cook 2020-05-08gfs2: Another gfs2_walk_metadata fixAndreas Gruenbacher 2020-03-27gfs2: Split gfs2_rsqa_delete into gfs2_rs_delete and gfs2_qa_putAndreas Gruenbacher 2020-03-27gfs2: Change inode qa_data to allow multiple usersBob Peterson 2020-03-27gfs2: eliminate gfs2_rsqa_alloc in favor of gfs2_qa_allocBob Peterson 2020-03-27gfs2: Switch to list_{first,last}_entryAndreas Gruenbacher 2019-12-05Merge tag 'gfs2-for-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs...Linus Torvalds 2019-11-07gfs2: Improve mmap write vs. punch_hole consistencyAndreas Gruenbacher 2019-10-21iomap: use a srcmap for a read-modify-write I/OGoldwyn Rodrigues 2019-09-17gfs2: clear buf_in_tr when ending a transaction in sweep_bh_for_rgrpsBob Peterson 2019-09-06gfs2: Improve mmap write vs. truncate consistencyAndreas Gruenbacher 2019-08-09gfs2: implement gfs2_block_zero_range using iomap_zero_rangeChristoph Hellwig 2019-08-09gfs2: Add support for IOMAP_ZEROAndreas Gruenbacher 2019-08-09gfs2: gfs2_iomap_begin cleanupAndreas Gruenbacher 2019-08-09gfs2: gfs2_walk_metadata fixAndreas Gruenbacher 2019-07-31gfs2: Inode dirtying fixAndreas Gruenbacher