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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <812f80051bdd23912e1e7bab36e29d9f4d71775b.1430769295.git.joe@perches.com>
Date:	Mon,  4 May 2015 13:05:45 -0700
From:	Joe Perches <joe@...ches.com>
To:	netdev@...r.kernel.org
Subject: [RFC PATCH net-next 1/8] skb: Add skb_put_uchar

skb_put currently returns an unsigned char *.

There are uses like "*skb_put(skb, 1) = <char>" that might be
better represented by a new skb_put_uchar(<char>) function.

This would allow the skb_put function to be converted to
return void and eliminate many casts of the unsigned char *
return to some other type.

Signed-off-by: Joe Perches <joe@...ches.com>
---
 include/linux/skbuff.h |  1 +
 net/core/skbuff.c      | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index acb83e2..894071e1 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1679,6 +1679,7 @@ static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
  */
 unsigned char *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
 unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
+void *skb_put_uchar(struct sk_buff *skb, unsigned char uc);
 static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
 {
 	unsigned char *tmp = skb_tail_pointer(skb);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 3cfff2a..73e20ad 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1410,6 +1410,32 @@ unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
 EXPORT_SYMBOL(skb_put);
 
 /**
+ *	skb_put_uchar - add an unsigned char to a buffer
+ *	@skb: buffer to use
+ *	@uc: unsigned char to add
+ *
+ *	This function extends the used data area of the buffer. If this would
+ *	exceed the total buffer size the kernel will panic. A pointer to the
+ *	first byte of the extra data is returned.
+ */
+void *skb_put_uchar(struct sk_buff *skb, unsigned char uc)
+{
+	unsigned char *tmp = skb_tail_pointer(skb);
+
+	SKB_LINEAR_ASSERT(skb);
+
+	skb->tail++;
+	skb->len++;
+	if (unlikely(skb->tail > skb->end))
+		skb_over_panic(skb, 1, __builtin_return_address(0));
+
+	*tmp = uc;
+
+	return tmp;
+}
+EXPORT_SYMBOL(skb_put_uchar);
+
+/**
  *	skb_push - add data to the start of a buffer
  *	@skb: buffer to use
  *	@len: amount of data to add
-- 
2.1.4

--
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