mirror of https://github.com/dynup/kpatch
test/integration: Add tests for patching a syscall
Add ".kpatch" to the end of "uname -s". Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
This commit is contained in:
parent
e9c0b67862
commit
373993ec1c
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
uname -s | grep -q kpatch
|
|
@ -0,0 +1,21 @@
|
|||
diff --git a/kernel/sys.c b/kernel/sys.c
|
||||
index 2e2e3f378d97..05271fe26c89 100644
|
||||
--- a/kernel/sys.c
|
||||
+++ b/kernel/sys.c
|
||||
@@ -1250,13 +1250,15 @@ static int override_release(char __user *release, size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
-SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
|
||||
+#include "kpatch-syscall.h"
|
||||
+KPATCH_SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
|
||||
{
|
||||
struct new_utsname tmp;
|
||||
|
||||
down_read(&uts_sem);
|
||||
memcpy(&tmp, utsname(), sizeof(tmp));
|
||||
up_read(&uts_sem);
|
||||
+ strcat(tmp.sysname, ".kpatch");
|
||||
if (copy_to_user(name, &tmp, sizeof(tmp)))
|
||||
return -EFAULT;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
uname -s | grep -q kpatch
|
|
@ -0,0 +1,26 @@
|
|||
diff --git a/kernel/sys.c b/kernel/sys.c
|
||||
index 1fbf388279832..b5186aa83adfa 100644
|
||||
--- a/kernel/sys.c
|
||||
+++ b/kernel/sys.c
|
||||
@@ -1392,14 +1392,18 @@ static int override_release(char __user *release, size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
-SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
|
||||
+#include "kpatch-syscall.h"
|
||||
+KPATCH_SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
|
||||
{
|
||||
+ struct new_utsname tmp;
|
||||
int errno = 0;
|
||||
|
||||
down_read(&uts_sem);
|
||||
- if (copy_to_user(name, utsname(), sizeof *name))
|
||||
- errno = -EFAULT;
|
||||
+ memcpy(&tmp, utsname(), sizeof(tmp));
|
||||
up_read(&uts_sem);
|
||||
+ strcat(tmp.sysname, ".kpatch");
|
||||
+ if (copy_to_user(name, &tmp, sizeof(tmp)))
|
||||
+ errno = -EFAULT;
|
||||
|
||||
if (!errno && override_release(name->release, sizeof(name->release)))
|
||||
errno = -EFAULT;
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
uname -s | grep -q kpatch
|
|
@ -0,0 +1,26 @@
|
|||
diff --git a/kernel/sys.c b/kernel/sys.c
|
||||
index 871c0848f05c8..479bf8725d2e6 100644
|
||||
--- a/kernel/sys.c
|
||||
+++ b/kernel/sys.c
|
||||
@@ -1241,14 +1241,18 @@ static int override_release(char __user *release, size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
-SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
|
||||
+#include "kpatch-syscall.h"
|
||||
+KPATCH_SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
|
||||
{
|
||||
+ struct new_utsname tmp;
|
||||
int errno = 0;
|
||||
|
||||
down_read(&uts_sem);
|
||||
- if (copy_to_user(name, utsname(), sizeof *name))
|
||||
- errno = -EFAULT;
|
||||
+ memcpy(&tmp, utsname(), sizeof(tmp));
|
||||
up_read(&uts_sem);
|
||||
+ strcat(tmp.sysname, ".kpatch");
|
||||
+ if (copy_to_user(name, &tmp, sizeof(tmp)))
|
||||
+ errno = -EFAULT;
|
||||
|
||||
if (!errno && override_release(name->release, sizeof(name->release)))
|
||||
errno = -EFAULT;
|
Loading…
Reference in New Issue