linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
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	[thread overview]
Message-ID: <20180108162708.16662-1-lucas.demarchi@intel.com> (raw)

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
-- 
2.14.3


             reply	other threads:[~2018-01-08 16:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-08 16:27 Lucas De Marchi [this message]
2018-01-08 21:28 ` [PATCH v2] testsuite: also wrap gettid in syscall() Lucas De Marchi
2018-01-08 21:31   ` Caio Marcelo de Oliveira Filho
2018-01-08 21:55     ` Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180108162708.16662-1-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=caio.oliveira@intel.com \
    --cc=linux-modules@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).