mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Muhammad Usama Anjum <musamaanjum@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	Pavel Begunkov <asml.silence@gmail.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	colin.king@canonical.com
Subject: Re: [PATCH] io_uring: Initialize variable before use
Date: Wed, 31 Mar 2021 14:57:25 +0500	[thread overview]
Message-ID: <d58921603fb8adf3bb335a9986c8c89348ab0985.camel@gmail.com> (raw)
In-Reply-To: <20210331084817.GH2088@kadam>

On Wed, 2021-03-31 at 11:48 +0300, Dan Carpenter wrote:
> On Mon, Mar 22, 2021 at 11:41:58PM +0500, Muhammad Usama Anjum wrote:
> > 1) Initialize the struct msghdr msg in the start of the function
> > 2) Uninitialized variable msg.msg_flags can get used if branch happens to
> > out_free before initialization.
> > 
> > So initialize variable in question in the start of the function for
> > simplicity in logic and use.
> > 
> > Addresses-Coverity: ("Uninitialized variable")
> > Addresses-Coverity: ("Uninitialized variable read")
> 
> This bug is a false positive.
> 
> When msg.msg_flags is uninitialized then ret is negative and min_ret is
> zero.
> 
> fs/io_uring.c
>   4666                  ret = -EINTR;
>   4667  out_free:
>   4668          if (req->flags & REQ_F_BUFFER_SELECTED)
>   4669                  cflags = io_put_recv_kbuf(req);
>   4670          if (ret < min_ret || ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))))
>                     ^^^^^^^^^^^^^                               ^^^^^^^^^^^^^
> The first part of the condition is true so the second part is not used.
> 
>   4671                  req_set_fail_links(req);
>   4672          __io_req_complete(req, issue_flags, ret, cflags);
>   4673          return 0;
>   4674  }
> 
Understood. Thank you so much!

Thanks,
Usama

> regards,
> dan carpenter
> 


      reply	other threads:[~2021-03-31  9:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 18:41 Muhammad Usama Anjum
2021-03-31  8:25 ` Muhammad Usama Anjum
2021-03-31  8:48 ` Dan Carpenter
2021-03-31  9:57   ` Muhammad Usama Anjum [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=d58921603fb8adf3bb335a9986c8c89348ab0985.camel@gmail.com \
    --to=musamaanjum@gmail.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=colin.king@canonical.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®