Re: [RFC][PATCH 0/4] slab: Allow for type introspection during allocation

2024-07-09 Thread Przemek Kitszel
On 7/10/24 01:28, Kees Cook wrote: On Tue, Jul 09, 2024 at 11:02:55PM +0200, Marco Elver wrote: On Tue, 9 Jul 2024 at 22:28, Kees Cook wrote: On Tue, Jul 09, 2024 at 10:26:32AM -0700, Christoph Lameter (Ampere) wrote: On Mon, 8 Jul 2024, Kees Cook wrote: obj = kmalloc(obj, gfp

[PATCH] mm/kmemleak: Replace strncpy() with strscpy()

2024-07-09 Thread Kees Cook
Replace the depreciated[1] strncpy() calls with strscpy(). Uses of object->comm do not depend on the padding side-effect. Link: https://github.com/KSPP/linux/issues/90 [1] Signed-off-by: Kees Cook --- Cc: Catalin Marinas Cc: Andrew Morton Cc: linux...@kvack.org --- mm/kmemleak.c | 6 +++--- 1

Re: [RFC][PATCH 0/4] slab: Allow for type introspection during allocation

2024-07-09 Thread Kees Cook
On Tue, Jul 09, 2024 at 11:02:55PM +0200, Marco Elver wrote: > On Tue, 9 Jul 2024 at 22:28, Kees Cook wrote: > > > > On Tue, Jul 09, 2024 at 10:26:32AM -0700, Christoph Lameter (Ampere) wrote: > > > On Mon, 8 Jul 2024, Kees Cook wrote: > > > > > > > > > > >obj = kmalloc(obj, gfp); > >

Re: [RFC][PATCH 0/4] slab: Allow for type introspection during allocation

2024-07-09 Thread Marco Elver
On Tue, 9 Jul 2024 at 22:28, Kees Cook wrote: > > On Tue, Jul 09, 2024 at 10:26:32AM -0700, Christoph Lameter (Ampere) wrote: > > On Mon, 8 Jul 2024, Kees Cook wrote: > > > > > > > >obj = kmalloc(obj, gfp); > > > > Could we avoid repeating "obj" in this pattern? > > > > F.e. > > > >

Re: [PATCH net-next v2] netdevice: define and allocate &net_device _properly_

2024-07-09 Thread Kees Cook
On Tue, Jul 09, 2024 at 01:19:44PM -0700, Breno Leitao wrote: > On Tue, Jul 09, 2024 at 07:11:28PM +0100, Simon Horman wrote: > > Flagged by: kernel-doc -none > > How do you run this test exactly? I would like to add to my workflow. Details here: https://docs.kernel.org/doc-guide/kernel-doc.html

Re: [RFC][PATCH 0/4] slab: Allow for type introspection during allocation

2024-07-09 Thread Kees Cook
On Tue, Jul 09, 2024 at 10:26:32AM -0700, Christoph Lameter (Ampere) wrote: > On Mon, 8 Jul 2024, Kees Cook wrote: > > > > >obj = kmalloc(obj, gfp); > > Could we avoid repeating "obj" in this pattern? > > F.e. > > KMALLOC(obj, gfp); This appears to be the common feedback, wh

Re: [PATCH net-next v2] netdevice: define and allocate &net_device _properly_

2024-07-09 Thread Breno Leitao
On Tue, Jul 09, 2024 at 08:27:45AM -0700, Eric Dumazet wrote: > On Tue, Jul 9, 2024 at 5:54 AM Breno Leitao wrote: > > @@ -2596,7 +2599,7 @@ void dev_net_set(struct net_device *dev, struct net > > *net) > > */ > > static inline void *netdev_priv(const struct net_device *dev) > > { > > -

Re: [PATCH net-next v2] netdevice: define and allocate &net_device _properly_

2024-07-09 Thread Breno Leitao
On Tue, Jul 09, 2024 at 07:11:28PM +0100, Simon Horman wrote: > On Tue, Jul 09, 2024 at 05:54:25AM -0700, Breno Leitao wrote: > > From: Alexander Lobakin > > > > In fact, this structure contains a flexible array at the end, but > > historically its size, alignment etc., is calculated manually. >

Re: [RFC][PATCH 0/4] slab: Allow for type introspection during allocation

2024-07-09 Thread Kees Cook
On Tue, Jul 09, 2024 at 04:57:38PM +, Roman Gushchin wrote: > On Mon, Jul 08, 2024 at 12:18:34PM -0700, Kees Cook wrote: > > Hi, > > > > This is an RFC for some changes I'd like to make to the kernel's > > allocators (starting with slab) that allow for type introspection, which > > has been a

Re: [PATCH] x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments()

2024-07-09 Thread Gustavo A. R. Silva
On 09/07/24 12:20, Mirsad Todorovac wrote: On 7/9/24 01:44, Gustavo A. R. Silva wrote: On 7/8/24 14:22, Kees Cook wrote: Modern (fortified) memcpy() prefers to avoid writing (or reading) beyond the end of the addressed destination (or source) struct member: In function ‘fortify_memcpy_c

Re: [PATCH] x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments()

2024-07-09 Thread Mirsad Todorovac
On 7/9/24 01:44, Gustavo A. R. Silva wrote: > > > On 7/8/24 14:22, Kees Cook wrote: >> Modern (fortified) memcpy() prefers to avoid writing (or reading) beyond >> the end of the addressed destination (or source) struct member: >> >> In function ‘fortify_memcpy_chk’, >> inlined from ‘sysca

Re: [PATCH net-next v2] netdevice: define and allocate &net_device _properly_

2024-07-09 Thread Simon Horman
On Tue, Jul 09, 2024 at 05:54:25AM -0700, Breno Leitao wrote: > From: Alexander Lobakin > > In fact, this structure contains a flexible array at the end, but > historically its size, alignment etc., is calculated manually. > There are several instances of the structure embedded into other > struc

Re: [RFC][PATCH 0/4] slab: Allow for type introspection during allocation

2024-07-09 Thread Christoph Lameter (Ampere)
On Mon, 8 Jul 2024, Kees Cook wrote: obj = kmalloc(obj, gfp); Could we avoid repeating "obj" in this pattern? F.e. KMALLOC(obj, gfp); instead?

Re: [RFC][PATCH 0/4] slab: Allow for type introspection during allocation

2024-07-09 Thread Roman Gushchin
On Mon, Jul 08, 2024 at 12:18:34PM -0700, Kees Cook wrote: > Hi, > > This is an RFC for some changes I'd like to make to the kernel's > allocators (starting with slab) that allow for type introspection, which > has been a long-time gap in potential analysis capabilities available > at compile-time

Re: [RFC][PATCH 4/4] pstore: Replace classic kmalloc code pattern with typed argument

2024-07-09 Thread Kees Cook
On Tue, Jul 09, 2024 at 09:06:58AM +0200, Przemek Kitszel wrote: > On 7/8/24 21:18, Kees Cook wrote: > > diff --git a/fs/pstore/blk.c b/fs/pstore/blk.c > > index de8cf5d75f34..7bb9cacb380f 100644 > > --- a/fs/pstore/blk.c > > +++ b/fs/pstore/blk.c > > @@ -297,7 +297,7 @@ static int __init __best_ef

Re: [RFC][PATCH 2/4] slab: Detect negative size values and saturate

2024-07-09 Thread Kees Cook
On Tue, Jul 09, 2024 at 08:57:55AM +0200, Przemek Kitszel wrote: > On 7/8/24 21:18, Kees Cook wrote: > > The allocator will already reject giant sizes seen from negative size > > arguments, so this commit mainly services as an example for initial > > type-based filtering. The size argument is check

Re: [PATCH net-next v2] netdevice: define and allocate &net_device _properly_

2024-07-09 Thread Kees Cook
On Tue, Jul 09, 2024 at 05:54:25AM -0700, Breno Leitao wrote: > From: Alexander Lobakin > > In fact, this structure contains a flexible array at the end, but > historically its size, alignment etc., is calculated manually. > There are several instances of the structure embedded into other > struc

[PATCH] usb: gadget: Use u16 types for 16-bit fields

2024-07-09 Thread Kees Cook
Since the beginning of time, struct usb_ep::maxpacket was a bitfield, and when new 16-bit members were added, the convention was followed: 1da177e4c3f41 (Linus Torvalds 2005-04-16 236) unsigned maxpacket:16; e117e742d3106 (Robert Baldyga 2013-12-13 237) unsigned maxpacket_limit:16; a59d6b91cbc

Re: [PATCH net-next v2] netdevice: define and allocate &net_device _properly_

2024-07-09 Thread Eric Dumazet
On Tue, Jul 9, 2024 at 5:54 AM Breno Leitao wrote: > > From: Alexander Lobakin > > In fact, this structure contains a flexible array at the end, but > historically its size, alignment etc., is calculated manually. > There are several instances of the structure embedded into other > structures, bu

[PATCH net-next v2] netdevice: define and allocate &net_device _properly_

2024-07-09 Thread Breno Leitao
From: Alexander Lobakin In fact, this structure contains a flexible array at the end, but historically its size, alignment etc., is calculated manually. There are several instances of the structure embedded into other structures, but also there's ongoing effort to remove them and we could in the

[PATCH 6.1 042/102] cdrom: rearrange last_media_change check to avoid unintentional overflow

2024-07-09 Thread Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know. -- From: Justin Stitt [ Upstream commit efb905aeb44b0e99c0e6b07865b1885ae0471ebf ] When running syzkaller with the newly reintroduced signed integer wrap sanitizer we encounter this splat: [ 366.01595

[PATCH 6.9 078/197] cdrom: rearrange last_media_change check to avoid unintentional overflow

2024-07-09 Thread Greg Kroah-Hartman
6.9-stable review patch. If anyone has any objections, please let me know. -- From: Justin Stitt [ Upstream commit efb905aeb44b0e99c0e6b07865b1885ae0471ebf ] When running syzkaller with the newly reintroduced signed integer wrap sanitizer we encounter this splat: [ 366.01595

[PATCH 6.6 056/139] cdrom: rearrange last_media_change check to avoid unintentional overflow

2024-07-09 Thread Greg Kroah-Hartman
6.6-stable review patch. If anyone has any objections, please let me know. -- From: Justin Stitt [ Upstream commit efb905aeb44b0e99c0e6b07865b1885ae0471ebf ] When running syzkaller with the newly reintroduced signed integer wrap sanitizer we encounter this splat: [ 366.01595

Re: [PATCH] Revert "bpf: Take return from set_memory_rox() into account with bpf_jit_binary_lock_ro()" for linux-6.6.37

2024-07-09 Thread LEROY Christophe
Le 09/07/2024 à 11:39, Greg KH a écrit : > On Tue, Jul 09, 2024 at 09:24:54AM +, LEROY Christophe wrote: >> >> >> Le 09/07/2024 à 11:15, Greg KH a écrit : >>> On Mon, Jul 08, 2024 at 03:12:55PM +, LEROY Christophe wrote: Le 08/07/2024 à 14:36, Greg KH a écrit : > On Sun

Re: [PATCH] Revert "bpf: Take return from set_memory_rox() into account with bpf_jit_binary_lock_ro()" for linux-6.6.37

2024-07-09 Thread Greg KH
On Tue, Jul 09, 2024 at 09:24:54AM +, LEROY Christophe wrote: > > > Le 09/07/2024 à 11:15, Greg KH a écrit : > > On Mon, Jul 08, 2024 at 03:12:55PM +, LEROY Christophe wrote: > >> > >> > >> Le 08/07/2024 à 14:36, Greg KH a écrit : > >>> On Sun, Jul 07, 2024 at 03:34:15PM +0800, WangYuli w

Re: [PATCH] Revert "bpf: Take return from set_memory_rox() into account with bpf_jit_binary_lock_ro()" for linux-6.6.37

2024-07-09 Thread LEROY Christophe
Le 09/07/2024 à 11:15, Greg KH a écrit : > On Mon, Jul 08, 2024 at 03:12:55PM +, LEROY Christophe wrote: >> >> >> Le 08/07/2024 à 14:36, Greg KH a écrit : >>> On Sun, Jul 07, 2024 at 03:34:15PM +0800, WangYuli wrote: On 2024/7/6 17:30, Greg KH wrote: > This makes it sound like y

Re: [PATCH] Revert "bpf: Take return from set_memory_rox() into account with bpf_jit_binary_lock_ro()" for linux-6.6.37

2024-07-09 Thread Greg KH
On Mon, Jul 08, 2024 at 03:12:55PM +, LEROY Christophe wrote: > > > Le 08/07/2024 à 14:36, Greg KH a écrit : > > On Sun, Jul 07, 2024 at 03:34:15PM +0800, WangYuli wrote: > >> > >> On 2024/7/6 17:30, Greg KH wrote: > >>> This makes it sound like you are reverting this because of a build > >>>

Re: [RFC][PATCH 4/4] pstore: Replace classic kmalloc code pattern with typed argument

2024-07-09 Thread Przemek Kitszel
On 7/8/24 21:18, Kees Cook wrote: Using a short Coccinelle script, it is possible to replace the classic kmalloc code patterns with the typed information: @alloc@ type TYPE; TYPE *P; expression GFP; identifier ALLOC =~ "k[mz]alloc"; @@ P = ALLOC( - \(sizeof(*P)\|sizeof(TYP