From nobody Mon Apr 6 14:57:14 2026 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C086341674 for ; Thu, 19 Mar 2026 07:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773905604; cv=none; b=TpOSOdSJuiF1Y3A/0o138Dxh8VUuf+cgofPQWcTAdlShh48FUnR3jr4s7HnNylBY4nu28u5vtp3SU6Vh5FopXRKjdBcWEY+Ex9w0bfkx60jpTUIr7hrarLrDxtiDU5H+ddqCkCPCxRcaSztGV/axd6hqYmIMJmPeUk/s1B1P1dM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773905604; c=relaxed/simple; bh=GYSppdIMaX/06nQtFbo2tTryX8SKqeX06P5GhztxMfM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=R28Mx+86CQe6sl1OJFxh0pk1ScHP8ORt5sFqd/LTpeKfp4OizraE8RV1TVC/j0MFXg8N9ocx1WaW94zwRs+Q1CaZkqiaEzhXL5hehKTbgHlemArLt1uxugMdYStiNmp4ap5PSksQzs0pY7LKQJAWxsuHPGClGC86o2kEBEaCTZ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I4jy+rzN; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I4jy+rzN" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-35b90d6fe14so298890a91.2 for ; Thu, 19 Mar 2026 00:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773905602; x=1774510402; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZLQ1MC6fP9cORHP27xWUIjVQ8sSQEHBL6tE36vI4nLE=; b=I4jy+rzNBghX1ypUyWkKjJKoK+A8dGtAtS6sZ84wu/n+/oKSGo7OXZHhSGcetF7JLh XxRaScyj3NYZFxFoSxJq7iuGeRzdoV2j60/J8nWjbOWRntc2AHiuHG+CTH4cgd7/a8K1 s+JWz2jGtSZ1HBI56SYkvqDem11cBccGl7Ui8K4DV02EhlKd/uNQ4ns6i3PXA9nzRwQS VM/lNZIB+0/aKiYwSE+UpKLR3CExZckob9IT/Cb4YkaaQkDyBbBM9HOlhv84WvonrptE cOiio+xiXBtgNJdpOvizbuUdF6/zNEDRcOuWuhiIOlMWyGbsDXemNLnUv7O5W6L/uKUs X3gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773905602; x=1774510402; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZLQ1MC6fP9cORHP27xWUIjVQ8sSQEHBL6tE36vI4nLE=; b=rF0PULbaNtZKYa8OSpbn9COnIFshZuzBpEVet7ceGgnbOXlQRqF5bIJq/tccWoOyDp HGg8ByWxrmZhWLhjbRcCGY50oJDgc75HTYkQVsV1EiFECgUdl+ozjd2pa4xOqrzKTqsz gyN8OYkxbNYIzcdhERTvY88fzLslOUo3jhMgVOSOF9tCXP7DNnUTiamZ16F75Np2zxXj Gcq3/nNXzmGWSmWiEfGPoEuRxwbTCqAJzYODboKIpe/mS9uBlPskV3OB8XRnoxAoY2WJ ii6GglMdtcoDsJ4A0kcLjQ4eH4+4a01jvRfXVETgByHBUMgrFwIb6XSfJ2htT9/iODq3 R5HQ== X-Forwarded-Encrypted: i=1; AJvYcCVkAn6dhZz7Z5M2zOmxdFDR7pq0pyaO/e+ZIGZZD1G9EuL1TAJJjDzufm1s0b/2l0d/6LwJVTQOYMku9iE=@vger.kernel.org X-Gm-Message-State: AOJu0YzaQe+b2bluuBAUS9IcilEXp31/7EHVfXHXl1qgqLs0zB76gR6c IA+py5yr+cb8Vo9PW30m6QgYqgz1HL5OHhSVwhwhElCpgKwXjRyrHIVS X-Gm-Gg: ATEYQzyNEZBvzVglG7m+EpwE06fYx/yFMPYCuaKmN/l0H1eYrSxwN65OpEuooJITmt8 41Q/D/RhqVyrBeGUFucD7H0BqCBniBppoxJQI9/f3OBiasUhinD1l9uF9eSzrQUMzKo8i//RBkN 2UdJUgl8vFAOc3zs5roCNx3hF8vcIZG52MDXzoq1jWCqD1UQOk1L0xB7TBizU+uY7D80P6tTxMi 3S2cYTz38MZ8saNwcbZGncoPEAjk6cXh2wbZEFkuAd1m5Om76ZLBnwKGpHxZ9bi8hnp79CkoYEg lsnfdNf1KCJvnAxk8WaA2lISBxxL2bwpCYyJUN+AOP2cm2OWWfczOxraUPl5nXeuP+xW7SD9PUt UHi5T49Qktr1+QxJrylK+9yOmeomXIkQSXBVd+i38fVc3/Dqol+CwJr6ip8xhE4/uCf0m6ngnGo cK0f7QJ5aA0D2hlfJ4ezXXzvC5ZLyAA1z+UDFnSm6Lb3xIvUEd6Q3+wRa12tF57kVqzd13/6cnW u+BM/Yo5no= X-Received: by 2002:a17:90a:e70d:b0:352:ba0f:fb28 with SMTP id 98e67ed59e1d1-35bb9e432f2mr5390169a91.1.1773905602343; Thu, 19 Mar 2026 00:33:22 -0700 (PDT) Received: from SLSGDTSWING002.tail0ac356.ts.net ([129.126.109.177]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35bc6026a5asm2166870a91.8.2026.03.19.00.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2026 00:33:21 -0700 (PDT) From: bestswngs@gmail.com To: security@kernel.org Cc: edumazet@google.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xmei5@asu.edu, Weiming Shi Subject: [PATCH net] nfnetlink_osf: validate individual option lengths in fingerprints Date: Thu, 19 Mar 2026 15:32:44 +0800 Message-ID: <20260319073243.1176330-2-bestswngs@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Weiming Shi nfnl_osf_add_callback() validates opt_num bounds and string NUL-termination but does not check individual option length fields. A zero-length option causes nf_osf_match_one() to enter the option matching loop even when foptsize sums to zero, which matches packets with no TCP options where ctx->optp is NULL: Oops: general protection fault, probably for non-canonical address 0xdffff= c0000000000: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:nf_osf_match_one (net/netfilter/nfnetlink_osf.c:98) Call Trace: nf_osf_match (net/netfilter/nfnetlink_osf.c:227) xt_osf_match_packet (net/netfilter/xt_osf.c:32) ipt_do_table (net/ipv4/netfilter/ip_tables.c:293) nf_hook_slow (net/netfilter/core.c:623) ip_local_deliver (net/ipv4/ip_input.c:262) ip_rcv (net/ipv4/ip_input.c:573) Kernel panic - not syncing: Fatal exception in interrupt Additionally, an MSS option (kind=3D2) with length < 4 causes out-of-bounds reads when nf_osf_match_one() unconditionally accesses optp[2] and optp[3] for MSS value extraction. While RFC 9293 section 3.2 specifies that the MSS option is always exactly 4 bytes (Kind=3D2, Length=3D4), the check uses "< 4" rather than "!=3D 4" because lengths greater than 4 do not cause memory safety issues -- the buffer is guaranteed to be at least foptsize bytes by the ctx->optsize =3D=3D foptsize check. Reject fingerprints where any option has zero length, or where an MSS option has length less than 4, at add time rather than trusting these values in the packet matching hot path. Fixes: 11eeef41d5f6 ("netfilter: passive OS fingerprint xtables match") Reported-by: Xiang Mei Signed-off-by: Weiming Shi --- net/netfilter/nfnetlink_osf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/netfilter/nfnetlink_osf.c b/net/netfilter/nfnetlink_osf.c index 94e3eac5743a..c35b831dac5a 100644 --- a/net/netfilter/nfnetlink_osf.c +++ b/net/netfilter/nfnetlink_osf.c @@ -303,6 +303,7 @@ static int nfnl_osf_add_callback(struct sk_buff *skb, struct nf_osf_user_finger *f; struct nf_osf_finger *kf =3D NULL, *sf; int err =3D 0; + int i; if (!capable(CAP_NET_ADMIN)) return -EPERM; @@ -318,6 +319,13 @@ static int nfnl_osf_add_callback(struct sk_buff *skb, if (f->opt_num > ARRAY_SIZE(f->opt)) return -EINVAL; + for (i =3D 0; i < f->opt_num; i++) { + if (!f->opt[i].length) + return -EINVAL; + if (f->opt[i].kind =3D=3D OSFOPT_MSS && f->opt[i].length < 4) + return -EINVAL; + } + if (!memchr(f->genre, 0, MAXGENRELEN) || !memchr(f->subtype, 0, MAXGENRELEN) || !memchr(f->version, 0, MAXGENRELEN)) -- 2.43.0