Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 47545
b: refs/heads/master
c: 34f5a39
h: refs/heads/master
i:
  47543: 80b73e1
v: v3
  • Loading branch information
Theodore Ts'o authored and Linus Torvalds committed Feb 11, 2007
1 parent c81f444 commit 502211d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a136e99f12cdc967a6f607644e471ed749f963db
refs/heads/master: 34f5a39899f3f3e815da64f48ddb72942d86c366
1 change: 1 addition & 0 deletions trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ extern enum system_states {
#define TAINT_FORCED_RMMOD (1<<3)
#define TAINT_MACHINE_CHECK (1<<4)
#define TAINT_BAD_PAGE (1<<5)
#define TAINT_USER (1<<6)

extern void dump_stack(void);

Expand Down
6 changes: 4 additions & 2 deletions trunk/kernel/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ EXPORT_SYMBOL(panic);
* 'R' - User forced a module unload.
* 'M' - Machine had a machine check experience.
* 'B' - System has hit bad_page.
* 'U' - Userspace-defined naughtiness.
*
* The string is overwritten by the next call to print_taint().
*/
Expand All @@ -158,13 +159,14 @@ const char *print_tainted(void)
{
static char buf[20];
if (tainted) {
snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c",
snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c",
tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G',
tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
tainted & TAINT_FORCED_RMMOD ? 'R' : ' ',
tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
tainted & TAINT_BAD_PAGE ? 'B' : ' ');
tainted & TAINT_BAD_PAGE ? 'B' : ' ',
tainted & TAINT_USER ? 'U' : ' ');
}
else
snprintf(buf, sizeof(buf), "Not tainted");
Expand Down
27 changes: 25 additions & 2 deletions trunk/kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
#ifdef CONFIG_PROC_SYSCTL
static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos);
static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos);
#endif

static ctl_table root_table[];
Expand All @@ -174,6 +176,7 @@ extern ctl_table inotify_table[];
int sysctl_legacy_va_layout;
#endif


static void *get_uts(ctl_table *table, int write)
{
char *which = table->data;
Expand Down Expand Up @@ -344,14 +347,16 @@ static ctl_table kern_table[] = {
.proc_handler = &proc_dostring,
.strategy = &sysctl_string,
},
#ifdef CONFIG_PROC_SYSCTL
{
.ctl_name = KERN_TAINTED,
.procname = "tainted",
.data = &tainted,
.maxlen = sizeof(int),
.mode = 0444,
.proc_handler = &proc_dointvec,
.mode = 0644,
.proc_handler = &proc_dointvec_taint,
},
#endif
{
.ctl_name = KERN_CAP_BSET,
.procname = "cap-bound",
Expand Down Expand Up @@ -1927,6 +1932,7 @@ int proc_dointvec(ctl_table *table, int write, struct file *filp,

#define OP_SET 0
#define OP_AND 1
#define OP_OR 2

static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
int *valp,
Expand All @@ -1938,6 +1944,7 @@ static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
switch(op) {
case OP_SET: *valp = val; break;
case OP_AND: *valp &= val; break;
case OP_OR: *valp |= val; break;
}
} else {
int val = *valp;
Expand Down Expand Up @@ -1970,6 +1977,22 @@ int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
do_proc_dointvec_bset_conv,&op);
}

/*
* Taint values can only be increased
*/
static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
int op;

if (!capable(CAP_SYS_ADMIN))
return -EPERM;

op = OP_OR;
return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
do_proc_dointvec_bset_conv,&op);
}

struct do_proc_dointvec_minmax_conv_param {
int *min;
int *max;
Expand Down

0 comments on commit 502211d

Please sign in to comment.