Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1244527
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/6] x86/ras/mce_amd_inj: Return early on invalid input |
| Date | 2015-10-12 11:30 +0200 |
| Message-ID | <qiHAD-38y-35@gated-at.bofh.it> (permalink) |
| References | <qiHAD-38y-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Invalid inputs such as these are currently reported in dmesg as failing:
$> echo sweet > flags
[ 122.079139] flags_write: Invalid flags value: et
even though the 'flags' attribute has been updated correctly:
$> cat flags
sw
This is because userspace keeps writing the remaining buffer until it
encounters an error.
However, the input as a whole is wrong and we should not be writing
anything to the file. Therefore, correct flags_write() to return -EINVAL
immediately on bad input strings.
Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Link: http://lkml.kernel.org/r/1443190851-2172-2-git-send-email-Aravind.Gopalakrishnan@amd.com
Signed-off-by: Borislav Petkov <bp@suse.de>
---
arch/x86/ras/mce_amd_inj.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/x86/ras/mce_amd_inj.c b/arch/x86/ras/mce_amd_inj.c
index 17e35b5bf779..4fd8bb9b90b9 100644
--- a/arch/x86/ras/mce_amd_inj.c
+++ b/arch/x86/ras/mce_amd_inj.c
@@ -129,12 +129,9 @@ static ssize_t flags_write(struct file *filp, const char __user *ubuf,
{
char buf[MAX_FLAG_OPT_SIZE], *__buf;
int err;
- size_t ret;
if (cnt > MAX_FLAG_OPT_SIZE)
- cnt = MAX_FLAG_OPT_SIZE;
-
- ret = cnt;
+ return -EINVAL;
if (copy_from_user(&buf, ubuf, cnt))
return -EFAULT;
@@ -150,9 +147,9 @@ static ssize_t flags_write(struct file *filp, const char __user *ubuf,
return err;
}
- *ppos += ret;
+ *ppos += cnt;
- return ret;
+ return cnt;
}
static const struct file_operations flags_fops = {
--
2.3.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/6] tip-queue 2015-10-12 Borislav Petkov <bp@alien8.de> - 2015-10-12 11:30 +0200
[PATCH 3/6] x86/ras/mce_amd_inj: Trigger deferred and thresholding errors interrupts Borislav Petkov <bp@alien8.de> - 2015-10-12 11:30 +0200
[tip:ras/core] x86/ras/mce_amd_inj: Trigger deferred and thresholding errors interrupts tip-bot for Aravind Gopalakrishnan <tipbot@zytor.com> - 2015-10-12 16:40 +0200
[PATCH 2/6] x86/ras/mce_amd_inj: Return early on invalid input Borislav Petkov <bp@alien8.de> - 2015-10-12 11:30 +0200
[tip:ras/core] x86/ras/mce_amd_inj: Return early on invalid input tip-bot for Aravind Gopalakrishnan <tipbot@zytor.com> - 2015-10-12 16:40 +0200
[PATCH 4/6] x86/ras/mce_amd_inj: Inject bank 4 errors on the NBC Borislav Petkov <bp@alien8.de> - 2015-10-12 11:30 +0200
[tip:ras/core] x86/ras/mce_amd_inj: Inject bank 4 errors on the NBC tip-bot for Aravind Gopalakrishnan <tipbot@zytor.com> - 2015-10-12 16:40 +0200
[PATCH 6/6] x86/microcode/amd: Do not overwrite final patch levels Borislav Petkov <bp@alien8.de> - 2015-10-12 11:30 +0200
[tip:ras/core] x86/microcode/amd: Do not overwrite final patch levels tip-bot for Borislav Petkov <tipbot@zytor.com> - 2015-10-12 16:40 +0200
csiph-web