From: "Jeff V. Merkey" <jmerkey@wolfmountaingroup.com>
To: Phillip Susi <psusi@cfl.rr.com>
Cc: jmerkey@ns1.utah-nac.org,
"linux-os (Dick Johnson)" <linux-os@analogic.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: 2.6.14 kernels and above copy_to_user stupidity with IRQ disabled check
Date: Fri, 27 Jan 2006 12:28:07 -0700 [thread overview]
Message-ID: <43DA7447.2010104@wolfmountaingroup.com> (raw)
In-Reply-To: <43DA851D.6070209@cfl.rr.com>
Phillip Susi wrote:
> jmerkey@ns1.utah-nac.org wrote:
>
>> OK. Got it. I guess I need to restructure. And BTW, This was a
>> code fragment
>> only, the spinlock gets released when -EFAULT is called -- was just
>> an example.
>>
>> Jeff
>
>
> Unless you have redefined EFAULT in some strange and hideous way, it
> is not "called" and doesn't free the spinlock. EFAULT is defined as a
> literal integer, so you're just returning a number without freeing the
> spinlock.
>
> If you have redefined EFAULT to a macro function call or whatever,
> then don't do that, it's REALLY horrible coding practice.
>
>
No. I posted a code fragment as an example. Here's the actual code:
int dump_regen(VIRTUAL_SETUP *s, ULONG count)
{
register int i = 0;
VIRTUAL_SETUP *v;
spin_lock_irqsave(®en_lock, regen_flags);
v = regen_head;
while (v)
{
if (i >= count)
{
spin_unlock_irqrestore(®en_lock, regen_flags);
return -EFAULT;
}
err = copy_to_user(&s[i++], v, sizeof(VIRTUAL_SETUP));
if (err)
{
spin_unlock_irqrestore(®en_lock, regen_flags);
return err;
}
v = v->next;
}
spin_unlock_irqrestore(®en_lock, regen_flags);
return 0;
}
Needless to say, this has been restructured to this:
int dump_regen(VIRTUAL_SETUP *s, ULONG count)
{
register int i = 0;
VIRTUAL_SETUP *v;
spin_lock_irqsave(®en_lock, regen_flags);
v = regen_head;
while (v)
{
if (i >= count)
{
spin_unlock_irqrestore(®en_lock, regen_flags);
return 0;
}
P_Copy(&s[i++], v, sizeof(VIRTUAL_SETUP));
v = v->next;
}
spin_unlock_irqrestore(®en_lock, regen_flags);
return 0;
}
Jeff
prev parent reply other threads:[~2006-01-27 21:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-27 18:13 2.6.14 kernels and above copy_to_user stupidity with IRQ disabled check Jeff V. Merkey
2006-01-27 19:30 ` Phillip Susi
2006-01-27 20:18 ` linux-os (Dick Johnson)
2006-01-27 20:10 ` jmerkey
2006-01-27 20:22 ` jmerkey
2006-01-27 20:39 ` Phillip Susi
2006-01-27 19:28 ` Jeff V. Merkey [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=43DA7447.2010104@wolfmountaingroup.com \
--to=jmerkey@wolfmountaingroup.com \
--cc=jmerkey@ns1.utah-nac.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.com \
--cc=psusi@cfl.rr.com \
/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