Revision 61bf318eac2c13356f7bd1c6a05421ef504ccc8a authored by Sergei Trofimovich on 13 March 2021, 05:08:27 UTC, committed by Linus Torvalds on 13 March 2021, 19:27:31 UTC
In https://bugs.gentoo.org/769614 Dmitry noticed that
`ptrace(PTRACE_GET_SYSCALL_INFO)` does not return error sign properly.

The bug is in mismatch between get/set errors:

static inline long syscall_get_error(struct task_struct *task,
                                     struct pt_regs *regs)
{
        return regs->r10 == -1 ? regs->r8:0;
}

static inline long syscall_get_return_value(struct task_struct *task,
                                            struct pt_regs *regs)
{
        return regs->r8;
}

static inline void syscall_set_return_value(struct task_struct *task,
                                            struct pt_regs *regs,
                                            int error, long val)
{
        if (error) {
                /* error < 0, but ia64 uses > 0 return value */
                regs->r8 = -error;
                regs->r10 = -1;
        } else {
                regs->r8 = val;
                regs->r10 = 0;
        }
}

Tested on v5.10 on rx3600 machine (ia64 9040 CPU).

Link: https://lkml.kernel.org/r/20210221002554.333076-2-slyfox@gentoo.org
Link: https://bugs.gentoo.org/769614
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Reported-by: Dmitry V. Levin <ldv@altlinux.org>
Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0ceb1ac
History
File Mode Size
amd
arm
intel
Kconfig -rw-r--r-- 11.9 KB
Makefile -rw-r--r-- 1.3 KB
dma-iommu.c -rw-r--r-- 38.7 KB
exynos-iommu.c -rw-r--r-- 38.7 KB
fsl_pamu.c -rw-r--r-- 32.9 KB
fsl_pamu.h -rw-r--r-- 12.7 KB
fsl_pamu_domain.c -rw-r--r-- 27.0 KB
fsl_pamu_domain.h -rw-r--r-- 2.0 KB
hyperv-iommu.c -rw-r--r-- 8.5 KB
io-pgtable-arm-v7s.c -rw-r--r-- 27.0 KB
io-pgtable-arm.c -rw-r--r-- 32.6 KB
io-pgtable-arm.h -rw-r--r-- 812 bytes
io-pgtable.c -rw-r--r-- 1.7 KB
ioasid.c -rw-r--r-- 13.1 KB
iommu-debugfs.c -rw-r--r-- 2.0 KB
iommu-sva-lib.c -rw-r--r-- 2.2 KB
iommu-sva-lib.h -rw-r--r-- 392 bytes
iommu-sysfs.c -rw-r--r-- 3.1 KB
iommu-traces.c -rw-r--r-- 669 bytes
iommu.c -rw-r--r-- 81.5 KB
iova.c -rw-r--r-- 25.0 KB
ipmmu-vmsa.c -rw-r--r-- 30.1 KB
irq_remapping.c -rw-r--r-- 3.2 KB
irq_remapping.h -rw-r--r-- 1.4 KB
msm_iommu.c -rw-r--r-- 19.9 KB
msm_iommu.h -rw-r--r-- 2.7 KB
msm_iommu_hw-8xxx.h -rw-r--r-- 73.4 KB
mtk_iommu.c -rw-r--r-- 31.5 KB
mtk_iommu.h -rw-r--r-- 2.4 KB
mtk_iommu_v1.c -rw-r--r-- 18.4 KB
of_iommu.c -rw-r--r-- 6.2 KB
omap-iommu-debug.c -rw-r--r-- 5.4 KB
omap-iommu.c -rw-r--r-- 41.5 KB
omap-iommu.h -rw-r--r-- 7.0 KB
omap-iopgtable.h -rw-r--r-- 2.7 KB
rockchip-iommu.c -rw-r--r-- 34.3 KB
s390-iommu.c -rw-r--r-- 9.3 KB
sun50i-iommu.c -rw-r--r-- 27.3 KB
tegra-gart.c -rw-r--r-- 9.1 KB
tegra-smmu.c -rw-r--r-- 27.8 KB
virtio-iommu.c -rw-r--r-- 28.5 KB

back to top