mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Felipe W Damasio <felipewd@terra.com.br>
To: marcelo.tosatti@cyclades.com.br
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	chas@cmf.nrl.navy.mil
Subject: [PATCH 2.4] Fix bug in atm/he.c
Date: Tue, 30 Sep 2003 10:36:02 -0300	[thread overview]
Message-ID: <3F7986C2.1030101@terra.com.br> (raw)

[-- Attachment #1: Type: text/plain, Size: 541 bytes --]

Hi Marcelo,

	Patch against 2.4.23-pre5.

	Backport of the fix the Chas applied in 2.6 kernel.

	If copy_from_user returns != 0, it means the the regs structure 
wasn't filled correctly, and since its fields are used to determine 
which ioctl the user is requesting the kernel could oops.

	And as long as we're covering the subject, the patch also audits 
copy_to_user on the same function to check a possible failure to copy 
  the result back to userspace.

	These bugs were found by smatch.

	Please consider applying.

	Thanks,

Felipe

[-- Attachment #2: atm_he-copy.patch --]
[-- Type: text/plain, Size: 913 bytes --]

--- linux-2.4.23-pre5/drivers/atm/he.c.orig	2003-09-22 11:41:20.000000000 -0300
+++ linux-2.4.23-pre5/drivers/atm/he.c	2003-09-22 11:44:50.000000000 -0300
@@ -2866,8 +2866,10 @@
 			if (!capable(CAP_NET_ADMIN))
 				return -EPERM;
 
-			copy_from_user(&reg, (struct he_ioctl_reg *) arg,
-						sizeof(struct he_ioctl_reg));
+			if (copy_from_user(&reg, (struct he_ioctl_reg *) arg,
+						sizeof(struct he_ioctl_reg)))
+				return -EFAULT;
+				
 			spin_lock_irqsave(&he_dev->global_lock, flags);
 			switch (reg.type) {
 				case HE_REGTYPE_PCI:
@@ -2891,8 +2893,9 @@
 			}
 			spin_unlock_irqrestore(&he_dev->global_lock, flags);
 			if (err == 0)
-				copy_to_user((struct he_ioctl_reg *) arg, &reg,
-							sizeof(struct he_ioctl_reg));
+				if (copy_to_user((struct he_ioctl_reg *) arg, &reg,
+							sizeof(struct he_ioctl_reg)))
+					return -EFAULT;
 			break;
 		default:
 #ifdef CONFIG_ATM_HE_USE_SUNI

             reply	other threads:[~2003-09-30 13:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-30 13:36 Felipe W Damasio [this message]
2003-09-30 14:04 ` David S. Miller

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=3F7986C2.1030101@terra.com.br \
    --to=felipewd@terra.com.br \
    --cc=chas@cmf.nrl.navy.mil \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.tosatti@cyclades.com.br \
    /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

all inboxes | Powered by JetHome®