From patchwork Mon Feb 26 21:03:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 129705 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp4290078edc; Mon, 26 Feb 2018 13:04:33 -0800 (PST) X-Google-Smtp-Source: AH8x225mNs6gmyRFJJo5/PHKZs17W7H/LPkEiQXKNRLgb1CRq3IC9qDoVLLxDVtSSA/O4+tpSG1F X-Received: by 10.99.127.69 with SMTP id p5mr9396063pgn.346.1519679073108; Mon, 26 Feb 2018 13:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519679073; cv=none; d=google.com; s=arc-20160816; b=OxBC7DnYz4C/Opt9Iwb5OKuO+Sw4s1jZOk68pH/XqvnswJ2rTmEPAqlKdMXezi6zhx QvQAuikX6GKn5EhTZREOnNK61QuH0V+4a9sIZ4d+H3Ob3d68aSM5IqGcKKYOaSfvZ5jd pXxGi2JjuB4PzPoa3rGw0KCfGu2sBWMRENr8ob8sKt+ksHQvN7ZKAEu3/t6IPze7pROq npK0s6ubcxrHh1KUHdSGXPW98pboLf8YdDyJUrD7nzPbk2YY8OnPOfxTdp8+WPArGdyO 0EwDOj5xh3ePFlWbHV9pj57h4oR9IMLNhzUS1EpF30pOZsKNTnnfa3V4VUyDEeFtl9Ak WNgA== 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:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=p8suRjrFsnvbGHU+pIxX4d3nMdMgiYQq/qYtPg2hiUQ=; b=QB6vIeDKLlimAPPCEAEHwGF8JC1Ss142cBu8mHTNui6wKdN0XN37DOVFXXrOM6Qywy 1S6WxsvHgltM4fCw23l/muvGATIJOnTmJ2H7kshb6Jiimt5V6nxRGJI79fwNVhYDrLkY Dn4jRgu1b1lXe/75Wzk7RRfPWXofs69XYsZIF1XobzY/yA/RhI8jWh8o9dM9ywvE18Wn PKE7ROFvEuqMGemi7fE8w64RJh00XROBe+PLB9YQt+O86isRZi1BqA2Pb6Ak4JEYu8r/ C7ofCPD4Rwulzigu8eU3jp20Bhhahsr5qMvv1EOkJy9U1cVp/dW1EVYUv/Bcgif0AvKP 2YZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=HT4YoxtJ; spf=pass (google.com: domain of libc-alpha-return-90620-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-90620-patch=linaro.org@sourceware.org; dmarc=fail (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 l9si7289875pff.155.2018.02.26.13.04.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2018 13:04:33 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-90620-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=HT4YoxtJ; spf=pass (google.com: domain of libc-alpha-return-90620-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-90620-patch=linaro.org@sourceware.org; dmarc=fail (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=pdfToa18g3t3qnx96BfvHA4XHSqoOrK 2E0Cb/Qek00RN+SkUCJNVTj3BELWAA88Z8CHExSDmyO02E6XnwD0WeqcdrG0MMpF 8hHpjfP7m8sgs2O9vl/Reek6JCXrnlsVnwj+bNdUrfWqIsTl9s9+3PuWxM4k6Rfs Q0lpUKB36FIg= 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=yRvVSlCnSHEmuGWp6ykAQdOwQeA=; b=HT4Yo xtJlbiT9S5npcmRGv8wWzKfaKrPjry5J4nyvEK1VhQiJ1p+VEteWb/XHb7nm5t5b GVDKkFH1h3PY4BaQtkDiniibdiF3t300w/Mi38Jd6zhHFa7BO9Uh4zF24QrJYCeO Y7piJpUgH6VcUxPkKXHYHW1XJ2Dwnkcpt51o7k= Received: (qmail 75031 invoked by alias); 26 Feb 2018 21:03:55 -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 74908 invoked by uid 89); 26 Feb 2018 21:03:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 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.2 spammy= X-HELO: mail-qt0-f195.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=p8suRjrFsnvbGHU+pIxX4d3nMdMgiYQq/qYtPg2hiUQ=; b=cLlhqnxd2WwWPsXhBHo8Ts1voyotn0HGN6nlQ7MNKl+CvLKWne0oZ5EyW681YdzMN1 P2HRp4J+t+IMQiALLH7Lkhm8CrqDMB3Lpi6XpZrxbi8H0DFTvrLZnFn7D3LGvk+n6hSz 88RaGexNYChvrpapQ7EJdzAdn0j+FpdCzBPowWYG0xFPt0ldeDJYHG7Tzn1wOOaWR9NT vD7RhAQq7droM9DG7oK+WtSuU58kZPlchuuKfTr9V/JHLYKIjW+cV6MqVitj6P7ZOauF lc+tTu96/3Ucx1oC/S8fCaYT39PySd1IcmgfRmwDo90v05ziNo1InnWYZnb+n5Kgdw18 dJEA== X-Gm-Message-State: APf1xPCHNPcZ0o6TWOEVBuD4rE7wcW8+kNur/g6Mz98mxrUSRWzWTLa1 ShHeVjBb9v0qFb2nvtK4Mbp/hslwgY8= X-Received: by 10.200.24.196 with SMTP id o4mr19306746qtk.79.1519679030987; Mon, 26 Feb 2018 13:03:50 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 05/21] nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 26 Feb 2018 18:03:20 -0300 Message-Id: <1519679016-12241-6-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1519679016-12241-1-git-send-email-adhemerval.zanella@linaro.org> References: <1519679016-12241-1-git-send-email-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. [BZ #12683] * sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h (__syscall_arg_t): Define type for x32. (__SSC): Add platform specific macro. * include/libc-pointer-arith.h (__integer_if_pointer_type_sub, __integer_if_pointer_type, cast_to_integer): Parametrize integer type cast. (cast_to_uinteger): New macro. --- ChangeLog | 9 +++++++++ include/libc-pointer-arith.h | 16 +++++++++++----- sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h | 13 +++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/include/libc-pointer-arith.h b/include/libc-pointer-arith.h index 1ee3362..65107cc 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 7f978c7..787e7f2 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