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 811BEC3A59C for ; Fri, 16 Aug 2019 10:05:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5400D206C2 for ; Fri, 16 Aug 2019 10:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565949903; bh=sk3XXzhLC+Nj0r8soA8ITDSVCJm/mzdFuNEYh1k0Q1I=; h=Subject:To:Cc:From:Date:List-ID:From; b=vSHkfoR9I4q2YTZx5wRZZUuQKiZ4FQyBkhcb3E/n0N4YVt9HUZnLsVwZofaHsm73o lLKlLuqASV8bFa74tREU3uqeBtbmpeQs8sWJRiX8YnP0jH0ue4Y/GQLfh6JsHPrB2z MZ7J0CninMeaD8MJ27qQCq1sFd5Z3003D63/vgW0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727039AbfHPKFD (ORCPT ); Fri, 16 Aug 2019 06:05:03 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:44469 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726989AbfHPKFC (ORCPT ); Fri, 16 Aug 2019 06:05:02 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 339BE21ADD; Fri, 16 Aug 2019 06:05:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 16 Aug 2019 06:05:02 -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=O/SGUt 4nbY/bOSXYNdFNyyRYDka6xKUr5NdtIz01YSA=; b=l+OC1n3yQbKAMiNyMPS54q tn/np5Wf1/cvT/XJ/lD4dwCF8UbmVITlllwPF5LgFvluftxbRjaWN/SEHhHzCgEf sTtihKMXZ88UBx9SvUwbkZazOlUBuEL2PIC9E+KiFDGBsO1XFpk39vBTUY4fNq1G 8i6gRYap84gpl1qfnTPzy/NWdWOoXRVkSLzvdnaFZET7kRSh68JHUBxeS+wU770l JtYwlmf7n83hMocW6lLeatEmDDy/3ApN6hQ3KGzqoDQWXbSgUgwKlbeyglsrB769 SNP7msk8tVzHS/5wFB7g4FCuJu+tpHxR235Ra582U5YWrnPojtlrPPvLP+h6pSrw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudeffedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvffhfffkgggtgfesthekredttd dtlfenucfhrhhomhepoehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhr gheqnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucfkphepkeefrdekiedrkeelrd dutdejnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvgheskhhrohgrhhdrtghomhen ucevlhhushhtvghrufhiiigvpeei 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 6E151380076; Fri, 16 Aug 2019 06:05:01 -0400 (EDT) Subject: FAILED: patch "[PATCH] mm/usercopy: use memory range to be accessed for wraparound" failed to apply to 4.9-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:52 +0200 Message-ID: <156594989217393@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.9-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. */