Content-Type: multipart/mixed; boundary="===============7457106047396746905==" MIME-Version: 1.0 From: Dmitry Safonov To: kbuild-all@lists.01.org Subject: Re: [kbuild] Re: [PATCH 11/31] net/tcp: Add TCP-AO sign to outgoing packets Date: Mon, 29 Aug 2022 18:55:03 +0100 Message-ID: In-Reply-To: <202208221901.Fs6wW5Jd-lkp@intel.com> List-Id: --===============7457106047396746905== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Dan, On 8/22/22 13:03, Dan Carpenter wrote: > Hi Dmitry, [..] > ea66758c1795cef Paolo Abeni 2022-05-04 608 static void tcp_op= tions_write(struct tcphdr *th, struct tcp_sock *tp, [..] > 85df6b860d509a9 Dmitry Safonov 2022-08-18 622 #ifdef CONFIG_TCP_= AO > 85df6b860d509a9 Dmitry Safonov 2022-08-18 623 if (unlikely(OPTI= ON_AO & options)) { > 85df6b860d509a9 Dmitry Safonov 2022-08-18 624 u8 maclen; > 33ad798c924b4a1 Adam Langley 2008-07-19 625 = > 85df6b860d509a9 Dmitry Safonov 2022-08-18 @626 if (tp) { > = > Can "tp" really be NULL? Everything else assumes it can't. It actually can be NULL, see tcp_make_synack(). At this moment code assumes that *either* (tp =3D=3D NULL) or (tcprsk =3D= =3D NULL). > 85df6b860d509a9 Dmitry Safonov 2022-08-18 627 struct tcp_ao_i= nfo *ao_info; > 85df6b860d509a9 Dmitry Safonov 2022-08-18 628 = > 85df6b860d509a9 Dmitry Safonov 2022-08-18 629 ao_info =3D rcu= _dereference_check(tp->ao_info, > 85df6b860d509a9 Dmitry Safonov 2022-08-18 630 lockdep_sock_i= s_held(&tp->inet_conn.icsk_inet.sk)); > 85df6b860d509a9 Dmitry Safonov 2022-08-18 631 if (WARN_ON_ONC= E(!ao_key || !ao_info || !ao_info->rnext_key)) > 85df6b860d509a9 Dmitry Safonov 2022-08-18 632 goto out_ao; > 85df6b860d509a9 Dmitry Safonov 2022-08-18 633 maclen =3D tcp_= ao_maclen(ao_key); > 85df6b860d509a9 Dmitry Safonov 2022-08-18 634 *ptr++ =3D hton= l((TCPOPT_AO << 24) | > 85df6b860d509a9 Dmitry Safonov 2022-08-18 635 (tcp_ao= _len(ao_key) << 16) | > 85df6b860d509a9 Dmitry Safonov 2022-08-18 636 (ao_key= ->sndid << 8) | > 85df6b860d509a9 Dmitry Safonov 2022-08-18 637 (ao_inf= o->rnext_key->rcvid)); > 85df6b860d509a9 Dmitry Safonov 2022-08-18 638 } > = > "maclen" not initialized on else path. Patch 15 ("net/tcp: Wire TCP-AO to request sockets") adds + if (tcprsk) { + u8 aolen =3D tcprsk->maclen + sizeof(struct tcp_ao_hdr); + + maclen =3D tcprsk->maclen; + *ptr++ =3D htonl((TCPOPT_AO << 24) | (aolen << 16) | + (tcprsk->ao_keyid << 8) | + (tcprsk->ao_rcv_next)); + } Assuming that tp !=3D NULL OR tcprsk !=3D NULL, maclen is always initialized _after both patches_. For version 2, I'll make it (break patches) in more bisect-able way for static analyzers and do WARN_ON(tp =3D=3D NULL && tcprsk =3D=3D NULL) with = break off TCP-AO signing to make sure the assumption will be valid with the code changing later on. [..] > ea66758c1795cef Paolo Abeni 2022-05-04 731 mptcp_options_wri= te(th, ptr, tp, opts); > = ^^ > Not checked here either. The function has checks inside. Thanks, Dmitry --===============7457106047396746905==--