From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796198616; b=Xlh4+qxNnTnDd2laxb8lDJYEmp0CWO6SG7qIhkKoLtPFSTkINmQz9GiW/D2db3U1s/iH rLN4XjYoRfJZ6RbaY4fgwHloputlc/gtKeN1D4rvE0jDI0aZ/vb6fja8AT9WK6NPLJYA/ uHgWsz/J95dviN0wzsb5ho+Jk/1G63xxakFPPKejEYk/wALgZA6Ai2zRxuv2dT+I/dPhM 5KFVpngEkT/okIT5+xKcOdLBQQN4vwCjeVXiKrXqY9JIC2GVjUxDx/fse/NXWX2rYtruD AD2LbiTI61wLlPrN1HgmdM/xcR/ef5x7a1dfpw/ykFiRRosGVG2tHV7TdH03xeZZjsA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796198616; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=0rQPW3/Imx7ukwv47ZXjt1M4I9hwOoEOyv8Xz03SFdw=; b=OJzFnyAQ/Z/MLYSYnQLHJNRB6urWb/LWhwpDU92pLxyX6W5MEsJJAOy0NyqYLCpYqn75 sdJw7Yh5lltFWkNg8lmmcnFKIYhdkshfoFIo/Szl1wcXW7j3hMKIbdBRGOOH5N4tbFVMr R60xLLXBTGr1vmo6TmlQvng+SHYms85GX/zun9MoHXBYMyyY9mAsNjHTqqEibuncLS+qT rd/rkvmm4qM4ru5MdWSxtIJX8hxqlNVaDE8z3mv91J1qVkMyYjhFtZpSnVGtju1Ldu4sI rH/Z+3ObQ9JGOU/gDUCYvSNk/3X3dtCW+h/hE9w4nDUqbZYz6LM1WgjkvqfhGONDTUQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=kHwTXQOX; arc=none smtp.remote-ip=95.215.58.170 Received: from mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B930606A31A for ; Wed, 2 Dec 2026 08:03:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5B930606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=kHwTXQOX X-Envelope-To: netdev@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=w5UDwtL+LnsdWLEayK9kc/6U7Um6Z3jEVyEd7jkTfxg=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796198613; v=1; x=1796803413; b=kHwTXQOXLkOyYIKk7q6Xz4FdQMVlsS5mj7PFJ3jSbP4OOoQOR9Z3EHFa0kAgR3Ux8wv5BOFq Smdy3Ou7Byp3HhYUP4v/zgpnCqHmDD9Is1h51d0WTetbNYXodo6YBcseaAUAfhcraiLcTnw2wDw NJB7rakh2KI4bFZONBNsIDXo= X-Envelope-To: netdev@vger.kernel.org Received: by mta12.migadu.com with ESMTPS id 853c0bdd45a4402e; Wed, 02 Dec 2026 08:03:32 +0000 X-Mizu-Trace-ID: 853c0bdd45a4402e X-Migadu-Flow: FLOW_OUT Date: Wed, 2 Dec 2026 16:03:23 +0800 From: Hangbin Liu To: Juan Agustin Niccolini Cc: Gabriel Goller , Andrea Mayer , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , netdev@vger.kernel.org, Simon Horman , David Ahern , Julien Massonneau Subject: Re: [PATCH net] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read Message-ID: References: <20261130031647.45247-1-juanagusnicco@gmail.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Juan and Gabriel, On Wed, Dec 02, 2026 at 01:30:54AM -0500, Juan Agustin Niccolini wrote: > On Tue, Dec 01, 2026 at 11:43:23AM +0100, Gabriel Goller wrote: > > On 01.12.2026 13:27, Hangbin Liu wrote: > > > If the user can write the segments_left field, can it write to other fields? > > > > Yes, but from a quick glance, no other field can make advance_nextseg() read > > past the segment list. > > Right. The sender can write to any byte that is still in the fragment, > but the other fields are only trusted after the pull: seg6_get_srh() > pulls the whole SRH into the linear area and then calls > seg6_validate_srh() on that copy. That checks type, hdrlen, > first_segment and the TLVs, and that segments_left <= first_segment + 1. > > The only value that passes this validation and that advance_nextseg() > cannot handle is segments_left == 0, and that one was checked only by > ipv6_find_hdr(), before the pull. > > > > And we put the check in get_and_validate_srh, what if it changed later > > > and before or after advance_nextseg()? > > > > I don't think it can be changed, because at that point we use the linearized > > copy. > > Yes. After seg6_get_srh() returns, srh points into the linear area of > the skb, which is kernel memory that the sender has no mapping of. The > new check and advance_nextseg() both read that copy. > > > I'd add a code comment here, otherwise this will be removed again :) > > Will do in v2, so that the check does not look redundant with > IP6_FH_F_SKIP_RH. Thanks for the review. Thanks for the explanations. I will review the v2 patch. Hangbin