From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1450B1EA80; Thu, 15 Aug 2024 14:19:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723731588; cv=none; b=DQZq4pFmPkZWHCdNDJTCKYmL0tshfLTCESMhQ2Jp2O9gUMsDhy4jJx3SUwDoqqXaSC8nIF6sXfGVFRoNsM94DAV1trZ+WoMXafvRv/pxSvciH3kUfI+iZhzq17i6RB75m+zjMuDysoVGvUGc3S38q8eJ6GRg2n4iflmrnv+mb+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723731588; c=relaxed/simple; bh=Mh2EHOszsZ/N5EQ7y1MVEH3OElDF+75XU58lpooqA6U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=StMno+dbG48MV04XiliTZwYfLwJZy1UHtGzwlSkqwzL4VCh+U3v+MKtcIV6awmCs9APBVyiEW8Fxr10nWtUnsAtmdI2TTy2OHwqq4TnP0VCUnZLHIca4UhbkmN4VMWEvuaB+IWzZ/zND1qpt+Uh9dZayETri2Gwfp2QWtg7sluE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DY11pM56; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DY11pM56" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E793C32786; Thu, 15 Aug 2024 14:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723731588; bh=Mh2EHOszsZ/N5EQ7y1MVEH3OElDF+75XU58lpooqA6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DY11pM56uykBV4Oa0LEXHXYsFtQTpnwZsHiSrpqXNcizFTA62sHS4LSahIpRTxxvR 331Gf9ZycTyA5m14VgFhfjMsVzZkLzx9AFK7HYJQjB4dU+Ky8K4TO2bN3H562kZmWs dEnOKX7uEnX+B8VKq78NfnS9o7xbrnT9CU3eR9i0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jen Linkova , Lorenzo Colitti , Patrick Rohr , David Ahern , =?UTF-8?q?YOSHIFUJI=20Hideaki=20/=20=E5=90=89=E8=97=A4=E8=8B=B1=E6=98=8E?= , Jakub Kicinski , =?UTF-8?q?Maciej=20=C5=BBenczykowski?= , Paolo Abeni , Sasha Levin Subject: [PATCH 5.4 177/259] ipv6: fix ndisc_is_useropt() handling for PIO Date: Thu, 15 Aug 2024 15:25:10 +0200 Message-ID: <20240815131909.614873148@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240815131902.779125794@linuxfoundation.org> References: <20240815131902.779125794@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maciej Żenczykowski [ Upstream commit a46c68debf3be3a477a69ccbf0a1d050df841676 ] The current logic only works if the PIO is between two other ND user options. This fixes it so that the PIO can also be either before or after other ND user options (for example the first or last option in the RA). side note: there's actually Android tests verifying a portion of the old broken behaviour, so: https://android-review.googlesource.com/c/kernel/tests/+/3196704 fixes those up. Cc: Jen Linkova Cc: Lorenzo Colitti Cc: Patrick Rohr Cc: David Ahern Cc: YOSHIFUJI Hideaki / 吉藤英明 Cc: Jakub Kicinski Signed-off-by: Maciej Żenczykowski Fixes: 048c796beb6e ("ipv6: adjust ndisc_is_useropt() to also return true for PIO") Link: https://patch.msgid.link/20240730001748.147636-1-maze@google.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/ipv6/ndisc.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 74977ec77c576..64729e7e6a866 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -225,6 +225,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev, return NULL; memset(ndopts, 0, sizeof(*ndopts)); while (opt_len) { + bool unknown = false; int l; if (opt_len < sizeof(struct nd_opt_hdr)) return NULL; @@ -260,22 +261,23 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev, break; #endif default: - if (ndisc_is_useropt(dev, nd_opt)) { - ndopts->nd_useropts_end = nd_opt; - if (!ndopts->nd_useropts) - ndopts->nd_useropts = nd_opt; - } else { - /* - * Unknown options must be silently ignored, - * to accommodate future extension to the - * protocol. - */ - ND_PRINTK(2, notice, - "%s: ignored unsupported option; type=%d, len=%d\n", - __func__, - nd_opt->nd_opt_type, - nd_opt->nd_opt_len); - } + unknown = true; + } + if (ndisc_is_useropt(dev, nd_opt)) { + ndopts->nd_useropts_end = nd_opt; + if (!ndopts->nd_useropts) + ndopts->nd_useropts = nd_opt; + } else if (unknown) { + /* + * Unknown options must be silently ignored, + * to accommodate future extension to the + * protocol. + */ + ND_PRINTK(2, notice, + "%s: ignored unsupported option; type=%d, len=%d\n", + __func__, + nd_opt->nd_opt_type, + nd_opt->nd_opt_len); } next_opt: opt_len -= l; -- 2.43.0