From: Eric Dumazet <eric.dumazet@gmail.com>
To: Haowen Bai <baihaowen@meizu.com>,
"David S. Miller" <davem@davemloft.net>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
David Ahern <dsahern@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net/ipv4: fix potential NULL dereference in sisfb_post_sis300()
Date: Fri, 1 Apr 2022 10:09:26 -0700 [thread overview]
Message-ID: <5d9fed4f-ff87-cb14-3c7d-8899cb3e4370@gmail.com> (raw)
In-Reply-To: <1648785432-21824-1-git-send-email-baihaowen@meizu.com>
On 3/31/22 20:57, Haowen Bai wrote:
> psin and psl could be null without checking null and return, so
> we need to dereference after checking.
>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
> net/ipv4/igmp.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
> index 2ad3c7b..d400080 100644
> --- a/net/ipv4/igmp.c
> +++ b/net/ipv4/igmp.c
> @@ -2569,7 +2569,7 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
> copy_to_user(optval, msf, IP_MSFILTER_SIZE(0))) {
> return -EFAULT;
> }
> - if (len &&
> + if (len && psl &&
len can not be !0 here if len was 0
psl = rtnl_dereference(pmc->sflist);
if (!psl) {
count = 0;
->len == 0
> copy_to_user(&optval->imsf_slist_flex[0], psl->sl_addr, len))
> return -EFAULT;
> return 0;
> @@ -2608,7 +2608,7 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
> count = psl ? psl->sl_count : 0;
> copycount = count < gsf->gf_numsrc ? count : gsf->gf_numsrc;
> gsf->gf_numsrc = count;
> - for (i = 0; i < copycount; i++, p++) {
> + for (i = 0; i < copycount && psin && psl; i++, p++) {
> struct sockaddr_storage ss;
>
> psin = (struct sockaddr_in *)&ss;
Same here.
prev parent reply other threads:[~2022-04-01 17:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 3:57 Haowen Bai
2022-04-01 17:09 ` Eric Dumazet [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=5d9fed4f-ff87-cb14-3c7d-8899cb3e4370@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=baihaowen@meizu.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yoshfuji@linux-ipv6.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®