From patchwork Mon Dec 11 19:06:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 121439 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3167401qgn; Mon, 11 Dec 2017 11:08:04 -0800 (PST) X-Google-Smtp-Source: ACJfBotjM8YSiIxKjYJUS3On8tPcoH8u70ZhTgvZF1knPvt4kXNUyXDZUdyqftNnOVt0qBHzzh3w X-Received: by 10.159.229.129 with SMTP id az1mr1254367plb.133.1513019284315; Mon, 11 Dec 2017 11:08:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513019284; cv=none; d=google.com; s=arc-20160816; b=z+QaYYy0IBCq5P4haVd+vanvGqGBEz3DP2McbRGX9fu7i7pxRz0yRwIf+T7vMNeGPj MnEWkOswVPo6bhthGNk5ioKhsm4SGZ8tcFm2sDipNogvp3lbge/7zQnWSH5wbozoxLZ8 zGn307Kv6TTJxpyMgHJlu37toapwtJoxSydSv/FnvVXTyJm4isB6MUK0HQJI2g3fOZeC jQqnYmOoCKUjujHgxAeIsJWE/cRhBInRuhharW4n/eROLcvCPnfOGB1ruDPYZ01I0vgx VDg58edZdu/rgbAZGkOStFyWlUf3PzQ7EDwpAsIqdtqKdqTMtKRpBLwtW68d/qY4s/Xn yEig== 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=CANBRdgKirol+rlz+5kKrRvYmaKcr5AvOnHny/WPNeY=; b=OOeRXHPkSqS4czz/jhYEV5EbyJ/VcgF5jWntO23vCw1lBTXWlqkYT8TtUgkd850gFR Sz4qUvVq8UwXyNb4jTI4Lfsp8+ZcKbXyy0zTmRBfLMVcs21gHan+tHzFxN99qdYotcdD Bn7RklXgDRJdvfF/dcNGE79Uxl+2qwIOD3tyxCsmpxJyFk9W943JqGP5xY5xvUxz4/jb /wLtoi5xrNaCnW2Ty2gHYN7QAkgzkUEJPNQzLJoM5Y+nmJgGZTazc2aIysy/6FxNo4F/ DwFyDw/G7E/KN1qO2IIsLcFCxvmMTFMdSp09X/Zy4WKra3XV7qrr8xPAy0o+1QJrQzq0 FUSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=hNpdTPup; spf=pass (google.com: domain of libc-alpha-return-88016-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-88016-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 b5si10206240pgu.108.2017.12.11.11.08.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 11:08:04 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-88016-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=hNpdTPup; spf=pass (google.com: domain of libc-alpha-return-88016-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-88016-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=nVf5EFhrbJe0xwN5zqIDOp1RRX7GkDo tJMHbiFd1Vfi3u325HYOT4fdJOh3/rAXV/7lKbpC1of8GKXs3gqvNlYEPkDlQ5zN 9DBHlt5/iNKIyGuWATzINR46A8fIKDFVuSke+skPcUmLE06coxJTkTDarrGvvwe8 dGqyjk6xOB78= 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=bXnufHF8B/xR/wqv5sfmn6PDbrk=; b=hNpdT PupqFzylewo/WBFAwGgpA/PZHsgtABG9MW4ZcbJYUwxTxv5vh0lf8r8tgLEpNhYC E9dUDP6B2ePDVHbSbzSfxn31WPFzyPVDr8g4RR3W9hqYAjns6VUbKPxW75FM2i0m fWLslN88EZRQO9b43ugm3rZ3oZouVh9MCBbz04= Received: (qmail 40843 invoked by alias); 11 Dec 2017 19:07:20 -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 40799 invoked by uid 89); 11 Dec 2017 19:07:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 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-f194.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=CANBRdgKirol+rlz+5kKrRvYmaKcr5AvOnHny/WPNeY=; b=cIktUSRQd9Ccs+KwtjuAD23lCoIter2+rEQlM2PG9hgRq2gGKIwMsuZ9VJqAHoCo+9 cic2OyX7vTiN4LC8IeRqX5RJfXPY4M2MZgs2qZpI0Ktd2h9+i2KryxIh/O/KJMGr22Vu 1As5ks7n5ubqjm1UOV4CPl9wiDf62CGH3+QXKKHDQ/wJI1N6vIkYd9h+lPaK2ELWTK+J c9zYCJPmPoe7pyVw44HGSnWqXvBWPHE57vit447avQzu3NiuEz+rslCYhvD2dsd23qyY klLSpoXd8dQKC1ZGoZry+ibcdL3QWYEwMrE6FhTzrbrCL/SjD0On7Hi+Lge1/n01//ul gy9A== X-Gm-Message-State: AKGB3mKxSGchA0gD/7KnTtbu98F9BZc8zleEpdzYZ+7ctjU5ZUtdJSa8 V0/H0odG5FGdKi9BBxCmiEgEZ10Qm0g= X-Received: by 10.200.27.76 with SMTP id p12mr2127588qtk.310.1513019236522; Mon, 11 Dec 2017 11:07:16 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 04/19] nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 11 Dec 2017 17:06:48 -0200 Message-Id: <1513019223-7603-5-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1513019223-7603-1-git-send-email-adhemerval.zanella@linaro.org> References: <1513019223-7603-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. * 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. Signed-off-by: Adhemerval Zanella --- ChangeLog | 8 ++++++++ include/libc-pointer-arith.h | 16 +++++++++++----- sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h | 13 +++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/include/libc-pointer-arith.h b/include/libc-pointer-arith.h index 715cbc1..4cacb6c 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 04c73a2..dedff6c 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