All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever III <chuck.lever@oracle.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna.schumaker@netapp.com>,
	Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] SUNRPC: fix ternary sign expansion bug in tracing
Date: Thu, 22 Apr 2021 15:06:01 +0000	[thread overview]
Message-ID: <468517FF-2C98-4A15-8B9D-16C2212AED13@oracle.com> (raw)
In-Reply-To: <YIE+fTOOnC9PLXbg@mwanda>



> On Apr 22, 2021, at 5:14 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> This code is supposed to pass negative "err" values for tracing but it
> passes positive values instead.  The problem is that the
> trace_svcsock_tcp_send() function takes a long but "err" is an int and
> "sent" is a u32.  The negative is first type promoted to u32 so it
> becomes a high positive then it is promoted to long and it stays
> positive.
> 
> Fix this by casting "err" directly to long.
> 
> Fixes: 998024dee197 ("SUNRPC: Add more svcsock tracepoints")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

I had a patch somewhere that simplified this logic and got rid
of the ternary, but I think it got postponed when Trond recently
changed the use of MSG_MORE.

Let's go with this for now. I've pushed it to the for-next
branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git


> ---
> net/sunrpc/svcsock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> index 9eb5b6b89077..478f857cdaed 100644
> --- a/net/sunrpc/svcsock.c
> +++ b/net/sunrpc/svcsock.c
> @@ -1174,7 +1174,7 @@ static int svc_tcp_sendto(struct svc_rqst *rqstp)
> 	tcp_sock_set_cork(svsk->sk_sk, true);
> 	err = svc_tcp_sendmsg(svsk->sk_sock, xdr, marker, &sent);
> 	xdr_free_bvec(xdr);
> -	trace_svcsock_tcp_send(xprt, err < 0 ? err : sent);
> +	trace_svcsock_tcp_send(xprt, err < 0 ? (long)err : sent);
> 	if (err < 0 || sent != (xdr->len + sizeof(marker)))
> 		goto out_close;
> 	if (atomic_dec_and_test(&svsk->sk_sendqlen))
> -- 
> 2.30.2
> 

--
Chuck Lever




      reply	other threads:[~2021-04-22 15:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22  9:14 [PATCH] SUNRPC: fix ternary sign expansion bug in tracing Dan Carpenter
2021-04-22 15:06 ` Chuck Lever III [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=468517FF-2C98-4A15-8B9D-16C2212AED13@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=anna.schumaker@netapp.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@hammerspace.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.