tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core/urgent
head:   451eb3f2053ea4eeb40f94947c542cfbd7636186
commit: 451eb3f2053ea4eeb40f94947c542cfbd7636186 [1/1] fs/proc: Report eip/esp 
in /prod/PID/stat for coredumping
config: i386-randconfig-x003-201737 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        git checkout 451eb3f2053ea4eeb40f94947c542cfbd7636186
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from arch/x86/include/asm/cpufeature.h:4:0,
                    from arch/x86/include/asm/thread_info.h:52,
                    from include/linux/thread_info.h:37,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:80,
                    from include/linux/spinlock.h:50,
                    from include/linux/seqlock.h:35,
                    from include/linux/time.h:5,
                    from fs/proc/array.c:57:
   fs/proc/array.c: In function 'do_task_stat':
>> arch/x86/include/asm/processor.h:839:39: error: implicit declaration of 
>> function 'task_stack_page' [-Werror=implicit-function-declaration]
     unsigned long __ptr = (unsigned long)task_stack_page(task); \
                                          ^
>> arch/x86/include/asm/processor.h:896:26: note: in expansion of macro 
>> 'task_pt_regs'
    #define KSTK_EIP(task)  (task_pt_regs(task)->ip)
                             ^~~~~~~~~~~~
>> fs/proc/array.c:430:10: note: in expansion of macro 'KSTK_EIP'
       eip = KSTK_EIP(task);
             ^~~~~~~~
   cc1: some warnings being treated as errors
--
   In file included from arch/x86/include/asm/cpufeature.h:4:0,
                    from arch/x86/include/asm/thread_info.h:52,
                    from include/linux/thread_info.h:37,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:80,
                    from include/linux/spinlock.h:50,
                    from include/linux/seqlock.h:35,
                    from include/linux/time.h:5,
                    from fs//proc/array.c:57:
   fs//proc/array.c: In function 'do_task_stat':
>> arch/x86/include/asm/processor.h:839:39: error: implicit declaration of 
>> function 'task_stack_page' [-Werror=implicit-function-declaration]
     unsigned long __ptr = (unsigned long)task_stack_page(task); \
                                          ^
>> arch/x86/include/asm/processor.h:896:26: note: in expansion of macro 
>> 'task_pt_regs'
    #define KSTK_EIP(task)  (task_pt_regs(task)->ip)
                             ^~~~~~~~~~~~
   fs//proc/array.c:430:10: note: in expansion of macro 'KSTK_EIP'
       eip = KSTK_EIP(task);
             ^~~~~~~~
   cc1: some warnings being treated as errors

vim +/KSTK_EIP +430 fs/proc/array.c

   392  
   393  static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
   394                          struct pid *pid, struct task_struct *task, int 
