From patchwork Thu Jul 16 02:13:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Dykstra X-Patchwork-Id: 29839 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 05F46B7B71 for ; Thu, 16 Jul 2009 12:13:49 +1000 (EST) Received: by ozlabs.org (Postfix) id E9EDCDDDA2; Thu, 16 Jul 2009 12:13:48 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 84721DDDA0 for ; Thu, 16 Jul 2009 12:13:48 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757117AbZGPCN1 (ORCPT ); Wed, 15 Jul 2009 22:13:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757107AbZGPCN1 (ORCPT ); Wed, 15 Jul 2009 22:13:27 -0400 Received: from wf-out-1314.google.com ([209.85.200.170]:53825 "EHLO wf-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757096AbZGPCN0 (ORCPT ); Wed, 15 Jul 2009 22:13:26 -0400 Received: by wf-out-1314.google.com with SMTP id 26so1366137wfd.4 for ; Wed, 15 Jul 2009 19:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:content-type :date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=LjpPrWHMzzWIErX0j0owvQsMmlxBai3XxIfShA3UatQ=; b=XNPdMbrbvxGLtTHwu86iMT4I3hgSNXnFMYENUuPvNu6IMRvu0c8w/dmk8jarW88mVZ f5Smtjgl7GFbUeaMBpXcW4wJNluhc672TQ/imNcCA+6nekXDeFKL3cWnjBQdVmp338SA +7GwsqgN3KUW+BfQXpy5Y9OWRvgqrK6xyTLNg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; b=ijQbhevaG1PvzL4nXQ4Q8C0BLxcpoKGcr6MYNZ2d3x7FpwmcGYc8fkN699IU8EyycD 020ZiKuD6gz9hvy9JhUs7Fz2VTbwRUeJqvhW6kRVSXfial38vKsSBz/e71Ck1Zz+VMmi rfeV2pxLGFUNL1NjeXPHtyRaa2eLrrybop8h8= Received: by 10.142.135.16 with SMTP id i16mr2014299wfd.29.1247710406305; Wed, 15 Jul 2009 19:13:26 -0700 (PDT) Received: from ?192.168.221.201? ([24.118.80.156]) by mx.google.com with ESMTPS id 31sm15999272wff.38.2009.07.15.19.13.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 15 Jul 2009 19:13:25 -0700 (PDT) Subject: [PATCH] tcp: Fix MD5 signature checking on IPv4 mapped sockets From: John Dykstra To: netdev , Stephen Hemminger Date: Thu, 16 Jul 2009 02:13:21 +0000 Message-Id: <1247710401.7129.25.camel@Maple> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fix MD5 signature checking so that an IPv4 active open to an IPv6 socket can succeed. In particular, use the correct address family's signature generation function for the SYN/ACK. Reported-by: Stephen Hemminger Signed-off-by: John Dykstra --- include/net/tcp.h | 5 +++++ net/ipv4/tcp_ipv4.c | 1 + net/ipv4/tcp_output.c | 3 ++- net/ipv6/tcp_ipv6.c | 1 + 4 files changed, 9 insertions(+), 1 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 19f4150..88af843 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1425,6 +1425,11 @@ struct tcp_request_sock_ops { #ifdef CONFIG_TCP_MD5SIG struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk, struct request_sock *req); + int (*calc_md5_hash) (char *location, + struct tcp_md5sig_key *md5, + struct sock *sk, + struct request_sock *req, + struct sk_buff *skb); #endif }; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 5a1ca26..7c107eb 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1160,6 +1160,7 @@ struct request_sock_ops tcp_request_sock_ops __read_mostly = { #ifdef CONFIG_TCP_MD5SIG static struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = { .md5_lookup = tcp_v4_reqsk_md5_lookup, + .calc_md5_hash = tcp_v4_md5_hash_skb, }; #endif diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 5bdf08d..17b049f 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2261,7 +2261,8 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst, #ifdef CONFIG_TCP_MD5SIG /* Okay, we have all we need - do the md5 hash if needed */ if (md5) { - tp->af_specific->calc_md5_hash(md5_hash_location, + tcp_rsk(req)->af_specific->calc_md5_hash(md5_hash_location, + md5, NULL, req, skb); } #endif diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 58810c6..ae3d657 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -896,6 +896,7 @@ struct request_sock_ops tcp6_request_sock_ops __read_mostly = { #ifdef CONFIG_TCP_MD5SIG static struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = { .md5_lookup = tcp_v6_reqsk_md5_lookup, + .calc_md5_hash = tcp_v6_md5_hash_skb, }; #endif