From patchwork Mon Oct 14 20:56:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176339 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5011706ill; Mon, 14 Oct 2019 13:57:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXcDEGmK4Myunc8mt48WUhWm26Ja3sHNZrbBjP/UbuLAvwKQBUgnGwf7h9MK885sFkdY75 X-Received: by 2002:a17:906:4cd2:: with SMTP id q18mr7594894ejt.319.1571086668310; Mon, 14 Oct 2019 13:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086668; cv=none; d=google.com; s=arc-20160816; b=GmxoZLPtQp8+8RqmHlLfzyyT/LLasa46raFeIRH/+enyjNo0+yeSy+wGRMuibSsVr/ 4Y8IF58g2howfd1vCUJPCtU2Nt7MllaN2sw4sr7cKN1PzjKRnzFCVph+kWLKqSnypfJT N11W25zTuSmdAajMxUYiaEMRVAyGjq4UpXh71ohtYCSvJO3Bq7P88+HqfJLZWKmdhW3L qE/gZ2AdXyhcjyz/KOpTff/c1Hw8fJifPhoDuoryxxPp4IG84DvqINiRIQmbagI6+jfQ Mnm6rZN2Cb/+KV8xPoxEP/QV7bWRas5Q8Fz6z71enHXia54+b+fEQF+6Terw8hgEkRUn 5fUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=qK1QMtopK/c1QQLbgPPXFUvm+Y3GEgQidzHkuFfoxV0=; b=03Vag/QUgf5IU5883rkIEcC9HRXUHGo25uHGs6EpmFgQ9K2h76ampOfBEQ6ZaPPOiR dgn6QYAYas4WAlE8QawshuKxR1BYxn4aZldf9ijll+s5n3jGoXZllF69vyiW4uS6ehVI 6i50w+2KDdppPeVieRiZDCF4jW33desE2hP2wtsIPVpeTdXCzWh4eqw5zJphvGfTR9ld /D4xr3PSiqJUBBnQehGOIGg9G4uNr0xjqZvnfwpHgiFb3deFBnF73NWkWtObd9CRAHva 2490rqwYfLdHILAjZ0si3UOrT8D0yYICClu/79DckIGcepI//Ti4ykgo5r5GKL3zAACb CCRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="jIexB/wB"; dkim=pass header.i=@linaro.org header.s=google header.b=w20nblId; spf=pass (google.com: domain of libc-alpha-return-105930-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105930-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v16si4251606ejx.96.2019.10.14.13.57.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:57:48 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105930-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="jIexB/wB"; dkim=pass header.i=@linaro.org header.s=google header.b=w20nblId; spf=pass (google.com: domain of libc-alpha-return-105930-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105930-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=LPKGRJacHQoQ/rQixRgGftgaezZCi2s xXK5yce5TUy3nh2GS4tmAQGzouYXmd1W9/qJGXYI5/aNsE7wDx8inQ+Rxyb3QGHq vElVDAXHn1YYmRtSK7Qg4YtDybqQBvpBphg8G5Nck7ZDkBdaBP7c+wJDvGS9kB0B UjBtZR82srIo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=gKFuD+q9rUpuexyqIQ10eGixIIo=; b=jIexB /wBx5AA7/4JfXEbHGDGUXuw0DF3yJCdz95/U26YLGNjklofKj7scVAiRKUmTvPno +l6uBhWv+T38jdDuQMhKeY9a6831f8VyRSb7+RxiRmIpn0VOwhn1voQ/q6hiNGcv eKTA7/Jm1cEf+I4bZbCf29vBO01UCGWgI6DvB4= Received: (qmail 113718 invoked by alias); 14 Oct 2019 20:57:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 113573 invoked by uid 89); 14 Oct 2019 20:57:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f193.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=qK1QMtopK/c1QQLbgPPXFUvm+Y3GEgQidzHkuFfoxV0=; b=w20nblId5eAD6/gkpN0UGlYshpWeirpYDfCpLVjdnyVBCju4yDqLcdLjcn4z6syWMy 5mqH5RC72zPfSwcKKgmSJ51buT4X1OifPWF89PzCe+KsCgZgNP4LY4UTfF28WKF5V2W/ zvPtnXkylz3vk3WQUhkVmPEbc6+ZWEO4+qAgbcLSPNNOvj0Jsijjr8FYzyhhiRb+cJEk xgjhFk0TYrovXD4jbCxzqCzz3GcVGZGapZ3cPPoxjp+/IPgryhFNUuejJJEB19f45XR3 ouYxWTE0aWpLUM2wXumiNfgFeXJCKDW56hlgdwyPY0APoBb9r0xpqxWSPo95Acdb1t5+ TJnQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 04/21] nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:39 -0300 Message-Id: <20191014205656.29834-5-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patches adds the x32 modification required for the BZ#12683. It basically adjust the syscall size used to pass the arguments to the syscall cancel wrappers by zero extending pointers type while preserting values for default types (such as off_t). Checked on x86_64-linux-gnu-x32. --- include/libc-pointer-arith.h | 16 +++++++++++----- sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h | 13 +++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/include/libc-pointer-arith.h b/include/libc-pointer-arith.h index b32df719d1..0e5bb83f56 100644 --- a/include/libc-pointer-arith.h +++ b/include/libc-pointer-arith.h @@ -25,17 +25,23 @@ # define __pointer_type(type) (__builtin_classify_type ((type) 0) == 5) /* intptr_t if P is true, or T if P is false. */ -# define __integer_if_pointer_type_sub(T, P) \ +# define __integer_if_pointer_type_sub(T, P, INTTYPE) \ __typeof__ (*(0 ? (__typeof__ (0 ? (T *) 0 : (void *) (P))) 0 \ - : (__typeof__ (0 ? (intptr_t *) 0 : (void *) (!(P)))) 0)) + : (__typeof__ (0 ? (INTTYPE *) 0 : (void *) (!(P)))) 0)) /* intptr_t if EXPR has a pointer type, or the type of EXPR otherwise. */ -# define __integer_if_pointer_type(expr) \ +# define __integer_if_pointer_type(expr, inttype) \ __integer_if_pointer_type_sub(__typeof__ ((__typeof__ (expr)) 0), \ - __pointer_type (__typeof__ (expr))) + __pointer_type (__typeof__ (expr)), \ + inttype) /* Cast an integer or a pointer VAL to integer with proper type. */ -# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val)) +# define cast_to_integer(val) \ + ((__integer_if_pointer_type (val, intptr_t)) (val)) + +/* Cast an integer or a pointer VAL to unsigned integer with proper type. */ +# define cast_to_uinteger(val) \ + ((__integer_if_pointer_type (val, uintptr_t)) (val)) /* Align a value by rounding down to closest size. e.g. Using size of 4096, we get this behavior: diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h index 60a144a474..568ca1c959 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h @@ -18,6 +18,19 @@ #ifndef _LINUX_X32_SYSDEP_H #define _LINUX_X32_SYSDEP_H 1 +#ifndef __ASSEMBLER__ +#include +#include + +typedef long long int __syscall_arg_t; + +/* Syscall arguments for x32 follows x86_64 size, however pointers are 32 + bits in size. The idea is to zero extend pointer types while cast to + signed 64 bit default arguments. */ +#define __SSC(__x) ((__syscall_arg_t) cast_to_uinteger (__x)) + +#endif + /* There is some commonality. */ #include #include