Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1731692
| From | Sylwester Nawrocki <s.nawrocki@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] [media] s3c-camif: fix out-of-bounds array access |
| Date | 2017-09-13 18:00 +0200 |
| Message-ID | <upieZ-Ri-1@gated-at.bofh.it> (permalink) |
| References | <upc9A-5vh-17@gated-at.bofh.it> <uoZFo-5Ul-13@gated-at.bofh.it> <upc9A-5vh-15@gated-at.bofh.it> <upgwy-8oG-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 09/13/2017 04:03 PM, Arnd Bergmann wrote:
> On Wed, Sep 13, 2017 at 11:25 AM, Sylwester Nawrocki
> <s.nawrocki@samsung.com> wrote:
>> On 09/12/2017 10:09 PM, Arnd Bergmann wrote:
>>> {
>>> const struct s3c_camif_variant *variant = camif->variant;
>>> const struct vp_pix_limits *pix_lim;
>>> - int i = ARRAY_SIZE(camif_mbus_formats);
>>>
>>> /* FIXME: constraints against codec or preview path ? */
>>> pix_lim = &variant->vp_pix_limits[VP_CODEC];
>>>
>>> - while (i-- >= 0)
>>> - if (camif_mbus_formats[i] == mf->code)
>>> - break;
>>> -
>>> - mf->code = camif_mbus_formats[i];
>>
>> Interesting finding... the function needs to ensure mf->code is set
>> to one of supported values by the driver, so instead of removing
>> how about changing the above line to:
>>
>> if (i < 0)
>> mf->code = camif_mbus_formats[0];
>>
>> ?
> That would still have one of the two out-of-bounds accesses;-)
Ah, indeed :/
> maybe this
>
> for (i = 0; i < ARRAY_SIZE(camif_mbus_formats); i++)
> if (camif_mbus_formats[i] == mf->code)
> break;
>
> if (i == ARRAY_SIZE(camif_mbus_formats))
> mf->code = camif_mbus_formats[0];
Yes, it should work that way.
--
Thanks,
Sylwester
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] [media] s3c-camif: fix out-of-bounds array access Arnd Bergmann <arnd@arndb.de> - 2017-09-12 22:10 +0200
Re: [PATCH] [media] s3c-camif: fix out-of-bounds array access Sylwester Nawrocki <s.nawrocki@samsung.com> - 2017-09-13 11:30 +0200
Re: [PATCH] [media] s3c-camif: fix out-of-bounds array access Arnd Bergmann <arnd@arndb.de> - 2017-09-13 16:10 +0200
Re: [PATCH] [media] s3c-camif: fix out-of-bounds array access Sylwester Nawrocki <s.nawrocki@samsung.com> - 2017-09-13 18:00 +0200
csiph-web