From patchwork Mon Jan 8 16:27:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 10150033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8076C601A1 for ; Mon, 8 Jan 2018 16:27:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AD8128778 for ; Mon, 8 Jan 2018 16:27:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F952287CF; Mon, 8 Jan 2018 16:27:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B2CF28778 for ; Mon, 8 Jan 2018 16:27:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932465AbeAHQ1U (ORCPT ); Mon, 8 Jan 2018 11:27:20 -0500 Received: from mga03.intel.com ([134.134.136.65]:53057 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932330AbeAHQ1T (ORCPT ); Mon, 8 Jan 2018 11:27:19 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 08:27:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,330,1511856000"; d="scan'208";a="19241872" Received: from ldmartin-desk.jf.intel.com (HELO ldmartin-desk.amr.corp.intel.com) ([10.24.10.86]) by fmsmga004.fm.intel.com with ESMTP; 08 Jan 2018 08:27:18 -0800 From: Lucas De Marchi To: linux-modules@vger.kernel.org Cc: caio.oliveira@intel.com Subject: [PATCH] testsuite: also wrap gettid in syscall() Date: Mon, 8 Jan 2018 08:27:08 -0800 Message-Id: <20180108162708.16662-1-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.14.3 Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Not a perfect solution for overriding syscall(), but at least it makes the testsuite to pass in a modified nsswitch.conf (one that has a module which calls syscall() to get the thread id). --- testsuite/init_module.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/testsuite/init_module.c b/testsuite/init_module.c index 199186b..130dd32 100644 --- a/testsuite/init_module.c +++ b/testsuite/init_module.c @@ -355,6 +355,22 @@ TS_EXPORT long int syscall(long int __sysno, ...) return ret; } + if (__sysno == __NR_gettid) { + static void *nextlib = NULL; + static long (*nextlib_syscall)(long number, ...); + + if (nextlib == NULL) { +#ifdef RTLD_NEXT + nextlib = RTLD_NEXT; +#else + nextlib = dlopen("libc.so.6", RTLD_LAZY); +#endif + nextlib_syscall = dlsym(nextlib, "syscall"); + } + + return nextlib_syscall(__NR_gettid); + } + /* * FIXME: no way to call the libc function due since this is a * variadic argument function and we don't have a vsyscall() variant