All of lore.kernel.org
 help / color / mirror / Atom feed
From: Domen Puncer <domen@coderock.org>
To: kernel-janitors@vger.kernel.org
Subject: Re: [Kernel-janitors]  [patch 2.6.1] audit *_user,
Date: Fri, 16 Jan 2004 22:28:43 +0000	[thread overview]
Message-ID: <200401162328.43453.domen@coderock.org> (raw)
In-Reply-To: <20040116141059.5f066b73.rddunlap@osdl.org>

On Friday 16 of January 2004 23:10, Randy.Dunlap wrote:
> On Fri, 16 Jan 2004 22:45:32 +0100 Domen Puncer <domen@coderock.org> wrote:
> | Hi.
> |
> | To be aplied on top of CONFIG_LEDMAN patch, or you'll get -11 lines
> | offsets.
> |
> | I left one copy_*_user, because locking needs to be fixed around it too.
> | About that s/break/return/ in switch: at end of switch there is a "return
> | 0". Didn't compile test it, since it's a motorola driver.
> |

<snip>

> rest of it looks fine.
> Please fix & resend (unless it's correct as is)

You are right, sorry, resending:

--- c/drivers/serial/mcfserial.c	2004-01-16 22:28:31.000000000 +0100
+++ a/drivers/serial/mcfserial.c	2004-01-16 23:24:42.000000000 +0100
@@ -880,8 +880,7 @@ static int get_serial_info(struct mcf_se
 	tmp.close_delay = info->close_delay;
 	tmp.closing_wait = info->closing_wait;
 	tmp.custom_divisor = info->custom_divisor;
-	copy_to_user(retinfo,&tmp,sizeof(*retinfo));
-	return 0;
+	return copy_to_user(retinfo,&tmp,sizeof(*retinfo)) ? -EFAULT : 0;
 }
 
 static int set_serial_info(struct mcf_serial * info,
@@ -893,7 +892,8 @@ static int set_serial_info(struct mcf_se
 
 	if (!new_info)
 		return -EFAULT;
-	copy_from_user(&new_serial,new_info,sizeof(new_serial));
+	if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
+		return -EFAULT;
 	old_info = *info;
 
 	if (!capable(CAP_SYS_ADMIN)) {
@@ -950,8 +950,7 @@ static int get_lsr_info(struct mcf_seria
 	status = (uartp[MCFUART_USR] & MCFUART_USR_TXEMPTY) ? TIOCSER_TEMT : 0;
 	local_irq_restore(flags);
 
-	put_user(status,value);
-	return 0;
+	return put_user(status,value);
 }
 
 /*
@@ -1009,79 +1008,55 @@ static int mcfrs_ioctl(struct tty_struct
 			send_break(info, arg ? arg*(HZ/10) : HZ/4);
 			return 0;
 		case TIOCGSOFTCAR:
-			error = verify_area(VERIFY_WRITE, (void *) arg,sizeof(long));
 			if (error)
-				return error;
-			put_user(C_CLOCAL(tty) ? 1 : 0,
+			error = put_user(C_CLOCAL(tty) ? 1 : 0,
 				    (unsigned long *) arg);
-			return 0;
+			return error;
 		case TIOCSSOFTCAR:
-			get_user(arg, (unsigned long *) arg);
+			if (get_user(arg, (unsigned long *) arg))
+				return -EFAULT;
 			tty->termios->c_cflag  				((tty->termios->c_cflag & ~CLOCAL) |
 				 (arg ? CLOCAL : 0));
 			return 0;
 		case TIOCGSERIAL:
-			error = verify_area(VERIFY_WRITE, (void *) arg,
-						sizeof(struct serial_struct));
-			if (error)
-				return error;
 			return get_serial_info(info,
 					       (struct serial_struct *) arg);
 		case TIOCSSERIAL:
 			return set_serial_info(info,
 					       (struct serial_struct *) arg);
 		case TIOCSERGETLSR: /* Get line status register */
-			error = verify_area(VERIFY_WRITE, (void *) arg,
-				sizeof(unsigned int));
-			if (error)
-				return error;
-			else
-			    return get_lsr_info(info, (unsigned int *) arg);
+			return get_lsr_info(info, (unsigned int *) arg);
 
 		case TIOCSERGSTRUCT:
-			error = verify_area(VERIFY_WRITE, (void *) arg,
-						sizeof(struct mcf_serial));
-			if (error)
-				return error;
-			copy_to_user((struct mcf_serial *) arg,
-				    info, sizeof(struct mcf_serial));
+			if (copy_to_user((struct mcf_serial *) arg,
+				    info, sizeof(struct mcf_serial)))
+				return -EFAULT;
 			return 0;
 			
 		case TIOCMGET:
-			if ((error = verify_area(VERIFY_WRITE, (void *) arg,
-                            sizeof(unsigned int))))
-                                return(error);
 			val = mcfrs_getsignals(info);
-			put_user(val, (unsigned int *) arg);
-			break;
+			return put_user(val, (unsigned int *) arg);
 
                 case TIOCMBIS:
-			if ((error = verify_area(VERIFY_WRITE, (void *) arg,
-                            sizeof(unsigned int))))
-				return(error);
-
-			get_user(val, (unsigned int *) arg);
+			if (get_user(val, (unsigned int *) arg))
+				return -EFAULT;
 			rts = (val & TIOCM_RTS) ? 1 : -1;
 			dtr = (val & TIOCM_DTR) ? 1 : -1;
 			mcfrs_setsignals(info, dtr, rts);
 			break;
 
                 case TIOCMBIC:
-			if ((error = verify_area(VERIFY_WRITE, (void *) arg,
-                            sizeof(unsigned int))))
-				return(error);
-			get_user(val, (unsigned int *) arg);
+			if (get_user(val, (unsigned int *) arg))
+				return -EFAULT;
 			rts = (val & TIOCM_RTS) ? 0 : -1;
 			dtr = (val & TIOCM_DTR) ? 0 : -1;
 			mcfrs_setsignals(info, dtr, rts);
 			break;
 
                 case TIOCMSET:
-			if ((error = verify_area(VERIFY_WRITE, (void *) arg,
-                            sizeof(unsigned int))))
-				return(error);
-			get_user(val, (unsigned int *) arg);
+			if (get_user(val, (unsigned int *) arg))
+				return -EFAULT;
 			rts = (val & TIOCM_RTS) ? 1 : 0;
 			dtr = (val & TIOCM_DTR) ? 1 : 0;
 			mcfrs_setsignals(info, dtr, rts);
@@ -1089,13 +1064,13 @@ static int mcfrs_ioctl(struct tty_struct
 
 #ifdef TIOCSET422
 		case TIOCSET422:
-			get_user(val, (unsigned int *) arg);
+			if (get_user(val, (unsigned int *) arg))
+				return -EFAULT;
 			mcf_setpa(MCFPP_PA11, (val ? 0 : MCFPP_PA11));
 			break;
 		case TIOCGET422:
 			val = (mcf_getpa() & MCFPP_PA11) ? 0 : 1;
-			put_user(val, (unsigned int *) arg);
-			break;
+			return put_user(val, (unsigned int *) arg);
 #endif
 
 		default:

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

      reply	other threads:[~2004-01-16 22:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-16 22:10 [Kernel-janitors] [patch 2.6.1] audit *_user, get rid of Randy.Dunlap
2004-01-16 22:28 ` Domen Puncer [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=200401162328.43453.domen@coderock.org \
    --to=domen@coderock.org \
    --cc=kernel-janitors@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 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.