Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win64 target #25

Open
staalmannen opened this issue Dec 3, 2015 · 7 comments
Open

Win64 target #25

staalmannen opened this issue Dec 3, 2015 · 7 comments

Comments

@staalmannen
Copy link

I played around a bit with cross-compiling to Win64 with mingw-w64 by adding the needed "pe-x86-64" in tools/lkl/Makefile and arch/lkl/Makefile.

"interestingly" it fails in two different ways if I add or don't add
select 64BIT if OUTPUT_FORMAT = "pe-x86-64"
in arch/lkl/Kbuild

Without it, it fails on the compilation check
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
in include/linux/bug.h

With it, it fails on
include/linux/tty.h
Width of "unused" is longer than its type
unused:BITS_PER_LONG - 2

I have tried setting BITS_PER_LONG=32 manually as a KBUILD_CFLAG
(which it should be on Win64)

I am guessing that both of these issues is due to Win64 being LLP64 which means that assumptions in compilation checks etc are not always correct.
The question is just - what would be the advisable approach - go for 64bit and try to solve the incompatibilities or rather go for 32bit and try to solve incompatibilities?

If someone smarter than me is already working on this I will just drop it :)

@tavip
Copy link
Member

tavip commented Dec 3, 2015

The question is just - what would be the advisable approach - go for 64bit and try to solve the incompatibilities or rather go for 32bit and try to solve incompatibilities?

I don't know :) But I think it will require significant changes to support 32bit longs. And we need to do that without too much intrusion in the kernel.

If someone smarter than me is already working on this I will just drop it :)

I don't plan to look into this in the next couple of months.

@spoiledsport
Copy link

I am trying to open this one again. I have been able to compile 64bit version in windows using MSYS2. I made very few directed changes in two makefiles and one KConfig file to address missing pe-x86-64. The compilation proceed normally. It generate the vmlinux file.

using the objdump command
objdump -f vmlinux

I get
vmlinux: file format pe-x86-64
architecture: i386:x86-64, flags 0x00000039:
HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
start address 0x0000000000000000

Looks good. The problem is that linking the dll is failing. I already rollback to binutils 2.6. I am getting the following errors

