All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Stephen Boyd <sboyd@codeaurora.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org,
	Arjan van de Ven <arjan@linux.intel.com>,
	Helge Deller <deller@gmx.de>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Chris Metcalf <cmetcalf@tilera.com>
Subject: Re: [PATCH] Consolidate CONFIG_DEBUG_STRICT_USER_COPY_CHECK
Date: Wed, 27 Feb 2013 14:52:57 -0800	[thread overview]
Message-ID: <512E8E49.3050206@zytor.com> (raw)
In-Reply-To: <20130228094510.3341017130e4476e046bdd22@canb.auug.org.au>

On 02/27/2013 02:45 PM, Stephen Rothwell wrote:
> Hi all,
> 
> On Wed, 27 Feb 2013 14:19:16 -0800 "H. Peter Anvin" <hpa@zytor.com>
> wrote:
>> 
>> Although some of the cases I have seen being flagged as "false 
>> positives" have been real bugs.
> 
> [hijacking the thread :-)]
> 
> I have been getting this warning for a very long time ( which would
> be an error if CONFIG_DEBUG_STRICT_USER_COPY_CHECK was set):
> 
> i386 defconfig i386-linux-gcc (GCC) 4.6.3
> 
> In file included from arch/x86/include/asm/uaccess.h:537:0, from
> include/linux/uaccess.h:5, from include/linux/highmem.h:8, from
> include/linux/pagemap.h:10, from fs/binfmt_misc.c:27: 
> arch/x86/include/asm/uaccess_32.h: In function
> 'parse_command.part.2': arch/x86/include/asm/uaccess_32.h:211:26:
> warning: call to 'copy_from_user_overflow' declared with attribute
> warning: copy_from_user() buffer size is not provably correct
> [enabled by default]
> 

OK, that is surprising, because that copy is very clearly properly
guarded:

static int parse_command(const char __user *buffer, size_t count)
{
	char s[4];

	if (!count)
		return 0;
	if (count > 3)
		return -EINVAL;
	if (copy_from_user(s, buffer, count))
		return -EFAULT;

It isn't possible for count to be anything other than 1, 2 or 3 there,
and it is very surprising that gcc can't see it.

This might be worth filing a gcc bug for.

	-hpa


  reply	other threads:[~2013-02-27 22:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-27  3:00 [PATCH] Consolidate CONFIG_DEBUG_STRICT_USER_COPY_CHECKS Stephen Boyd
2013-02-27 20:32 ` [PATCH] Consolidate CONFIG_DEBUG_STRICT_USER_COPY_CHECK Arnd Bergmann
2013-02-27 20:42   ` Stephen Boyd
2013-02-27 21:33     ` Arnd Bergmann
2013-02-27 22:19     ` H. Peter Anvin
2013-02-27 22:45       ` Stephen Rothwell
2013-02-27 22:52         ` H. Peter Anvin [this message]
2013-02-27 22:56         ` Arjan van de Ven
2013-02-27 22:52       ` Stephen Boyd
2013-02-27 22:55         ` H. Peter Anvin
2013-02-27 23:19           ` Stephen Boyd
2013-02-27 23:21             ` H. Peter Anvin
2013-02-27 22:41 ` [PATCH] Consolidate CONFIG_DEBUG_STRICT_USER_COPY_CHECKS Helge Deller

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=512E8E49.3050206@zytor.com \
    --to=hpa@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=cmetcalf@tilera.com \
    --cc=deller@gmx.de \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sboyd@codeaurora.org \
    --cc=sfr@canb.auug.org.au \
    /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.