lkml.org 
[lkml]   [2023]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH 01/24] mm/swap: fix a potential undefined behavior issue
    Hi Kairui,

    On Sun, Nov 19, 2023 at 12:55 PM Matthew Wilcox <willy@infradead.org> wrote:
    >
    > On Mon, Nov 20, 2023 at 03:47:17AM +0800, Kairui Song wrote:
    > > From: Kairui Song <kasong@tencent.com>
    > >
    > > When folio is NULL, taking the address of its struct member is an
    > > undefined behavior, the UB is caused by applying -> operator

    I think dereferencing the NULL pointer is undefined behavior. There is
    no dereferencing here. It is just pointer arithmetic of NULL pointers,
    which is adding offset of page to the NULL pointer, you got NULL.

    > > won't lead to a real issue, still better to fix it, also makes the
    > > code less error-prone, when folio is NULL, page is also NULL,
    > > instead of a meanless offset value.

    I consider your reasoning is invalid. NULL pointer arithmetic should
    be legal. This patch is not needed.

    Chris

    \
     
     \ /
      Last update: 2023-11-20 14:05    [W:4.648 / U:0.192 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site