public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: PATCH: tcp rfc 2385 security/bugfix for sparc64
@ 2007-10-16 16:47 Matthias Dellweg
  2007-10-30  3:51 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Matthias Dellweg @ 2007-10-16 16:47 UTC (permalink / raw)
  To: David Miller; +Cc: Peter Lieven, sparclinux, alan, torvalds, linux-kernel

Hi David,
while reviewing the tcp_md5-related code further i came across with another
two of these casts which you probably have missed. I don't actually think
that they impose a problem by now, but as you said we should remove them.
Matthias


--- linux-2.6.23.1.orig/net/ipv4/tcp_ipv4.c     2007-10-16 17:25:05.000000000 +0200
+++ linux-2.6.23.1/net/ipv4/tcp_ipv4.c  2007-10-16 17:50:05.000000000 +0200
@@ -857,16 +857,16 @@ int tcp_v4_md5_do_add(struct sock *sk, _
                      u8 *newkey, u8 newkeylen)
 {
        /* Add Key to the list */
-       struct tcp4_md5sig_key *key;
+       struct tcp_md5sig_key *key;
        struct tcp_sock *tp = tcp_sk(sk);
        struct tcp4_md5sig_key *keys;

-       key = (struct tcp4_md5sig_key *)tcp_v4_md5_do_lookup(sk, addr);
+       key = tcp_v4_md5_do_lookup(sk, addr);
        if (key) {
                /* Pre-existing entry - just update that one. */
-               kfree(key->base.key);
-               key->base.key = newkey;
-               key->base.keylen = newkeylen;
+               kfree(key->key);
+               key->key = newkey;
+               key->keylen = newkeylen;
        } else {
                struct tcp_md5sig_info *md5sig;

--- linux-2.6.23.1.orig/net/ipv6/tcp_ipv6.c     2007-10-16 17:47:57.000000000 +0200
+++ linux-2.6.23.1/net/ipv6/tcp_ipv6.c  2007-10-16 17:49:25.000000000 +0200
@@ -560,16 +560,16 @@ static int tcp_v6_md5_do_add(struct sock
                             char *newkey, u8 newkeylen)
 {
        /* Add key to the list */
-       struct tcp6_md5sig_key *key;
+       struct tcp_md5sig_key *key;
        struct tcp_sock *tp = tcp_sk(sk);
        struct tcp6_md5sig_key *keys;

-       key = (struct tcp6_md5sig_key*) tcp_v6_md5_do_lookup(sk, peer);
+       key = tcp_v6_md5_do_lookup(sk, peer);
        if (key) {
                /* modify existing entry - just update that one */
-               kfree(key->base.key);
-               key->base.key = newkey;
-               key->base.keylen = newkeylen;
+               kfree(key->key);
+               key->key = newkey;
+               key->keylen = newkeylen;
        } else {
                /* reallocate new list if current one is full. */
                if (!tp->md5sig_info) {


Signed-off-by: Matthias M. Dellweg <2500@gmx.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread
* PATCH: tcp rfc 2385 security/bugfix for sparc64
@ 2007-09-28 20:42 Peter Lieven
  2007-09-28 21:20 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Lieven @ 2007-09-28 20:42 UTC (permalink / raw)
  To: sparclinux, davem; +Cc: alan, torvalds, linux-kernel

TCP MD5 signatures on sparc64 (big-endian) completely fail on current
kernel releases in interoperability with Cisco/Foundry or other
little-endian linux systems.

The root cause is a cast in the return statement of tcp_v4_md5_do_lookup,
where a tcp4_md5sig_key is casted onto tcp_md5sig_key without proper
conversion. On little-endian systems the upper 8 bits are cut of which
yields the expected behaviour. However, on big-endian systems (like
sparc64) only the most significant 8 bits are preserved. Since
TCP_MD5SIG_MAXKEYLEN is 80, this always yields 0.

In the calculation of the md5 signature afterwards the key is therefore
not appended to the tcp segment which could result in a security problem
since only the presence of a md5 signature is checked, and the key itself
doesn't matter.

--- linux.old/include/net/tcp.h 2007-09-28 21:43:26.000000000 +0200 +++
linux/include/net/tcp.h     2007-09-28 21:45:35.000000000 +0200 @@ -1055,6
+1055,7 @@ static inline void clear_all_retrans_hin
 struct crypto_hash;

 /* - key database */
+/* this should be compatible with the head of the following two structs */
 struct tcp_md5sig_key {
        u8                      *key;
        u8                      keylen;
@@ -1062,13 +1063,13 @@ struct tcp_md5sig_key {

 struct tcp4_md5sig_key {
        u8                      *key;
-       u16                     keylen;
+       u8                      keylen;
        __be32                  addr;
 };

 struct tcp6_md5sig_key {
        u8                      *key;
-       u16                     keylen;
+       u8                      keylen;
 #if 0
        u32                     scope_id;       /* XXX */
 #endif


Signed-off-by: Peter Lieven <pl@dlh.net>
Signed-off-by: Matthias M. Dellweg <2500@gmx.de>




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-10-30  3:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-16 16:47 PATCH: tcp rfc 2385 security/bugfix for sparc64 Matthias Dellweg
2007-10-30  3:51 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2007-09-28 20:42 Peter Lieven
2007-09-28 21:20 ` David Miller
2007-09-28 21:30   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox