All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fengguang Wu <fengguang.wu@intel.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [next:akpm 18/86] kernel/sys.c:1287:10: warning: comparison of distinct pointer types lacks a ca
Date: Fri, 12 Oct 2012 18:29:49 +0000	[thread overview]
Message-ID: <20121012182949.GA24374@localhost> (raw)
In-Reply-To: <20121012165655.GB20312@localhost>

On Fri, Oct 12, 2012 at 10:46:34AM -0700, Kees Cook wrote:
> On Fri, Oct 12, 2012 at 9:56 AM, Fengguang Wu <fengguang.wu@intel.com> wrote:
> > FYI, there are new compile warnings show up in
> >
> > tree:   git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git akpm
> > head:   04b956faad392f46c9a234962a9990196b8e48fc
> > commit: b8763455880e371a81b07599bc66ae94f96dc6d6 [18/86] kernel/sys.c: fix stack memory content leak via UNAME26
> > config: mn10300-asb2364_defconfig # make ARCH=mn10300 asb2364_defconfig
> >
> > All warnings:
> >
> > kernel/sys.c: In function 'override_release':
> > kernel/sys.c:1287:10: warning: comparison of distinct pointer types lacks a cast [enabled by default]
> 
> Hrm, I don't see this on my builds. Is this check specific to mn10300
> in some way?

Maybe it's more than mn10300.

(gdb) whatis sizeof(long)
type = int

And size_t (__kernel_size_t) is defined to "unsigned int".

> > vim +1287 kernel/sys.c
> >
> > be27425d Andi Kleen     2011-08-19  1271
> > be27425d Andi Kleen     2011-08-19  1272        if (current->personality & UNAME26) {
> > b8763455 Kees Cook      2012-10-12  1273                const char *rest = UTS_RELEASE;
> > b8763455 Kees Cook      2012-10-12  1274                char buf[65] = { 0 };
> > be27425d Andi Kleen     2011-08-19  1275                int ndots = 0;
> > be27425d Andi Kleen     2011-08-19  1276                unsigned v;
> > b8763455 Kees Cook      2012-10-12  1277                size_t copy;
> > be27425d Andi Kleen     2011-08-19  1278
> > be27425d Andi Kleen     2011-08-19  1279                while (*rest) {
> > be27425d Andi Kleen     2011-08-19  1280                        if (*rest = '.' && ++ndots >= 3)
> > be27425d Andi Kleen     2011-08-19  1281                                break;
> > be27425d Andi Kleen     2011-08-19  1282                        if (!isdigit(*rest) && *rest != '.')
> > be27425d Andi Kleen     2011-08-19  1283                                break;
> > be27425d Andi Kleen     2011-08-19  1284                        rest++;
> > be27425d Andi Kleen     2011-08-19  1285                }
> > be27425d Andi Kleen     2011-08-19  1286                v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
> > b8763455 Kees Cook      2012-10-12 @1287                copy = min(sizeof(buf), max_t(size_t, 1, len));
> 
> Should I change this to min_t(size_t, sizeof(buf), max_t(size_t, 1, len)) ?

clamp_t() looks easier. :-)

Thanks,
Fengguang

      parent reply	other threads:[~2012-10-12 18:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-12 16:56 [next:akpm 18/86] kernel/sys.c:1287:10: warning: comparison of distinct pointer types lacks a cast Fengguang Wu
2012-10-12 17:46 ` [next:akpm 18/86] kernel/sys.c:1287:10: warning: comparison of distinct pointer types lacks a ca Kees Cook
2012-10-12 18:29 ` Fengguang Wu [this message]

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=20121012182949.GA24374@localhost \
    --to=fengguang.wu@intel.com \
    --cc=kernel-janitors@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.