lkml.org 
[lkml]   [2000]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] tty_io.c: s/suser/capable/, check get_user
Linus,

Please consider applying. Also an RFC: is it ok to do a kfree
without checking if it is NULL in case of error handling? By looking
at the code it is safe and becomes mostly a no op, but it is ok to
do it this way?


- Arnaldo

--- linux-2.4.0-test7/drivers/char/tty_io.c Thu Aug 24 07:39:58 2000
+++ linux-2.4.0-test7.acme/drivers/char/tty_io.c Sat Aug 26 20:29:14 2000
@@ -60,6 +60,9 @@
*
* Reduced memory usage for older ARM systems
* -- Russell King <rmk@arm.linux.org.uk>
+ *
+ * Check get_user return, s/suser/capable/
+ * -- Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 26-08-2000
*/

#include <linux/config.h>
@@ -986,14 +989,11 @@

/* Release locally allocated memory ... nothing placed in slots */
free_mem_out:
- if (o_tp)
- kfree(o_tp);
+ kfree(o_tp);
if (o_tty)
free_tty_struct(o_tty);
- if (ltp)
- kfree(ltp);
- if (tp)
- kfree(tp);
+ kfree(ltp);
+ kfree(tp);
free_tty_struct(tty);

fail_no_mem:
@@ -1379,7 +1379,7 @@
retval = -ENODEV;
filp->f_flags = saved_flags;

- if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) && !suser())
+ if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN))
retval = -EBUSY;

if (retval) {
@@ -1481,7 +1481,7 @@
{
char ch, mbz = 0;

- if ((current->tty != tty) && !suser())
+ if ((current->tty != tty) && !capable(CAP_SYS_ADMIN))
return -EPERM;
if (get_user(ch, arg))
return -EFAULT;
@@ -1519,7 +1519,7 @@
{
if (inode->i_rdev == SYSCONS_DEV ||
inode->i_rdev == CONSOLE_DEV) {
- if (!suser())
+ if (!capable(CAP_SYS_ADMIN))
return -EPERM;
redirect = NULL;
return 0;
@@ -1561,7 +1561,7 @@
* This tty is already the controlling
* tty for another session group!
*/
- if ((arg == 1) && suser()) {
+ if ((arg == 1) && capable(CAP_SYS_ADMIN)) {
/*
* Steal it away
*/
@@ -1608,7 +1608,8 @@
(current->tty != real_tty) ||
(real_tty->session != current->session))
return -ENOTTY;
- get_user(pgrp, (pid_t *) arg);
+ if (get_user(pgrp, (pid_t *) arg))
+ return -EFAULT;
if (pgrp < 0)
return -EINVAL;
if (session_of_pgrp(pgrp) != current->session)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.036 / U:7.784 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site