Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1845460rdb; Sun, 19 Nov 2023 12:56:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFfehq95fcR8hOefGIp9gQTOYxjxHPD7zHppmdixEqGpWxwNgv/6QqVhv4GfGlzsJ9Ngts X-Received: by 2002:a05:6a00:22ce:b0:6cb:87d0:fc9e with SMTP id f14-20020a056a0022ce00b006cb87d0fc9emr3174205pfj.21.1700427386698; Sun, 19 Nov 2023 12:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700427386; cv=none; d=google.com; s=arc-20160816; b=bF9aloEY3K2zA8yEQVTZlxYoK35fOUgJ5WBfXBsu5jEa6b3HrVOkmHXhZYOQBfNxP9 /8oznC9i43as2Pnw9wjKxAEA/pF4/39zzDPLn7AOp+smrurjltqbcv7OvPB2yWvVOlp3 /spn858Qz4r4JlUVwklCT5DCT6lB1CCZC+D+IpEX+Bw0QCv3RO26aHtIJigVVB4Xgmni n1OposhhT61N0joDDuf8KT3LNBhNVJY+OnNhP0FoH1T4codlyCsxj+Avag+YUnmrDrYc pyI7B4CY+MBQyo1lJWoLsnWfy/ef4h55SYq9m2f7TV+9bKRjk+nm6mGOO2JuAiwmxwXC yJEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K2UUUKZDs86DqLJwfJUbwqH9tdoEHH2Sfe13rGBM3MQ=; fh=xtla2RzbqQcC9iS2w/NLQ5Gl8jt2MNg63K3u0HRJPcc=; b=bsqfHKcQqgku1h42Zp55Q6OzTUsnf9m2F/H0AMLHcL0mOaQR7lGwKuwGR+U/wf+Vi8 9Q2CzWmUsdgicnvlJe7LmukOrjnr1Ibstd+XY9aafUGJ2m2BL42ps+ROUUexG8CPoN6w 8VfnVuxGXjYJIm9fqoYdr0/vwB3VV0oZa8BHAU/y1T4Q3wZvRoJFyl8Ba0TGSKtOyTE3 l/p8J8aGZbg/XOijHPCz5EGsd3S0edCJ1yAj179Js0H45nue2X3lQzsS4yQcRvmb/bUm SQlt8SB7dCnvLHY6pv6FMnC0e/71/aEZ3dehBugg3zEJW8go0k25SjddUb0NHbhZBMBO BEzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=iZTb7wMn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id a21-20020a631a55000000b005c16f07b3e6si6568098pgm.164.2023.11.19.12.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 12:56:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=iZTb7wMn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 33FD3805D5F0; Sun, 19 Nov 2023 12:56:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229607AbjKSU4Q (ORCPT + 99 others); Sun, 19 Nov 2023 15:56:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjKSU4P (ORCPT ); Sun, 19 Nov 2023 15:56:15 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C09C115 for ; Sun, 19 Nov 2023 12:56:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=K2UUUKZDs86DqLJwfJUbwqH9tdoEHH2Sfe13rGBM3MQ=; b=iZTb7wMnS0rIEO8XUBHZdY2Y2Y viDQ3g36LuUdwMM7eA4c7yJLd32QYPu9aM4/uvEsSgRmd+lMBpMavthHoZksXkZrun2o846YBQOOj xqFTdmGzZL0M+/yJpuNF3/Q2W8727vY/hZcTeIGVpOIKWCjflM4Il47ZLUM6A/36qfNodcDK69Qcn zoZ3a7AChlyW9te40JV+piKkgAE2DylVbgYg2rLX7vFLSTHSgc1OoI+2lRX3JCG/bx0Qi5urxxmKR F+/JNxvaYZtGZIG07ctrkif+NqwJW+7U3SHKrKK3NOc5sK28BLKco0jMVwCInTNU/H8A4/MgcPlG3 utdhhyGA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r4opV-0032da-18; Sun, 19 Nov 2023 20:55:45 +0000 Date: Sun, 19 Nov 2023 20:55:44 +0000 From: Matthew Wilcox To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , "Huang, Ying" , David Hildenbrand , Hugh Dickins , Johannes Weiner , Michal Hocko , linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/24] mm/swap: fix a potential undefined behavior issue Message-ID: References: <20231119194740.94101-1-ryncsn@gmail.com> <20231119194740.94101-2-ryncsn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231119194740.94101-2-ryncsn@gmail.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 19 Nov 2023 12:56:24 -0800 (PST) On Mon, Nov 20, 2023 at 03:47:17AM +0800, Kairui Song wrote: > From: Kairui Song > > When folio is NULL, taking the address of its struct member is an > undefined behavior, the UB is caused by applying -> operator > to a pointer not pointing to any object. Although in practice this > 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. Um, &folio->page is NULL if folio is NULL. The offset of 'page' within 'folio' is 0. By definition; and this will never change.