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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221102083159.2rqu6j27weg2cxtq@intra2net.com>
Date:   Wed, 2 Nov 2022 09:31:59 +0100
From:   Thomas Jarosch <thomas.jarosch@...ra2net.com>
To:     Herbert Xu <herbert@...dor.apana.org.au>
Cc:     Antony Antony <antony.antony@...unet.com>,
        Steffen Klassert <steffen.klassert@...unet.com>,
        Sabrina Dubroca <sd@...asysnail.net>,
        Leon Romanovsky <leon@...nel.org>, Roth Mark <rothm@...l.com>,
        Zhihao Chen <chenzhihao@...zu.com>,
        Tobias Brunner <tobias@...ongswan.org>, netdev@...r.kernel.org
Subject: Re: [PATCH] xfrm: Fix oops in __xfrm_state_delete()

Hi Herbert,

You wrote on Wed, Nov 02, 2022 at 03:07:57PM +0800:
> > xfrm_user sets msg_seq to zero in mapping change message. seq is only useful for
> 
> Oh I had misread the patch and thought this was send_acquire.

it's a complex bug after all ^^ it took many printks() to trace
the flow of the state corruption on the production system.

> > acquire message. I think setting to zero would be a better fix.
> > 
> > -	hdr->sadb_msg_seq = x->km.seq = get_acqseq();
> > +	hdr->sadb_msg_seq = 0;
> > 
> > While increasing x->km.seq in every call to pfkey_send_new_mapping()
> > could be an issue, would it alone explan the crash?
> 
> Probably, if you change the state without moving it to the right
> hash slot then the xfrm state hash table will be inconsistent.

in the observed cases, km.seq is always zero before. So it was never added to
the byseq hash table in the first place, resulting in the NULL pointer Oops.

If km.seq would be non-zero before entering pfkey_send_new_mapping(),
then of course the xfrm_state would stay in the wrong hash table bucket.
The only other xfrm_states I've seen in my extensive tracing with a non-zero 
sequence number were ACQUIRE states and I'm not sure those will ever end up on 
the pfkey_send_new_mapping() code path. Either way, let's fix the root cause.

> We should copy the xfrm_user behaviour which is to leave x->km.seq
> alone.  So the patch should change the above line to
> 
> 	hdr->sadb_msg_seq = x->km.seq;

thanks for your feedback, I'll update the patch and send a v2.
I'll also put it in production tonight.

Cheers,
Thomas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