Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 18014
b: refs/heads/master
c: 5f1d189
h: refs/heads/master
v: v3
  • Loading branch information
Jan Beulich authored and Linus Torvalds committed Jan 12, 2006
1 parent 539c9fd commit 8fd77c5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 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: 1b2f6304500930ab534a6aa3198bce0c51586206
refs/heads/master: 5f1d189f8a87930d62c507800a8ac20b9a185e41
12 changes: 9 additions & 3 deletions trunk/arch/x86_64/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ void show_registers(struct pt_regs *regs)
void handle_BUG(struct pt_regs *regs)
{
struct bug_frame f;
char tmp;
long len;
const char *prefix = "";

if (user_mode(regs))
return;
Expand All @@ -350,10 +351,15 @@ void handle_BUG(struct pt_regs *regs)
if (f.filename >= 0 ||
f.ud2[0] != 0x0f || f.ud2[1] != 0x0b)
return;
if (__get_user(tmp, (char *)(long)f.filename))
len = __strnlen_user((char *)(long)f.filename, PATH_MAX) - 1;
if (len < 0 || len >= PATH_MAX)
f.filename = (int)(long)"unmapped filename";
else if (len > 50) {
f.filename += len - 50;
prefix = "...";
}
printk("----------- [cut here ] --------- [please bite here ] ---------\n");
printk(KERN_ALERT "Kernel BUG at %.50s:%d\n", (char *)(long)f.filename, f.line);
printk(KERN_ALERT "Kernel BUG at %s%.50s:%d\n", prefix, (char *)(long)f.filename, f.line);
}

#ifdef CONFIG_BUG
Expand Down
12 changes: 8 additions & 4 deletions trunk/arch/x86_64/lib/usercopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
* Return 0 on exception, a value greater than N if too long
*/

long strnlen_user(const char __user *s, long n)
long __strnlen_user(const char __user *s, long n)
{
long res = 0;
char c;

if (!access_ok(VERIFY_READ, s, n))
return 0;

while (1) {
if (res>n)
return n+1;
Expand All @@ -129,6 +126,13 @@ long strnlen_user(const char __user *s, long n)
}
}

long strnlen_user(const char __user *s, long n)
{
if (!access_ok(VERIFY_READ, s, n))
return 0;
return __strnlen_user(s, n);
}

long strlen_user(const char __user *s)
{
long res = 0;
Expand Down
1 change: 1 addition & 0 deletions trunk/include/asm-x86_64/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ static inline int __copy_in_user(void __user *dst, const void __user *src, unsig
long strncpy_from_user(char *dst, const char __user *src, long count);
long __strncpy_from_user(char *dst, const char __user *src, long count);
long strnlen_user(const char __user *str, long n);
long __strnlen_user(const char __user *str, long n);
long strlen_user(const char __user *str);
unsigned long clear_user(void __user *mem, unsigned long len);
unsigned long __clear_user(void __user *mem, unsigned long len);
Expand Down

0 comments on commit 8fd77c5

Please sign in to comment.