lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 26 Apr 2014 14:26:35 -0700 (PDT)
From:	Tom Herbert <therbert@...gle.com>
To:	davem@...emloft.net, netdev@...r.kernel.org
Subject: [PATCH 9/9 v2] net: Add sysctl to trust checksum_complete

Currently if a device provides CHECKSUM_COMPLETE but the checksum
is calculated to be invalid we recompute the checksum and try
again in software. On the other hand, if device returns
CHECKSUM_UNNECESSARY we implicitly trust it and don't verify what it
did. This seems backwards!

Add a sysctl to trust the device and report an invalid checksum when
CHECKSUM_COMPLETE shows it is incorrect. sysctl defaults to enabled.

Signed-off-by: Tom Herbert <therbert@...gle.com>
---
 include/linux/skbuff.h     | 7 ++++++-
 net/core/dev.c             | 3 +++
 net/core/sysctl_net_core.c | 7 +++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 3b14acc..f3c6018 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2763,6 +2763,8 @@ static inline __sum16 __skb_checksum_validate_unnecessary(struct sk_buff *skb,
 	return 1;
 }
 
+extern int sysctl_trust_dev_checksum;
+
 /*
  * Validate (init) checksum based on checksum complete.
  *
@@ -2775,9 +2777,12 @@ static inline __sum16 __skb_checksum_validate_complete(struct sk_buff *skb,
 						       __wsum psum)
 {
 	if (skb->ip_summed == CHECKSUM_COMPLETE) {
-		if (!csum_fold(csum_add(psum, skb->csum))) {
+		__sum16 csum = csum_fold(csum_add(psum, skb->csum));
+		if (!csum) {
 			skb->ip_summed = CHECKSUM_UNNECESSARY;
 			return 0;
+		} else if (sysctl_trust_dev_checksum) {
+			return csum;
 		}
 	}
 
diff --git a/net/core/dev.c b/net/core/dev.c
index 11d70e3..4f7980a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2918,6 +2918,9 @@ int netdev_tstamp_prequeue __read_mostly = 1;
 int netdev_budget __read_mostly = 300;
 int weight_p __read_mostly = 64;            /* old backlog weight */
 
+int sysctl_trust_dev_checksum = 1;
+EXPORT_SYMBOL(sysctl_trust_dev_checksum);
+
 /* Called with irq disabled */
 static inline void ____napi_schedule(struct softnet_data *sd,
 				     struct napi_struct *napi)
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index cf9cd13..246b9e3 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -263,6 +263,13 @@ static struct ctl_table net_core_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec
 	},
+	{
+		.procname	= "trust_dev_checksum",
+		.data		= &sysctl_trust_dev_checksum,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec
+	},
 #ifdef CONFIG_BPF_JIT
 	{
 		.procname	= "bpf_jit_enable",
-- 
1.9.1.423.g4596e3a

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