* [PATCH] net/ipv4: fix potential NULL dereference in sisfb_post_sis300()
@ 2022-04-01 3:57 Haowen Bai
2022-04-01 17:09 ` Eric Dumazet
0 siblings, 1 reply; 2+ messages in thread
From: Haowen Bai @ 2022-04-01 3:57 UTC (permalink / raw)
To: David S. Miller, Hideaki YOSHIFUJI, David Ahern, Jakub Kicinski,
Paolo Abeni
Cc: Haowen Bai, netdev, linux-kernel
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 &&
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;
--
2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] net/ipv4: fix potential NULL dereference in sisfb_post_sis300()
2022-04-01 3:57 [PATCH] net/ipv4: fix potential NULL dereference in sisfb_post_sis300() Haowen Bai
@ 2022-04-01 17:09 ` Eric Dumazet
0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2022-04-01 17:09 UTC (permalink / raw)
To: Haowen Bai, David S. Miller, Hideaki YOSHIFUJI, David Ahern,
Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-01 17:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 3:57 [PATCH] net/ipv4: fix potential NULL dereference in sisfb_post_sis300() Haowen Bai
2022-04-01 17:09 ` Eric Dumazet
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®