netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Ursula Braun <ubraun@linux.ibm.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	linux-s390@vger.kernel.org, schwidefsky@de.ibm.com,
	heiko.carstens@de.ibm.com, raspl@linux.ibm.com,
	linux-kernel@vger.kernel.org, eric.dumazet@gmail.com,
	lifeasageek@gmail.com
Subject: Re: [PATCH net 1/4] net/smc: take sock lock in smc_ioctl()
Date: Mon, 16 Jul 2018 12:09:15 +0200	[thread overview]
Message-ID: <20180716120915.09d35dc0@epycfail> (raw)
In-Reply-To: <20180716100101.79272-1-ubraun@linux.ibm.com>

On Mon, 16 Jul 2018 12:01:01 +0200
Ursula Braun <ubraun@linux.ibm.com> wrote:

> From: Ursula Braun <ursula.braun@linux.ibm.com>
> 
> SMC ioctl processing requires the sock lock to work properly in
> all thinkable scenarios.
> Problem has been found with RaceFuzzer and fixes:
>    KASAN: null-ptr-deref Read in smc_ioctl
> 
> Reported-by: Byoungyoung Lee <lifeasageek@gmail.com>
> Reported-by: syzbot+35b2c5aa76fd398b9fd4@syzkaller.appspotmail.com
> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
> ---
>  net/smc/af_smc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index 5334157f5065..a4381b38a521 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -1524,6 +1524,7 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd,
>  			return -EBADF;
>  		return smc->clcsock->ops->ioctl(smc->clcsock, cmd, arg);
>  	}
> +	lock_sock(&smc->sk);
>  	switch (cmd) {
>  	case SIOCINQ: /* same as FIONREAD */
>  		if (smc->sk.sk_state == SMC_LISTEN)

                        return -EINVAL;

you should also unlock here, and:

        case SIOCOUTQ:
                /* output queue size (not send + not acked) */
                if (smc->sk.sk_state == SMC_LISTEN)
                        return -EINVAL;

here, and:

        case SIOCOUTQNSD:
                /* output queue size (not send only) */
                if (smc->sk.sk_state == SMC_LISTEN)
                        return -EINVAL;

here, and:

        case SIOCATMARK:
                if (smc->sk.sk_state == SMC_LISTEN)
                        return -EINVAL;

here.

-- 
Stefano

  reply	other threads:[~2018-07-16 10:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16 10:01 [PATCH net 1/4] net/smc: take sock lock in smc_ioctl() Ursula Braun
2018-07-16 10:09 ` Stefano Brivio [this message]
2018-07-16 11:56   ` Ursula Braun

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=20180716120915.09d35dc0@epycfail \
    --to=sbrivio@redhat.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=lifeasageek@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=raspl@linux.ibm.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=ubraun@linux.ibm.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 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).