[bug report] file: convert to SLAB_TYPESAFE_BY_RCU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Christian Brauner,

The patch d089d9d056c0: "file: convert to SLAB_TYPESAFE_BY_RCU" from
Sep 29, 2023 (linux-next), leads to the following Smatch static
checker warning:

	kernel/bpf/task_iter.c:302 task_file_seq_get_next()
	warn: ignoring unreachable code.

kernel/bpf/task_iter.c
    258 static struct file *
    259 task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info)
    260 {
    261         u32 saved_tid = info->tid;
    262         struct task_struct *curr_task;
    263         unsigned int curr_fd = info->fd;
    264 
    265         /* If this function returns a non-NULL file object,
    266          * it held a reference to the task/file.
    267          * Otherwise, it does not hold any reference.
    268          */
    269 again:
    270         if (info->task) {
    271                 curr_task = info->task;
    272                 curr_fd = info->fd;
    273         } else {
    274                 curr_task = task_seq_get_next(&info->common, &info->tid, true);
    275                 if (!curr_task) {
    276                         info->task = NULL;
    277                         return NULL;
    278                 }
    279 
    280                 /* set info->task */
    281                 info->task = curr_task;
    282                 if (saved_tid == info->tid)
    283                         curr_fd = info->fd;
    284                 else
    285                         curr_fd = 0;
    286         }
    287 
    288         rcu_read_lock();
    289         for (;; curr_fd++) {
    290                 struct file *f;
    291                 f = task_lookup_next_fdget_rcu(curr_task, &curr_fd);
    292                 if (!f)
    293                         continue;

Should this be a break?

    294 
    295                 /* set info->fd */
    296                 info->fd = curr_fd;
    297                 rcu_read_unlock();
    298                 return f;
    299         }
    300 
    301         /* the current task is done, go to the next task */
--> 302         rcu_read_unlock();

Unreachable

    303         put_task_struct(curr_task);
    304 
    305         if (info->common.type == BPF_TASK_ITER_TID) {
    306                 info->task = NULL;
    307                 return NULL;
    308         }
    309 
    310         info->task = NULL;
    311         info->fd = 0;
    312         saved_tid = ++(info->tid);
    313         goto again;
    314 }

regards,
dan carpenter




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux