From mboxrd@z Thu Jan 1 00:00:00 1970 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.astral-os.org; s=s2026; t=1795120437; bh=VibEVoydAgKIEVCIwJiT0a/WF/G0Qv+Wh24ccmGDzJ4=; h=Date:From:To:Subject:In-Reply-To:References:List-Id:List-Help: List-Owner:List-Post:List-Subscribe:List-Unsubscribe:From; b=Z7Do1pVeEBWrE8oBys40XEX1S6z8Iz9pe5y0UoSL2bFRKEWA0r0kfiQHvpS+TzUil r7sxFp3vlcHKq5TVnAfJsDKAahu1E+Xw7Y8AphBDncoQnhb20OwZ3PoArUqmSwX1gH 1/u1FgIkrJnjPyvtUAJetUBnKyFhsj/xhVgtunvxJBbTZIscHuDguczmRtK08AIwRK +bCuUff1xB1Y9Xbgz7W5dghByjZCRMG8MhGU/6+Duk3gPpBU0AZOqPqT5eB+C8QGIc strpJbJHQMk8pxurM5q3ymGwjYDle5y3vPolJU/JFI8PpSj0qEccW19sbIIepovUdO M8xNPNf5nhbtA== Received: from vps-ace4d786.vps.ovh.us (localhost [127.0.0.1]) by mail.astral-os.org (Postfix) with ESMTP id 414713EE69; Thu, 19 Nov 2026 20:33:57 +0000 (UTC) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=lists.astral-os.org; s=arc2026; t=1795120437; b=PRAABuWQjU65zGK4YO6BWL+V2zP4QIH/zEvmiYD1w1Bk9Isy4SZcfvMVykRyQo5N5+jJW hcFsdUTGCPnER70NGO2vAWq9ImLEn4c+GD7FYqqJG7Va7+qmW1gWoKhcTYEFORWpQWJsJ5m A5Krd/AaoTqJtwMNwfNud8h+BkU1bUXS4xmNKt2ffa4H4MoNtxvLP1+xW3cSEWYLfNfBZxV Z8CQwqf+Gkk1h53lIlvGD0YM1x5YorJ/ekkyy4WeUxsEQvzj0gb5cqAP3EdUrelz9P81BWe /MUSViEygqYX+9IDztqxOUni1WOQi/BkdQHNA3uDVssAuHEqqiTNaHHyn9xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.astral-os.org; s=arc2026; t=1795120437; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=WNJvSPSWOURNf8lichfEr8YKM2Nr8g3uMEibbRe5Dhk=; b=T95RJG//RIE7px1UKRoMLKviyp8L8pAvxueroP4pZJAcj7/41VCCgRZrCZe64IZgf09fw qELf3jhLvcSl78Pjqybyfasjjl/Fl44ERpZkfWhZj1NnfoNajsiYZMsMtMJM1yu0ML92qp7 RKtRX3PMa/rhNTEi9gUvoeTVvtmNDw3Z8gNkXiHatjsE3vCgCZ5KlgmHzk4EESNt9t5qsmL fcMtj1pP7G7nl/9I3zYtH4CRYDJfU5bO+SH/GSZHwWx+fTvl3G8nFO4git5HGFVNxcxRcXy 6b+ffSUmSQIAUZapH9uOEXeQxFjzg3ZPlxlIn589283PBsR0XcYeHe/5qhaw== ARC-Authentication-Results: i=1; lists.astral-os.org; dkim=pass header.d=astral-os.org; arc=none; dmarc=none Authentication-Results: lists.astral-os.org; dkim=pass header.d=astral-os.org; arc=none (Message is not ARC signed); dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=astral-os.org; s=mail2026; t=1795120435; bh=VibEVoydAgKIEVCIwJiT0a/WF/G0Qv+Wh24ccmGDzJ4=; h=Date:From:To:Subject:In-Reply-To:References:From; b=caCwHJezpbb+BHFLxnBQkf7XgWWx+h8zXp7u4Li9zeiRNYGxP+oUkwDFcA9CZ54Md gpC8e8Pt5vxD1nQgoFfLhAOFav3wzzkd5yN0rnqHHSFouqbm8Zw/C6KDz3nizxyRrm HKbZih+IUbzNy3pblq4kCTWki7asPCXt9ybMXV1mUvYhLWHgHjwKhoFX5ejQgbsp8G AQyZNwAFyNO0N7yFZKi/kP218JpB2cqXWKEuhFNVOERLHo9O3dnT5+KKAwOSl9wGuJ Lik+sWU1mHSDl3ronHRFpYcovfoWWLjBm7f5MqxSH866/gTUk2pv4+dm9FLK6Vz1Za 3uly4pnS7MMVg== Received: from ehlo.thunderbird.net (unknown [189.6.233.4]) by mail.astral-os.org (Postfix) with ESMTPSA id 0883B3ED4E; Thu, 19 Nov 2026 20:33:54 +0000 (UTC) Date: Thu, 19 Nov 2026 17:33:51 -0300 From: Matheus To: astral-devel@lists.astral-os.org, Marvin Friedrich Subject: Re: [PATCH] iovec: reject iovecs whose total size overflows User-Agent: Thunderbird for Android In-Reply-To: <20261119183926.81087-1-contact@marvinf.com> References: <20261119183926.81087-1-contact@marvinf.com> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: T2EDT64PT5T5T225EQA5GVQIUEM7NF3N X-Message-ID-Hash: T2EDT64PT5T5T225EQA5GVQIUEM7NF3N X-MailFrom: matheus@astral-os.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Em 19 de novembro de 2026 15:39:26 BRT, Marvin Friedrich escreveu: >diff --git a/kernel-src/include/kernel/iovec=2Eh b/kernel-src/include/ker= nel/iovec=2Eh >index ad3e8e96=2E=2Eb7ad0a0d 100644 >--- a/kernel-src/include/kernel/iovec=2Eh >+++ b/kernel-src/include/kernel/iovec=2Eh >@@ -21,7 +21,7 @@ typedef struct { > size_t total_size; > } iovec_iterator_t; >=20 >-// checks if all iovec[x]=2Eaddr is an userspace address >+// checks if all iovec[x]=2Eaddr is an userspace address and that the to= tal size fits in an ssize_t > bool iovec_user_check(iovec_t *iovec, size_t count); >=20 > // returns the sum of the size of all iovecs >diff --git a/kernel-src/io/iovec=2Ec b/kernel-src/io/iovec=2Ec >index ff8e638c=2E=2E840dfba3 100644 >--- a/kernel-src/io/iovec=2Ec >+++ b/kernel-src/io/iovec=2Ec >@@ -1,17 +1,23 @@ > #include > #include > #include >+#include >=20 > static inline bool iovec_iterator_finished(iovec_iterator_t *iovec_itera= tor) { > return iovec_iterator->total_size =3D=3D iovec_iterator->total_offset; > } >=20 > bool iovec_user_check(iovec_t *iovec, size_t count) { >- // TODO add size overflow check >+ size_t total =3D 0; >+ > for (int i =3D 0; i < count; ++i) { > // POSIX says that when len is zero, the addr can be an invalid buffer > if (iovec[i]=2Elen && IS_USER_ADDRESS(iovec[i]=2Eaddr) =3D=3D false) > return false; >+ >+ // The total size has to fit in the ssize_t returned to userspace >+ if (__builtin_add_overflow(total, iovec[i]=2Elen, &total) || total > S= IZE_MAX / 2) >+ return false; > } >=20 > return true; Applied=2E Thanks, Matheus