$ make -C tools/lkl V=1
make: Entering directory '/e/Dev/GitHub/lkl/linux/tools/lkl'
make -f /e/Dev/GitHub/lkl/linux/tools/build/Makefile.build dir=lib obj=lkl
gcc -shared -o /e/Dev/GitHub/lkl/linux/tools/lkl/liblkl.dll /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o -lws2_32
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_mkdir': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:464: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:464:(.text+0x103): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_mount':
/e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:539: undefined reference to lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:539:(.text+0x166): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_rmdir': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:467: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:467:(.text+0x199): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_umount':
/e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:533: undefined reference to lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:533:(.text+0x214): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_nanosleep': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:254: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:254:(.text+0x25a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:/e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356: more undefined references to lkl_syscall' follow
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_open': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356:(.text+0x2d7): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_lseek': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:371:(.text+0x39a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_close': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:365:(.text+0x3ea): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_getdents64': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:506:(.text+0x47e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_open': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356:(.text+0x6b9): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_read': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:374:(.text+0x6fe): additional relocation overflows omitted from the output /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function virtio_dev_setup':
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:529: undefined reference to lkl_get_free_irq' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:550: undefined reference to lkl_is_running'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_virtio_mmio_device_add': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:2: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function virtio_dev_setup': /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:555: undefined reference to lkl_put_irq'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function virtio_dev_cleanup': /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:582: undefined reference to lkl_is_running'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_open': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_write': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:377: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_close': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:365: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function virtio_dev_cleanup': /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:618: undefined reference to lkl_put_irq'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_umount': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:533: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function virtio_deliver_irq': /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:84: undefined reference to lkl_trigger_irq'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_open': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_read': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:374: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_close': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:365: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_open': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_write': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:377: undefined reference to lkl_syscall'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:/e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:365: more undefined references to `lkl_syscall' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:148: /e/Dev/GitHub/lkl/linux/tools/lkl/liblkl.dll] Error 1
make: Leaving directory '/e/Dev/GitHub/lkl/linux/tools/lkl'

Any ideas?

@Rondom
Copy link

Rondom commented Jan 22, 2017

MSYS2/Cygwin are LP64, so there is no problem there. This issue is about "native" MinGW 64-bit, which is LLP64.

Therefore I think what you are describing is some other issue.

@spoiledsport
Copy link

Rondom

MinGW has nothing to do with this. This is MSYS2. The problem is not related to LP64/LLP64. This is related to problems with GCC. I see that this is a common problem with large codebases. I actually changed the build configuration to LD in the Makefile as suggested in many different newsgroups., but that came up with different issues.

I added the link options -mcmodel=large -shared, now I am getting a different set of errors

ld -r -o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/fs.o /e/Dev/GiHub/lkl/linux/tools/lkl/lib/iomem.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/net.o /e/Dev/GitHub/lkl/linux/tools/lk/lib/jmp_buf.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/nt-host.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/utils.o /e/ev/GitHub/lkl/linux/tools/lkl/lib/virtio_blk.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.o /e/Dev/GitHub/lkl/inux/tools/lkl/lib/dbg.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/dbg_handler.o
ar -rc /e/Dev/GitHub/lkl/linux/tools/lkl/liblkl.a /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o /e/Dev/GitHub/ll/linux/tools/lkl/lib/lkl.o
gcc -shared -o /e/Dev/GitHub/lkl/linux/tools/lkl/liblkl.dll /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o /e/De/GitHub/lkl/linux/tools/lkl/lib/lkl.o -lws2_32
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:fs.c:(.rdata$.refptr.lkl_syscall[.refptr.lkl_syscall]+0x0): undefned reference to lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:fs.c:(.rdata$.refptr.lkl_put_irq[.refptr.lkl_put_irq]+0x0): undefned reference to lkl_put_irq'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:fs.c:(.rdata$.refptr.lkl_is_running[.refptr.lkl_is_running]+0x0):undefined reference to lkl_is_running' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:fs.c:(.rdata$.refptr.lkl_get_free_irq[.refptr.lkl_get_free_irq]+00): undefined reference to lkl_get_free_irq'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:fs.c:(.rdata$.refptr.lkl_trigger_irq[.refptr.lkl_trigger_irq]+0x0: undefined reference to lkl_trigger_irq' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xb478): relocation truncated to fit: rva32 against exit.text'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xb47c): relocation truncated to fit: rva32 against exit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xd8f0): relocation truncated to fit: rva32 against exit.text'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xd8f4): relocation truncated to fit: rva32 against exit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xec4c): relocation truncated to fit: rva32 against exit.text'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xec50): relocation truncated to fit: rva32 against exit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xec58): relocation truncated to fit: rva32 against exit.text'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xec5c): relocation truncated to fit: rva32 against exit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xf1bc): relocation truncated to fit: rva32 against exit.text'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xf1c0): relocation truncated to fit: rva32 against `exit.text'
/e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xf1c8): additional relocation overflows omitted fromthe output
collect2: error: ld returned 1 exit status
make: *** [Makefile:148: /e/Dev/GitHub/lkl/linux/tools/lkl/liblkl.dll] Error 1
make: Leaving directory '/e/Dev/GitHub/lkl/linux/tools/lkl'

@spoiledsport
Copy link

I will open a new issue with more clean understanding and explanation

@spoiledsport
Copy link

#306

@Rondom
Copy link

Rondom commented Jan 22, 2017

I think there was a misunderstanding. What I meant to say was that your MSYS2-linker-issue is unrelated to this one and is thus better dealt with in a separate issue.

tavip pushed a commit to tavip/linux that referenced this issue Mar 20, 2018
Documentation: teaching: lectures: syscalls.rst: Corrected minor typos
retrage pushed a commit to retrage/linux that referenced this issue Dec 14, 2018
syzbot caught an infinite recursion in nsh_gso_segment().

Problem here is that we need to make sure the NSH header is of
reasonable length.

BUG: MAX_LOCK_DEPTH too low!
turning off the locking correctness validator.
depth: 48  max: 48!
48 locks held by syz-executor0/10189:
 #0:         (ptrval) (rcu_read_lock_bh){....}, at: __dev_queue_xmit+0x30f/0x34c0 net/core/dev.c:3517
 #1:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 #1:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 #2:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 #2:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 #3:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 #3:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 #4:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 #4:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#5:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#5:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#6:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#6:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#7:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#7:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#8:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#8:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#9:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#9:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#10:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#10:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#11:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#11:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#12:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#12:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#13:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#13:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#14:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#14:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#15:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#15:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#16:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#16:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#17:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#17:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#18:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#18:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#19:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#19:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#20:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#20:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#21:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#21:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#22:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#22:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#23:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#23:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#24:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#24:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#25:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#25:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#26:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#26:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#27:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#27:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#28:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#28:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#29:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#29:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#30:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#30:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#31:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#31:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
