From patchwork Wed Sep 30 21:05:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1374708 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Y0s38T2q; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C1ph70xHNz9sVH for ; Thu, 1 Oct 2020 07:05:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 96300385DC14; Wed, 30 Sep 2020 21:05:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 96300385DC14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1601499955; bh=7J8Q1efx4bOzkXleWwg+9Bh2io24YA/JGPIHHScSLjs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Y0s38T2qDL/wsjHw3m7yf1uiF08fx/zroNZsU56G1/aFtdeMvH3QWVo1gWBBmnJuS AHFcI+BFY2QqBdrJIVip48Fs9A4M1ii1pAJGIHY5c+qU0UmJx6fMFg0q+QobjsSEVi YWMp0diwbtiN+qLtPcYT80DMmJztGiYxy18beE1g= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by sourceware.org (Postfix) with ESMTPS id 2EA2B385702F for ; Wed, 30 Sep 2020 21:05:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2EA2B385702F Received: by mail-qk1-x743.google.com with SMTP id q63so3038051qkf.3 for ; Wed, 30 Sep 2020 14:05:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7J8Q1efx4bOzkXleWwg+9Bh2io24YA/JGPIHHScSLjs=; b=uJ0wqktRMDxBErhqk55pCYJqj8M5QAN2OTMBfydY8j7lQhOg4c5XOL6wc6AVZSwoKe paPnSKeocBwjQK40q/85MOa3QFpA5UuPvCmJVVGHa5QqFGmVLplY+gPIoNCZJT51plds O0WfBWOZy6utDLX9ZcLh2/4WmFzFll8qSOJoWUPXDyquTiRxHOvtpgzRaoLWCpDNlpQt 5hKuHG5gT53ZqAoRBCfqFW2+9rRW+y6CRhn+tKt+007LTL4o1l+QNEzvkLJFqK+KrvWG jzgurn9XYE/Gmxzd9RwEEeRnGvBRDJLJSrPUIh9s0Fg+qmbRmVcSx6MR11O2Jjzmo2HG NEcA== X-Gm-Message-State: AOAM533K7KApTkmOFIwn7gU87QJN2HRxouWwIZy2XBgMOAgD4iFdEIqI YrJhSkRzz0rglhX+4W6njUgX6LczJ67Mkw== X-Google-Smtp-Source: ABdhPJxGJrJ6Ux1om4+xOJEzdn8ca7jzaHCu3y9i/f/wVzx0mOW2P7UAQhXJkKzTF/LQPgprZdR0oA== X-Received: by 2002:a37:38f:: with SMTP id 137mr4483217qkd.416.1601499951004; Wed, 30 Sep 2020 14:05:51 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id k20sm3734883qtm.44.2020.09.30.14.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 14:05:50 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [COMMITTED] sysvipc: Fix semtimedop for Linux < 5.1 for 64-bit ABI Date: Wed, 30 Sep 2020 18:05:46 -0300 Message-Id: <20200930210546.1203213-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Both powerpc64 and s390x provides semtimedop through __NR_ipc for pre v5.1 kernel. Neither the y2038 support (7c437d3778) nor the attempt to fix an issue for !__ASSUME_DIRECT_SYSVIPC_SYSCALLS (aaa12e9ff0) took this in consideration. This patch fixes it by issuing __NR_semtimedop_time64 iff it is defined, otherwise __NR_semtimeop is issued if both __ASSUME_DIRECT_SYSVIPC_SYSCALLS it set and __NR_semtimedop is define, other __NR_ipc is used instead. To summarize: 1. For 32-bit architetures __NR_semtimedop_time64 is always issued. The fallback is used only for !__ASSUME_TIME64_SYSCALLS and it issues either __NR_ipc or __NR_semtimedop. 2. For 64-bit architecture with wire-up SysV syscall (__ASSUME_DIRECT_SYSVIPC_SYSCALLS and __NR_semtimeop defined) __NR_semtimeop is issued. 3. Otherwise __NR_ipc is used instead. Checked on x86_64-linux-gnu, i686-linux-gnu (kernel 4.15 and 5.4), powerpc64le (kernel 4.18), and s390x (kernel 4.12). Reviewed-by: Matheus Castanho --- sysdeps/unix/sysv/linux/semtimedop.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sysdeps/unix/sysv/linux/semtimedop.c b/sysdeps/unix/sysv/linux/semtimedop.c index a9ad922ee2..29647f8ccd 100644 --- a/sysdeps/unix/sysv/linux/semtimedop.c +++ b/sysdeps/unix/sysv/linux/semtimedop.c @@ -26,11 +26,15 @@ int __semtimedop64 (int semid, struct sembuf *sops, size_t nsops, const struct __timespec64 *timeout) { -#ifndef __NR_semtimedop_time64 -# define __NR_semtimedop_time64 __NR_semtimedop + int r; +#if defined __NR_semtimedop_time64 + r = INLINE_SYSCALL_CALL (semtimedop_time64, semid, sops, nsops, timeout); +#elif defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS && defined __NR_semtimedop + r = INLINE_SYSCALL_CALL (semtimedop, semid, sops, nsops, timeout); +#else + r = INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid, + SEMTIMEDOP_IPC_ARGS (nsops, sops, timeout)); #endif - int r = INLINE_SYSCALL_CALL (semtimedop_time64, semid, sops, nsops, - timeout); #ifndef __ASSUME_TIME64_SYSCALLS if (r == 0 || errno != ENOSYS)