]> sourceware.org Git - systemtap.git/commitdiff
stapconf: adapt to kernel_read_file_from_path API change for v5.10-rc1
authorSerhei Makarov <smakarov@redhat.com>
Mon, 26 Oct 2020 17:41:04 +0000 (13:41 -0400)
committerSerhei Makarov <smakarov@redhat.com>
Mon, 26 Oct 2020 17:42:21 +0000 (13:42 -0400)
The following kernel commit changed the get_user_pages_remote()
function signature:

commit 0fa8e084648779eeb8929ae004301b3acf3bad84
Author: Kees Cook <keescook@chromium.org>
Date:   Fri Oct 2 10:38:25 2020 -0700

   fs/kernel_file_read: Add "offset" arg for partial reads

   To perform partial reads, callers of kernel_read_file*() must have a
   non-NULL file_size argument and a preallocated buffer. The new "offset"
   argument can then be used to seek to specific locations in the file to
   fill the buffer to, at most, "buf_size" per call.

   Where possible, the LSM hooks can report whether a full file has been
   read or not so that the contents can be reasoned about.

This and the preceding commits changed the function signature from:

int kernel_read_file_from_path(const char *path,
       void **buf, loff_t *size, loff_t max_size,
       enum kernel_read_file_id id);

to:

int kernel_read_file_from_path(const char *path, loff_t offset,
       void **buf, size_t buf_size,
       size_t *file_size,
       enum kernel_read_file_id id);

===

XXX kernel commit b89999d004931ab2e51236 also split
kernel_read_file_* functions into a separate header.

As both changes were merged for v5.10-rc1 within the same day,
we detect them with the same autoconf program.

buildrun.cxx
runtime/linux/autoconf-kernel_read_file_from_path-offset.c [new file with mode: 0644]
runtime/transport/symbols.c

index 468139c912a4404f33fee53aca2c045865974968..7c52986826e0969b1b3b43edc548cb47e04a0aa6 100644 (file)
@@ -421,6 +421,7 @@ compile_pass (systemtap_session& s)
   output_exportconf(s, o2, "PDE_DATA", "STAPCONF_PDE_DATA");
   output_autoconf(s, o, cs, "autoconf-module-sect-attrs.c", "STAPCONF_MODULE_SECT_ATTRS", NULL);
   output_exportconf(s, o2, "kernel_read_file_from_path", "STAPCONF_KERNEL_READ_FILE_FROM_PATH");
+  output_autoconf(s, o, cs, "autoconf-kernel_read_file_from_path-offset.c", "STAPCONF_KERNEL_READ_FILE_FROM_PATH_OFFSET", NULL);
   output_autoconf(s, o, cs, "autoconf-utrace-via-tracepoints.c", "STAPCONF_UTRACE_VIA_TRACEPOINTS", NULL);
   output_autoconf(s, o, cs, "autoconf-task_work-struct.c", "STAPCONF_TASK_WORK_STRUCT", NULL);
   output_autoconf(s, o, cs, "autoconf-vm-area-pte.c", "STAPCONF_VM_AREA_PTE", NULL);
diff --git a/runtime/linux/autoconf-kernel_read_file_from_path-offset.c b/runtime/linux/autoconf-kernel_read_file_from_path-offset.c
new file mode 100644 (file)
index 0000000..052e330
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// The following kernel commit changed the get_user_pages_remote()
+// function signature:
+//
+// commit 0fa8e084648779eeb8929ae004301b3acf3bad84
+// Author: Kees Cook <keescook@chromium.org>
+// Date:   Fri Oct 2 10:38:25 2020 -0700
+//
+//    fs/kernel_file_read: Add "offset" arg for partial reads
+//
+//    To perform partial reads, callers of kernel_read_file*() must have a
+//    non-NULL file_size argument and a preallocated buffer. The new "offset"
+//    argument can then be used to seek to specific locations in the file to
+//    fill the buffer to, at most, "buf_size" per call.
+//
+//    Where possible, the LSM hooks can report whether a full file has been
+//    read or not so that the contents can be reasoned about.
+//
+// This and the preceding commits changed the function signature from:
+//
+// int kernel_read_file_from_path(const char *path,
+//                            void **buf, loff_t *size, loff_t max_size,
+//                            enum kernel_read_file_id id);
+//
+// to:
+//
+// int kernel_read_file_from_path(const char *path, loff_t offset,
+//                            void **buf, size_t buf_size,
+//                            size_t *file_size,
+//                            enum kernel_read_file_id id);
+//
+
+// XXX kernel commit b89999d004931ab2e51236 also split
+// kernel_read_file_* functions into a separate header.
+//
+// As both changes were merged for v5.10-rc1 within the same day,
+// we detect them with the same autoconf program:
+#include <linux/kernel_read_file.h>
+
+int krffp_wrapper(const char *path, loff_t offset,
+                  void **buf, size_t buf_size,
+                  size_t *file_size,
+                  enum kernel_read_file_id id)
+{
+  return kernel_read_file_from_path(path, offset, buf, buf_size, file_size, id);
+}
index db69f2b097fbfc60f46748890e03310d736987e9..91102fcafd076456a55974c2a44c12384c8a7765 100644 (file)
 #include "../sym.h"
 #include "relay_compat.h"
 
+#ifdef STAPCONF_KERNEL_READ_FILE_FROM_PATH_OFFSET
+// XXX kernel commit b89999d004931ab2e51236 for v5.10-rc1 split
+// kernel_read_file_* functions into a separate header.
+#include <linux/kernel_read_file.h>
+#endif
+
 #ifndef KERN_CONT
 #define KERN_CONT      ""
 #endif
@@ -158,15 +164,26 @@ read_sect_sysfs(const char* module, const char *section)
         int rc;
         unsigned long addr = 0;
         void *buffer = NULL;
+#ifdef STAPCONF_KERNEL_READ_FILE_FROM_PATH_OFFSET
+        size_t size;
+#else
         loff_t size;
-        
+#endif
+
         if (pathname == 0)
                 goto out;
         rc = snprintf(pathname, PATH_MAX, "/sys/module/%s/sections/%s", module, section);
         if (rc >= PATH_MAX)
                 goto out1;
+#ifdef STAPCONF_KERNEL_READ_FILE_FROM_PATH_OFFSET
+        rc = kernel_read_file_from_path(pathname, 0 /* offset */,
+                                        &buffer, 64 /* max. bytes expected */,
+                                        &size /* file_size */,
+                                        READING_UNKNOWN);
+#else
         rc = kernel_read_file_from_path(pathname, &buffer, &size, 64 /* max. bytes expected */,
                                         READING_UNKNOWN);
+#endif
         if (rc <= 0)
                 goto out1;
         rc = kstrtoul(buffer, 0, &addr);
This page took 0.033964 seconds and 5 git commands to generate.