From patchwork Sat Feb 8 08:35:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 11371499 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FB7313A4 for ; Sat, 8 Feb 2020 08:37:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DFA6C21741 for ; Sat, 8 Feb 2020 08:37:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ljxpLjut" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFA6C21741 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 01D266B000C; Sat, 8 Feb 2020 03:37:42 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F0FDF6B000D; Sat, 8 Feb 2020 03:37:41 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D896A6B000E; Sat, 8 Feb 2020 03:37:41 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id BE46C6B000C for ; Sat, 8 Feb 2020 03:37:41 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6CEC8249F for ; Sat, 8 Feb 2020 08:37:41 +0000 (UTC) X-FDA: 76466306322.05.flesh74_8e21174b585f X-Spam-Summary: 2,0,0,244c050d2af52a47,d41d8cd98f00b204,lixinhai.lxh@gmail.com,::akpm@linux-foundation.org:kirill.shutemov@linux.intel.com:willy@infradead.org:hannes@cmpxchg.org,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:4250:4321:5007:6261:6653:7514:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:12986:13069:13153:13161:13228:13229:13311:13357:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21990:30054,0,RBL:209.85.208.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: flesh74_8e21174b585f X-Filterd-Recvd-Size: 4073 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Sat, 8 Feb 2020 08:37:40 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id w1so1788949ljh.5 for ; Sat, 08 Feb 2020 00:37:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/6GyCmOdNDkGYSFzgyq/aYodLQz4kK1nBI1CPz/kIME=; b=ljxpLjutlIdHkR0uLyjd+8l6clX1XNNoR+OyWtke/XXzgQjDgqWuDKENrrJ54ZB2/0 PiD4EJHyvgWLX1/rB8OtYncR66tU4W9fhfRLgGOWtK7hKf+nFnhCDrCSajmZAwqgW12V R/kb7sJuDLvL1fRXlRV+2umBsaVAqHj50Wb44RN4CBPH4VXOSe22lC1J72Uu8oSpwRVp sPBtTkHAbkBQySGgbgZqmyq/OIeKJ+fgK8wEPAUQVY3N6WMt6XSgHr3yeVTgFun0UnGd D033O5sZBduljiDU7+ztwfgt++rtP+LUYilOtMkxLkucBzVOBKSjpMyGXwDTf9xAGV9p Hweg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/6GyCmOdNDkGYSFzgyq/aYodLQz4kK1nBI1CPz/kIME=; b=CU61PxvKS4QFzQIoR2qJdTv9MAvPpY2g7D819p/YRdFbyxUh74Mq/JbhWBRCoePzFN /Bcnt3+tQi8T0riEoZ+HBBLWu9n/DGD/1dkqC9gCpmIFm6iGiR/v/YjovGXdSI78Q0lX lspx19ZY35+MLc6ZJbP6vr7JMvfEbEtBO5GIgvqOYjqp8bR/iOI5C4IWvVB/qA5K0tvw t51rRykrf1yggzQ6ZnndNfGVS0eDJVlhkFx7pYsAgfwJF0e8wyTEMZaSLdXqo6/SYOAS 7FTQtND4GxZVs8Pd+y8qPzI1PSSBrrWSjTIuHS782d6Epq64vDn+RW82K4sSk5KN3NZB Lu9w== X-Gm-Message-State: APjAAAUl5ZCfJVpQYHkE9b9ZHDU4B3bE9OXDprPgFAiI7LyM3/GXtvyc zImjS7bdGd5YwAE5Yd0bEw1tHqRM+nY= X-Google-Smtp-Source: APXvYqzm3Qojf/tICk6Wb9E70etSbdMBJO1V+mGp/tXVn6Lm3D/u2C70IdWYpcxKPXRA7tkv/bwEVw== X-Received: by 2002:a2e:8e63:: with SMTP id t3mr2095812ljk.239.1581151059643; Sat, 08 Feb 2020 00:37:39 -0800 (PST) Received: from localhost.localdomain.localdomain ([131.228.2.21]) by smtp.gmail.com with ESMTPSA id n11sm2663404ljg.15.2020.02.08.00.37.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Feb 2020 00:37:39 -0800 (PST) From: Li Xinhai To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, "Kirill A. Shutemov" , Matthew Wilcox , Johannes Weiner Subject: [PATCH 3/3] mm: set vm_next and vm_prev to NULL in vm_area_dup() Date: Sat, 8 Feb 2020 08:35:28 +0000 Message-Id: <1581150928-3214-4-git-send-email-lixinhai.lxh@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1581150928-3214-1-git-send-email-lixinhai.lxh@gmail.com> References: <1581150928-3214-1-git-send-email-lixinhai.lxh@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Set ->vm_next and ->vm_prev to NULL to prevent potential misuse from the new duplicated vma. Currently, only in fork path there are misuse for handling anon_vma. No other bugs been revealed with this patch applied. Signed-off-by: Li Xinhai Cc: Kirill A. Shutemov Cc: Matthew Wilcox Cc: Johannes Weiner Acked-by: Kirill A. Shutemov --- kernel/fork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/fork.c b/kernel/fork.c index 1bbd49a..eb3a148 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -361,6 +361,7 @@ struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig) if (new) { *new = *orig; INIT_LIST_HEAD(&new->anon_vma_chain); + new->vm_next = new->vm_prev = NULL; } return new; } @@ -561,7 +562,6 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, } else if (anon_vma_fork(tmp, mpnt)) goto fail_nomem_anon_vma_fork; tmp->vm_flags &= ~(VM_LOCKED | VM_LOCKONFAULT); - tmp->vm_next = tmp->vm_prev = NULL; file = tmp->vm_file; if (file) { struct inode *inode = file_inode(file);