Merge tag 'hardening-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
[platform/kernel/linux-starfive.git] / fs / coredump.c
index 97eaee3..de78bde 100644 (file)
@@ -328,6 +328,10 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm,
                                err = cn_printf(cn, "%lu",
                                              rlimit(RLIMIT_CORE));
                                break;
+                       /* CPU the task ran on */
+                       case 'C':
+                               err = cn_printf(cn, "%d", cprm->cpu);
+                               break;
                        default:
                                break;
                        }
@@ -528,7 +532,6 @@ void do_coredump(const kernel_siginfo_t *siginfo)
        static atomic_t core_dump_count = ATOMIC_INIT(0);
        struct coredump_params cprm = {
                .siginfo = siginfo,
-               .regs = signal_pt_regs(),
                .limit = rlimit(RLIMIT_CORE),
                /*
                 * We must use the same mm->flags while dumping core to avoid
@@ -537,6 +540,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)
                 */
                .mm_flags = mm->flags,
                .vma_meta = NULL,
+               .cpu = raw_smp_processor_id(),
        };
 
        audit_core_dumps(siginfo->si_signo);
@@ -719,8 +723,8 @@ void do_coredump(const kernel_siginfo_t *siginfo)
                 * filesystem.
                 */
                mnt_userns = file_mnt_user_ns(cprm.file);
-               if (!uid_eq(i_uid_into_mnt(mnt_userns, inode),
-                           current_fsuid())) {
+               if (!vfsuid_eq_kuid(i_uid_into_vfsuid(mnt_userns, inode),
+                                   current_fsuid())) {
                        pr_info_ratelimited("Core dump to %s aborted: cannot preserve file owner\n",
                                            cn.corename);
                        goto close_fail;
@@ -856,7 +860,7 @@ static int dump_emit_page(struct coredump_params *cprm, struct page *page)
        if (dump_interrupted())
                return 0;
        pos = file->f_pos;
-       iov_iter_bvec(&iter, WRITE, &bvec, 1, PAGE_SIZE);
+       iov_iter_bvec(&iter, ITER_SOURCE, &bvec, 1, PAGE_SIZE);
        n = __kernel_write_iter(cprm->file, &iter, &pos);
        if (n != PAGE_SIZE)
                return 0;