qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH] linux-user: Check lock_user result for ip_mreq_source sockopts
Date: Mon, 13 Sep 2021 21:20:21 +0200	[thread overview]
Message-ID: <5ec74137-ae15-a27a-5570-6ce2c791aff6@vivier.eu> (raw)
In-Reply-To: <20210809155424.30968-1-peter.maydell@linaro.org>

Le 09/08/2021 à 17:54, Peter Maydell a écrit :
> In do_setsockopt(), the code path for the options which take a struct
> ip_mreq_source (IP_BLOCK_SOURCE, IP_UNBLOCK_SOURCE,
> IP_ADD_SOURCE_MEMBERSHIP and IP_DROP_SOURCE_MEMBERSHIP) fails to
> check the return value from lock_user().  Handle this in the usual
> way by returning -TARGET_EFAULT.
> 
> (In practice this was probably harmless because we'd pass a NULL
> pointer to setsockopt() and the kernel would then return EFAULT.)
> 
> Fixes: Coverity CID 1459987
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Compile-tested only; I don't have a test case to hand that
> uses these socket options.
> 
>  linux-user/syscall.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ccd3892b2df..d2b062ea5a9 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2121,6 +2121,9 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
>                  return -TARGET_EINVAL;
>  
>              ip_mreq_source = lock_user(VERIFY_READ, optval_addr, optlen, 1);
> +            if (!ip_mreq_source) {
> +                return -TARGET_EFAULT;
> +            }
>              ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq_source, optlen));
>              unlock_user (ip_mreq_source, optval_addr, 0);
>              break;
> 

Applied to my linux-user-for-6.2 branch.

Thanks,
Laurent


      parent reply	other threads:[~2021-09-13 19:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 15:54 [PATCH] linux-user: Check lock_user result for ip_mreq_source sockopts Peter Maydell
2021-08-09 16:00 ` Philippe Mathieu-Daudé
2021-08-10 13:25 ` Laurent Vivier
2021-09-13 19:20 ` Laurent Vivier [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=5ec74137-ae15-a27a-5570-6ce2c791aff6@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).