kurt-vd / linux

Linux kernel source tree

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Correct kernel configuration

grabor opened this issue · comments

Hello,
I have merged the branch j1939d-v4.9.10 into the Debian kernel linux-image-4.9.0-5-amd64 (4.9.65-3 + deb9u2). I have added the rt patches (rt52) and built the kernel with the Debian rt kernel configuration. Afterwards I loaded the kernel module can-j1939 with modprobe and got a segmentation fault.

I rebuilt the kernel again with a different configuration (custom). After that, there was no segmentation fault anymore. I do not know what setting in the kernel configuration has the can-j1939 module made to work.

The two kernel configurations differed a lot. What I noticed is that CONFIG_CAN_VCAN, CONFIG_CAN_SLCAN, CONFIG_NETFILTER and CONFIG_HYPERVISOR_GUEST are not set in the working configuration. Maybe that has an effect. But I am not sure.

Does anyone know if certain kernel configurations can cause a conflict with the can-j1939 module?

best regards

Thanks for your reply.

I tried again with a different approach.
(The OS im working on is Debian 9 amd64.)

I have cloned the stable vanilla kernel 4.9.65:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cd linux-stable
git checkout v4.9.65

After that I merged in the branch j1939d-v4.9.10:
git remote add j1939 git://github.com/kurt-vd/linux
git remote update j1939
git merge j1939/j1939d-v4.9.10

Below is the output of the git merge process:

automatischer Merge von net/can/raw.c
automatischer Merge von net/can/bcm.c
automatischer Merge von net/can/af_can.h
automatischer Merge von include/linux/can/core.h
Merge made by the 'recursive' strategy.
Documentation/networking/j1939.txt | 576 +++++++++++++++++++++++++++++++++++++++++++++++
Documentation/sysctl/net.txt | 46 ++++
MAINTAINERS | 9 +
include/linux/can/core.h | 9 +
include/uapi/linux/can.h | 24 +-
include/uapi/linux/can/Kbuild | 1 +
include/uapi/linux/can/j1939.h | 93 ++++++++
net/can/Kconfig | 2 +
net/can/Makefile | 2 +
net/can/af_can.h | 3 +
net/can/bcm.c | 4 +-
net/can/j1939/Kconfig | 22 ++
net/can/j1939/Makefile | 11 +
net/can/j1939/address-claim.c | 212 ++++++++++++++++++
net/can/j1939/bus.c | 244 ++++++++++++++++++++
net/can/j1939/j1939-priv.h | 313 ++++++++++++++++++++++++++
net/can/j1939/main.c | 474 +++++++++++++++++++++++++++++++++++++++
net/can/j1939/socket.c | 811 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
net/can/j1939/transport.c | 1505 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
net/can/raw.c | 4 +-
20 files changed, 4359 insertions(+), 6 deletions(-)
create mode 100644 Documentation/networking/j1939.txt
create mode 100644 include/uapi/linux/can/j1939.h
create mode 100644 net/can/j1939/Kconfig
create mode 100644 net/can/j1939/Makefile
create mode 100644 net/can/j1939/address-claim.c
create mode 100644 net/can/j1939/bus.c
create mode 100644 net/can/j1939/j1939-priv.h
create mode 100644 net/can/j1939/main.c
create mode 100644 net/can/j1939/socket.c
create mode 100644 net/can/j1939/transport.c

Then, I built the kernel with the Debian kernel configuration for 4.9.65:
http://security.debian.org/debian-security/pool/updates/main/l/linux/linux-source-4.9_4.9.65-3+deb9u2_all.deb

mkdir ../debian_kernel_conf; cd ../debian_kernel_conf
wget http://security.debian.org/debian-security/pool/updates/main/l/linux/linux-source-4.9_4.9.65-3+deb9u2_all.deb
ar -x linux-source-4.9_4.9.65-3+deb9u2_all.deb
tar xf data.tar.gz
cd -
xzcat ../debian_kernel_conf/usr/src/linux-config-4.9/config.amd64_none_amd64.xz > .config
make oldconfig

Below is a part of the output of make oldconfig process.
I chose CAN_J1939 as module and set CAN_J1939_DEBUG to "yes". The rest I left everything to default.

HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --oldconfig Kconfig
Restart config...
CAN bus subsystem support
CAN bus subsystem support (CAN) [M/n/y/?] m
Raw CAN Protocol (raw access with CAN-ID filtering) (CAN_RAW) [M/n/?] m
Broadcast Manager CAN Protocol (with content filtering) (CAN_BCM) [M/n/?] m
CAN Gateway/Router (with netlink configuration) (CAN_GW) [M/n/?] m
SAE J1939 (CAN_J1939) [N/m/?] (NEW) m
debug SAE J1939 (CAN_J1939_DEBUG) [N/y/?] (NEW) y
CAN Device Drivers
Virtual Local CAN Interface (vcan) (CAN_VCAN) [M/n/?] m
Serial / USB serial CAN Adaptors (slcan) (CAN_SLCAN) [M/n/?] m
Platform CAN drivers with Netlink support (CAN_DEV) [M/n/?] m
CAN bit-timing calculation (CAN_CALC_BITTIMING) [Y/n/?] y
Enable LED triggers for Netlink based drivers (CAN_LEDS) [N/y/?] n
Bosch C_CAN/D_CAN devices
Bosch C_CAN/D_CAN devices (CAN_C_CAN) [N/m] n
Bosch CC770 and Intel AN82527 devices
Bosch CC770 and Intel AN82527 devices (CAN_CC770) [N/m] n
IFI CAN_FD IP (CAN_IFI_CANFD) [N/m/?] n
Bosch M_CAN devices (CAN_M_CAN) [N/m/?] n
Philips/NXP SJA1000 devices
Philips/NXP SJA1000 devices (CAN_SJA1000) [M/n] m
ISA Bus based legacy SJA1000 driver (CAN_SJA1000_ISA) [M/n/?] m
Generic Platform Bus based SJA1000 driver (CAN_SJA1000_PLATFORM) [N/m/?] n
EMS CPC-CARD Card (CAN_EMS_PCMCIA) [M/n/?] m
EMS CPC-PCI, CPC-PCIe and CPC-104P Card (CAN_EMS_PCI) [M/n/?] m
PEAK PCAN-PC Card (CAN_PEAK_PCMCIA) [M/n/?] m
PEAK PCAN-PCI/PCIe/miniPCI Cards (CAN_PEAK_PCI) [M/n/?] m
PEAK PCAN-ExpressCard Cards (CAN_PEAK_PCIEC) [Y/n/?] y
Kvaser PCIcanx and Kvaser PCIcan PCI Cards (CAN_KVASER_PCI) [M/n/?] m
PLX90xx PCI-bridge based Cards (CAN_PLX_PCI) [M/n/?] m
Softing Gmbh CAN generic support (CAN_SOFTING) [M/n/?] m
Softing Gmbh CAN pcmcia cards (CAN_SOFTING_CS) [M/n/?] m
CAN SPI interfaces
Microchip MCP251x SPI CAN controllers (CAN_MCP251X) [N/m/?] n
CAN USB interfaces
EMS CPC-USB/ARM7 CAN/USB interface (CAN_EMS_USB) [M/n/?] m
ESD USB/2 CAN/USB interface (CAN_ESD_USB2) [M/n/?] m
Geschwister Schneider UG interfaces (CAN_GS_USB) [M/n/?] m
Kvaser CAN/USB interface (CAN_KVASER_USB) [M/n/?] m
PEAK PCAN-USB/USB Pro interfaces for CAN 2.0b/CAN-FD (CAN_PEAK_USB) [M/n/?] m
8 devices USB2CAN interface (CAN_8DEV_USB) [M/n/?] m
CAN devices debugging messages (CAN_DEBUG_DEVICES) [N/y/?] n
Frame buffer Devices
Support for frame buffer devices
Support for frame buffer devices (FB) [Y/m/?] y
Enable firmware EDID (FIRMWARE_EDID) [Y/n/?] y
...

Then, I built the kernel:
make -j5 deb-pkg > ../kernel_make.log 2>&1

...and installed it (on Debian9 amd64):
sudo dpkg -i ../linux-image-4.9.65+_4.9.65+-2_amd64.deb

After a reboot i start the can-j1939 kernel module:
sudo modprobe can-j1939

An then I get a segmentation fault and the system is not stable anymore.
I hope you can reproduce my steps. I have no idea which kernel configuration setting(s) causing the issue.

best regards