Skip to contentSkip to conversation

af_iucv updates

PATCH Applied Julian Wiedmann 3 participants 7 messages Jun 23, 2017 – Jun 25, 2017

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

cover af_iucv updates

Hi Dave,
please apply two af_iucv patches for net-next.

Thanks,
Julian

Hans Wippel (1):
net/iucv: improve endianness handling

Mateusz Jurczyk (1):
af_iucv: Move sockaddr length checks to before accessing sa_family in
bind and connect handlers

 net/iucv/af_iucv.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
Signature · 1 line
2.11.2
#1 lore raw

PATCH 1/2 net/iucv: improve endianness handling

From: Hans Wippel <[email protected]>

Use proper endianness conversion for an skb protocol assignment. Given that IUCV is only available on big endian systems (s390), this simply avoids an endianness warning reported by sparse.

---
 net/iucv/af_iucv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/iucv/af_iucv.c +1 -1
index 2cf9d59f1b72..05112094d76b 100644
@@ -362,7 +362,7 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock,
 		else
 			skb_trim(skb, skb->dev->mtu);
 	}
-	skb->protocol = ETH_P_AF_IUCV;
+	skb->protocol = cpu_to_be16(ETH_P_AF_IUCV);
 	nskb = skb_clone(skb, GFP_ATOMIC);
 	if (!nskb)
 		return -ENOMEM;
Signature · 1 line
2.11.2
maintainer Applied
#2 lore raw

Re: [PATCH net-next 1/2] net/iucv: improve endianness handling

From: Julian Wiedmann <[email protected]>
Date: Fri, 23 Jun 2017 19:32:27 +0200

Quoted 10 lines

From: Hans Wippel <[email protected]>

Use proper endianness conversion for an skb protocol assignment. Given that IUCV is only available on big endian systems (s390), this simply avoids an endianness warning reported by sparse.

Applied.

#3 lore raw

PATCH 2/2 af_iucv: Move sockaddr length checks to before accessing sa_family in bind and connect handlers

In reply to Julian Wiedmann

From: Mateusz Jurczyk <[email protected]>

Verify that the caller-provided sockaddr structure is large enough to contain the sa_family field, before accessing it in bind() and connect() handlers of the AF_IUCV socket. Since neither syscall enforces a minimum size of the corresponding memory region, very short sockaddrs (zero or one byte long) result in operating on uninitialized memory while referencing .sa_family.

Fixes 52a82e23b9f2 ("af_iucv: Validate socket address length in iucv_sock_bind()")
[jwi: removed unneeded null-check for addr]
---
 net/iucv/af_iucv.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
net/iucv/af_iucv.c +3 -5
index 05112094d76b..ac033e413bc5 100644
@@ -715,10 +715,8 @@ static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
 	char uid[9];
 
 	/* Verify the input sockaddr */
-	if (!addr || addr->sa_family != AF_IUCV)
-		return -EINVAL;
-
-	if (addr_len < sizeof(struct sockaddr_iucv))
+	if (addr_len < sizeof(struct sockaddr_iucv) ||
+	    addr->sa_family != AF_IUCV)
 		return -EINVAL;
 
 	lock_sock(sk);
@@ -862,7 +860,7 @@ static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr,
 	struct iucv_sock *iucv = iucv_sk(sk);
 	int err;
 
-	if (addr->sa_family != AF_IUCV || alen < sizeof(struct sockaddr_iucv))
+	if (alen < sizeof(struct sockaddr_iucv) || addr->sa_family != AF_IUCV)
 		return -EINVAL;
 
 	if (sk->sk_state != IUCV_OPEN && sk->sk_state != IUCV_BOUND)
Signature · 1 line
2.11.2
#4 lore raw

Re: [PATCH net-next 2/2] af_iucv: Move sockaddr length checks to before accessing sa_family in bind and connect handlers

Quoted 8 lines · Julian Wiedmann

From: Mateusz Jurczyk <[email protected]>

Verify that the caller-provided sockaddr structure is large enough to contain the sa_family field, before accessing it in bind() and connect() handlers of the AF_IUCV socket. Since neither syscall enforces a minimum size of the corresponding memory region, very short sockaddrs (zero or one byte long) result in operating on uninitialized memory while referencing .sa_family.

Won't it make sense to generally check the minimum length for .sa_family at a single point before fixing all called sites?

Regards,
Oliver

Quoted 36 lines
Fixes 52a82e23b9f2 ("af_iucv: Validate socket address length in iucv_sock_bind()")
[jwi: removed unneeded null-check for addr]
---
 net/iucv/af_iucv.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
net/iucv/af_iucv.c +3 -5
index 05112094d76b..ac033e413bc5 100644
@@ -715,10 +715,8 @@ static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
 	char uid[9];
 
 	/* Verify the input sockaddr */
-	if (!addr || addr->sa_family != AF_IUCV)
-		return -EINVAL;
-
-	if (addr_len < sizeof(struct sockaddr_iucv))
+	if (addr_len < sizeof(struct sockaddr_iucv) ||
+	    addr->sa_family != AF_IUCV)
 		return -EINVAL;
 
 	lock_sock(sk);
@@ -862,7 +860,7 @@ static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr,
 	struct iucv_sock *iucv = iucv_sk(sk);
 	int err;
 
-	if (addr->sa_family != AF_IUCV || alen < sizeof(struct sockaddr_iucv))
+	if (alen < sizeof(struct sockaddr_iucv) || addr->sa_family != AF_IUCV)
 		return -EINVAL;
 
 	if (sk->sk_state != IUCV_OPEN && sk->sk_state != IUCV_BOUND)
maintainer
#5 lore raw

Re: [PATCH net-next 2/2] af_iucv: Move sockaddr length checks to before accessing sa_family in bind and connect handlers

From: Oliver Hartkopp <[email protected]>
Date: Fri, 23 Jun 2017 19:36:12 +0200

Quoted 12 lines · Julian Wiedmann
Quoted 8 lines

From: Mateusz Jurczyk <[email protected]>

Verify that the caller-provided sockaddr structure is large enough to contain the sa_family field, before accessing it in bind() and connect() handlers of the AF_IUCV socket. Since neither syscall enforces a minimum size of the corresponding memory region, very short sockaddrs (zero or one byte long) result in operating on uninitialized memory while referencing .sa_family.

Quoted 2 lines

Won't it make sense to generally check the minimum length for .sa_family at a single point before fixing all called sites?

We had this discussion last week and we decided that putting it into the handlers is the way to go for now.

maintainer Applied
#6 lore raw

Re: [PATCH net-next 2/2] af_iucv: Move sockaddr length checks to before accessing sa_family in bind and connect handlers

In reply to Julian Wiedmann

From: Julian Wiedmann <[email protected]>
Date: Fri, 23 Jun 2017 19:32:28 +0200

Quoted 9 lines

From: Mateusz Jurczyk <[email protected]>

Verify that the caller-provided sockaddr structure is large enough to contain the sa_family field, before accessing it in bind() and connect() handlers of the AF_IUCV socket. Since neither syscall enforces a minimum size of the corresponding memory region, very short sockaddrs (zero or one byte long) result in operating on uninitialized memory while referencing .sa_family.

Quoted 4 lines
Fixes 52a82e23b9f2 ("af_iucv: Validate socket address length in iucv_sock_bind()")
[jwi: removed unneeded null-check for addr]

Applied.