From: Dan Carpenter <dan.carpenter@linaro.org>
To: Wenchao Hao <haowenchao2@huawei.com>
Cc: Wenchao Hao <haowenchao22@gmail.com>,
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 10:07:00 +0300 [thread overview]
Message-ID: <9207ed62-4e41-4b8c-8aee-5143c1a71bf8@kadam.mountain> (raw)
In-Reply-To: <afe1eca8-cdf8-612b-867e-4fef50ad423f@huawei.com>
On Wed, Oct 25, 2023 at 02:10:41PM +0800, Wenchao Hao wrote:
> 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.
I mean, I could just tell you that your kzalloc(count + 1, GFP_KERNEL)
fix will work. It does work.
But how is passing "dirty data" a "correct write"? I feel like it
should be treated as incorrect and returning -EINVAL is the correct
behavior. I'm so confused. Why are users doing that?
I have looked at the code and it just doesn't seem that complicated.
They shouldn't be passing messed up strings and expect the kernel to
allow it.
regards,
dan carpenter
next prev parent reply other threads:[~2023-10-25 7:07 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
2023-10-25 7:07 ` Dan Carpenter [this message]
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=9207ed62-4e41-4b8c-8aee-5143c1a71bf8@kadam.mountain \
--to=dan.carpenter@linaro.org \
--cc=Eugeniy.Paltsev@synopsys.com \
--cc=dgilbert@interlog.com \
--cc=dmaengine@vger.kernel.org \
--cc=haowenchao22@gmail.com \
--cc=haowenchao2@huawei.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