From: Russell King <rmk@arm.linux.org.uk>
To: Alex Bligh - linux-kernel <linux-kernel@alex.org.uk>,
torvalds@transmeta.com, tytso@valinux.com
Cc: Dawson Engler <engler@csl.stanford.edu>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Evan Parker <nave@stanford.edu>,
linux-kernel@vger.kernel.org, mc@cs.stanford.edu
Subject: Re: [CHECKER] repetitive/contradictory comparison bugs for 2.4.7
Date: Thu, 26 Jul 2001 21:15:58 +0100 [thread overview]
Message-ID: <20010726211558.F2200@flint.arm.linux.org.uk> (raw)
In-Reply-To: <200107260113.SAA11847@csl.Stanford.EDU> <602725597.996180886@[169.254.62.211]>
In-Reply-To: <602725597.996180886@[169.254.62.211]>; from linux-kernel@alex.org.uk on Thu, Jul 26, 2001 at 08:54:48PM +0100
On Thu, Jul 26, 2001 at 08:54:48PM +0100, Alex Bligh - linux-kernel wrote:
> May be I'm being dumb here, and without wishing to open the 'volatile'
> can of worms elsewhere, but:
>
> static char * tmp_buf;
Here is the fix... I've updated it a bit to plug another small race in
rs_write as well.
The following code uses the tmp_buf_sem to lock the creation and freeing
of the tmp_buf page. This same lock is used to prevent concurrent accesses
to this very same page in rs_write().
--
Russell King (rmk@arm.linux.org.uk) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html
--- orig/drivers/char/serial.c Sat Jul 21 10:46:42 2001
+++ linux/drivers/char/serial.c Thu Jul 26 21:14:12 2001
@@ -1848,12 +1848,17 @@
if (serial_paranoia_check(info, tty->device, "rs_write"))
return 0;
- if (!tty || !info->xmit.buf || !tmp_buf)
+ if (!tty || !info->xmit.buf)
return 0;
save_flags(flags);
if (from_user) {
down(&tmp_buf_sem);
+ if (!tmp_buf) {
+ up(&tmp_buf_sem);
+ restore_flags(flags);
+ return 0;
+ }
while (1) {
int c1;
c = CIRC_SPACE_TO_END(info->xmit.head,
@@ -3129,7 +3134,6 @@
{
struct async_struct *info;
int retval, line;
- unsigned long page;
MOD_INC_USE_COUNT;
line = MINOR(tty->device) - tty->driver.minor_start;
@@ -3157,17 +3161,16 @@
info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
#endif
+ down(&tmp_buf_sem);
if (!tmp_buf) {
- page = get_zeroed_page(GFP_KERNEL);
- if (!page) {
+ tmp_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
+ if (!tmp_buf) {
+ up(&tmp_buf_sem);
MOD_DEC_USE_COUNT;
return -ENOMEM;
}
- if (tmp_buf)
- free_page(page);
- else
- tmp_buf = (unsigned char *) page;
}
+ up(&tmp_buf_sem);
/*
* If the port is the middle of closing, bail out now
@@ -5666,12 +5669,13 @@
if (DEACTIVATE_FUNC(brd->dev))
(DEACTIVATE_FUNC(brd->dev))(brd->dev);
}
-#endif
+#endif
+ down(&tmp_buf_sem);
if (tmp_buf) {
- unsigned long pg = (unsigned long) tmp_buf;
+ free_page(tmp_buf);
tmp_buf = NULL;
- free_page(pg);
}
+ up(&tmp_buf_sem);
#ifdef ENABLE_SERIAL_PCI
if (serial_pci_driver.name[0])
next prev parent reply other threads:[~2001-07-26 20:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-25 0:08 [CHECKER] repetitive/contradictory comparison bugs for 2.4.7 Evan Parker
2001-07-25 0:51 ` Neil Brown
2001-07-25 8:27 ` Russell King
2001-07-25 13:34 ` Alan Cox
2001-07-26 1:13 ` Dawson Engler
2001-07-26 19:54 ` Alex Bligh - linux-kernel
2001-07-26 20:15 ` Russell King [this message]
2001-07-26 22:07 ` Alan Cox
2001-07-26 22:06 ` Alan Cox
2001-07-26 22:24 ` Alex Bligh - linux-kernel
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=20010726211558.F2200@flint.arm.linux.org.uk \
--to=rmk@arm.linux.org.uk \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=engler@csl.stanford.edu \
--cc=linux-kernel@alex.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=mc@cs.stanford.edu \
--cc=nave@stanford.edu \
--cc=torvalds@transmeta.com \
--cc=tytso@valinux.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