From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 30CAC3852C4D; Wed, 23 Nov 2022 14:46:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30CAC3852C4D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669214794; bh=byBiAFiiJ+6VDR6ctaCRWAlOH2k7Hnb0CI+isOqvXig=; h=From:To:Subject:Date:From; b=SGBVCX5cPFA2Mrub3M2lEYCtJ7ikFiUozLBt8RXxFiYAacnmWUoaUM0oG2vdLq50X wjsxk1n4XVPKW8wWENvFHlyMzNBA6H15FOrG9gfyiS0/k4QgEGGjnC3nfH9XBKY+8E MhVq3bMD5dEtFFskqJW+81mKkf2uV0dRTFTmF8M8= 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: bcc70e4b2b213030e7f4ac1f4dddd9858d5b2968 X-Git-Newrev: cf95053a832df4dc3c6f72de76d366856cdf7eae Message-Id: <20221123144634.30CAC3852C4D@sourceware.org> Date: Wed, 23 Nov 2022 14:46:34 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cf95053a832df4dc3c6f72de76d366856cdf7eae commit cf95053a832df4dc3c6f72de76d366856cdf7eae 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;