From: "André Pereira de Almeida" <andre@cachola.com.br>
To: linux-kernel@vger.kernel.org
Subject: [PATCH (?)] vt: fix possible memory corruption in complement_pos
Date: Wed, 25 May 2005 15:18:13 -0300 [thread overview]
Message-ID: <4294C165.7010503@cachola.com.br> (raw)
[-- Attachment #1: Type: text/plain, Size: 1692 bytes --]
Hi.
In the file drivers/char/vt.c the function complement_pos (used by
selection: complement pointer position) saves the memory position of
previous pointer position. If, between 2 successive calls of this
function, the memory location of the screen has changed (e.g. the window
has been resized), the old pointer position is invalid, and, if this
memory position has been allocated by another kernel data, this data may
be corrupted since this function will try to restore the previous data.
I don't know if this is the right approach, but this patch will solve
this bug.
--- linux-2.6.12-rc4-mm2.orig/drivers/char/vt.c 2005-05-25
12:04:54.000000000 -0300
+++ linux-2.6.12-rc4-mm2/drivers/char/vt.c 2005-05-25
12:36:20.000000000 -0300
@@ -434,21 +434,21 @@ void invert_screen(struct vc_data *vc, i
/* used by selection: complement pointer position */
void complement_pos(struct vc_data *vc, int offset)
{
- static unsigned short *p;
+ static int old_offset=-1;
static unsigned short old;
static unsigned short oldx, oldy;
WARN_CONSOLE_UNLOCKED();
- if (p) {
- scr_writew(old, p);
+ if (old_offset!=-1) {
+ scr_writew(old, screenpos(vc, old_offset, 1));
if (DO_UPDATE(vc))
vc->vc_sw->con_putc(vc, old, oldy, oldx);
}
- if (offset == -1)
- p = NULL;
- else {
+ old_offset=offset;
+ if (offset != -1) {
unsigned short new;
+ unsigned short *p;
p = screenpos(vc, offset, 1);
old = scr_readw(p);
new = old ^ vc->vc_complement_mask;
[-- Attachment #2: vt.patch --]
[-- Type: text/x-patch, Size: 894 bytes --]
--- linux-2.6.12-rc4-mm2.orig/drivers/char/vt.c 2005-05-25 12:04:54.000000000 -0300
+++ linux-2.6.12-rc4-mm2/drivers/char/vt.c 2005-05-25 12:36:20.000000000 -0300
@@ -434,21 +434,21 @@ void invert_screen(struct vc_data *vc, i
/* used by selection: complement pointer position */
void complement_pos(struct vc_data *vc, int offset)
{
- static unsigned short *p;
+ static int old_offset=-1;
static unsigned short old;
static unsigned short oldx, oldy;
WARN_CONSOLE_UNLOCKED();
- if (p) {
- scr_writew(old, p);
+ if (old_offset!=-1) {
+ scr_writew(old, screenpos(vc, old_offset, 1));
if (DO_UPDATE(vc))
vc->vc_sw->con_putc(vc, old, oldy, oldx);
}
- if (offset == -1)
- p = NULL;
- else {
+ old_offset=offset;
+ if (offset != -1) {
unsigned short new;
+ unsigned short *p;
p = screenpos(vc, offset, 1);
old = scr_readw(p);
new = old ^ vc->vc_complement_mask;
reply other threads:[~2005-05-25 18:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4294C165.7010503@cachola.com.br \
--to=andre@cachola.com.br \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox