From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 173843846431; Wed, 26 Oct 2022 15:18:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 173843846431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666797486; bh=DqWpX70MMu1cKHEIcS01MA0nn8h7mnk5w0VPlUoEkYs=; h=From:To:Subject:Date:From; b=fHVKNVBIYzIMoQB9jyxXwlxIe3tFlhl03XJom6B8t6DqnsUIGwp2HGiFXQztCSLOj 56/4pjH8zZo9aFLFcC4zuQ73yZbkf4RBl24TQhdg+p8k5WkuQMdDJ/69RzZry3cHAW U0919H5CQyEfjtGDtSsWECm+I750PEc95uQCzZzg= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] cheri: fix qsort for capabilities X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: d891654a253a4f4399e446c6ac437c85baad8e89 X-Git-Newrev: 5e3c7df415a06e99191afc0fe47514821d969567 Message-Id: <20221026151806.173843846431@sourceware.org> Date: Wed, 26 Oct 2022 15:18:05 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5e3c7df415a06e99191afc0fe47514821d969567 commit 5e3c7df415a06e99191afc0fe47514821d969567 Author: Szabolcs Nagy Date: Mon Jul 12 13:06:40 2021 +0100 cheri: fix qsort for capabilities On capability targets avoid copying pointers via unsigned long. Diff: --- stdlib/msort.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stdlib/msort.c b/stdlib/msort.c index cbe9a4a8fd..43222e6c9a 100644 --- a/stdlib/msort.c +++ b/stdlib/msort.c @@ -289,6 +289,10 @@ __qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg) && ((char *) b - (char *) 0) % __alignof__ (uint64_t) == 0) p.var = 1; else if ((s & (sizeof (unsigned long) - 1)) == 0 +#ifdef __CHERI_PURE_CAPABILITY__ + && ((char *) b - (char *) 0) + % __alignof__ (void *) != 0 +#endif && ((char *) b - (char *) 0) % __alignof__ (unsigned long) == 0) p.var = 2;