Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1972675rdb; Sun, 19 Nov 2023 19:36:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNA3nFrXv23XFdN+3k+Ubjjh+Wzd4YykL5evEK8puWkWq7H9XkQ2gQciZHBsjX7hSWI9pF X-Received: by 2002:a05:6808:178f:b0:3b6:c398:eac4 with SMTP id bg15-20020a056808178f00b003b6c398eac4mr9268904oib.9.1700451374239; Sun, 19 Nov 2023 19:36:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700451374; cv=none; d=google.com; s=arc-20160816; b=t8fhYqFxlsnLe+yqh1sEVQvBtVALQGYw16LKYmz6lSgbZDYsx2mT9adlkCe2EY5Wuv WPPUlIzKrXwBnComm1kO+ytbk4vQpcwT/b7swvCh/tjd3g85gWgKBlp9X1b3GXrRq4rQ iJ4xAbQoGI59/390Md4fReWK+j9o4AiJ6M/6nGYT42E6hUw4iczZLc1Iih5EKBGMIiml 8XNyRq5E72i3NoMlgq4KDpxipQ1LRnJhsNV/8KMz2Q+4O4BjGhVzEZyw6xUtd7YWFI7l k9lvhUUgiALrq1AmZ58wt6Owwkp2Es5FG63FcGQkLHXdSlLWDntcyXw7dGoGqihIBkR9 kNjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=62lRMD43jjAKjDzraj2ZVEWyz4K9K7STu+VjEnu4DJk=; fh=h9/dQV7/4FcB08QFRsncPn+S7waXJfEDlfA57ofMDbY=; b=DCTabo6kWzFpKh7U35GfVRUIGi/m0weXIG5QqgcY8KWkpF6X5p2oHqHsCYSt2iH+a0 HFBJuXgcBd/I6GdG4z1gPeF8QPRxftUgz3j6oa4cKfgpP4YvlzrmhJ3b6dA9PbgKeXvq A6WINARyMEhP2pXeePzfo5xjQLRjiyZf/yiAl2rMlz4xGSub8EyVvaQxmESijFj/BNym bziTiuAgVEgRdbEaISHBe4dTG17ZYQwCrAo9AgUz5wwUxmK7jZUoHC5Um8JTLakH6VVc Gg3LU+1G4G5Yd8VrW8APl88ARTYeyBZXDC8mvYzz/TuznIvK7gcVZmLYWV9N9FuzuAI1 yZKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sB8jmsae; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bz40-20020a056a02062800b005be1ee5bea2si7760978pgb.374.2023.11.19.19.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 19:36:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sB8jmsae; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B37188058C44; Sun, 19 Nov 2023 19:36:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231698AbjKTDf7 (ORCPT + 99 others); Sun, 19 Nov 2023 22:35:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbjKTDf6 (ORCPT ); Sun, 19 Nov 2023 22:35:58 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC3A6AA for ; Sun, 19 Nov 2023 19:35:54 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83A64C433C8 for ; Mon, 20 Nov 2023 03:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700451354; bh=62lRMD43jjAKjDzraj2ZVEWyz4K9K7STu+VjEnu4DJk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=sB8jmsaenxaQSZtTnEZhkNerXZATf+rVxpKOLUwpsTswT10G+JSMumZkBKND6uKv0 PXj9CITTz6fNPvlwmaPvBOYfg7L2ZfgGG1hGr1+MFmeWHXTPQT5SXQ327vjIKsMeve wPHhq+QzhxuyZpolzmrMhp3uxO083zodSWQt4DfYZXieNO/6YSEEAHuZgaUPX8I5Kz +v5AxoXgGNeQLCwJN7GH/jJWR65nBMUiq8qn9FVRcqZrQO3KTj64QiIPIMZUmnlXll WuBPQxxxYnrUUi5z90LNPZXyj7RIM3iXzVFeNoEToMQpOindvc9cLa0czfSPcnYIxe Yl0/WoJEyyd0A== Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2809a824bbbso2607731a91.3 for ; Sun, 19 Nov 2023 19:35:54 -0800 (PST) X-Gm-Message-State: AOJu0YzILFUh47bm7VzcmX5fw6D+5amvCGKR2OdfHEYeWYWPqOATGO/e 9IoqYMHOQTo2nfP86QPPgCrAs36MCoB0T9ieX7JRNg== X-Received: by 2002:a17:90a:191a:b0:27d:c95:b0ad with SMTP id 26-20020a17090a191a00b0027d0c95b0admr4539183pjg.21.1700451353958; Sun, 19 Nov 2023 19:35:53 -0800 (PST) MIME-Version: 1.0 References: <20231119194740.94101-1-ryncsn@gmail.com> <20231119194740.94101-2-ryncsn@gmail.com> In-Reply-To: From: Chris Li Date: Sun, 19 Nov 2023 19:35:42 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 01/24] mm/swap: fix a potential undefined behavior issue To: Matthew Wilcox Cc: Kairui Song , linux-mm , Andrew Morton , "Huang, Ying" , David Hildenbrand , Hugh Dickins , Johannes Weiner , Michal Hocko , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 agentk.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 (agentk.vger.email [0.0.0.0]); Sun, 19 Nov 2023 19:36:11 -0800 (PST) Hi Kairui, On Sun, Nov 19, 2023 at 12:55=E2=80=AFPM Matthew Wilcox wrote: > > 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 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