From: Wenchao Hao <haowenchao2@huawei.com>
To: Dan Carpenter <dan.carpenter@linaro.org>,
Wenchao Hao <haowenchao22@gmail.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>,
Vinod Koul <vkoul@kernel.org>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Douglas Gilbert <dgilbert@interlog.com>,
<dmaengine@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH 1/2] scsi: scsi_debug: fix some bugs in sdebug_error_write()
Date: Wed, 25 Oct 2023 14:10:41 +0800 [thread overview]
Message-ID: <afe1eca8-cdf8-612b-867e-4fef50ad423f@huawei.com> (raw)
In-Reply-To: <9767953c-480d-4ad9-a553-a45ae80c572b@kadam.mountain>
On 2023/10/25 12:11, Dan Carpenter wrote:
> On Wed, Oct 25, 2023 at 01:09:34AM +0800, Wenchao Hao wrote:
>> Yes, there is bug here if write with .c code. Because your change to use
>> strndup_user() would make write with dirty data appended to "ubuf" failed,
>
> I don't understand this sentence. What is "dirty" data in this context?
>
This is what I posted in previous reply:
We might have following pairs of parameters for sdebug_error_write:
ubuf: "0 -10 0x12\n0 0 0x2 0x6 0x4 0x2"
count=11
the valid data in ubuf is "0 -10 -x12\n", others are dirty data.
strndup_user() would return EINVAL for this pair which caused
a correct write to fail.
>> can we fix it with following change:
>>
>> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
>> index 67922e2c4c19..0e8ct724463f 100644
>> --- a/drivers/scsi/scsi_debug.c
>> +++ b/drivers/scsi/scsi_debug.c
>> @@ -1019,7 +1019,7 @@ static seize_t sdebug_error_write(struct file *file, const char __user *ubuf,
>> struct sdebug_err_inject *inject;
>> struct scsi_device *sdev = (struct scsi_device *)file->f_inode->i_private;
>>
>> - buf = kmalloc(count, GFP_KERNEL);
>> + buf = kzalloc(count + 1, GFP_KERNEL);
>
> That would also fix the bug.
>
>> if (!buf)
>> return -ENOMEM;
>>
>> Or is there other kernel lib function which can address this issue?
>
> I don't understand the issue.
>
I mean the bug you mentioned.
Thanks.
> regards,
> dan carpenter
>
>
next prev parent reply other threads:[~2023-10-25 6:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-20 14:15 [PATCH 1/2] scsi: scsi_debug: fix some bugs in sdebug_error_write() Dan Carpenter
2023-10-21 10:10 ` Wenchao Hao
2023-10-23 13:39 ` Dan Carpenter
2023-10-24 17:09 ` Wenchao Hao
2023-10-25 4:11 ` Dan Carpenter
2023-10-25 6:10 ` Wenchao Hao [this message]
2023-10-25 7:07 ` Dan Carpenter
2023-11-03 18:00 ` Wenchao Hao
2023-11-03 18:13 ` Wenchao Hao
2023-11-06 13:44 ` Dan Carpenter
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=afe1eca8-cdf8-612b-867e-4fef50ad423f@huawei.com \
--to=haowenchao2@huawei.com \
--cc=Eugeniy.Paltsev@synopsys.com \
--cc=dan.carpenter@linaro.org \
--cc=dgilbert@interlog.com \
--cc=dmaengine@vger.kernel.org \
--cc=haowenchao22@gmail.com \
--cc=jejb@linux.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=vkoul@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