Linux Modules
 help / color / mirror / Atom feed
From: Jan Luebbe <jlu@pengutronix.de>
To: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Cc: linux-modules <linux-modules@vger.kernel.org>
Subject: Re: [PATCH] libkmod: Avoid calling syscall() with -1
Date: Thu, 2 May 2013 21:41:19 +0200	[thread overview]
Message-ID: <20130502194119.GA18636@pengutronix.de> (raw)
In-Reply-To: <CAMOw1v64418ddfM4v3OW7sEYGq+d7FKmHUsizAsDbNRQnSy10w@mail.gmail.com>

On Thu, May 02, 2013 at 01:21:08PM -0300, Lucas De Marchi wrote:
> Indeed. But I had already a patch for that, just waiting the bug
> reporter to test it:
> 
> http://bugs.funtoo.org/browse/FL-534
> 
> And the patch:
> http://bugs.funtoo.org/secure/attachment/11098/dont-call-libc.diff

In that patch, the new #ifndef is never used, as __NR_finit_module is
defined a few lines up.

This one looks better, but failes to compile:
http://bugs.funtoo.org/secure/attachment/11099/0001-missing-Don-t-call-syscall-with-syscallno-1.patch
libkmod/missing.h:27:17: error: '__NR_finit_module' undeclared (first use in this function)

I've changed your patch a little (put the real call into the #else branch).
With this version, I don't see the problem any more.

----

From: Lucas De Marchi <lucas.de.marchi@gmail.com>
Date: Thu, 2 May 2013 13:22:57 -0300
Subject: [PATCH] missing: Don't call syscall() with syscallno == -1

Reported-by: Jean-Francis Roy <jeanfrancis@funtoo.org>
Reported-by: Jan Luebbe <jlu@pengutronix.de>
---
 libkmod/missing.h |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libkmod/missing.h b/libkmod/missing.h
index edb88b9..b31af84 100644
--- a/libkmod/missing.h
+++ b/libkmod/missing.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <errno.h>
 #include <unistd.h>
 #include <sys/syscall.h>
 
@@ -15,13 +16,14 @@
 # define MODULE_INIT_IGNORE_VERMAGIC 2
 #endif
 
-#ifndef __NR_finit_module
-# define __NR_finit_module -1
-#endif
-
 #ifndef HAVE_FINIT_MODULE
 static inline int finit_module(int fd, const char *uargs, int flags)
 {
+#ifndef __NR_finit_module
+	errno = ENOSYS;
+	return -1;
+#else
 	return syscall(__NR_finit_module, fd, uargs, flags);
+#endif
 }
 #endif

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2013-05-02 19:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-02 14:47 [PATCH] libkmod: Avoid calling syscall() with -1 Jan Luebbe
2013-05-02 16:21 ` Lucas De Marchi
2013-05-02 19:41   ` Jan Luebbe [this message]
2013-05-02 19:56     ` Lucas De Marchi
2013-05-11  4:01 ` 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=20130502194119.GA18636@pengutronix.de \
    --to=jlu@pengutronix.de \
    --cc=linux-modules@vger.kernel.org \
    --cc=lucas.demarchi@profusion.mobi \
    /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