Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2547809pxb; Sun, 24 Apr 2022 18:35:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKTHrqkdBrLaLucvXBeDGhWSnsF7ICaIWotwNrLQ1NsumYTHu4gqYRABrtlZ7tuMY+Tjj4 X-Received: by 2002:aa7:9041:0:b0:507:9219:ce61 with SMTP id n1-20020aa79041000000b005079219ce61mr16493374pfo.30.1650850516733; Sun, 24 Apr 2022 18:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650850516; cv=none; d=google.com; s=arc-20160816; b=b8Px4mpYHtoEm9kSzJh1vxW4sbAw7Th2FewE1K5blzrM/hq1+drrxGCM9GZutABK7d 7OVxAO4EfpHUJlEdoPAyhO9Vc2G71/shct+Z4Ra1j1AKqtKxR/jKcExafYJERqQRJLtz d8tfH3ukAvBOtenOCXMN58GKLve/NtjQednKz7P2c9UcODlehICpeWfSy0EWIs9g9iEK FWiLG4pR7RR5NGtBkume5t+YVNXHMvpMXnGMc1CiAwNNEB4hW1OF5suj1b8Vix2SVrCG AbR26qlc1VUTgMIU0ZMS0QQlB0NOU1Z1CTTKjG+zuWpUPz8nizrMkAg59NWfWSiHA2Ur YqEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ifhTT6RWFXDH8HUEGtKLOt2yTklDAIxczpprS6iV9sg=; b=NS/vDw90Jvv+M0PxdnumRF/NfrtAYGEYp1QGtj7o/nXL6KZ3bq6pNr3zCyq4m50Tnb v4JwgaJXpM9DqXN2XJNTHUkcThcOwueGyAWSQCkIdEzn0WMYmiXZm7Y0tvHt3xnnF1be q7iTSYo2OrjgNbmVYm+X2KWP7ksZa6edd6UQzYUlQmZANNkWAgBN9Mm4dFqr7NQ3/f11 z73u97bHXF7cnmD5eqsGgYA11NcG9x0ZMeMHRSWht8Q3KAYfMMkbB1PE3e/LhJfd3Mlr eIOCfztOqp48wQcRYWCGzNsF4ZvBK/XJKEgfjxlEJB2fmBykVBk55x6ApAP5zyvQGAll oE5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n55X0jCN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 1-20020a630101000000b003ab0e0a6b62si4492939pgb.803.2022.04.24.18.34.58; Sun, 24 Apr 2022 18:35:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n55X0jCN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239140AbiDXKv2 (ORCPT + 99 others); Sun, 24 Apr 2022 06:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239046AbiDXKvN (ORCPT ); Sun, 24 Apr 2022 06:51:13 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C71E17D496 for ; Sun, 24 Apr 2022 03:48:12 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id dk23so1099006ejb.8 for ; Sun, 24 Apr 2022 03:48:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ifhTT6RWFXDH8HUEGtKLOt2yTklDAIxczpprS6iV9sg=; b=n55X0jCN3rd+35JSwnUSgh9WdYBxyYC0C/eVbUYHLd6G/I6dl3R66sgt7bEARIfGPa U92qMQviohsxEm8dzT6VPNZAOWPWPkmkagUDnTXNEahjzw0aG1oXAZvj+PL5VLH+k6W7 Raogl5ajpBl4qazS8tw3BSG+K91ZsMchhewqdP2+R4NlVa+C3SEM1/7YXBrVsbW1cDpw G7ofklYP3B9U9CJKYXyNZXllYXfe1t7SSugAFpFbyF9PtSXVrOmlCArrgfsDbksCPs6p Q5G1HXk+YyEETVU2m7kWdTuzlcU4En35jAd5km5GeX1MOwcdWcCKqQuS7eCU+xYpnE04 hlUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ifhTT6RWFXDH8HUEGtKLOt2yTklDAIxczpprS6iV9sg=; b=iXpMTJuPU1zVhx+C/Zewr8KaC5hafUw8BBiLoZx7jpgGU6/o76bETiQCSJV1+PZXxP xehlA7ec49MkxPAVXPOUmg8wkSPiEWzMbBbj15B/lSb/kKZ1QjCbRi8OGa7JZCFxp2Qv cZjTYC+99ufeKMcjPTKA5ZXGfAMKE4WLWcYp3Ml00NXjoKLIP1r8EhNdoOuzG4zOaiyV /eqelOYS5YGwFdsKWj9fN2+AbIZvkfl5d2yR1J+2GQCNU9QTZPNK3oGyJcCvXzCYhjUl E/rvOExd7meGMXd66aB/KqLUD137WHN0JAd6vHxSlMOC6vQplkrj65m1k7enJCubHpWg 3Cew== X-Gm-Message-State: AOAM533ZOkl0rBLBsLKI7b8Q4glvuM5msuTpWm1OOKRwD18GyevLD7ul 18cqvJhquVY3/rtlkEZH4f8= X-Received: by 2002:a17:906:c116:b0:6f3:832f:3c8 with SMTP id do22-20020a170906c11600b006f3832f03c8mr3765451ejc.235.1650797291042; Sun, 24 Apr 2022 03:48:11 -0700 (PDT) Received: from localhost.localdomain (host-79-50-86-254.retail.telecomitalia.it. [79.50.86.254]) by smtp.gmail.com with ESMTPSA id h8-20020a1709066d8800b006e09a49a713sm2488133ejt.159.2022.04.24.03.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 03:48:09 -0700 (PDT) From: "Fabio M. De Francesco" To: Ira Weiny , Andrew Morton , "Matthew Wilcox (Oracle)" , Catalin Marinas , Will Deacon , Peter Collingbourne , linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" Subject: [RFC PATCH] mm/highmem: VM_BUG_ON() if offset + len > PAGE_SIZE Date: Sun, 24 Apr 2022 12:48:06 +0200 Message-Id: <20220424104806.25396-1-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call VM_BUG_ON() if offset + len > PAGE_SIZE. This is an RFC patch because I'm not sure if we actually need to BUG_ON(), so I'd like to know what Maintainers and other developers think about this proposal. Please note that memset_page() uses VM_BUG_ON() to prevent the same issue. Furthermore, I also cannot understand why memset_page() does not call flush_dcache_page() after memset() but I suppose that the different implementations of these two functions should be addressed in another RFC. Signed-off-by: Fabio M. De Francesco --- include/linux/highmem.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index c3d562b5f0c1..bdb16d5f8148 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -349,6 +349,8 @@ static inline void memcpy_to_page(struct page *page, size_t offset, static inline void memzero_page(struct page *page, size_t offset, size_t len) { char *addr = kmap_local_page(page); + + VM_BUG_ON(offset + len > PAGE_SIZE); memset(addr + offset, 0, len); flush_dcache_page(page); kunmap_local(addr); -- 2.34.1