bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] file: convert to SLAB_TYPESAFE_BY_RCU
@ 2023-10-05 11:26 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2023-10-05 11:26 UTC (permalink / raw)
  To: brauner; +Cc: bpf

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-05 11:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-05 11:26 [bug report] file: convert to SLAB_TYPESAFE_BY_RCU Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).