public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, sensors@stimpy.netroedge.com
Subject: Re: [PATCH] i2c driver fixes for 2.6.1
Date: Mon, 19 Jan 2004 15:59:24 -0800	[thread overview]
Message-ID: <10745567643883@kroah.com> (raw)
In-Reply-To: <10745567633966@kroah.com>

ChangeSet 1.1474.98.16, 2004/01/15 17:28:54-08:00, khali@linux-fr.org

[PATCH] I2C: restore correct vaio handling in eeprom driver

Here is a patch to the eeprom driver in 2.6.1 that changes the way Vaio
eeproms are handled. In 2.6.1, the eeprom is readable only by root,
which isn't consistent with the 2.4 driver which simple hides (i.e.
fills it with zeroes) the first row (16 bytes) of the eeprom to regular
users.

The patch restores a similar behaviour in the 2.6 driver.


 drivers/i2c/chips/eeprom.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)


diff -Nru a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
--- a/drivers/i2c/chips/eeprom.c	Mon Jan 19 15:30:17 2004
+++ b/drivers/i2c/chips/eeprom.c	Mon Jan 19 15:30:17 2004
@@ -27,6 +27,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/sched.h>
 #include <linux/i2c.h>
 #include <linux/i2c-sensor.h>
 
@@ -62,6 +63,7 @@
 	char valid;			/* !=0 if following fields are valid */
 	unsigned long last_updated;	/* In jiffies */
 	u8 data[EEPROM_SIZE];		/* Register values */
+	enum eeprom_nature nature;
 };
 
 
@@ -127,7 +129,16 @@
 	if (off + count > EEPROM_SIZE)
 		count = EEPROM_SIZE - off;
 
-	memcpy(buf, &data->data[off], count);
+	/* Hide Vaio security settings to regular users (16 first bytes) */
+	if (data->nature == VAIO && off < 16 && !capable(CAP_SYS_ADMIN)) {
+		int in_row1 = 16 - off;
+		memset(buf, 0, in_row1);
+		if (count - in_row1 > 0)
+			memcpy(buf + in_row1, &data->data[16], count - in_row1);
+	} else {
+		memcpy(buf, &data->data[off], count);
+	}
+
 	return count;
 }
 
@@ -151,7 +162,6 @@
 	int i, cs;
 	struct i2c_client *new_client;
 	struct eeprom_data *data;
-	enum eeprom_nature nature = UNKNOWN;
 	int err = 0;
 
 	/* Make sure we aren't probing the ISA bus!! This is just a safety check
@@ -199,6 +209,7 @@
 			goto exit_kfree;
 	}
 
+	data->nature = UNKNOWN;
 	/* Detect the Vaio nature of EEPROMs.
 	   We use the "PCG-" prefix as the signature. */
 	if (address == 0x57) {
@@ -206,17 +217,7 @@
 		    i2c_smbus_read_byte_data(new_client, 0x81) == 'C' && 
 		    i2c_smbus_read_byte_data(new_client, 0x82) == 'G' &&
 		    i2c_smbus_read_byte_data(new_client, 0x83) == '-')
-			nature = VAIO;
-	}
-
-	/* If this is a VIAO, then we only allow root to read from this file,
-	   as BIOS passwords can be present here in plaintext */
-	switch (nature) {
- 	case VAIO:
-		eeprom_attr.attr.mode = S_IRUSR;
-		break;
-	default:
-		eeprom_attr.attr.mode = S_IRUGO;
+			data->nature = VAIO;
 	}
 
 	/* Fill in the remaining client fields */


  reply	other threads:[~2004-01-20  0:00 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-19 23:57 [BK PATCH] i2c driver fixes for 2.6.1 Greg KH
2004-01-19 23:59 ` [PATCH] " Greg KH
2004-01-19 23:59   ` Greg KH
2004-01-19 23:59     ` Greg KH
2004-01-19 23:59       ` Greg KH
2004-01-19 23:59         ` Greg KH
2004-01-19 23:59           ` Greg KH
2004-01-19 23:59             ` Greg KH
2004-01-19 23:59               ` Greg KH
2004-01-19 23:59                 ` Greg KH
2004-01-19 23:59                   ` Greg KH
2004-01-19 23:59                     ` Greg KH
2004-01-19 23:59                       ` Greg KH
2004-01-19 23:59                         ` Greg KH
2004-01-19 23:59                           ` Greg KH
2004-01-19 23:59                             ` Greg KH
2004-01-19 23:59                               ` Greg KH [this message]
2004-01-19 23:59                                 ` Greg KH
2004-01-19 23:59                                   ` Greg KH
2004-01-19 23:59                                     ` Greg KH
2004-01-19 23:59                                       ` Greg KH
2004-01-19 23:59                                         ` Greg KH
2004-01-19 23:59                                           ` Greg KH
2004-01-19 23:59                                             ` Greg KH
2004-01-19 23:59                                               ` Greg KH
2004-01-19 23:59                                                 ` Greg KH
2004-01-19 23:59                                                   ` Greg KH
2004-01-19 23:59                                                     ` Greg KH
2004-01-19 23:59                                                       ` Greg KH
2004-01-19 23:59                                                         ` Greg KH
2004-01-21 21:50                                                 ` Jean Delvare
2004-01-21 23:56                                                   ` Greg KH
2004-01-31  8:56                                                     ` Jean Delvare
2004-01-31 15:23                                                       ` Greg KH
2004-01-20 22:03     ` Jean Delvare
2004-01-20 22:07       ` Greg KH
2004-01-21 20:47         ` Jean Delvare
2004-01-24  1:14           ` Greg KH

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=10745567643883@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sensors@stimpy.netroedge.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