Skip to contentSkip to conversation

b43/leds: Ensure NUL-termination of LED name string

PATCH Michael Büsch 4 participants 8 messages Jul 31, 2018 – Aug 10, 2018 B43 wireless driver

lore
Share & tools
lore
#0 lore raw

strncpy might not NUL-terminate the string, if the name equals the buffer size. Use strlcpy instead.

---
 drivers/net/wireless/broadcom/b43/leds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/b43/leds.c +1 -1
index cb987c2ecc6b..87131f663292 100644
@@ -131,7 +131,7 @@ static int b43_register_led(struct b43_wldev *dev, struct b43_led *led,
 	led->wl = dev->wl;
 	led->index = led_index;
 	led->activelow = activelow;
-	strncpy(led->name, name, sizeof(led->name));
+	strlcpy(led->name, name, sizeof(led->name));
 	atomic_set(&led->state, 0);
 
 	led->led_dev.name = led->name;
Signature · 1 line
Michael
#1 lore raw

TWljaGFlbCBCw7xzY2ggPG1AYnVlcy5jaD4gd3JpdGVzOg0KDQo+IHN0cm5jcHkgbWlnaHQgbm90 IE5VTC10ZXJtaW5hdGUgdGhlIHN0cmluZywgaWYgdGhlIG5hbWUgZXF1YWxzIHRoZSBidWZmZXIg c2l6ZS4NCj4gVXNlIHN0cmxjcHkgaW5zdGVhZC4NCj4NCj4gU2lnbmVkLW9mZi1ieTogTWljaGFl bCBCdWVzY2ggPG1AYnVlcy5jaD4NCj4gQ2M6IHN0YWJsZUB2Z2VyLmtlcm5lbC5vcmcNCg0KVGhp cyBpcyB3ZWlyZCwgd2l0aCBhbGwgdGhlIHBhdGNoZXMgeW91IHN1Ym1pdHRlZCBsYXN0IHdlZWsg SSBnZXQgdGhpcw0KaWYgSSBkb3dubG9hZCB0aGUgcGF0Y2ggZnJvbSBwYXRjaHdvcms6DQoNCiQg Z2l0IGFtIC1zIDEubWJveA0KUGF0Y2ggaXMgZW1wdHkuIFdhcyBpdCBzcGxpdCB3cm9uZz8NCg0K QnV0IGlmIEkgZG93bmxvYWQgdGhlIHBhdGNoIGRpcmVjdGx5IGZyb20gbXkgSU1BUCBmb2xkZXIg SSBoYXZlIG5vDQpwcm9ibGVtczoNCg0KJCBnaXQgYW0gLXMgMS5tYm94DQpBcHBseWluZzogYjQz L2xlZHM6IEVuc3VyZSBOVUwtdGVybWluYXRpb24gb2YgTEVEIG5hbWUgc3RyaW5nDQoNClRoaXMg aGFwcGVucyBldmVuIHdpdGhvdXQgbXkgY3VzdG9tIHBhdGNod29yayBzY3JpcHQgc28gdGhpcyBo YXMNCnNvbWV0aGluZyB0byBkbyB3aXRoIHRoZSBwYXRjaHdvcmsgc2VydmVyLCBidXQgaXQncyBu b3Qgb2J2aW91cyB0byBtZQ0Kd2hhdCB0cmlnZ2VycyBpdC4gSUlSQyBJIGhhdmUgbm90IHNlZW4g YW55dGhpbmcgbGlrZSB0aGlzIGJlZm9yZS4gSXQNCnNlZW1zIHRoYXQgeW91IGRpZG4ndCB1c2Ug Z2l0LXNlbmQtZW1haWwsIEkgc3Ryb25nbHkgc3VnZ2VzdCB0byB1c2UgdGhhdA0KanVzdCB0byBh dm9pZCBwcm9ibGVtcyBsaWtlIHRoaXMuDQoNCkFueXdheSwgYXBwbGllZCBtYW51YWxseToNCg0K MmFhNjUwZDE5NTBmIGI0My9sZWRzOiBFbnN1cmUgTlVMLXRlcm1pbmF0aW9uIG9mIExFRCBuYW1l IHN0cmluZw0KDQotLSANCkthbGxlIFZhbG8=

#2 lore raw
Quoted 3 lines · Kalle Valo
Quoted 1 line · Michael B=C3=BCsch <[email protected]> writes:

strncpy might not NUL-terminate the string, if the name equals the buffe=

r size.

Quoted 14 lines
Quoted 4 lines

Use strlcpy instead.

This is weird, with all the patches you submitted last week I get this if I download the patch from patchwork:

$ git am -s 1.mbox
Patch is empty. Was it split wrong?

But if I download the patch directly from my IMAP folder I have no problems:

Quoted 8 lines
$ git am -s 1.mbox
Applying: b43/leds: Ensure NUL-termination of LED name string

This happens even without my custom patchwork script so this has something to do with the patchwork server, but it's not obvious to me what triggers it. IIRC I have not seen anything like this before. It seems that you didn't use git-send-email, I strongly suggest to use that just to avoid problems like this.

Looks like patchwork mishandles the pgp signature, the patchwork mbox has

Quoted 2 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512;
boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/pgp-s=

ignature"

as the only content-type (and the boundary is nowhere to be found), while the one in my inbox has

Quoted 1 line

Content-Type: multipart/signed; micalg=3Dpgp-sha512; boundary=3D"Sig_/EN9=

0ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/pgp-signature"

Quoted 4 lines

--Sig_/EN90ciRq4eWXDUcnZABQ0Ak
Content-Type: text/plain; charset=3DUS-ASCII
Content-Transfer-Encoding: quoted-printable

When I remove the Content-Type: line(s) from the mbox from patchwork, git recognises it again as a patch. I guess git am ignores everything until the boundary, which got dropped by patchwork, so it never finds the actual patch.

Regards
Jonas

#3 lore raw
Quoted 4 lines · Jonas Gorski
Quoted 3 lines · Kalle Valo
Quoted 1 line · Michael B=C3=BCsch <[email protected]> writes:

strncpy might not NUL-terminate the string, if the name equals the buff=

er size.

Quoted 17 lines
Quoted 17 lines
Quoted 4 lines

Use strlcpy instead.

This is weird, with all the patches you submitted last week I get this if I download the patch from patchwork:

$ git am -s 1.mbox
Patch is empty. Was it split wrong?

But if I download the patch directly from my IMAP folder I have no problems:

$ git am -s 1.mbox
Applying: b43/leds: Ensure NUL-termination of LED name string
Quoted 10 lines
Quoted 5 lines

This happens even without my custom patchwork script so this has something to do with the patchwork server, but it's not obvious to me what triggers it. IIRC I have not seen anything like this before. It seems that you didn't use git-send-email, I strongly suggest to use that just to avoid problems like this.

Looks like patchwork mishandles the pgp signature, the patchwork mbox has

Quoted 2 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512;
boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/pgp-=

signature"

Quoted 8 lines

as the only content-type (and the boundary is nowhere to be found), while the one in my inbox has

Quoted 4 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512; boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/pgp-signature"

Quoted 8 lines
Quoted 3 lines

--Sig_/EN90ciRq4eWXDUcnZABQ0Ak
Content-Type: text/plain; charset=3DUS-ASCII
Content-Transfer-Encoding: quoted-printable

When I remove the Content-Type: line(s) from the mbox from patchwork, git recognises it again as a patch. I guess git am ignores everything until the boundary, which got dropped by patchwork, so it never finds the actual patch.

Awesome, thanks for debugging this! It would be great if someone could report this to the patchwork maintainers, I don't have the time right now.

--=20
Kalle Valo

#4 lore raw
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Jonas Gorski
Quoted 3 lines · Kalle Valo
Quoted 1 line · Michael B=C3=BCsch <[email protected]> writes:

strncpy might not NUL-terminate the string, if the name equals the buf=

fer size.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 4 lines

Use strlcpy instead.

This is weird, with all the patches you submitted last week I get this if I download the patch from patchwork:

$ git am -s 1.mbox
Patch is empty. Was it split wrong?

But if I download the patch directly from my IMAP folder I have no problems:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
$ git am -s 1.mbox
Applying: b43/leds: Ensure NUL-termination of LED name string

This happens even without my custom patchwork script so this has something to do with the patchwork server, but it's not obvious to me what triggers it. IIRC I have not seen anything like this before. It seems that you didn't use git-send-email, I strongly suggest to use tha=

t

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

just to avoid problems like this.

Looks like patchwork mishandles the pgp signature, the patchwork mbox ha=

s

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512;
boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/pgp=

-signature"

Quoted 12 lines
Quoted 12 lines

as the only content-type (and the boundary is nowhere to be found), while the one in my inbox has

Quoted 7 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512; boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/pgp-signature"

--Sig_/EN90ciRq4eWXDUcnZABQ0Ak
Content-Type: text/plain; charset=3DUS-ASCII
Content-Transfer-Encoding: quoted-printable

Quoted 8 lines
Quoted 4 lines

When I remove the Content-Type: line(s) from the mbox from patchwork, git recognises it again as a patch. I guess git am ignores everything until the boundary, which got dropped by patchwork, so it never finds the actual patch.

Awesome, thanks for debugging this! It would be great if someone could report this to the patchwork maintainers, I don't have the time right now.

Silly question, but who *are* the maintainers? I just spend several minutes on https://patchwork.kernel.org/ and google, and failed to find any contact information.

Regards
Jonas

#5 lore raw
Quoted 7 lines · Jonas Gorski
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Jonas Gorski
Quoted 3 lines · Kalle Valo
Quoted 1 line · Michael B=C3=BCsch <[email protected]> writes:

strncpy might not NUL-terminate the string, if the name equals the bu=

ffer size.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 4 lines

Use strlcpy instead.

This is weird, with all the patches you submitted last week I get this if I download the patch from patchwork:

$ git am -s 1.mbox
Patch is empty. Was it split wrong?

But if I download the patch directly from my IMAP folder I have no problems:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
$ git am -s 1.mbox
Applying: b43/leds: Ensure NUL-termination of LED name string

This happens even without my custom patchwork script so this has something to do with the patchwork server, but it's not obvious to me what triggers it. IIRC I have not seen anything like this before. It seems that you didn't use git-send-email, I strongly suggest to use th=

at

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

just to avoid problems like this.

Looks like patchwork mishandles the pgp signature, the patchwork mbox h=

as

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512;
boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/pg=

p-signature"

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines

as the only content-type (and the boundary is nowhere to be found), while the one in my inbox has

Quoted 7 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512; boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/pgp-signature"

--Sig_/EN90ciRq4eWXDUcnZABQ0Ak
Content-Type: text/plain; charset=3DUS-ASCII
Content-Transfer-Encoding: quoted-printable

When I remove the Content-Type: line(s) from the mbox from patchwork, git recognises it again as a patch. I guess git am ignores everything until the boundary, which got dropped by patchwork, so it never finds the actual patch.

Quoted 7 lines
Quoted 3 lines

Awesome, thanks for debugging this! It would be great if someone could report this to the patchwork maintainers, I don't have the time right now.

Silly question, but who *are* the maintainers? I just spend several minutes on https://patchwork.kernel.org/ and google, and failed to find any contact information.

Not a silly question at all. I'm not sure what's the preferred way to report bugs but at least I found this:

http://jk.ozlabs.org/projects/patchwork/

I guess they use the github tracker:

https://github.com/getpatchwork/patchwork/issues/

--=20
Kalle Valo

#6 lore raw
Quoted 9 lines · Kalle Valo
Quoted 7 lines · Jonas Gorski
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Jonas Gorski
Quoted 3 lines · Kalle Valo
Quoted 1 line · Michael B=C3=BCsch <[email protected]> writes:

strncpy might not NUL-terminate the string, if the name equals the b=

uffer size.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Use strlcpy instead.

This is weird, with all the patches you submitted last week I get thi=

s

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

if I download the patch from patchwork:

$ git am -s 1.mbox
Patch is empty. Was it split wrong?

But if I download the patch directly from my IMAP folder I have no problems:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
$ git am -s 1.mbox
Applying: b43/leds: Ensure NUL-termination of LED name string

This happens even without my custom patchwork script so this has something to do with the patchwork server, but it's not obvious to me what triggers it. IIRC I have not seen anything like this before. It seems that you didn't use git-send-email, I strongly suggest to use t=

hat

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

just to avoid problems like this.

Looks like patchwork mishandles the pgp signature, the patchwork mbox =

has

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512;
boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/p=

gp-signature"

Quoted 25 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines

as the only content-type (and the boundary is nowhere to be found), while the one in my inbox has

Quoted 7 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512; boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/pgp-signature"

--Sig_/EN90ciRq4eWXDUcnZABQ0Ak
Content-Type: text/plain; charset=3DUS-ASCII
Content-Transfer-Encoding: quoted-printable

When I remove the Content-Type: line(s) from the mbox from patchwork, git recognises it again as a patch. I guess git am ignores everything until the boundary, which got dropped by patchwork, so it never finds the actual patch.

Quoted 7 lines
Quoted 3 lines

Awesome, thanks for debugging this! It would be great if someone could report this to the patchwork maintainers, I don't have the time right now.

Silly question, but who *are* the maintainers? I just spend several minutes on https://patchwork.kernel.org/ and google, and failed to find any contact information.

Quoted 8 lines

Not a silly question at all. I'm not sure what's the preferred way to report bugs but at least I found this:

http://jk.ozlabs.org/projects/patchwork/

I guess they use the github tracker:

https://github.com/getpatchwork/patchwork/issues/

Going through the issues, I guess this is already fixed in master with

https://github.com/getpatchwork/patchwork/commit/e27ff061dc01e51967a978884a=
5c59152863ab9c

and queued for the next 2.1 release (or not? the stable/2.1 branch also contains a version bump to 2.2 ... )

I have still no idea who runs the patchwork instance at patchwork.kernel.org though.

Regards
Jonas

#7 lore raw
Quoted 10 lines · Jonas Gorski
Quoted 9 lines · Kalle Valo
Quoted 7 lines · Jonas Gorski
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Jonas Gorski
Quoted 3 lines · Kalle Valo
Quoted 1 line · Michael B=C3=BCsch <[email protected]> writes:

strncpy might not NUL-terminate the string, if the name equals the =

buffer size.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Use strlcpy instead.

This is weird, with all the patches you submitted last week I get th=

is

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

if I download the patch from patchwork:

$ git am -s 1.mbox
Patch is empty. Was it split wrong?

But if I download the patch directly from my IMAP folder I have no problems:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
$ git am -s 1.mbox
Applying: b43/leds: Ensure NUL-termination of LED name string

This happens even without my custom patchwork script so this has something to do with the patchwork server, but it's not obvious to me what triggers it. IIRC I have not seen anything like this before. It seems that you didn't use git-send-email, I strongly suggest to use =

that

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

just to avoid problems like this.

Looks like patchwork mishandles the pgp signature, the patchwork mbox=

has

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512;
boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/=

pgp-signature"

Quoted 30 lines
Quoted 30 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines

as the only content-type (and the boundary is nowhere to be found), while the one in my inbox has

Quoted 7 lines

Content-Type: multipart/signed; micalg=3Dpgp-sha512; boundary=3D"Sig_/EN90ciRq4eWXDUcnZABQ0Ak"; protocol=3D"application/pgp-signature"

--Sig_/EN90ciRq4eWXDUcnZABQ0Ak
Content-Type: text/plain; charset=3DUS-ASCII
Content-Transfer-Encoding: quoted-printable

When I remove the Content-Type: line(s) from the mbox from patchwork, git recognises it again as a patch. I guess git am ignores everything until the boundary, which got dropped by patchwork, so it never finds the actual patch.

Quoted 7 lines
Quoted 3 lines

Awesome, thanks for debugging this! It would be great if someone could report this to the patchwork maintainers, I don't have the time right now.

Silly question, but who *are* the maintainers? I just spend several minutes on https://patchwork.kernel.org/ and google, and failed to find any contact information.

Not a silly question at all. I'm not sure what's the preferred way to report bugs but at least I found this:

http://jk.ozlabs.org/projects/patchwork/

Quoted 7 lines
Quoted 3 lines

I guess they use the github tracker:

https://github.com/getpatchwork/patchwork/issues/

Going through the issues, I guess this is already fixed in master with

https://github.com/getpatchwork/patchwork/commit/e27ff061dc01e51967a97888=

4a5c59152863ab9c

Quoted 3 lines

and queued for the next 2.1 release (or not? the stable/2.1 branch also contains a version bump to 2.2 ... )

Very nice, thanks so much for investigating this!

Quoted 2 lines

I have still no idea who runs the patchwork instance at patchwork.kernel.org though.

The admins are Linux Foundation's IT group and one can file a ticket via [email protected] But IMHO there's no need to do that, this is the first time I'm seeing the bug and it can easily wait until patchwork.kernel.org is updated anyway. As long as the issue is fixed upstream.

--=20
Kalle Valo