dccp_close: ABORT with 65423 bytes unread
 lkl#32:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#32:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#33:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#33:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#34:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#34:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#35:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#35:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#36:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#36:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#37:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#37:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#38:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#38:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#39:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#39:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#40:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#40:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#41:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#41:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#42:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#42:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#43:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#43:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#44:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#44:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#45:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#45:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#46:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#46:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
 lkl#47:         (ptrval) (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2080 [inline]
 lkl#47:         (ptrval) (rcu_read_lock){....}, at: skb_mac_gso_segment+0x221/0x720 net/core/dev.c:2787
INFO: lockdep is turned off.
CPU: 1 PID: 10189 Comm: syz-executor0 Not tainted 4.17.0-rc2+ lkl#26
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1b9/0x294 lib/dump_stack.c:113
 __lock_acquire+0x1788/0x5140 kernel/locking/lockdep.c:3449
 lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
 rcu_lock_acquire include/linux/rcupdate.h:246 [inline]
 rcu_read_lock include/linux/rcupdate.h:632 [inline]
 skb_mac_gso_segment+0x25b/0x720 net/core/dev.c:2789
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 nsh_gso_segment+0x405/0xb60 net/nsh/nsh.c:107
 skb_mac_gso_segment+0x3ad/0x720 net/core/dev.c:2792
 __skb_gso_segment+0x3bb/0x870 net/core/dev.c:2865
 skb_gso_segment include/linux/netdevice.h:4025 [inline]
 validate_xmit_skb+0x54d/0xd90 net/core/dev.c:3118
 validate_xmit_skb_list+0xbf/0x120 net/core/dev.c:3168
 sch_direct_xmit+0x354/0x11e0 net/sched/sch_generic.c:312
 qdisc_restart net/sched/sch_generic.c:399 [inline]
 __qdisc_run+0x741/0x1af0 net/sched/sch_generic.c:410
 __dev_xmit_skb net/core/dev.c:3243 [inline]
 __dev_queue_xmit+0x28ea/0x34c0 net/core/dev.c:3551
 dev_queue_xmit+0x17/0x20 net/core/dev.c:3616
 packet_snd net/packet/af_packet.c:2951 [inline]
 packet_sendmsg+0x40f8/0x6070 net/packet/af_packet.c:2976
 sock_sendmsg_nosec net/socket.c:629 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:639
 __sys_sendto+0x3d7/0x670 net/socket.c:1789
 __do_sys_sendto net/socket.c:1801 [inline]
 __se_sys_sendto net/socket.c:1797 [inline]
 __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1797
 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Fixes: c411ed8 ("nsh: add GSO support")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jiri Benc <jbenc@redhat.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Acked-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
retrage pushed a commit to retrage/linux that referenced this issue Jan 15, 2019
Chen Yu reported a divide-by-zero error when accessing the 'size'
resctrl file when a MBA resource is enabled.

