From patchwork Mon Oct 3 22:45:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Jenkins X-Patchwork-Id: 12997875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ECA0C433F5 for ; Mon, 3 Oct 2022 22:45:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 909396B0071; Mon, 3 Oct 2022 18:45:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8921E6B0073; Mon, 3 Oct 2022 18:45:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 733A16B0074; Mon, 3 Oct 2022 18:45:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5C2346B0071 for ; Mon, 3 Oct 2022 18:45:45 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2E2FD1601C2 for ; Mon, 3 Oct 2022 22:45:45 +0000 (UTC) X-FDA: 79981121850.15.A02D873 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf30.hostedemail.com (Postfix) with ESMTP id D285480007 for ; Mon, 3 Oct 2022 22:45:44 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id n6-20020a5b0486000000b006aff8dc9865so11508779ybp.11 for ; Mon, 03 Oct 2022 15:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date; bh=2D8PxGUCZHsFgO4lCALcKFXM0FNRUUxMOX6ZaOvyf7A=; b=EaUMjMrkuO/0pzj10phRZC8Q7qXSACWOml8Jvm2ZC8i19LqKtL4T83KCavNRJdubyb 2+EKTRtteHA5pHi7qjDroOtPwD/Z3oXqvABLTXrJVcHc+8+s6HFFUPN4flJeI0Hzefjj p3u6GlXphseRDM0bbV6z/rprG87ZibXpxf/2wQs+oftxc4ZL+VNmkDar9OM4wk0N794o V6PvV2xvNkehWWIuG98aFQg0V2nLelgK0F3oM9q2qczH+sOczMtLHEDzz4Z5qFxFge+6 wOrZSJvPC52pPQ8SywgPEO7Guag1ZF4Nu3bFtKYhFXveU7omnu+gkmuxMe+J/H91F1mm Rciw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date; bh=2D8PxGUCZHsFgO4lCALcKFXM0FNRUUxMOX6ZaOvyf7A=; b=3bW/dzL8Mk0W1OW7jnXL5YIcUbHueSYHGLQ+LVBowTXQyuziS6VNZ/S5sbikZKIGYz MXtt+ff4bvEgzkGtCo15xB2APMKXdW6ljKxD7JAyGymiv8pGlwz8xLfUyjfeQzsOQWy7 yAG36fSBSYfITp+uigV/EgvXCImTBeUinwkV0I4hFWfMxqE0dalaGPU2ZGQJRHpLbM6j RzaDVb2xG3Acb7MgC1sxshsSbuuZB1T52cF0f8etRMjzQFgSZFn/lZFSWHe1hUJNf7oZ Oqu/K2X/fUbj4Z855RnAFfqG90x4RGDwfkRwTvCwmtXEqlRxvqDEwQwBXw0QAcb1ZXh8 R1aw== X-Gm-Message-State: ACrzQf1E7iXXN2USlG6upQZn5AfTAkBYBe2WuMCJFq4XK2Xcb+jVy4VL I9nMz1A07ckkiPgP+lSbkW2jzqjgxB8fk7H1dw== X-Google-Smtp-Source: AMsMyM64B2YS6PMg7/9SgtM+m8Osn9M/a/x6JzdrTZ5MyLjtOSW9gSWbKfpy3xDMzkBAhE0YRkyVpH8pDLEGC3Vo6w== X-Received: from roguebantha-cloud.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:1eee]) (user=sethjenkins job=sendgmr) by 2002:a25:ac4c:0:b0:6be:2d74:a33f with SMTP id r12-20020a25ac4c000000b006be2d74a33fmr378047ybd.379.1664837144053; Mon, 03 Oct 2022 15:45:44 -0700 (PDT) Date: Mon, 3 Oct 2022 18:45:31 -0400 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog Message-ID: <20221003224531.1930646-1-sethjenkins@google.com> Subject: [PATCH] mm: /proc/pid/smaps_rollup: fix no vma's null-deref From: FirstName LastName To: Andrew Morton , linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan , Vlastimil Babka , Seth Jenkins , Jann Horn , linux-mm@kvack.org, stable@vger.kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664837144; a=rsa-sha256; cv=none; b=UMnedDCz3yIEDoEzy51dEHgoz1goqUq4TTi3c+URZxG4ONiltdjusB+XM5XuQA88T1XRtr 3uWivPyMl7jlAoGFrtXZMpXPX8PRt+/Y5gNqf1IPI9z/nXOxMBBybuFAmJTjce3GXh0275 dTvV6CBAMWGtl3N+f4rcA62wjlvcRdI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=EaUMjMrk; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3GGY7YwsKCPElXmacXgdbglZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--sethjenkins.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3GGY7YwsKCPElXmacXgdbglZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--sethjenkins.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664837144; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=2D8PxGUCZHsFgO4lCALcKFXM0FNRUUxMOX6ZaOvyf7A=; b=rZoXERi9KzGtSZgTyF210Gn5emO/3WKx1ekj+GIl1ALMxk8MffbNANF9vf5MbCcUIaIO6K e1BknkWFgAGHSpgou/aEMyOpRBXqvA3vr9qQZSJhE9LLqsN0bRISVYjTRd3oNYVLxGt30n z14TlrnF45Tm3H3D1gdU3YP4fUPt5+A= X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=EaUMjMrk; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3GGY7YwsKCPElXmacXgdbglZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--sethjenkins.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3GGY7YwsKCPElXmacXgdbglZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--sethjenkins.bounces.google.com X-Stat-Signature: 4mhuwxyy97auujtpfhowizye7y8n6tz1 X-Rspamd-Queue-Id: D285480007 X-Rspamd-Server: rspam09 X-HE-Tag: 1664837144-228528 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000010, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Seth Jenkins Commit 258f669e7e88 ("mm: /proc/pid/smaps_rollup: convert to single value seq_file") introduced a null-deref if there are no vma's in the task in show_smaps_rollup. Fixes: 258f669e7e88 ("mm: /proc/pid/smaps_rollup: convert to single value seq_file") Cc: stable@vger.kernel.org Signed-off-by: Seth Jenkins Reviewed-by: Alexey Dobriyan Tested-by: Alexey Dobriyan --- fs/proc/task_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 4e0023643f8b..1e7bbc0873a4 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -969,7 +969,7 @@ static int show_smaps_rollup(struct seq_file *m, void *v) vma = vma->vm_next; } - show_vma_header_prefix(m, priv->mm->mmap->vm_start, + show_vma_header_prefix(m, priv->mm->mmap ? priv->mm->mmap->vm_start : 0, last_vma_end, 0, 0, 0, 0); seq_pad(m, ' '); seq_puts(m, "[rollup]\n");