lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20221130220111.zfrzckiyayaoka3z@skbuf>
Date:   Thu, 1 Dec 2022 00:01:11 +0200
From:   Vladimir Oltean <olteanv@...il.com>
To:     Yuri Karpov <YKarpov@...ras.ru>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, lvc-project@...uxtesting.org
Subject: Re: [PATCH] net: dsa: fix NULL pointer dereference in seq_match()

On Wed, Nov 30, 2022 at 11:44:31AM +0300, Yuri Karpov wrote:
> ptp_parse_header() result is not checked in seq_match() that can lead
> to NULL pointer dereferense.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: c6fe0ad2c349 ("net: dsa: mv88e6xxx: add rx/tx timestamping support")
> Signed-off-by: Yuri Karpov <YKarpov@...ras.ru>
> ---
>  drivers/net/dsa/mv88e6xxx/hwtstamp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/hwtstamp.c b/drivers/net/dsa/mv88e6xxx/hwtstamp.c
> index 331b4ca089ff..97f30795a2bb 100644
> --- a/drivers/net/dsa/mv88e6xxx/hwtstamp.c
> +++ b/drivers/net/dsa/mv88e6xxx/hwtstamp.c
> @@ -246,7 +246,7 @@ static int seq_match(struct sk_buff *skb, u16 ts_seqid)
>  
>  	hdr = ptp_parse_header(skb, type);
>  
> -	return ts_seqid == ntohs(hdr->sequence_id);
> +	return hdr ? ts_seqid == ntohs(hdr->sequence_id) : 0;

NACK.

ptp_parse_header() will never return NULL when called from seq_match().
The skb comes from mv88e6xxx_get_rxts(), which takes it from ps->rx_queue.
It was put there by mv88e6xxx_port_rxtstamp(), which prior to that, had
a check for ptp_parse_header() returning NULL in mv88e6xxx_should_tstamp().

Please don't just blindly trust your tools.

>  }
>  
>  static void mv88e6xxx_get_rxts(struct mv88e6xxx_chip *chip,
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