divide error: 0000 [#1] SMP PTI
CPU: 93 PID: 1929 Comm: cat Not tainted 4.19.0-rc2-debug-rdt+ lkl#25
RIP: 0010:rdtgroup_cbm_to_size+0x7e/0xa0
Call Trace:
rdtgroup_size_show+0x11a/0x1d0
seq_read+0xd8/0x3b0

Quoting Chen Yu's report: This is because for MB resource, the
r->cache.cbm_len is zero, thus calculating size in rdtgroup_cbm_to_size()
will trigger the exception.

Fix this issue in the 'size' file by getting correct memory bandwidth value
which is in MBps when MBA software controller is enabled or in percentage
when MBA software controller is disabled.

Fixes: d9b48c8 ("x86/intel_rdt: Display resource groups' allocations in bytes")
Reported-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Chen Yu <yu.c.chen@intel.com>
Cc: "H Peter Anvin" <hpa@zytor.com>
Cc: "Tony Luck" <tony.luck@intel.com>
Cc: "Xiaochen Shen" <xiaochen.shen@intel.com>
Link: https://lkml.kernel.org/r/20180904174614.26682-1-yu.c.chen@intel.com
Link: https://lkml.kernel.org/r/1537048707-76280-3-git-send-email-fenghua.yu@intel.com
retrage pushed a commit to retrage/linux that referenced this issue Jan 15, 2019
Add missing prepare/unprepare operations for fbi->clk,
this fixes following kernel warning:

  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:874 clk_core_enable+0x2c/0x1b0
  Enabling unprepared disp0_clk
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper Not tainted 4.18.0-rc8-00032-g02b43ddd4f21-dirty lkl#25
  Hardware name: Marvell MMP2 (Device Tree Support)
  [<c010f7cc>] (unwind_backtrace) from [<c010cc6c>] (show_stack+0x10/0x14)
  [<c010cc6c>] (show_stack) from [<c011dab4>] (__warn+0xd8/0xf0)
  [<c011dab4>] (__warn) from [<c011db10>] (warn_slowpath_fmt+0x44/0x6c)
  [<c011db10>] (warn_slowpath_fmt) from [<c043898c>] (clk_core_enable+0x2c/0x1b0)
  [<c043898c>] (clk_core_enable) from [<c0439ec8>] (clk_core_enable_lock+0x18/0x2c)
  [<c0439ec8>] (clk_core_enable_lock) from [<c0436698>] (pxa168fb_probe+0x464/0x6ac)
  [<c0436698>] (pxa168fb_probe) from [<c04779a0>] (platform_drv_probe+0x48/0x94)
  [<c04779a0>] (platform_drv_probe) from [<c0475bec>] (driver_probe_device+0x328/0x470)
  [<c0475bec>] (driver_probe_device) from [<c0475de4>] (__driver_attach+0xb0/0x124)
  [<c0475de4>] (__driver_attach) from [<c0473c38>] (bus_for_each_dev+0x64/0xa0)
  [<c0473c38>] (bus_for_each_dev) from [<c0474ee0>] (bus_add_driver+0x1b8/0x230)
  [<c0474ee0>] (bus_add_driver) from [<c0476a20>] (driver_register+0xac/0xf0)
  [<c0476a20>] (driver_register) from [<c0102dd4>] (do_one_initcall+0xb8/0x1f0)
  [<c0102dd4>] (do_one_initcall) from [<c0b010a0>] (kernel_init_freeable+0x294/0x2e0)
  [<c0b010a0>] (kernel_init_freeable) from [<c07e9eb8>] (kernel_init+0x8/0x10c)
  [<c07e9eb8>] (kernel_init) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
  Exception stack(0xd008bfb0 to 0xd008bff8)
  bfa0:                                     00000000 00000000 00000000 00000000
  bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  bfe0: 00000000 00000000 00000000 00000000 00000013 00000000
  ---[ end trace c0af40f9e2ed7cb4 ]---

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
[b.zolnierkie: enhance patch description a bit]
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
prp pushed a commit to lsds/lkl that referenced this issue Sep 7, 2020
[ Upstream commit e24c644 ]

I compiled with AddressSanitizer and I had these memory leaks while I
was using the tep_parse_format function:

    Direct leak of 28 byte(s) in 4 object(s) allocated from:
        #0 0x7fb07db49ffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
        #1 0x7fb07a724228 in extend_token /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:985
        #2 0x7fb07a724c21 in __read_token /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:1140
        #3 0x7fb07a724f78 in read_token /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:1206
        #4 0x7fb07a725191 in __read_expect_type /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:1291
        #5 0x7fb07a7251df in read_expect_type /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:1299
        #6 0x7fb07a72e6c8 in process_dynamic_array_len /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:2849
        #7 0x7fb07a7304b8 in process_function /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:3161
        #8 0x7fb07a730900 in process_arg_token /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:3207
        #9 0x7fb07a727c0b in process_arg /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:1786
        #10 0x7fb07a731080 in event_read_print_args /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:3285
        lkl#11 0x7fb07a731722 in event_read_print /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:3369
        lkl#12 0x7fb07a740054 in __tep_parse_format /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:6335
        lkl#13 0x7fb07a74047a in __parse_event /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:6389
        lkl#14 0x7fb07a740536 in tep_parse_format /home/pduplessis/repo/linux/tools/lib/traceevent/event-parse.c:6431
        lkl#15 0x7fb07a785acf in parse_event ../../../src/fs-src/fs.c:251
        lkl#16 0x7fb07a785ccd in parse_systems ../../../src/fs-src/fs.c:284
        lkl#17 0x7fb07a786fb3 in read_metadata ../../../src/fs-src/fs.c:593
        lkl#18 0x7fb07a78760e in ftrace_fs_source_init ../../../src/fs-src/fs.c:727
        lkl#19 0x7fb07d90c19c in add_component_with_init_method_data ../../../../src/lib/graph/graph.c:1048
        lkl#20 0x7fb07d90c87b in add_source_component_with_initialize_method_data ../../../../src/lib/graph/graph.c:1127
        lkl#21 0x7fb07d90c92a in bt_graph_add_source_component ../../../../src/lib/graph/graph.c:1152
        lkl#22 0x55db11aa632e in cmd_run_ctx_create_components_from_config_components ../../../src/cli/babeltrace2.c:2252
        lkl#23 0x55db11aa6fda in cmd_run_ctx_create_components ../../../src/cli/babeltrace2.c:2347
        lkl#24 0x55db11aa780c in cmd_run ../../../src/cli/babeltrace2.c:2461
        lkl#25 0x55db11aa8a7d in main ../../../src/cli/babeltrace2.c:2673
        lkl#26 0x7fb07d5460b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

The token variable in the process_dynamic_array_len function is
allocated in the read_expect_type function, but is not freed before
calling the read_token function.

Free the token variable before calling read_token in order to plug the
leak.

Signed-off-by: Philippe Duplessis-Guindon <pduplessis@efficios.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lore.kernel.org/linux-trace-devel/20200730150236.5392-1-pduplessis@efficios.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
thehajime pushed a commit to thehajime/linux that referenced this issue Aug 5, 2022
When bringing down the netdevice or system shutdown, a panic can be
triggered while accessing the sysfs path because the device is already
removed.

    [  755.549084] mlx5_core 0000:12:00.1: Shutdown was called
    [  756.404455] mlx5_core 0000:12:00.0: Shutdown was called
    ...
    [  757.937260] BUG: unable to handle kernel NULL pointer dereference at           (null)
    [  758.031397] IP: [<ffffffff8ee11acb>] dma_pool_alloc+0x1ab/0x280

    crash> bt
    ...
    PID: 12649  TASK: ffff8924108f2100  CPU: 1   COMMAND: "amsd"
    ...
     lkl#9 [ffff89240e1a38b0] page_fault at ffffffff8f38c778
        [exception RIP: dma_pool_alloc+0x1ab]
        RIP: ffffffff8ee11acb  RSP: ffff89240e1a3968  RFLAGS: 00010046
        RAX: 0000000000000246  RBX: ffff89243d874100  RCX: 0000000000001000
        RDX: 0000000000000000  RSI: 0000000000000246  RDI: ffff89243d874090
        RBP: ffff89240e1a39c0   R8: 000000000001f080   R9: ffff8905ffc03c00
        R10: ffffffffc04680d4  R11: ffffffff8edde9fd  R12: 00000000000080d0
        R13: ffff89243d874090  R14: ffff89243d874080  R15: 0000000000000000
        ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
    lkl#10 [ffff89240e1a39c8] mlx5_alloc_cmd_msg at ffffffffc04680f3 [mlx5_core]
    lkl#11 [ffff89240e1a3a18] cmd_exec at ffffffffc046ad62 [mlx5_core]
    lkl#12 [ffff89240e1a3ab8] mlx5_cmd_exec at ffffffffc046b4fb [mlx5_core]
    lkl#13 [ffff89240e1a3ae8] mlx5_core_access_reg at ffffffffc0475434 [mlx5_core]
    lkl#14 [ffff89240e1a3b40] mlx5e_get_fec_caps at ffffffffc04a7348 [mlx5_core]
    lkl#15 [ffff89240e1a3bb0] get_fec_supported_advertised at ffffffffc04992bf [mlx5_core]
    lkl#16 [ffff89240e1a3c08] mlx5e_get_link_ksettings at ffffffffc049ab36 [mlx5_core]
    lkl#17 [ffff89240e1a3ce8] __ethtool_get_link_ksettings at ffffffff8f25db46
    lkl#18 [ffff89240e1a3d48] speed_show at ffffffff8f277208
    lkl#19 [ffff89240e1a3dd8] dev_attr_show at ffffffff8f0b70e3
    lkl#20 [ffff89240e1a3df8] sysfs_kf_seq_show at ffffffff8eedbedf
    lkl#21 [ffff89240e1a3e18] kernfs_seq_show at ffffffff8eeda596
    lkl#22 [ffff89240e1a3e28] seq_read at ffffffff8ee76d10
    lkl#23 [ffff89240e1a3e98] kernfs_fop_read at ffffffff8eedaef5
    lkl#24 [ffff89240e1a3ed8] vfs_read at ffffffff8ee4e3ff
    lkl#25 [ffff89240e1a3f08] sys_read at ffffffff8ee4f27f
    lkl#26 [ffff89240e1a3f50] system_call_fastpath at ffffffff8f395f92

    crash> net_device.state ffff89443b0c0000
      state = 0x5  (__LINK_STATE_START| __LINK_STATE_NOCARRIER)

To prevent this scenario, we also make sure that the netdevice is present.

Signed-off-by: suresh kumar <suresh2514@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants