From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: prevent stack buffer overflow in host_reset
Date: Fri, 30 Nov 2012 09:07:57 +0000 [thread overview]
Message-ID: <1354266477.2259.5.camel@dabdike.int.hansenpartnership.com> (raw)
In-Reply-To: <1353012706-28182-1-git-send-email-sasha.levin@oracle.com>
On Thu, 2012-11-15 at 15:51 -0500, Sasha Levin wrote:
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index ce5224c..77ba946 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -249,9 +249,9 @@ static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL)
>
> static int check_reset_type(char *str)
> {
> - if (strncmp(str, "adapter", 10) == 0)
> + if (sysfs_streq(str, "adapter"))
> return SCSI_ADAPTER_RESET;
> - else if (strncmp(str, "firmware", 10) == 0)
> + else if (sysfs_streq(str, "firmware"))
> return SCSI_FIRMWARE_RESET;
> else
> return 0;
> @@ -264,12 +264,9 @@ store_host_reset(struct device *dev, struct device_attribute *attr,
> struct Scsi_Host *shost = class_to_shost(dev);
> struct scsi_host_template *sht = shost->hostt;
> int ret = -EINVAL;
> - char str[10];
> int type;
>
> - sscanf(buf, "%s", str);
> - type = check_reset_type(str);
> -
> + type = check_reset_type(buf);
> if (!type)
> goto exit_store_host_reset;
You didn't compile test this:
CC [M] drivers/scsi/scsi_sysfs.o
drivers/scsi/scsi_sysfs.c: In function ‘store_host_reset’:
drivers/scsi/scsi_sysfs.c:269:2: warning: passing argument 1 of ‘check_reset_type’ discards ‘const’ qualifier from pointer target type [enabled by default]
drivers/scsi/scsi_sysfs.c:250:12: note: expected ‘char *’ but argument is of type ‘const char *’
It needs a const in check_reset_type().
I've added it.
James
prev parent reply other threads:[~2012-11-30 9:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-15 20:51 Sasha Levin
2012-11-16 9:35 ` Rolf Eike Beer
2012-11-30 9:07 ` James Bottomley [this message]
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=1354266477.2259.5.camel@dabdike.int.hansenpartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sasha.levin@oracle.com \
/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
all inboxes | Powered by JetHome®