phonet: some signedness bugs
Subsystems (4)
PATCH 1/1 phonet: some signedness bugs
Dan Rosenberg pointed out that there were some signed comparison bugs in the phonet protocol.
http://marc.info/?l=full-disclosure&m9424528425330&w=2
If you have already have CAP_SYS_ADMIN then you could use the bugs to get root, or someone could cause an oops by mistake.
include/net/phonet/phonet.h +2 -2
@@ -107,8 +107,8 @@ struct phonet_protocol {int sock_type; }; -int phonet_proto_register (int protocol,struct phonet_protocol *pp); -void phonet_proto_unregister (int protocol,struct phonet_protocol *pp); +int phonet_proto_register (unsigned int protocol,struct phonet_protocol *pp); +void phonet_proto_unregister (unsigned int protocol,struct phonet_protocol *pp);int phonet_sysctl_init (void );void phonet_sysctl_exit (void );
net/phonet/af_phonet.c +5 -5
@@ -37,7 +37,7 @@/* Transport protocol registration */ static struct phonet_protocol *proto_tab[PHONET_NPROTO ]__read_mostly ; -static struct phonet_protocol *phonet_proto_get (int protocol) +static struct phonet_protocol *phonet_proto_get (unsigned int protocol) {struct phonet_protocol *pp;
@@ -60,8 +60,8 @@ static inline void phonet_proto_put(struct phonet_protocol *pp)/* protocol family functions */ -static int pn_socket_create (struct net *net,struct socket *sock,int protocol, -int kern) +static int pn_socket_create (struct net *net,struct socket *sock, +unsigned int protocol,int kern) {struct sock *sk;struct pn_sock *pn;
@@ -458,7 +458,7 @@ static struct packet_type phonet_packet_type __read_mostly = {static DEFINE_MUTEX (proto_tab_lock); -int __init_or_module phonet_proto_register(int protocol, +int __init_or_module phonet_proto_register(unsigned int protocol,struct phonet_protocol *pp) {int err =0 ;
@@ -481,7 +481,7 @@ int __init_or_module phonet_proto_register(int protocol, }EXPORT_SYMBOL (phonet_proto_register); -void phonet_proto_unregister (int protocol,struct phonet_protocol *pp) +void phonet_proto_unregister (unsigned int protocol,struct phonet_protocol *pp) {mutex_lock (&proto_tab_lock);BUG_ON (proto_tab[protocol] != pp);
David Miller
maintainerFrom: Dan Carpenter <[email protected]>
Date: Fri, 7 Jan 2011 23:37:55 +0300
Quoted 9 lines
Dan Rosenberg pointed out that there were some signed comparison bugs in the phonet protocol.
http://marc.info/?l=full-disclosure&m=129424528425330&w=2
If you have already have
CAP_SYS_ADMINthen you could use the bugs to get root, or someone could cause an oops by mistake.Signed-off-by Dan Carpenter <[email protected]>
Applied and queued up for -stable, thanks Dan.
David Miller
maintainerFrom: David Miller <[email protected]>
Date: Sun, 09 Jan 2011 16:45:48 -0800 (PST)
Quoted 6 lines
From: Dan Carpenter <[email protected]>
Date: Fri, 7 Jan 2011 23:37:55 +0300Quoted 3 lines
Dan Rosenberg pointed out that there were some signed comparison bugs in the phonet protocol.
Quoted 8 lines
Quoted 6 lines
http://marc.info/?l=full-disclosure&m=129424528425330&w=2
If you have already have
CAP_SYS_ADMINthen you could use the bugs to get root, or someone could cause an oops by mistake.Signed-off-by Dan Carpenter <[email protected]>Applied and queued up for -stable, thanks Dan.
Actually I'm reverting this.
You can't change the prototype of pn_socket_create() because if you do then it doesn't match up with the prototype required by net_proto_family->create().
You didn't see this warning in your build?
net/phonet/af_phonet.c:124:2: warning: initialization from incompatible pointer type
Quoted 2 lines · you
Dan Rosenberg pointed out that there were some signed comparison bugs in the phonet protocol.
There are two ways to solve this: change *only* the proto_get function to use an unsigned parameter, or cast the protocol to unsigned in the comparison.
As David pointed out, your patch breaks the socket() callback prototype.
Signature · 2 lines
Rémi Denis-Courmont Nokia Devices R&D, Maemo Software, Helsinki
Quoted 9 lines · Rémi Denis-Courmont
Quoted 2 lines · you
Dan Rosenberg pointed out that there were some signed comparison bugs in the phonet protocol.
There are two ways to solve this: change *only* the
proto_getfunction to use an unsigned parameter, or cast the protocol to unsigned in the comparison.As David pointed out, your patch breaks the
socket()callback prototype.
Yes. I really appologize for that. I'll send version 2 with that create() change dropped. It's not needed.
I would like to keep the change to phonet_proto_register() because the
check in there isn't right and it's similar to phonet_proto_get(). We
may as well keep phonet_proto_unregister() as well so it's symmetric. Let me know if you disagree and I'll redo it.
regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · you
I would like to keep the change to
phonet_proto_register()because the
check in there isn't right and it's similar tophonet_proto_get(). We
may as well keepphonet_proto_unregister()as well so it's symmetric. Let me know if you disagree and I'll redo it.
Sounds sensible to me.
Signature · 2 lines
Rémi Denis-Courmont Nokia Devices R&D, Maemo Software, Helsinki
PATCH v2 1/1 phonet: some signedness bugs
In reply to Rémi Denis-CourmontDan Rosenberg pointed out that there were some signed comparison bugs in the phonet protocol.
http://marc.info/?l=full-disclosure&m9424528425330&w=2
The problem is that we check for array overflows but "protocol" is signed and we don't check for array underflows. If you have already have CAP_SYS_ADMIN then you could use the bugs to get root, or someone could cause an oops by mistake.
---
v2: in v1 I changed pn_socket_create() but that change caused a compiler warning. That part of the patch wasn't needed so I've just dropped.
include/net/phonet/phonet.h +2 -2
@@ -107,8 +107,8 @@ struct phonet_protocol {int sock_type; }; -int phonet_proto_register (int protocol,struct phonet_protocol *pp); -void phonet_proto_unregister (int protocol,struct phonet_protocol *pp); +int phonet_proto_register (unsigned int protocol,struct phonet_protocol *pp); +void phonet_proto_unregister (unsigned int protocol,struct phonet_protocol *pp);int phonet_sysctl_init (void );void phonet_sysctl_exit (void );
net/phonet/af_phonet.c +3 -3
@@ -37,7 +37,7 @@/* Transport protocol registration */ static struct phonet_protocol *proto_tab[PHONET_NPROTO ]__read_mostly ; -static struct phonet_protocol *phonet_proto_get (int protocol) +static struct phonet_protocol *phonet_proto_get (unsigned int protocol) {struct phonet_protocol *pp;
@@ -458,7 +458,7 @@ static struct packet_type phonet_packet_type __read_mostly = {static DEFINE_MUTEX (proto_tab_lock); -int __init_or_module phonet_proto_register(int protocol, +int __init_or_module phonet_proto_register(unsigned int protocol,struct phonet_protocol *pp) {int err =0 ;
@@ -481,7 +481,7 @@ int __init_or_module phonet_proto_register(int protocol, }EXPORT_SYMBOL (phonet_proto_register); -void phonet_proto_unregister (int protocol,struct phonet_protocol *pp) +void phonet_proto_unregister (unsigned int protocol,struct phonet_protocol *pp) {mutex_lock (&proto_tab_lock);BUG_ON (proto_tab[protocol] != pp);
Quoted 11 lines · you
Dan Rosenberg pointed out that there were some signed comparison bugs in the phonet protocol.
http://marc.info/?l=full-disclosure&m=129424528425330&w=2
The problem is that we check for array overflows but "protocol" is signed and we don't check for array underflows. If you have already have
CAP_SYS_ADMINthen you could use the bugs to get root, or someone could cause an oops by mistake.Signed-off-by Dan Carpenter <[email protected]>
Signature · 2 lines
Rémi Denis-Courmont Nokia Devices R&D, Maemo Software, Helsinki
From: Dan Carpenter <[email protected]>
Date: Mon, 10 Jan 2011 17:06:58 +0300
Quoted 11 lines
Dan Rosenberg pointed out that there were some signed comparison bugs in the phonet protocol.
http://marc.info/?l=full-disclosure&m=129424528425330&w=2
The problem is that we check for array overflows but "protocol" is signed and we don't check for array underflows. If you have already have
CAP_SYS_ADMINthen you could use the bugs to get root, or someone could cause an oops by mistake.Signed-off-by Dan Carpenter <[email protected]>
Applied.
Quoted 8 lines · you
From: Dan Carpenter <[email protected]>
Date: Mon, 10 Jan 2011 17:06:58 +0300Quoted 5 lines
Dan Rosenberg pointed out that there were some signed comparison bugs in the phonet protocol.
Quoted 8 lines
Quoted 6 lines
The problem is that we check for array overflows but "protocol" is signed and we don't check for array underflows. If you have already have
CAP_SYS_ADMINthen you could use the bugs to get root, or someone could cause an oops by mistake.Signed-off-by Dan Carpenter <[email protected]>Applied.
Shouldn't this be sent to stable trees?
Signature · 2 lines
Rémi Denis-Courmont Nokia Devices R&D, Maemo Software, Helsinki
David Miller
maintainerFrom: "Rémi Denis-Courmont" <[email protected]>
Date: Thu, 13 Jan 2011 14:32:57 +0200
Quoted 14 lines · you
Quoted 13 lines
From: Dan Carpenter <[email protected]>
Date: Mon, 10 Jan 2011 17:06:58 +0300Quoted 10 lines
Dan Rosenberg pointed out that there were some signed comparison bugs in the phonet protocol.
http://marc.info/?l=full-disclosure&m=129424528425330&w=2
The problem is that we check for array overflows but "protocol" is signed and we don't check for array underflows. If you have already have
CAP_SYS_ADMINthen you could use the bugs to get root, or someone could cause an oops by mistake.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Dan Carpenter <[email protected]>Applied.
Shouldn't this be sent to stable trees?
It will be.