* [PATCH] usb: f_fs: Drop check on Reserved1 field on OS_DESC_EXT_COMPAT
@ 2017-11-09 16:34 John Keeping
2017-11-10 10:40 ` Felipe Balbi
0 siblings, 1 reply; 7+ messages in thread
From: John Keeping @ 2017-11-09 16:34 UTC (permalink / raw)
To: Felipe Balbi
Cc: linux-usb, linux-kernel, Greg Kroah-Hartman, Vincent Pelletier,
Jim Lin, Janusz Dziedzic, John Keeping, stable
This check has gone through several incompatible variations in commits
53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of
OS_DESC_EXT_COMPAT"), 354bc45bf329 ("usb: gadget: f_fs: Fix ExtCompat
descriptor validation") and 3ba534df815f ("Revert "usb: gadget: f_fs:
Fix ExtCompat descriptor validation"") after initially being introduced
in commit f0175ab51993 ("usb: gadget: f_fs: OS descriptors support").
The various changes make it impossible for a single userspace
implementation to work with different kernel versions, so let's just
drop the condition to avoid breaking userspace.
Fixes: 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of OS_DESC_EXT_COMPAT")
Cc: stable@vger.kernel.org # v4.7+
Signed-off-by: John Keeping <john@metanate.com>
---
drivers/usb/gadget/function/f_fs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 652397eda6d6..0d9962834345 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2282,8 +2282,7 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
int i;
if (len < sizeof(*d) ||
- d->bFirstInterfaceNumber >= ffs->interfaces_count ||
- !d->Reserved1)
+ d->bFirstInterfaceNumber >= ffs->interfaces_count)
return -EINVAL;
for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
if (d->Reserved2[i])
--
2.15.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] usb: f_fs: Drop check on Reserved1 field on OS_DESC_EXT_COMPAT
2017-11-09 16:34 [PATCH] usb: f_fs: Drop check on Reserved1 field on OS_DESC_EXT_COMPAT John Keeping
@ 2017-11-10 10:40 ` Felipe Balbi
2017-11-10 18:34 ` John Keeping
0 siblings, 1 reply; 7+ messages in thread
From: Felipe Balbi @ 2017-11-10 10:40 UTC (permalink / raw)
To: John Keeping
Cc: linux-usb, linux-kernel, Greg Kroah-Hartman, Vincent Pelletier,
Jim Lin, Janusz Dziedzic, John Keeping, stable
[-- Attachment #1: Type: text/plain, Size: 1824 bytes --]
Hi,
John Keeping <john@metanate.com> writes:
> This check has gone through several incompatible variations in commits
> 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of
> OS_DESC_EXT_COMPAT"), 354bc45bf329 ("usb: gadget: f_fs: Fix ExtCompat
> descriptor validation") and 3ba534df815f ("Revert "usb: gadget: f_fs:
> Fix ExtCompat descriptor validation"") after initially being introduced
> in commit f0175ab51993 ("usb: gadget: f_fs: OS descriptors support").
>
> The various changes make it impossible for a single userspace
> implementation to work with different kernel versions, so let's just
> drop the condition to avoid breaking userspace.
>
> Fixes: 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of OS_DESC_EXT_COMPAT")
> Cc: stable@vger.kernel.org # v4.7+
> Signed-off-by: John Keeping <john@metanate.com>
> ---
> drivers/usb/gadget/function/f_fs.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 652397eda6d6..0d9962834345 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -2282,8 +2282,7 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
> int i;
>
> if (len < sizeof(*d) ||
> - d->bFirstInterfaceNumber >= ffs->interfaces_count ||
> - !d->Reserved1)
> + d->bFirstInterfaceNumber >= ffs->interfaces_count)
> return -EINVAL;
> for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
> if (d->Reserved2[i])
Sorry, but no. We want to be compliant with the specification. If there
are older still-maintained stable trees which are not working, we need
to backport a fix to them, but we're not allowing uncompliant
implementations.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] usb: f_fs: Drop check on Reserved1 field on OS_DESC_EXT_COMPAT
2017-11-10 10:40 ` Felipe Balbi
@ 2017-11-10 18:34 ` John Keeping
2017-11-13 10:57 ` Felipe Balbi
0 siblings, 1 reply; 7+ messages in thread
From: John Keeping @ 2017-11-10 18:34 UTC (permalink / raw)
To: Felipe Balbi
Cc: linux-usb, linux-kernel, Greg Kroah-Hartman, Vincent Pelletier,
Jim Lin, Janusz Dziedzic, stable
On Fri, 10 Nov 2017 12:40:39 +0200, Felipe Balbi wrote:
> John Keeping <john@metanate.com> writes:
> > This check has gone through several incompatible variations in commits
> > 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of
> > OS_DESC_EXT_COMPAT"), 354bc45bf329 ("usb: gadget: f_fs: Fix ExtCompat
> > descriptor validation") and 3ba534df815f ("Revert "usb: gadget: f_fs:
> > Fix ExtCompat descriptor validation"") after initially being introduced
> > in commit f0175ab51993 ("usb: gadget: f_fs: OS descriptors support").
> >
> > The various changes make it impossible for a single userspace
> > implementation to work with different kernel versions, so let's just
> > drop the condition to avoid breaking userspace.
> >
> > Fixes: 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of OS_DESC_EXT_COMPAT")
> > Cc: stable@vger.kernel.org # v4.7+
> > Signed-off-by: John Keeping <john@metanate.com>
> > ---
> > drivers/usb/gadget/function/f_fs.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> > index 652397eda6d6..0d9962834345 100644
> > --- a/drivers/usb/gadget/function/f_fs.c
> > +++ b/drivers/usb/gadget/function/f_fs.c
> > @@ -2282,8 +2282,7 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
> > int i;
> >
> > if (len < sizeof(*d) ||
> > - d->bFirstInterfaceNumber >= ffs->interfaces_count ||
> > - !d->Reserved1)
> > + d->bFirstInterfaceNumber >= ffs->interfaces_count)
> > return -EINVAL;
> > for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
> > if (d->Reserved2[i])
>
> Sorry, but no. We want to be compliant with the specification. If there
> are older still-maintained stable trees which are not working, we need
> to backport a fix to them, but we're not allowing uncompliant
> implementations.
Aren't we allowing non-compliant implementations now? The spec says the
value must be 1 but since v4.7 this code has allowed all non-zero
values.
At this point I don't think the kernel can disallow any values of
Reserved1 without breaking someone's userspace.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] usb: f_fs: Drop check on Reserved1 field on OS_DESC_EXT_COMPAT
2017-11-10 18:34 ` John Keeping
@ 2017-11-13 10:57 ` Felipe Balbi
2017-11-13 18:19 ` John Keeping
0 siblings, 1 reply; 7+ messages in thread
From: Felipe Balbi @ 2017-11-13 10:57 UTC (permalink / raw)
To: John Keeping
Cc: linux-usb, linux-kernel, Greg Kroah-Hartman, Vincent Pelletier,
Jim Lin, Janusz Dziedzic, stable
[-- Attachment #1: Type: text/plain, Size: 2295 bytes --]
Hi,
John Keeping <john@metanate.com> writes:
> On Fri, 10 Nov 2017 12:40:39 +0200, Felipe Balbi wrote:
>
>> John Keeping <john@metanate.com> writes:
>> > This check has gone through several incompatible variations in commits
>> > 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of
>> > OS_DESC_EXT_COMPAT"), 354bc45bf329 ("usb: gadget: f_fs: Fix ExtCompat
>> > descriptor validation") and 3ba534df815f ("Revert "usb: gadget: f_fs:
>> > Fix ExtCompat descriptor validation"") after initially being introduced
>> > in commit f0175ab51993 ("usb: gadget: f_fs: OS descriptors support").
>> >
>> > The various changes make it impossible for a single userspace
>> > implementation to work with different kernel versions, so let's just
>> > drop the condition to avoid breaking userspace.
>> >
>> > Fixes: 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of OS_DESC_EXT_COMPAT")
>> > Cc: stable@vger.kernel.org # v4.7+
>> > Signed-off-by: John Keeping <john@metanate.com>
>> > ---
>> > drivers/usb/gadget/function/f_fs.c | 3 +--
>> > 1 file changed, 1 insertion(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
>> > index 652397eda6d6..0d9962834345 100644
>> > --- a/drivers/usb/gadget/function/f_fs.c
>> > +++ b/drivers/usb/gadget/function/f_fs.c
>> > @@ -2282,8 +2282,7 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
>> > int i;
>> >
>> > if (len < sizeof(*d) ||
>> > - d->bFirstInterfaceNumber >= ffs->interfaces_count ||
>> > - !d->Reserved1)
>> > + d->bFirstInterfaceNumber >= ffs->interfaces_count)
>> > return -EINVAL;
>> > for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
>> > if (d->Reserved2[i])
>>
>> Sorry, but no. We want to be compliant with the specification. If there
>> are older still-maintained stable trees which are not working, we need
>> to backport a fix to them, but we're not allowing uncompliant
>> implementations.
>
> Aren't we allowing non-compliant implementations now? The spec says the
> value must be 1 but since v4.7 this code has allowed all non-zero
> values.
Good point. Then how about we just force the value to 1 in f_fs.c and
remove the check?
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] usb: f_fs: Drop check on Reserved1 field on OS_DESC_EXT_COMPAT
2017-11-13 10:57 ` Felipe Balbi
@ 2017-11-13 18:19 ` John Keeping
2017-11-27 11:34 ` Felipe Balbi
0 siblings, 1 reply; 7+ messages in thread
From: John Keeping @ 2017-11-13 18:19 UTC (permalink / raw)
To: Felipe Balbi
Cc: linux-usb, linux-kernel, Greg Kroah-Hartman, Vincent Pelletier, Jim Lin
On Mon, 13 Nov 2017 12:57:21 +0200, Felipe Balbi wrote:
> Good point. Then how about we just force the value to 1 in f_fs.c and
> remove the check?
That seems reasonable. Something like this?
-- >8 --
Subject: [PATCH] usb: f_fs: Force Reserved1=1 in OS_DESC_EXT_COMPAT
The specification says that the Reserved1 field in OS_DESC_EXT_COMPAT
must have the value "1", but when this feature was first implemented we
rejected any non-zero values.
This was adjusted to accept all non-zero values (while now rejecting
zero) in commit 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on
reserved1 of OS_DESC_EXT_COMPAT"), but that breaks any userspace
programs that worked previously by returning EINVAL when Reserved1 == 0
which was previously the only value that succeeded!
If we just set the field to "1" ourselves, both old and new userspace
programs continue to work correctly and, as a bonus, old programs are
now compliant with the specification without having to fix anything
themselves.
Fixes: 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of OS_DESC_EXT_COMPAT")
Cc: stable@vger.kernel.org
Signed-off-by: John Keeping <john@metanate.com>
---
drivers/usb/gadget/function/f_fs.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 652397eda6d6..520a96e7ef9a 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2282,9 +2282,18 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
int i;
if (len < sizeof(*d) ||
- d->bFirstInterfaceNumber >= ffs->interfaces_count ||
- !d->Reserved1)
+ d->bFirstInterfaceNumber >= ffs->interfaces_count)
return -EINVAL;
+ if (d->Reserved1 != 1) {
+ /*
+ * According to the spec, Reserved1 must be set to 1
+ * but older kernels incorrectly rejected non-zero
+ * values. We fix it here to avoid returning EINVAL
+ * in response to values we used to accept.
+ */
+ pr_debug("usb_ext_compat_desc::Reserved1 forced to 1\n");
+ d->Reserved1 = 1;
+ }
for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
if (d->Reserved2[i])
return -EINVAL;
--
2.15.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] usb: f_fs: Drop check on Reserved1 field on OS_DESC_EXT_COMPAT
2017-11-13 18:19 ` John Keeping
@ 2017-11-27 11:34 ` Felipe Balbi
2017-11-27 18:15 ` [PATCH v2] usb: f_fs: Force Reserved1=1 in OS_DESC_EXT_COMPAT John Keeping
0 siblings, 1 reply; 7+ messages in thread
From: Felipe Balbi @ 2017-11-27 11:34 UTC (permalink / raw)
To: John Keeping
Cc: linux-usb, linux-kernel, Greg Kroah-Hartman, Vincent Pelletier, Jim Lin
[-- Attachment #1: Type: text/plain, Size: 2397 bytes --]
Hi,
John Keeping <john@metanate.com> writes:
> On Mon, 13 Nov 2017 12:57:21 +0200, Felipe Balbi wrote:
>> Good point. Then how about we just force the value to 1 in f_fs.c and
>> remove the check?
>
> That seems reasonable. Something like this?
>
> -- >8 --
> Subject: [PATCH] usb: f_fs: Force Reserved1=1 in OS_DESC_EXT_COMPAT
>
> The specification says that the Reserved1 field in OS_DESC_EXT_COMPAT
> must have the value "1", but when this feature was first implemented we
> rejected any non-zero values.
>
> This was adjusted to accept all non-zero values (while now rejecting
> zero) in commit 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on
> reserved1 of OS_DESC_EXT_COMPAT"), but that breaks any userspace
> programs that worked previously by returning EINVAL when Reserved1 == 0
> which was previously the only value that succeeded!
>
> If we just set the field to "1" ourselves, both old and new userspace
> programs continue to work correctly and, as a bonus, old programs are
> now compliant with the specification without having to fix anything
> themselves.
>
> Fixes: 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of OS_DESC_EXT_COMPAT")
> Cc: stable@vger.kernel.org
> Signed-off-by: John Keeping <john@metanate.com>
> ---
> drivers/usb/gadget/function/f_fs.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 652397eda6d6..520a96e7ef9a 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -2282,9 +2282,18 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
> int i;
>
> if (len < sizeof(*d) ||
> - d->bFirstInterfaceNumber >= ffs->interfaces_count ||
> - !d->Reserved1)
> + d->bFirstInterfaceNumber >= ffs->interfaces_count)
> return -EINVAL;
> + if (d->Reserved1 != 1) {
> + /*
> + * According to the spec, Reserved1 must be set to 1
> + * but older kernels incorrectly rejected non-zero
> + * values. We fix it here to avoid returning EINVAL
> + * in response to values we used to accept.
> + */
> + pr_debug("usb_ext_compat_desc::Reserved1 forced to 1\n");
> + d->Reserved1 = 1;
> + }
exactly like that. Care to send as a formal patch so I can apply?
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] usb: f_fs: Force Reserved1=1 in OS_DESC_EXT_COMPAT
2017-11-27 11:34 ` Felipe Balbi
@ 2017-11-27 18:15 ` John Keeping
0 siblings, 0 replies; 7+ messages in thread
From: John Keeping @ 2017-11-27 18:15 UTC (permalink / raw)
To: Felipe Balbi
Cc: linux-usb, linux-kernel, Greg Kroah-Hartman, Vincent Pelletier, Jim Lin
The specification says that the Reserved1 field in OS_DESC_EXT_COMPAT
must have the value "1", but when this feature was first implemented we
rejected any non-zero values.
This was adjusted to accept all non-zero values (while now rejecting
zero) in commit 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on
reserved1 of OS_DESC_EXT_COMPAT"), but that breaks any userspace
programs that worked previously by returning EINVAL when Reserved1 == 0
which was previously the only value that succeeded!
If we just set the field to "1" ourselves, both old and new userspace
programs continue to work correctly and, as a bonus, old programs are
now compliant with the specification without having to fix anything
themselves.
Fixes: 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of OS_DESC_EXT_COMPAT")
Cc: stable@vger.kernel.org
Signed-off-by: John Keeping <john@metanate.com>
---
drivers/usb/gadget/function/f_fs.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
On Mon, 27 Nov 2017 13:34:20 +0200, Felipe Balbi wrote:
> exactly like that. Care to send as a formal patch so I can apply?
Here it is.
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 97ea059a7aa4..7537cc1a7d79 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2282,9 +2282,18 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
int i;
if (len < sizeof(*d) ||
- d->bFirstInterfaceNumber >= ffs->interfaces_count ||
- !d->Reserved1)
+ d->bFirstInterfaceNumber >= ffs->interfaces_count)
return -EINVAL;
+ if (d->Reserved1 != 1) {
+ /*
+ * According to the spec, Reserved1 must be set to 1
+ * but older kernels incorrectly rejected non-zero
+ * values. We fix it here to avoid returning EINVAL
+ * in response to values we used to accept.
+ */
+ pr_debug("usb_ext_compat_desc::Reserved1 forced to 1\n");
+ d->Reserved1 = 1;
+ }
for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
if (d->Reserved2[i])
return -EINVAL;
--
2.15.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-11-27 18:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 16:34 [PATCH] usb: f_fs: Drop check on Reserved1 field on OS_DESC_EXT_COMPAT John Keeping
2017-11-10 10:40 ` Felipe Balbi
2017-11-10 18:34 ` John Keeping
2017-11-13 10:57 ` Felipe Balbi
2017-11-13 18:19 ` John Keeping
2017-11-27 11:34 ` Felipe Balbi
2017-11-27 18:15 ` [PATCH v2] usb: f_fs: Force Reserved1=1 in OS_DESC_EXT_COMPAT John Keeping
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.