Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31e6d363 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net: correct off-by-one write allocations reports



commit 2b85a34e
(net: No more expensive sock_hold()/sock_put() on each tx)
changed initial sk_wmem_alloc value.

We need to take into account this offset when reporting
sk_wmem_alloc to user, in PROC_FS files or various
ioctls (SIOCOUTQ/TIOCOUTQ)

Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d3b238a0
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -204,8 +204,8 @@ static int atalk_seq_socket_show(struct seq_file *seq, void *v)
			"%02X %d\n",
			"%02X %d\n",
		   s->sk_type, ntohs(at->src_net), at->src_node, at->src_port,
		   s->sk_type, ntohs(at->src_net), at->src_node, at->src_port,
		   ntohs(at->dest_net), at->dest_node, at->dest_port,
		   ntohs(at->dest_net), at->dest_node, at->dest_port,
		   atomic_read(&s->sk_wmem_alloc),
		   sk_wmem_alloc_get(s),
		   atomic_read(&s->sk_rmem_alloc),
		   sk_rmem_alloc_get(s),
		   s->sk_state, SOCK_INODE(s->sk_socket)->i_uid);
		   s->sk_state, SOCK_INODE(s->sk_socket)->i_uid);
out:
out:
	return 0;
	return 0;
+1 −2
Original line number Original line Diff line number Diff line
@@ -1748,8 +1748,7 @@ static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
	switch (cmd) {
	switch (cmd) {
		/* Protocol layer */
		/* Protocol layer */
		case TIOCOUTQ: {
		case TIOCOUTQ: {
			long amount = sk->sk_sndbuf -
			long amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
				      atomic_read(&sk->sk_wmem_alloc);


			if (amount < 0)
			if (amount < 0)
				amount = 0;
				amount = 0;
+6 −5
Original line number Original line Diff line number Diff line
@@ -1690,7 +1690,8 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
	switch (cmd) {
	switch (cmd) {
	case TIOCOUTQ: {
	case TIOCOUTQ: {
		long amount;
		long amount;
		amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);

		amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
		if (amount < 0)
		if (amount < 0)
			amount = 0;
			amount = 0;
		res = put_user(amount, (int __user *)argp);
		res = put_user(amount, (int __user *)argp);
@@ -1780,8 +1781,8 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
		ax25_info.idletimer = ax25_display_timer(&ax25->idletimer) / (60 * HZ);
		ax25_info.idletimer = ax25_display_timer(&ax25->idletimer) / (60 * HZ);
		ax25_info.n2count   = ax25->n2count;
		ax25_info.n2count   = ax25->n2count;
		ax25_info.state     = ax25->state;
		ax25_info.state     = ax25->state;
		ax25_info.rcv_q     = atomic_read(&sk->sk_rmem_alloc);
		ax25_info.rcv_q     = sk_wmem_alloc_get(sk);
		ax25_info.snd_q     = atomic_read(&sk->sk_wmem_alloc);
		ax25_info.snd_q     = sk_rmem_alloc_get(sk);
		ax25_info.vs        = ax25->vs;
		ax25_info.vs        = ax25->vs;
		ax25_info.vr        = ax25->vr;
		ax25_info.vr        = ax25->vr;
		ax25_info.va        = ax25->va;
		ax25_info.va        = ax25->va;
@@ -1921,8 +1922,8 @@ static int ax25_info_show(struct seq_file *seq, void *v)


	if (ax25->sk != NULL) {
	if (ax25->sk != NULL) {
		seq_printf(seq, " %d %d %lu\n",
		seq_printf(seq, " %d %d %lu\n",
			   atomic_read(&ax25->sk->sk_wmem_alloc),
			   sk_wmem_alloc_get(ax25->sk),
			   atomic_read(&ax25->sk->sk_rmem_alloc),
			   sk_rmem_alloc_get(ax25->sk),
			   sock_i_ino(ax25->sk));
			   sock_i_ino(ax25->sk));
	} else {
	} else {
		seq_puts(seq, " * * *\n");
		seq_puts(seq, " * * *\n");
+1 −1
Original line number Original line Diff line number Diff line
@@ -337,7 +337,7 @@ int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
		if (sk->sk_state == BT_LISTEN)
		if (sk->sk_state == BT_LISTEN)
			return -EINVAL;
			return -EINVAL;


		amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
		amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
		if (amount < 0)
		if (amount < 0)
			amount = 0;
			amount = 0;
		err = put_user(amount, (int __user *) arg);
		err = put_user(amount, (int __user *) arg);
+1 −1
Original line number Original line Diff line number Diff line
@@ -1240,7 +1240,7 @@ static int dn_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
		return val;
		return val;


	case TIOCOUTQ:
	case TIOCOUTQ:
		amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
		amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
		if (amount < 0)
		if (amount < 0)
			amount = 0;
			amount = 0;
		err = put_user(amount, (int __user *)arg);
		err = put_user(amount, (int __user *)arg);
Loading