whole)
   395  {
   396          unsigned long vsize, eip, esp, wchan = 0;
   397          int priority, nice;
   398          int tty_pgrp = -1, tty_nr = 0;
   399          sigset_t sigign, sigcatch;
   400          char state;
   401          pid_t ppid = 0, pgid = -1, sid = -1;
   402          int num_threads = 0;
   403          int permitted;
   404          struct mm_struct *mm;
   405          unsigned long long start_time;
   406          unsigned long cmin_flt = 0, cmaj_flt = 0;
   407          unsigned long  min_flt = 0,  maj_flt = 0;
   408          u64 cutime, cstime, utime, stime;
   409          u64 cgtime, gtime;
   410          unsigned long rsslim = 0;
   411          char tcomm[sizeof(task->comm)];
   412          unsigned long flags;
   413  
   414          state = *get_task_state(task);
   415          vsize = eip = esp = 0;
   416          permitted = ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS | 
PTRACE_MODE_NOAUDIT);
   417          mm = get_task_mm(task);
   418          if (mm) {
   419                  vsize = task_vsize(mm);
   420                  /*
   421                   * esp and eip are intentionally zeroed out.  There is 
no
   422                   * non-racy way to read them without freezing the task.
   423                   * Programs that need reliable values can use ptrace(2).
   424                   *
   425                   * The only exception is if the task is core dumping 
because
   426                   * a program is not able to use ptrace(2) in that case. 
It is
   427                   * safe because the task has stopped executing 
permanently.
   428                   */
   429                  if (permitted && (task->flags & PF_DUMPCORE)) {
 > 430                          eip = KSTK_EIP(task);
   431                          esp = KSTK_ESP(task);
   432                  }
   433          }
   434  
   435          get_task_comm(tcomm, task);
   436  
   437          sigemptyset(&sigign);
   438          sigemptyset(&sigcatch);
   439          cutime = cstime = utime = stime = 0;
   440          cgtime = gtime = 0;
   441  
   442          if (lock_task_sighand(task, &flags)) {
   443                  struct signal_struct *sig = task->signal;
   444  
   445                  if (sig->tty) {
   446                          struct pid *pgrp = tty_get_pgrp(sig->tty);
   447                          tty_pgrp = pid_nr_ns(pgrp, ns);
   448                          put_pid(pgrp);
   449                          tty_nr = new_encode_dev(tty_devnum(sig->tty));
   450                  }
   451  
   452                  num_threads = get_nr_threads(task);
   453                  collect_sigign_sigcatch(task, &sigign, &sigcatch);
   454  
   455                  cmin_flt = sig->cmin_flt;
   456                  cmaj_flt = sig->cmaj_flt;
   457                  cutime = sig->cutime;
   458                  cstime = sig->cstime;
   459                  cgtime = sig->cgtime;
   460                  rsslim = ACCESS_ONCE(sig->rlim[RLIMIT_RSS].rlim_cur);
   461  
   462                  /* add up live thread stats at the group level */
   463                  if (whole) {
   464                          struct task_struct *t = task;
   465                          do {
   466                                  min_flt += t->min_flt;
   467                                  maj_flt += t->maj_flt;
   468                                  gtime += task_gtime(t);
   469                          } while_each_thread(task, t);
   470  
   471                          min_flt += sig->min_flt;
   472                          maj_flt += sig->maj_flt;
   473                          thread_group_cputime_adjusted(task, &utime, 
&stime);
   474                          gtime += sig->gtime;
   475                  }
   476  
   477                  sid = task_session_nr_ns(task, ns);
   478                  ppid = task_tgid_nr_ns(task->real_parent, ns);
   479                  pgid = task_pgrp_nr_ns(task, ns);
   480  
   481                  unlock_task_sighand(task, &flags);
   482          }
   483  
   484          if (permitted && (!whole || num_threads < 2))
   485                  wchan = get_wchan(task);
   486          if (!whole) {
   487                  min_flt = task->min_flt;
   488                  maj_flt = task->maj_flt;
   489                  task_cputime_adjusted(task, &utime, &stime);
   490                  gtime = task_gtime(task);
   491          }
   492  
   493          /* scale priority and nice values from timeslices to -20..20 */
   494          /* to make it look like a "normal" Unix priority/nice value  */
   495          priority = task_prio(task);
   496          nice = task_nice(task);
   497  
   498          /* convert nsec -> ticks */
   499          start_time = nsec_to_clock_t(task->real_start_time);
   500  
   501          seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state);
   502          seq_put_decimal_ll(m, " ", ppid);
   503          seq_put_decimal_ll(m, " ", pgid);
   504          seq_put_decimal_ll(m, " ", sid);
   505          seq_put_decimal_ll(m, " ", tty_nr);
   506          seq_put_decimal_ll(m, " ", tty_pgrp);
   507          seq_put_decimal_ull(m, " ", task->flags);
   508          seq_put_decimal_ull(m, " ", min_flt);
   509          seq_put_decimal_ull(m, " ", cmin_flt);
   510          seq_put_decimal_ull(m, " ", maj_flt);
   511          seq_put_decimal_ull(m, " ", cmaj_flt);
   512          seq_put_decimal_ull(m, " ", nsec_to_clock_t(utime));
   513          seq_put_decimal_ull(m, " ", nsec_to_clock_t(stime));
   514          seq_put_decimal_ll(m, " ", nsec_to_clock_t(cutime));
   515          seq_put_decimal_ll(m, " ", nsec_to_clock_t(cstime));
   516          seq_put_decimal_ll(m, " ", priority);
   517          seq_put_decimal_ll(m, " ", nice);
   518          seq_put_decimal_ll(m, " ", num_threads);
   519          seq_put_decimal_ull(m, " ", 0);
   520          seq_put_decimal_ull(m, " ", start_time);
   521          seq_put_decimal_ull(m, " ", vsize);
   522          seq_put_decimal_ull(m, " ", mm ? get_mm_rss(mm) : 0);
   523          seq_put_decimal_ull(m, " ", rsslim);
   524          seq_put_decimal_ull(m, " ", mm ? (permitted ? mm->start_code : 
1) : 0);
   525          seq_put_decimal_ull(m, " ", mm ? (permitted ? mm->end_code : 1) 
: 0);
   526          seq_put_decimal_ull(m, " ", (permitted && mm) ? mm->start_stack 
: 0);
   527          seq_put_decimal_ull(m, " ", esp);
   528          seq_put_decimal_ull(m, " ", eip);
   529          /* The signal information here is obsolete.
   530           * It must be decimal for Linux 2.0 compatibility.
   531           * Use /proc/#/status for real-time signals.
   532           */
   533          seq_put_decimal_ull(m, " ", task->pending.signal.sig[0] & 
0x7fffffffUL);
   534          seq_put_decimal_ull(m, " ", task->blocked.sig[0] & 
0x7fffffffUL);
   535          seq_put_decimal_ull(m, " ", sigign.sig[0] & 0x7fffffffUL);
   536          seq_put_decimal_ull(m, " ", sigcatch.sig[0] & 0x7fffffffUL);
   537  
   538          /*
   539           * We used to output the absolute kernel address, but that's an
   540           * information leak - so instead we show a 0/1 flag here, to 
signal
   541           * to user-space whether there's a wchan field in 
/proc/PID/wchan.
   542           *
   543           * This works with older implementations of procps as well.
   544           */
   545          if (wchan)
   546                  seq_puts(m, " 1");
   547          else
   548                  seq_puts(m, " 0");
   549  
   550          seq_put_decimal_ull(m, " ", 0);
   551          seq_put_decimal_ull(m, " ", 0);
   552          seq_put_decimal_ll(m, " ", task->exit_signal);
   553          seq_put_decimal_ll(m, " ", task_cpu(task));
   554          seq_put_decimal_ull(m, " ", task->rt_priority);
   555          seq_put_decimal_ull(m, " ", task->policy);
   556          seq_put_decimal_ull(m, " ", delayacct_blkio_ticks(task));
   557          seq_put_decimal_ull(m, " ", nsec_to_clock_t(gtime));
   558          seq_put_decimal_ll(m, " ", nsec_to_clock_t(cgtime));
   559  
   560          if (mm && permitted) {
   561                  seq_put_decimal_ull(m, " ", mm->start_data);
   562                  seq_put_decimal_ull(m, " ", mm->end_data);
   563                  seq_put_decimal_ull(m, " ", mm->start_brk);
   564                  seq_put_decimal_ull(m, " ", mm->arg_start);
   565                  seq_put_decimal_ull(m, " ", mm->arg_end);
   566                  seq_put_decimal_ull(m, " ", mm->env_start);
   567                  seq_put_decimal_ull(m, " ", mm->env_end);
   568          } else
   569                  seq_puts(m, " 0 0 0 0 0 0 0");
   570  
   571          if (permitted)
   572                  seq_put_decimal_ll(m, " ", task->exit_code);
   573          else
   574                  seq_puts(m, " 0");
   575  
   576          seq_putc(m, '\n');
   577          if (mm)
   578                  mmput(mm);
   579          return 0;
   580  }
   581  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip

Reply via email to