Skip to contentSkip to conversation

net/core: remove address space warnings on verify_iovec()

PATCH Applied Namhyung Kim 2 participants 4 messages Sep 8, 2010 – Sep 9, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 net/core: remove address space warnings on verify_iovec()

move_addr_to_kernel() and copy_from_user() requires their argument as __user pointer but were missing proper markups. Add it. This removes following warnings from sparse.

net/core/iovec.c:44:52: warning: incorrect type in argument 1 (different address spaces)
net/core/iovec.c:44:52: expected void [noderef] <asn:1>*uaddr
net/core/iovec.c:44:52: got void *msg_name
net/core/iovec.c:55:34: warning: incorrect type in argument 2 (different address spaces)
net/core/iovec.c:55:34: expected void const [noderef] <asn:1>*from
net/core/iovec.c:55:34: got struct iovec *msg_iov

---
 net/core/iovec.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
net/core/iovec.c +4 -2
index 1cd98df..f4657c2 100644
@@ -41,7 +41,9 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address,
 
 	if (m->msg_namelen) {
 		if (mode == VERIFY_READ) {
-			err = move_addr_to_kernel(m->msg_name, m->msg_namelen,
+			void __user *namep;
+			namep = (void __user __force *) m->msg_name;
+			err = move_addr_to_kernel(namep, m->msg_namelen,
 						  address);
 			if (err < 0)
 				return err;
@@ -52,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address,
 	}
 
 	size = m->msg_iovlen * sizeof(struct iovec);
-	if (copy_from_user(iov, m->msg_iov, size))
+	if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
 		return -EFAULT;
 
 	m->msg_iov = iov;
Signature · 1 line
1.7.2.2
#1 lore raw

PATCH 2/2 net/core: add lock context change annotations in net/core/sock.c

__lock_sock() and __release_sock() releases and regrabs lock but were missing proper annotations. Add it. This removes following warning from sparse. (Currently __lock_sock() does not emit any warning about it but I think it is better to add also.)

net/core/sock.c:1580:17: warning: context imbalance in '__release_sock' - unexpected unlock

---
 net/core/sock.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/core/sock.c +4 -0
index b05b9b6..f3a06c4 100644
@@ -1557,6 +1557,8 @@ struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size,
 EXPORT_SYMBOL(sock_alloc_send_skb);
 
 static void __lock_sock(struct sock *sk)
+	__releases(&sk->sk_lock.slock)
+	__acquires(&sk->sk_lock.slock)
 {
 	DEFINE_WAIT(wait);
 
@@ -1573,6 +1575,8 @@ static void __lock_sock(struct sock *sk)
 }
 
 static void __release_sock(struct sock *sk)
+	__releases(&sk->sk_lock.slock)
+	__acquires(&sk->sk_lock.slock)
 {
 	struct sk_buff *skb = sk->sk_backlog.head;
 
Signature · 1 line
1.7.2.2
maintainer Applied
#2 lore raw

Re: [PATCH 2/2] net/core: add lock context change annotations in net/core/sock.c

From: Namhyung Kim <[email protected]>
Date: Wed, 8 Sep 2010 22:48:48 +0900

Quoted 8 lines

__lock_sock() and __release_sock() releases and regrabs lock but were missing proper annotations. Add it. This removes following warning from sparse. (Currently __lock_sock() does not emit any warning about it but I think it is better to add also.)

net/core/sock.c:1580:17: warning: context imbalance in '__release_sock' - unexpected unlock

Applied.

maintainer Applied
#3 lore raw
In reply to Namhyung Kim

From: Namhyung Kim <[email protected]>
Date: Wed, 8 Sep 2010 22:48:47 +0900

Quoted 4 lines

move_addr_to_kernel() and copy_from_user() requires their argument as __user pointer but were missing proper markups. Add it. This removes following warnings from sparse.

Quoted 8 lines

net/core/iovec.c:44:52: warning: incorrect type in argument 1 (different address spaces)
net/core/iovec.c:44:52: expected void [noderef] <asn:1>*uaddr
net/core/iovec.c:44:52: got void *msg_name
net/core/iovec.c:55:34: warning: incorrect type in argument 2 (different address spaces)
net/core/iovec.c:55:34: expected void const [noderef] <asn:1>*from
net/core/iovec.c:55:34: got struct iovec *msg_iov

Applied.