cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [bug report] cgroup: make cgroup_path() and friends behave in the style of strlcpy()
Date: Thu, 29 Sep 2016 12:27:22 +0300	[thread overview]
Message-ID: <20160929092722.GA5513@mwanda> (raw)

Hello Tejun Heo,

The patch 4c737b41de7f: "cgroup: make cgroup_path() and friends
behave in the style of strlcpy()" from Aug 10, 2016, leads to the
following static checker warning:

	kernel/cpuset.c:2732 proc_cpuset_show()
	warn: signed compare with PATH_MAX 'retval'

kernel/cpuset.c
  2715  int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
  2716                       struct pid *pid, struct task_struct *tsk)
  2717  {
  2718          char *buf;
  2719          struct cgroup_subsys_state *css;
  2720          int retval;
  2721  
  2722          retval = -ENOMEM;
  2723          buf = kmalloc(PATH_MAX, GFP_KERNEL);
  2724          if (!buf)
  2725                  goto out;
  2726  
  2727          retval = -ENAMETOOLONG;
  2728          css = task_get_css(tsk, cpuset_cgrp_id);
  2729          retval = cgroup_path_ns(css->cgroup, buf, PATH_MAX,
  2730                                  current->nsproxy->cgroup_ns);
  2731          css_put(css);
  2732          if (retval >= PATH_MAX)
  2733                  goto out_free;
  2734          seq_puts(m, buf);
  2735          seq_putc(m, '\n');
  2736          retval = 0;
  2737  out_free:
  2738          kfree(buf);
  2739  out:
  2740          return 0;

Theoretically the out label should make this code totally future proof
but something broke somehow.  The comments imply that cgroup_path_ns()
returns negative error codes.

  2741  }

regards,
dan carpenter

             reply	other threads:[~2016-09-29  9:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29  9:27 Dan Carpenter [this message]
2016-09-29  9:58 ` [PATCH cgroup/for-4.9] cpuset: fix error error handling regression in proc_cpuset_show() Tejun Heo
     [not found]   ` <20160929095836.GB24034-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2016-09-29 13:27     ` Dan Carpenter
2016-09-29 13:54       ` [PATCH cgroup/for-4.6] cgroup: fix error handling regressions in proc_cgroup_show() and cgroup_release_agent() Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160929092722.GA5513@mwanda \
    --to=dan.carpenter-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).