Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1093098
Bug: https://github.com/falcosecurity/libs/issues/2277
diff --git a/driver/Makefile.in b/driver/Makefile.in
index 7b1fdc2..6ae7578 100644
--- a/driver/Makefile.in
+++ b/driver/Makefile.in
@@ -26,13 +26,21 @@ clean:
 
 install: all
 	$(MAKE) -C $(KERNELDIR) M=$(TOP) modules_install
 
 else
 
-KERNELDIR 	?= $(CURDIR)
+# See https://github.com/falcosecurity/libs/issues/2277
+#
+# This needs to point to the Linux kernel sources. Prior to Linux 6.13 we could
+# use the $(CURDIR), but in 6.13 this changed. See the link above for notes. At
+# this time it isn't clear how to make this work generically (all kernel
+# versions, all architectures, all OSs, dkms or not). Until a proven "good"
+# solution is found I'm doing THIS, which works for Debian.
+KERNELDIR ?= $(realpath $(MODLIB)/build)
+
 #
 # Get the path of the module sources
 #
 FIRST_MAKEFILE := $(firstword $(MAKEFILE_LIST))
 FIRST_MAKEFILE_FILENAME := $(notdir $(FIRST_MAKEFILE))
 FIRST_MAKEFILE_DIRNAME := $(shell basename $(dir $(FIRST_MAKEFILE)))
