From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by gnuweeb.org (Postfix) with ESMTPS id BB92E83229 for ; Tue, 28 Feb 2023 18:05:01 +0000 (UTC) Authentication-Results: gnuweeb.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=EuHDnDxA; dkim-atps=neutral Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-536c02eea4dso297132007b3.4 for ; Tue, 28 Feb 2023 10:05:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rpV99OKSTpIRzIpX89x9E7KBkQmTINaa7AEfKXJe4DE=; b=EuHDnDxAN39r4+yOuGdRF5UMA037GmTcY1WDH060nxXx4LzWSy+M3htrEsuL5FcfAz Rj6frPsLMdQF2246BJygq37UEUu30Bh6j8KXwoxqTeJkhOkibLzoBVk8hLxSDFroydUV kB061OnkFleByRyVQsg2kT7f6oVYGCMz1z9ePbHTaK7OT3eR/40qdzY9nKUbCtArHKRB gYOboQcc/ha0yIwiaAtYcssiaDzaqUgEVyfSBj15mv0ztWy6iGA/bRtTK0V0Z8v7f/1+ vItc3NKAhWbIgRcLaDON1SGxs2vX7qpEAROD8bw4VcjuEpu4Cm2H+ejVd/efGQXNhSUV sgsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rpV99OKSTpIRzIpX89x9E7KBkQmTINaa7AEfKXJe4DE=; b=KeaM9YKtJcztZB3qhvXIa64Z5FL8+CUPh/6KWDAsLI9bZ79Q8ZP4cMz9/1xjFM4Avt Je2gTF0cMUjTZiavobuk5oS4Q6z2S4W4ITkhyfLtxEi0x70/g1yg7RmvGuf6ugEZxX5w 8yRd0B5CFDILPFYZCFe22zHdgRphjQIA70QGltElT/ynRp/cctd+rECF/9sM0lV+Orer P7fiEpoWGP8AcEUwWtOTYZ2ZHbxQzEMQDivaR/QTnr2UlCSADaBRkqcDkQKl4kXPRkec WUWTvlwpPjJjQzFvbFzhMzpZqUEB4Pr1moaNKtbmjDyUCjNRcC0J2OSR6UsCuSSXrLWC dV4A== X-Gm-Message-State: AO0yUKVtZGgIFrHx7NT8x9oWBhucdXLPvmD3FmbrdJbCOjk21F5kDamn Up5BVBoEiaPOwuc4ZJVzxOz4qffo7wHkbsopP+Up8g== X-Google-Smtp-Source: AK7set+9MztI9r7zEzAu1vny2Hg5q1wq3BcKzf3IYbntzcbRXNrbfMh8bwEdnJMVwNIM6qCS4Nmr3QMhP+bkyI9Bdfg= X-Received: by 2002:a81:ad03:0:b0:530:bbd3:798b with SMTP id l3-20020a81ad03000000b00530bbd3798bmr2233090ywh.0.1677607500530; Tue, 28 Feb 2023 10:05:00 -0800 (PST) MIME-Version: 1.0 References: <202302281802.J93Nma7q-lkp@intel.com> In-Reply-To: <202302281802.J93Nma7q-lkp@intel.com> From: Suren Baghdasaryan Date: Tue, 28 Feb 2023 10:04:49 -0800 Message-ID: Subject: Re: [ammarfaizi2-block:akpm/mm/mm-unstable 82/99] mm/mmap.c:516 vma_prepare() error: we previously assumed 'vp->vma' could be null (see line 505) To: Dan Carpenter Cc: oe-kbuild@lists.linux.dev, lkp@intel.com, oe-kbuild-all@lists.linux.dev, Ammar Faizi , "GNU/Weeb Mailing List" , Andrew Morton , Linux Memory Management List Content-Type: text/plain; charset="UTF-8" List-Id: On Tue, Feb 28, 2023 at 6:24 AM Dan Carpenter wrote: > > tree: https://github.com/ammarfaizi2/linux-block akpm/mm/mm-unstable > head: 61edd3b68c3185673c9b05dfe48038692964c73b > commit: f517f7ae341d933856cdf4d9d773027681ed5dff [82/99] mm/mmap: write-lock VMAs in vma_prepare before modifying them > config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20230228/202302281802.J93Nma7q-lkp@intel.com/config) > compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 > > If you fix the issue, kindly add following tag where applicable > | Reported-by: kernel test robot > | Reported-by: Dan Carpenter > | Link: https://lore.kernel.org/r/202302281802.J93Nma7q-lkp@intel.com/ Thanks for reporting! > > smatch warnings: > mm/mmap.c:516 vma_prepare() error: we previously assumed 'vp->vma' could be null (see line 505) > > vim +516 mm/mmap.c > > 440703e082b9c7 Liam R. Howlett 2023-01-20 503 static inline void vma_prepare(struct vma_prepare *vp) > 440703e082b9c7 Liam R. Howlett 2023-01-20 504 { > f517f7ae341d93 Suren Baghdasaryan 2023-02-27 @505 if (vp->vma) > > Check presumes that vp->vma can be NULL. On my other system (with > yesterday's linux-next code) vp->vma can never be NULL. I think the check here is not needed since vp->vma should always be non-NULL. I'll double-check and will remove it if that is confirmed. Thanks, Suren. > > f517f7ae341d93 Suren Baghdasaryan 2023-02-27 506 vma_start_write(vp->vma); > f517f7ae341d93 Suren Baghdasaryan 2023-02-27 507 if (vp->adj_next) > f517f7ae341d93 Suren Baghdasaryan 2023-02-27 508 vma_start_write(vp->adj_next); > f517f7ae341d93 Suren Baghdasaryan 2023-02-27 509 /* vp->insert is always a newly created VMA, no need for locking */ > f517f7ae341d93 Suren Baghdasaryan 2023-02-27 510 if (vp->remove) > f517f7ae341d93 Suren Baghdasaryan 2023-02-27 511 vma_start_write(vp->remove); > f517f7ae341d93 Suren Baghdasaryan 2023-02-27 512 if (vp->remove2) > f517f7ae341d93 Suren Baghdasaryan 2023-02-27 513 vma_start_write(vp->remove2); > f517f7ae341d93 Suren Baghdasaryan 2023-02-27 514 > 440703e082b9c7 Liam R. Howlett 2023-01-20 515 if (vp->file) { > 440703e082b9c7 Liam R. Howlett 2023-01-20 @516 uprobe_munmap(vp->vma, vp->vma->vm_start, vp->vma->vm_end); > ^^^^^^^ > Uncheck dereference. > > 440703e082b9c7 Liam R. Howlett 2023-01-20 517 > 440703e082b9c7 Liam R. Howlett 2023-01-20 518 if (vp->adj_next) > 440703e082b9c7 Liam R. Howlett 2023-01-20 519 uprobe_munmap(vp->adj_next, vp->adj_next->vm_start, > 440703e082b9c7 Liam R. Howlett 2023-01-20 520 vp->adj_next->vm_end); > 440703e082b9c7 Liam R. Howlett 2023-01-20 521 > 440703e082b9c7 Liam R. Howlett 2023-01-20 522 i_mmap_lock_write(vp->mapping); > 440703e082b9c7 Liam R. Howlett 2023-01-20 523 if (vp->insert && vp->insert->vm_file) { > 440703e082b9c7 Liam R. Howlett 2023-01-20 524 /* > 440703e082b9c7 Liam R. Howlett 2023-01-20 525 * Put into interval tree now, so instantiated pages > 440703e082b9c7 Liam R. Howlett 2023-01-20 526 * are visible to arm/parisc __flush_dcache_page > 440703e082b9c7 Liam R. Howlett 2023-01-20 527 * throughout; but we cannot insert into address > 440703e082b9c7 Liam R. Howlett 2023-01-20 528 * space until vma start or end is updated. > 440703e082b9c7 Liam R. Howlett 2023-01-20 529 */ > 440703e082b9c7 Liam R. Howlett 2023-01-20 530 __vma_link_file(vp->insert, > 440703e082b9c7 Liam R. Howlett 2023-01-20 531 vp->insert->vm_file->f_mapping); > 440703e082b9c7 Liam R. Howlett 2023-01-20 532 } > 440703e082b9c7 Liam R. Howlett 2023-01-20 533 } > 440703e082b9c7 Liam R. Howlett 2023-01-20 534 > 440703e082b9c7 Liam R. Howlett 2023-01-20 535 if (vp->anon_vma) { > 440703e082b9c7 Liam R. Howlett 2023-01-20 536 anon_vma_lock_write(vp->anon_vma); > 440703e082b9c7 Liam R. Howlett 2023-01-20 537 anon_vma_interval_tree_pre_update_vma(vp->vma); > > More unchecked dereferences. > > 440703e082b9c7 Liam R. Howlett 2023-01-20 538 if (vp->adj_next) > 440703e082b9c7 Liam R. Howlett 2023-01-20 539 anon_vma_interval_tree_pre_update_vma(vp->adj_next); > 440703e082b9c7 Liam R. Howlett 2023-01-20 540 } > 440703e082b9c7 Liam R. Howlett 2023-01-20 541 > 440703e082b9c7 Liam R. Howlett 2023-01-20 542 if (vp->file) { > 440703e082b9c7 Liam R. Howlett 2023-01-20 543 flush_dcache_mmap_lock(vp->mapping); > 440703e082b9c7 Liam R. Howlett 2023-01-20 544 vma_interval_tree_remove(vp->vma, &vp->mapping->i_mmap); > 440703e082b9c7 Liam R. Howlett 2023-01-20 545 if (vp->adj_next) > 440703e082b9c7 Liam R. Howlett 2023-01-20 546 vma_interval_tree_remove(vp->adj_next, > 440703e082b9c7 Liam R. Howlett 2023-01-20 547 &vp->mapping->i_mmap); > 440703e082b9c7 Liam R. Howlett 2023-01-20 548 } > > -- > 0-DAY CI Kernel Test Service > https://github.com/intel/lkp-tests >