linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: kaike.wan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org,
	ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org,
	richard.weinberger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
	tgraf-G/eBtMaohhA@public.gmane.org,
	daniel-FeC+5ew28dpmcu3hnIyYJQ@public.gmane.org,
	chamaken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	nicolas.dichtel-pdR9zngts4EAvxtiuMwx3w@public.gmane.org,
	fw-HFFVJYpyMKqzQB+pC5nmwQ@public.gmane.org,
	syzkaller-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
	kcc-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	glider-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	sasha.levin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
	edumazet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	dvyukov-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH 1/1] IB/sa: Fix netlink local service GFP crash
Date: Thu, 21 Jan 2016 12:49:29 -0500	[thread overview]
Message-ID: <56A11A29.8010203@redhat.com> (raw)
In-Reply-To: <1453383691-2306-1-git-send-email-kaike.wan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2571 bytes --]

On 01/21/2016 08:41 AM, kaike.wan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org wrote:
> From: Kaike Wan <kaike.wan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> 
> The rdma netlink local service registers a handler to handle RESOLVE
> response and another handler to handle SET_TIMEOUT request. The first
> thing these handlers do is to call netlink_capable() to check the
> access right of the received skb to make sure that the sender has root
> access. Under normal conditions, such responses and requests will be
> directly forwarded to the handlers without going through the netlink_dump
> pathway (see ibnl_rcv_msg() in drivers/infiniband/core/netlink.c).
> However, a user application could send a RESOLVE request (not response)
> to the local service, which will fall into the netlink_dump pathway,
> where a new skb will be created without initializing the control block.
> This new skb will be eventually forwarded to the local service RESOLVE
> response handler. Unfortunately, netlink_capable() will cause general
> protection fault if the skb's control block is not initialized. This
> patch will address the problem by checking the skb first.
> 
> Signed-off-by: Kaike Wan <kaike.wan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Reported-by: Dmitry Vyukov <dvyukov-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/infiniband/core/sa_query.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index 1f91b6e..f334090 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -717,7 +717,9 @@ static int ib_nl_handle_set_timeout(struct sk_buff *skb,
>  	struct nlattr *tb[LS_NLA_TYPE_MAX];
>  	int ret;
>  
> -	if (!netlink_capable(skb, CAP_NET_ADMIN))
> +	if (!(nlh->nlmsg_flags & NLM_F_REQUEST) ||
> +	    !(NETLINK_CB(skb).sk) ||
> +	    !netlink_capable(skb, CAP_NET_ADMIN))
>  		return -EPERM;
>  
>  	ret = nla_parse(tb, LS_NLA_TYPE_MAX - 1, nlmsg_data(nlh),
> @@ -791,7 +793,9 @@ static int ib_nl_handle_resolve_resp(struct sk_buff *skb,
>  	int found = 0;
>  	int ret;
>  
> -	if (!netlink_capable(skb, CAP_NET_ADMIN))
> +	if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
> +	    !(NETLINK_CB(skb).sk) ||
> +	    !netlink_capable(skb, CAP_NET_ADMIN))
>  		return -EPERM;
>  
>  	spin_lock_irqsave(&ib_nl_request_lock, flags);
> 

Thanks, applied.

-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
              GPG KeyID: 0E572FDD



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

      parent reply	other threads:[~2016-01-21 17:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 13:41 [PATCH 1/1] IB/sa: Fix netlink local service GFP crash kaike.wan-ral2JQCrhuEAvxtiuMwx3w
     [not found] ` <1453383691-2306-1-git-send-email-kaike.wan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-01-21 17:49   ` Doug Ledford [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=56A11A29.8010203@redhat.com \
    --to=dledford-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=chamaken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=daniel-FeC+5ew28dpmcu3hnIyYJQ@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=dvyukov-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
    --cc=edumazet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=fw-HFFVJYpyMKqzQB+pC5nmwQ@public.gmane.org \
    --cc=glider-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org \
    --cc=kaike.wan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=kcc-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nicolas.dichtel-pdR9zngts4EAvxtiuMwx3w@public.gmane.org \
    --cc=richard.weinberger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=sasha.levin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=syzkaller-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=tgraf-G/eBtMaohhA@public.gmane.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).