From: Nikolay Aleksandrov <nikolay@redhat.com>
To: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, JBottomley@parallels.com,
nikolay@redhat.com
Subject: [PATCH] [SCSI] scsi_sysfs: fix a buffer overflow in sysfs handling
Date: Wed, 7 Nov 2012 11:57:46 +0100 [thread overview]
Message-ID: <1352285866-16593-1-git-send-email-nikolay@redhat.com> (raw)
Fix a stack buffer overflow in the SCSI layer sysfs handling code
(store_host_reset()). When a host reset type is read via sscanf in str
there is no limit on the length and str is defined as char str[10].
How to reproduce:
Given that the sysfs entry exists, execute
echo "AAAAAAAAAAAAAAAA" > /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0/host_reset
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
---
drivers/scsi/scsi_sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index ce5224c..51826e2 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -267,7 +267,7 @@ store_host_reset(struct device *dev, struct device_attribute *attr,
char str[10];
int type;
- sscanf(buf, "%s", str);
+ sscanf(buf, "%9s", str);
type = check_reset_type(str);
if (!type)
--
1.7.11.4
reply other threads:[~2012-11-07 10:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1352285866-16593-1-git-send-email-nikolay@redhat.com \
--to=nikolay@redhat.com \
--cc=JBottomley@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).