From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 9315C1643B for ; Thu, 16 Apr 2026 03:19:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776309562; cv=none; b=DtI1FG9WiSgsT0PqjO3yLIa7QmvDQ05X/7qXDgNCHRH8wM1OpMRCmWc0mugmhKa8iABgeWFBCEM5UsYj42y4HKih+TdFoCga4waTvKpoIYv0fiMpVcqPjeGIFC9Jv5voUzH0+71gnoCHxa4ovTO2zBGCYPQ47zmPgunoXV7SnZI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776309562; c=relaxed/simple; bh=6gffQwVrZbWmmoZmS6ntD3kXVEXf3L650/1kWkyePIs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sU+CsNbIZoyPQKmeV+8yhxOmBTlrCns5pNK/6xzkWpneHMyJ2ZV27vOExUP3QSaOJvmSNE3ZG1gJjvc651+cmFeviOjEX9QTvIalw3a0QFwPU38N5yoX5RGz6qxizr4HSO0lGqAJh4ndyUGA0uqBrsWK+X82zthPlweT9wS2gec= 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=VaPreFgq; arc=none smtp.client-ip=209.85.222.169 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="VaPreFgq" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-8d560ede296so884536985a.0 for ; Wed, 15 Apr 2026 20:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776309560; x=1776914360; 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=GgBzs6EKzyDLWZ+aqE87/ScBh1gHb7gMVIBVANVXsG8=; b=VaPreFgqvH6YxdHi7lpfMyQ8zQHsFSai9T1koCoIkNPxbjCkYMK/NNaRkJYWC79mpk XcU29drJP427G9fYkn0q/U7P5v51t3MNzKYGskE2ShwIvZ464bXMlVzg3WbrD5s5qo4r iuuZQHh2EufS1CQIiGqyNnk+de0K5c6DIjsbcaBAuVRJ3Lq4IPM/hwcUuyQn8dNpC0zv eZfFRpzS4DWJX2PRsr13c6Gs5fOECcA9vmzjq5lvqMX8U0julgXQqm1NzJl1ph1ShERi BpbMxDgN30zBimN6LircLEgTNU98k+Lw58NB7poGNl/Dzna8dYplLnG3U24w0bJYiboR Lv1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776309560; x=1776914360; 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=GgBzs6EKzyDLWZ+aqE87/ScBh1gHb7gMVIBVANVXsG8=; b=IvrovpfgapBoFFLzcPrnB17ZK2XR88jasVy1E+0JYG7SVsEmr+N1VC5OmN3+dogMpD PW6Gdv6rcOuo26XuAKrT7gHxb1r0WMr0XcReRRGxh4rbSFwEMWwptzOgrWX+EX95SMBo aDsouU6F7E/I/8qkLHxVWG4T8m105Bsh/YN6isFzKn9ND5M6ETbqqvvXEPmB0+A9cPmw n0EsTzZ8LNCWGIdlIWUebkzGcDH28rV88wD2E/9BnIG/4DLmT1EKOLcV4MshcieJGf+S D5q6nIPDNbUzSg+wWl6fKlBISb8n0to9V/wRoz2o3fQj4jliXmGQ8E/2UgAGYf20d839 JjXg== X-Forwarded-Encrypted: i=1; AFNElJ+x86qV5bK9w5Pq5jI8PXTbHeuoG2YbngSTp1RIOeC/+FdpFJI4GSGTyrhroGG/p797uIfTqvfweUvOe+E=@vger.kernel.org X-Gm-Message-State: AOJu0YwGMf9uMNa8OuwfX/YzY/lJbgdn3HTo+MqJXNyPgRHlaxN9nnC8 78eDXmW26Xf5hEmPuGfZNtAwDVQHETi97cN449wrUAhxi6WQ0C/SheTb X-Gm-Gg: AeBDies4rT+vHQgOzvCF1L9XvmmOwksUf/3QAbvCYFrXmdR+Ap3d9T34NQTSg6eQuMz vFAF5uiHsWVNzt19txk5s3wo8LxFDLrjtF5P6hY31ALzfIkhTtrbiRI1Gk2atAEjPlC8cJGzgtr lOYBTzP5f/knOIN3xURz0RrysnVR2jGrWBgLLV33a459nxgYCoBRYkqOhbLsakQJuFdX0KpvQnG hqgTTMu5VwyolQuwf7lwtZ/8ebW1SanZMA8+JXrV8KJP3RswDu1tTf0ifTBUACNyTSuSGm5C+KR baw5UiBSw3m/kce6fqYlP7GgTtUKOvSdi+m+nviwW/SoCBpmzkoEEBOU+OWUhJS4H4f4BfhmXKk q37bBsrBs2kFzSMJEOc8IRMSarg7Pdrf46RV8HFLszVzDxmYVoILMW2O7QTvXyPsSVyQx154c1K xp5k4zp1Q3n9UuSFZkFvi2yT1vl2OZNXkzOGQ56bFhLqHbc696nTkvS8mna9PBXq/XneaAGaVeh 1hZ/Fm+sccgLfaBz/lJVRl5GEG6iOvFUMjJHnk5Sh7401/F9yNhRg== X-Received: by 2002:a05:620a:29d1:b0:8dc:eca0:35bd with SMTP id af79cd13be357-8ddcd11942bmr3421071185a.5.1776309560487; Wed, 15 Apr 2026 20:19:20 -0700 (PDT) Received: from server0.tail6e7dd.ts.net (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8e4eed6eef3sm297805585a.2.2026.04.15.20.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2026 20:19:19 -0700 (PDT) From: Michael Bommarito To: linux-sctp@vger.kernel.org, Marcelo Ricardo Leitner , Xin Long Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net] sctp: fix OOB write to userspace in sctp_getsockopt_peer_auth_chunks Date: Wed, 15 Apr 2026 23:19:03 -0400 Message-ID: <20260416031903.1447072-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit sctp_getsockopt_peer_auth_chunks() checks that the caller's optval buffer is large enough for the peer AUTH chunk list with if (len < num_chunks) return -EINVAL; but then writes num_chunks bytes to p->gauth_chunks, which lives at offset offsetof(struct sctp_authchunks, gauth_chunks) == 8 inside optval. The check is missing the sizeof(struct sctp_authchunks) = 8-byte header. When the caller supplies len == num_chunks (for any num_chunks > 0) the test passes but copy_to_user() writes sizeof(struct sctp_authchunks) = 8 bytes past the declared buffer. The sibling function sctp_getsockopt_local_auth_chunks() at the next line already has the correct check: if (len < sizeof(struct sctp_authchunks) + num_chunks) return -EINVAL; Align the peer variant with its sibling. Reproducer confirms on v7.0-13-generic: an unprivileged userspace caller that opens a loopback SCTP association with AUTH enabled, queries num_chunks with a short optval, then issues the real getsockopt with len == num_chunks and sentinel bytes painted past the buffer observes those sentinel bytes overwritten with the peer's AUTH chunk type. The bytes written are under the peer's control but land in the caller's own userspace; this is not a kernel memory corruption, but it is a kernel-side contract violation that can silently corrupt adjacent userspace data. Fixes: 65b07e5d0d09 ("[SCTP]: API updates to suport SCTP-AUTH extensions.") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Michael Bommarito --- net/sctp/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 05fb00c9c335..f5d442753dc9 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -7033,7 +7033,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, /* See if the user provided enough room for all the data */ num_chunks = ntohs(ch->param_hdr.length) - sizeof(struct sctp_paramhdr); - if (len < num_chunks) + if (len < sizeof(struct sctp_authchunks) + num_chunks) return -EINVAL; if (copy_to_user(to, ch->chunks, num_chunks)) -- 2.53.0