]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Jeff Mahoney <jeffm@suse.com> |
2 | Subject: [PATCH] reiserfs: add locking around error buffer | |
3 | ||
4 | The formatting of the error buffer is race prone. It uses static buffers | |
5 | for both formatting and output. While overwriting the error buffer | |
6 | can product garbled output, overwriting the format buffer with incompatible | |
7 | % directives can cause crashes. | |
8 | ||
9 | Signed-off-by: Jeff Mahoney <jeffm@suse.com> | |
10 | --- | |
11 | fs/reiserfs/prints.c | 5 ++++- | |
12 | 1 file changed, 4 insertions(+), 1 deletion(-) | |
13 | ||
14 | --- a/fs/reiserfs/prints.c | |
15 | +++ b/fs/reiserfs/prints.c | |
16 | @@ -184,7 +184,7 @@ static char *is_there_reiserfs_struct(ch | |
17 | printk ("bad key %lu %lu %lu %lu", key->k_dir_id, key->k_objectid, | |
18 | key->k_offset, key->k_uniqueness); | |
19 | */ | |
20 | - | |
21 | +static DEFINE_SPINLOCK(error_lock); | |
22 | static void prepare_error_buf(const char *fmt, va_list args) | |
23 | { | |
24 | char *fmt1 = fmt_buf; | |
25 | @@ -192,6 +192,8 @@ static void prepare_error_buf(const char | |
26 | char *p = error_buf; | |
27 | int what; | |
28 | ||
29 | + spin_lock(&error_lock); | |
30 | + | |
31 | strcpy(fmt1, fmt); | |
32 | ||
33 | while ((k = is_there_reiserfs_struct(fmt1, &what)) != NULL) { | |
34 | @@ -237,6 +239,7 @@ static void prepare_error_buf(const char | |
35 | fmt1 = k + 2; | |
36 | } | |
37 | vsprintf(p, fmt1, args); | |
38 | + spin_unlock(&error_lock); | |
39 | ||
40 | } | |
41 |