From patchwork Sun Dec 9 07:21:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gchen chen X-Patchwork-Id: 10719859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2BCFA109C for ; Sun, 9 Dec 2018 07:21:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F08EB2A865 for ; Sun, 9 Dec 2018 07:21:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7EE02A923; Sun, 9 Dec 2018 07:21:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28E0E2A865 for ; Sun, 9 Dec 2018 07:21:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 47B9D8E0054; Sun, 9 Dec 2018 02:21:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 42A0A8E0004; Sun, 9 Dec 2018 02:21:45 -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 31B3D8E0054; Sun, 9 Dec 2018 02:21:45 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id E2E598E0004 for ; Sun, 9 Dec 2018 02:21:44 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id u20so7219427pfa.1 for ; Sat, 08 Dec 2018 23:21:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=ONkZ9i+vSVBwiKv0jCSx2lBpiXozUtvPXgShMmZkvZE=; b=QHKasJoCrbEfLNbmytRGvyOhmtGwk2/egeqSflge0yx7nMB+Rt4Cq0zQa7aw2M3d+o IO2yJVbB61XY3YPHVUR4d8yMs9KYOBzHmSRxipSYFUtTNpvG0Nmgly0rN8dZ7gyumhoU X2p0fKF7r6jeBjHcZzd9D5GxvsR9FHGzsSH2Ld73xC2SyJV1arvlYHeL+soR24ABcp6g WT/slj58LsJ/NO/ubQMlJ4MylzRMsjFRec+D+oxP3EG9zn4OuJuUQVVjYnXb460bif81 rKez1BwOldz9W0VkPjsz72tDiXT0hf+ktjdTz77NhMx2jZOm//h9QrbWM/O5yGwn8pIq dh6g== X-Gm-Message-State: AA+aEWYBw3eu18+g/CqPMsATjINi1AQwAO1fLs1Jd58mkdSwotBnqrSg TPlAq64up6TKNSMENdYrBZFYKdsPozto6VxcwgPeeRtCoWXp7z3jaLZXfBjY6Igbz14np//JeuA jWImL5C/L4Tg1FHeH9uUEw74Axjaqu3CwRdYjOB8koY82RI6s+4lEAlpg0VCguHjJ4AZj0IMrYA C8ur6E5gkj9FHoMgeJlb5RdVALACrRvl4RiwSrU5d78qbq6z9kSPiTKONxJYTt+L9tOoT0FQt36 emYW/BMctKjpi1tccyKj1kBbu9rwcW3dyOqic6A5pP3ycL6qEiWZLt/RgtI4vIK1JDjRgg2LXG1 8sfeVOcaNhXZF8e1kuE7pjBHsR269xxuUpp9uwgCwC/UWN/AQIndQiQg76M5rtHTpGZdxVZVdbh l X-Received: by 2002:a63:1b1f:: with SMTP id b31mr7053145pgb.66.1544340104298; Sat, 08 Dec 2018 23:21:44 -0800 (PST) X-Received: by 2002:a63:1b1f:: with SMTP id b31mr7053121pgb.66.1544340103256; Sat, 08 Dec 2018 23:21:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544340103; cv=none; d=google.com; s=arc-20160816; b=bUnpgqKsgO8mIZTo5CoofWOld/vn3GSp5eRkX/o7GCLhQbPKCESteep9xBqNwyZuWR TvvNHAloyQXq7X0iyBbnLtegFaV+RKLB21G1GCFIVaR9C9zJYTLDybAYb4OcPUih86// 31SD5wEoqmvdRcjolgWKm6brs/3ZcS7EF0LQEcWtYRIEZYiQYgH/OT+IvvRHyKjf1ubk TA0JiQAlecIUDmctIK5++r/c4/h7aJENC05G+J5zXtxnWvr3Wn58fY/qfYbOQAXlBg95 JydKDqvNN8gfEoPQbfuq2I5rWGOvQlO/GfcwHGbOMOKRdYqfRjw68bVkVcQw0e17EiRH rwSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=ONkZ9i+vSVBwiKv0jCSx2lBpiXozUtvPXgShMmZkvZE=; b=fTXrq6RoiwMQioHAhzzS6xkLJhVeNMxO+BzDnKH/9gJW8jArmQdKDueH7a+W6RQvHx kODhWcQwUkedSbES64YiNMG8MLzoIgaPttHqygnRCMlYlMQzfp/FdaKEtIMrd/mAcVgw G4e5gIbeBoLyxR9MgxZZ3Ny9/t8wwnzUSoELUUs52srzrUi5WCcmZcJXhKT1VGhNVXAi 8fG+7H6caxiPp3QwRP4pmUzYFqT7lJ1aMEqa330bIF8ZnfDq/lMYknIATSakX0seaE1B b/PDsW9j35OJ/5L2p61+j2riO5QNiw19bKxULmRh9KaKYYEi0TeDR0xnVYSUi1QQxtwG j6Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SIey4V7D; spf=pass (google.com: domain of gchen.guomin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=gchen.guomin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n6sor12206425pgv.69.2018.12.08.23.21.42 for (Google Transport Security); Sat, 08 Dec 2018 23:21:43 -0800 (PST) Received-SPF: pass (google.com: domain of gchen.guomin@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SIey4V7D; spf=pass (google.com: domain of gchen.guomin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=gchen.guomin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ONkZ9i+vSVBwiKv0jCSx2lBpiXozUtvPXgShMmZkvZE=; b=SIey4V7DZEVEzGD8JerF+CaPVC26cyP/HPBc7f7nqRUzKE6UI7S7QLnQkggx19NmQa Ig7ZsORmTeXQc3bfEe1OThH4VWlJw0vQ94nEiA6DZLp50xjlj3u/0czyJtbl3/uMqukx 3hwCVo2qmVgMBjj+d5eCL4Nu/8O5oAYZApQF6LkwRG8R1u9TPSavHDCxIjUzsVfA4+Dq +xRIaGBYnMj+iiYH4e53BkXlRYkCNJn8J+bxIJS8SN/nRXwuNcgJlh7ISwF5H0+iFE5S oEpr3gQ0FX7l8UBra266bu1JJ/v/WdrQeNbJoU/2OjWhue43XwVg6b1qAa/yspR5MUQu phYg== X-Google-Smtp-Source: AFSGD/UeG1S+spJZwpsO7uTIMmtFllcxMzQuBh73tHi/xSlPgrOaMhWIO6j9HLnMvUp8Z8Atp1DtXQ== X-Received: by 2002:a63:ae01:: with SMTP id q1mr6948431pgf.402.1544340102774; Sat, 08 Dec 2018 23:21:42 -0800 (PST) Received: from VM_15_152_centos.localdomain ([193.112.178.48]) by smtp.gmail.com with ESMTPSA id v9sm11425173pfg.144.2018.12.08.23.21.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Dec 2018 23:21:42 -0800 (PST) From: gchen.guomin@gmail.com To: "Michael S. Tsirkin" Cc: guominchen , , , Jason Wang , Subject: [PATCH] Fix mm->owner point to a task that does not exists Date: Sun, 9 Dec 2018 15:21:17 +0800 Message-Id: <1544340077-11491-1-git-send-email-gchen.guomin@gmail.com> X-Mailer: git-send-email 1.8.3.1 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: X-Virus-Scanned: ClamAV using ClamSMTP From: guominchen Under normal circumstances,When do_exit exits, mm->owner will be updated, but when the kernel process calls unuse_mm and exits, mm->owner cannot be updated. And will point to a task that has been released. Below is my issue on vhost_net: A, B are two kernel processes(such as vhost_worker), C is a user space process(such as qemu), and all three use the mm of the user process C. Now, because user process C exits abnormally, the owner of this mm becomes A. When A calls unuse_mm and exits, this mm->ower still points to the A that has been released. When B accesses this mm->owner again, A has been released. Process A Process B vhost_worker() vhost_worker() --------- --------- use_mm() use_mm() ... unuse_mm() tsk->mm=NULL do_exit() page fault exit_mm() access mm->owner can't update owner kernel Oops unuse_mm() Cc: Cc: Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: Signed-off-by: guominchen --- mm/mmu_context.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/mmu_context.c b/mm/mmu_context.c index 3e612ae..185bb23 100644 --- a/mm/mmu_context.c +++ b/mm/mmu_context.c @@ -56,7 +56,6 @@ void unuse_mm(struct mm_struct *mm) task_lock(tsk); sync_mm_rss(mm); - tsk->mm = NULL; /* active_mm is still 'mm' */ enter_lazy_tlb(mm, tsk); task_unlock(tsk);