lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230105090807.51213cea@gandalf.local.home>
Date:   Thu, 5 Jan 2023 09:08:07 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Yunhui Cui <cuiyunhui@...edance.com>
Cc:     mhiramat@...nel.org, davem@...emloft.net, edumazet@...gle.com,
        kuba@...nel.org, pabeni@...hat.com, duanxiongchun@...edance.com,
        kuniyu@...zon.com, linux-kernel@...r.kernel.org,
        linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH v2] sock: add tracepoint for send recv length

On Thu,  5 Jan 2023 18:00:14 +0800
Yunhui Cui <cuiyunhui@...edance.com> wrote:

> @@ -715,6 +716,10 @@ static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg)
>  				     inet_sendmsg, sock, msg,
>  				     msg_data_left(msg));
>  	BUG_ON(ret == -EIOCBQUEUED);
> +
> +	trace_sock_sendmsg_length(sock->sk, sock->sk->sk_family,
> +				  sock->sk->sk_protocol,
> +				  ret > 0 ? ret : 0, ret > 0 ? 0 : ret, 0);

The length and error seem confusing. Basically, length is ret > 0 and error
is ret < 0, right?

That means we don't need both. We could simply have:

> +	TP_ARGS(sk, family, protocol, length, error, flags),

	TP_ARGS(sk, family, protocol, ret, flags)

> +
> +	TP_STRUCT__entry(
> +		__field(void *, sk)
> +		__field(__u16, family)
> +		__field(__u16, protocol)
> +		__field(int, length)
> +		__field(int, error)
> +		__field(int, flags)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->sk = sk;
> +		__entry->family = sk->sk_family;
> +		__entry->protocol = sk->sk_protocol;
> +		__entry->length = length;

		__entry->length = ret > 0 ? ret : 0;

> +		__entry->error = error;

		__entry->error = ret < 0 ? ret : 0;

> +		__entry->flags = flags;
> +	),
> +

>  	return ret;
>  }
>  
> @@ -992,9 +997,17 @@ INDIRECT_CALLABLE_DECLARE(int inet6_recvmsg(struct socket *, struct msghdr *,
>  static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
>  				     int flags)
>  {
> -	return INDIRECT_CALL_INET(sock->ops->recvmsg, inet6_recvmsg,
> +	int ret = INDIRECT_CALL_INET(sock->ops->recvmsg, inet6_recvmsg,
>  				  inet_recvmsg, sock, msg, msg_data_left(msg),
>  				  flags);
> +
> +	trace_sock_recvmsg_length(sock->sk, sock->sk->sk_family,
> +				  sock->sk->sk_protocol,
> +				  (ret > 0 && !(flags & MSG_PEEK)) ?
> +				  ret : 0,
> +				  (ret > 0 && !(flags & MSG_PEEK)) ? 0 : ret,

Since both length and error are zero when flags has MSG_PEEK set:

	trace_sock_recvmsg_length(sock->sk, sock->sk->sk_family,
				  sock->sk->sk_protocol,
				  !(flags & MSG_PEEK) ? ret : 0,

-- Steve

> +				  flags);
> +	return ret;
>  }
>  
>  /**
> @@ -1044,6 +1057,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
>  {
>  	struct socket *sock;
>  	int flags;
> +	int ret;
>  
>  	sock = file->private_data;
>  
> @@ -1051,7 +1065,12 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
>  	/* more is a combination of MSG_MORE and MSG_SENDPAGE_NOTLAST */
>  	flags |= more;
>  
> -	return kernel_sendpage(sock, page, offset, size, flags);
> +	ret = kernel_sendpage(sock, page, offset, size, flags);
> +
> +	trace_sock_sendmsg_length(sock->sk, sock->sk->sk_family,
> +				  sock->sk->sk_protocol,
> +				  ret > 0 ? ret : 0, ret > 0 ? 0 : ret, 0);
> +	return ret;
>  }
>  
>  static ssize_t sock_splice_read(struct file *file, loff_t *ppos,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