From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E190C3A59C for ; Fri, 16 Aug 2019 10:04:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2068F206C2 for ; Fri, 16 Aug 2019 10:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565949895; bh=D1Y3syBGmyvRwi3ZhGcvKcy+RQqxobpumsfPWPHcuK0=; h=Subject:To:Cc:From:Date:List-ID:From; b=TMyT/vGdEIVptKaQ8WHbWNn2yej67Wc/SSo9+ACoR205CwG6m/shyV3WMIIocHYJf 01W7A9ddC+tNghy/X0pINazwElOcPysLgfB2xWlYCNsQ+NqVaMmFG6OYpxwYId1bHw OZSk2ZdlinKC2kJktdHTZbf/kb85jetw17vGuAwI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727007AbfHPKEy (ORCPT ); Fri, 16 Aug 2019 06:04:54 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:47253 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726989AbfHPKEy (ORCPT ); Fri, 16 Aug 2019 06:04:54 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5F82F221D2; Fri, 16 Aug 2019 06:04:53 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 16 Aug 2019 06:04:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=6Q56Q7 V6e6UjxLTjAoRwaSHSd+cjM5Yb8BVPecXiW1U=; b=SzmiDt1R4Vr5eAQ/CEcu7O 8ANJmtsjGn23r0luTaUpsfvX4aisJ4e4Y6MxVzj03YZACa2KhYe02rgM8lBfhuiO FmYxf1tfK9wqkZ/o+6nuJ2mX3NLmzQN4KBnHrmQZHSthvRaG3wdSoqilJHTa386E q9GD/o8XO36cmiMxsRZ1uywnYcoId+bXYef/avKSy7Ii9XFSEu13+VLbtUYyoEDj or5f3Po63HH350x7lj+fuCRNVhNN/+RcOn0LKxkYX1pvRZd50eTXz6KeFul4ji/u A9fcy5GCYIqmCFswQBaSgnklrx7oiNZBPHJGUh7JzZDjSlHfZfsoN25xpZwiE4bQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudeffedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvffhfffkgggtgfesthekredttd dtlfenucfhrhhomhepoehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhr gheqnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucfkphepkeefrdekiedrkeelrd dutdejnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvgheskhhrohgrhhdrtghomhen ucevlhhushhtvghrufhiiigvpeeh X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id AE00B380083; Fri, 16 Aug 2019 06:04:52 -0400 (EDT) Subject: FAILED: patch "[PATCH] mm/usercopy: use memory range to be accessed for wraparound" failed to apply to 4.14-stable tree To: isaacm@codeaurora.org, akpm@linux-foundation.org, gregkh@linuxfoundation.org, keescook@chromium.org, psodagud@codeaurora.org, stable@vger.kernel.org, torvalds@linux-foundation.org, tsoni@codeaurora.org, william.kucharski@oracle.com Cc: From: Date: Fri, 16 Aug 2019 12:04:51 +0200 Message-ID: <156594989124927@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.14-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 951531691c4bcaa59f56a316e018bc2ff1ddf855 Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Tue, 13 Aug 2019 15:37:37 -0700 Subject: [PATCH] mm/usercopy: use memory range to be accessed for wraparound check Currently, when checking to see if accessing n bytes starting at address "ptr" will cause a wraparound in the memory addresses, the check in check_bogus_address() adds an extra byte, which is incorrect, as the range of addresses that will be accessed is [ptr, ptr + (n - 1)]. This can lead to incorrectly detecting a wraparound in the memory address, when trying to read 4 KB from memory that is mapped to the the last possible page in the virtual address space, when in fact, accessing that range of memory would not cause a wraparound to occur. Use the memory range that will actually be accessed when considering if accessing a certain amount of bytes will cause the memory address to wrap around. Link: http://lkml.kernel.org/r/1564509253-23287-1-git-send-email-isaacm@codeaurora.org Fixes: f5509cc18daa ("mm: Hardened usercopy") Signed-off-by: Prasad Sodagudi Signed-off-by: Isaac J. Manjarres Co-developed-by: Prasad Sodagudi Reviewed-by: William Kucharski Acked-by: Kees Cook Cc: Greg Kroah-Hartman Cc: Trilok Soni Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/mm/usercopy.c b/mm/usercopy.c index 2a09796edef8..98e924864554 100644 --- a/mm/usercopy.c +++ b/mm/usercopy.c @@ -147,7 +147,7 @@ static inline void check_bogus_address(const unsigned long ptr, unsigned long n, bool to_user) { /* Reject if object wraps past end of memory. */ - if (ptr + n < ptr) + if (ptr + (n - 1) < ptr) usercopy_abort("wrapped address", NULL, to_user, 0, ptr + n); /* Reject if NULL or ZERO-allocation. */