Skip to content

Commit 01db403

Browse files
committed
tcp: Fix >4GB writes on 64-bit.
Fixes kernel bugzilla #16603 tcp_sendmsg() truncates iov_len to an 'int' which a 4GB write to write zero bytes, for example. There is also the problem higher up of how verify_iovec() works. It wants to prevent the total length from looking like an error return value. However it does this using 'int', but syscalls return 'long' (and thus signed 64-bit on 64-bit machines). So it could trigger false-positives on 64-bit as written. So fix it to use 'long'. Reported-by: Olaf Bonorden <bono@onlinehome.de> Reported-by: Daniel Büse <dbuese@gmx.de> Reported-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0b20406 commit 01db403

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

include/linux/socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ extern int csum_partial_copy_fromiovecend(unsigned char *kdata,
322322
int offset,
323323
unsigned int len, __wsum *csump);
324324

325-
extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode);
325+
extern long verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode);
326326
extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len);
327327
extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
328328
int offset, int len);

net/core/iovec.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
* in any case.
3636
*/
3737

38-
int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode)
38+
long verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode)
3939
{
40-
int size, err, ct;
40+
int size, ct;
41+
long err;
4142

4243
if (m->msg_namelen) {
4344
if (mode == VERIFY_READ) {

net/ipv4/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
943943
sg = sk->sk_route_caps & NETIF_F_SG;
944944

945945
while (--iovlen >= 0) {
946-
int seglen = iov->iov_len;
946+
size_t seglen = iov->iov_len;
947947
unsigned char __user *from = iov->iov_base;
948948

949949
iov++;

0 commit comments

Comments
 (0)