af_iucv updates
Subsystems (4)
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
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
@@ -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
PATCH 2/2 af_iucv: Move sockaddr length checks to before accessing sa_family in bind and connect handlers
In reply to Julian WiedmannFrom: 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.
--- net/iucv/af_iucv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
net/iucv/af_iucv.c +3 -5
@@ -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
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_familyfield, before accessing it inbind()andconnect()handlers of theAF_IUCVsocket. 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()")Signed-off-by Mateusz Jurczyk <[email protected]>[jwi: removed unneeded null-check for addr]Signed-off-by Julian Wiedmann <[email protected]>--- net/iucv/af_iucv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)net/iucv/af_iucv.c +3
-5@@ -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 )
David Miller
maintainerRe: [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_familyfield, before accessing it inbind()andconnect()handlers of theAF_IUCVsocket. 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.
Re: [PATCH net-next 1/2] net/iucv: improve endianness handling
In reply to Julian WiedmannFrom: 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.
Signed-off-by Hans Wippel <[email protected]>Reviewed-by Julian Wiedmann <[email protected]>Reviewed-by Ursula Braun <[email protected]>Signed-off-by Julian Wiedmann <[email protected]>
Applied.
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 WiedmannFrom: 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_familyfield, before accessing it inbind()andconnect()handlers of theAF_IUCVsocket. 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()")Signed-off-by Mateusz Jurczyk <[email protected]>[jwi: removed unneeded null-check for addr]Signed-off-by Julian Wiedmann <[email protected]>
Applied.