From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH] ipv4: fib: avoid NULL dereference Date: Fri, 6 Jul 2018 08:39:11 -0700 Message-ID: References: <20180706142836.1822-1-mark.rutland@arm.com> <3ad39534-400a-8d4e-ac50-94eb5655e565@gmail.com> <20180706145728.57utqqrjzq7iupnh@lakrids.cambridge.arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: linux-kernel@vger.kernel.org, Alexey Kuznetsov , "David S . Miller" , Hideaki YOSHIFUJI , netdev@vger.kernel.org To: Mark Rutland , Eric Dumazet Return-path: In-Reply-To: <20180706145728.57utqqrjzq7iupnh@lakrids.cambridge.arm.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On 07/06/2018 07:57 AM, Mark Rutland wrote: > On Fri, Jul 06, 2018 at 07:47:04AM -0700, Eric Dumazet wrote: >> >> >> On 07/06/2018 07:28 AM, Mark Rutland wrote: >>> In tnode_free() we iterate over a callback_head list with a while loop. >>> At the start of the loop body we generate the next head pointer, and at >>> the end of the loop body we generate the tn pointer for the next >>> iteration of the loop by using container_of() on the head pointer to >>> find the tnode, and deriving the kv pointer from this. >>> >>> In the final iteration of the loop, this means that we derive a pointer >>> from NULL, which is undefined behaviour, which UBSAN detects: >> >> There is no dereference, your patch title is misleading. >> >> UBSAN might be fooled, not the C compiler. > > I'm happy to change the title to "avoid undefined behaviour". > Are you planning to change this as well ? include/linux/stddef.h:19:#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER) (And probably dozens of other locations)