Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rY29z-00Dxtc-KS for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Feb 2024 11:01:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rY29y-00GpZ5-Dy for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Feb 2024 11:01:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rY29y-00GpYx-20 for pgsql-hackers@lists.postgresql.org; Thu, 08 Feb 2024 11:01:38 +0000 Received: from mail-vk1-xa2f.google.com ([2607:f8b0:4864:20::a2f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rY29u-005hVR-D4 for pgsql-hackers@lists.postgresql.org; Thu, 08 Feb 2024 11:01:36 +0000 Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-4affeacaff9so585844e0c.3 for ; Thu, 08 Feb 2024 03:01:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timescale.com; s=google; t=1707390093; x=1707994893; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=7Tuqc1xFXNzdqAl/U9NIZ/bk5r5K7ipellP9O5PZ1/Q=; b=AjXVdpSVotKu3kXPDXvESKg4zKj9NMVu6ZCXGHQrYzPL4zDoJ0DHSbnx2px3Pqic57 Z0mqYxK/e0hcKqSfLR1Y/crL2PxUDrXt3AMbu1a9yDWqVK/hqnkIX6msjnD8XYvqY3os WWZjmfYCxzV3OSJWOJ0hEads0B2D+N3V9B2cuvZgd4E0xNlPZp6AzNrsOCes4UZ1yLxX TQk0aC1eINjl2n/DDaPuD3NcinTwfNJEk+wvgXoNyNYQNPVLypG6MkX9Sj3RUrvoLI1T V8QbeMkkcH1rjcKo6s5hSb4gpBGMppfiLmpoZj+qOf8PxrcmnEcC06x21gjr4VNpo24d avYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707390093; x=1707994893; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7Tuqc1xFXNzdqAl/U9NIZ/bk5r5K7ipellP9O5PZ1/Q=; b=fm3B6d3gyjGnpyjgbG1n687YIh73hZERswLW6WnSrRNE7XN+OkMp1IIK3+3/5+VSdv 79Y+IeIXsyTeJ8c6HEou3eeBkvr/2N46lnMaqB/+x7Y3Og1p51NZINDed0hH+VGvcxQH o+Z+0vA4i86h2GuWaa6/uPnNIhCtk7V6lFo9hGbqqtU7o3UCgr7IQCqWjuTAxDCQesiz LCpAbrRmUuDb72rGdHhRgg9W00AcGMaz8CWPs1wHZImZNj63TLP6X+U7mQW6jDvqgLnx r5C+F9ZZEyW+lvPC93uSY6RNPKLKmOdOyBabUb5P8iB3cAgBb5rmvP6mDvuX2C2ADSNC fyQA== X-Forwarded-Encrypted: i=1; AJvYcCWeV6tAPNFgnLw4pvBMBNDGfjYTZYfLLLkx+sYVTGcxuuDDBSugA0ZliJaZs0uYJ72K/0UuPCZY4tizyJCH04GBDQu89NMFqEbkhIu/JEZVlEyx X-Gm-Message-State: AOJu0YzDP6hlaYOlgzKrfXPWx6ivdC62+Ax9ektdqq7y7/8uvMEdL0cv lptaTcue98ndo75wjABvhS5RMZ+NvhCLC55b+fW/Axr4BR53k8RZxadRdjldemNXgPb5jRcxchc 2rd0Bq6kqdefB9+mp4NNXoIYGCXYdyC2Q5m0sQw== X-Google-Smtp-Source: AGHT+IFl91YpotrMo5IJ2+z1h0MAKvUUudER++p2k1Da6PU/DfTYZvw8InRzN6e7C37cO7gQU7CTtLHv6qOIxgzf6fM= X-Received: by 2002:a05:6122:4497:b0:4bb:36bf:78f5 with SMTP id cz23-20020a056122449700b004bb36bf78f5mr5309102vkb.16.1707390092930; Thu, 08 Feb 2024 03:01:32 -0800 (PST) MIME-Version: 1.0 References: <508821.1707232276@sss.pgh.pa.us> <20240206205305.GB3891538@nathanxps13> <642084.1707252958@sss.pgh.pa.us> <20240207205600.GA378707@nathanxps13> In-Reply-To: <20240207205600.GA378707@nathanxps13> From: Mats Kindahl Date: Thu, 8 Feb 2024 12:01:22 +0100 Message-ID: Subject: Re: glibc qsort() vulnerability To: Nathan Bossart Cc: Heikki Linnakangas , Tom Lane , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000fb89020610dcbb53" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000fb89020610dcbb53 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 7, 2024 at 9:56=E2=80=AFPM Nathan Bossart wrote: > On Wed, Feb 07, 2024 at 08:46:56PM +0200, Heikki Linnakangas wrote: > > Doesn't hurt to fix the comparison functions, and +1 on using the same > > pattern everywhere. > > I attached a new version of the patch with some small adjustments. I > haven't looked through all in-tree qsort() comparators to see if any othe= rs > need to be adjusted, but we should definitely do so as part of this threa= d. > Mats, are you able to do this? > Sure, I checked them and the only ones remaining are those using int16. Shall I modify those as well? > > However, we use our qsort() with user-defined comparison functions, and > we > > cannot make any guarantees about what they might do. So we must ensure > that > > our qsort() doesn't overflow, no matter what the comparison function > does. > > > > Looking at our ST_SORT(), it seems safe to me. > > Cool. > > -- > Nathan Bossart > Amazon Web Services: https://aws.amazon.com > --000000000000fb89020610dcbb53 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Feb 7, 2024 at 9:56=E2=80=AFPM Na= than Bossart <nathandbossart= @gmail.com> wrote:
On Wed, Feb 07, 2024 at 08:46:56PM +02= 00, Heikki Linnakangas wrote:
> Doesn't hurt to fix the comparison functions, and +1 on using the = same
> pattern everywhere.

I attached a new version of the patch with some small adjustments.=C2=A0 I<= br> haven't looked through all in-tree qsort() comparators to see if any ot= hers
need to be adjusted, but we should definitely do so as part of this thread.=
Mats, are you able to do this?

Sure, I = checked them and the only ones remaining are those using int16. Shall I mod= ify those as well?
=C2=A0
> However, we use our qsort() with user-defined comparison functions, an= d we
> cannot make any guarantees about what they might do. So we must ensure= that
> our qsort() doesn't overflow, no matter what the comparison functi= on does.
>
> Looking at our ST_SORT(), it seems safe to me.

Cool.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
--000000000000fb89020610dcbb53--