From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752006AbdH3QhV (ORCPT ); Wed, 30 Aug 2017 12:37:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51316 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751309AbdH3QhS (ORCPT ); Wed, 30 Aug 2017 12:37:18 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 83FB5155E1 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=oleg@redhat.com Date: Wed, 30 Aug 2017 18:37:14 +0200 From: Oleg Nesterov To: Eric Biggers Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Eric Biggers , Alexander Shishkin , Andrew Morton , Arnaldo Carvalho de Melo , Dmitry Vyukov , Ingo Molnar , Konstantin Khlebnikov , Mark Rutland , Michal Hocko , Peter Zijlstra , Vlastimil Babka , stable@vger.kernel.org Subject: Re: [PATCH] mm, uprobes: fix multiple free of ->uprobes_state.xol_area Message-ID: <20170830163714.GA24774@redhat.com> References: <20170830033303.17927-1-ebiggers3@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170830033303.17927-1-ebiggers3@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 30 Aug 2017 16:37:18 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/29, Eric Biggers wrote: > > --- a/kernel/events/uprobes.c > +++ b/kernel/events/uprobes.c > @@ -1262,8 +1262,6 @@ void uprobe_end_dup_mmap(void) > > void uprobe_dup_mmap(struct mm_struct *oldmm, struct mm_struct *newmm) > { > - newmm->uprobes_state.xol_area = NULL; > - > if (test_bit(MMF_HAS_UPROBES, &oldmm->flags)) { > set_bit(MMF_HAS_UPROBES, &newmm->flags); > /* unconditionally, dup_mmap() skips VM_DONTCOPY vmas */ > diff --git a/kernel/fork.c b/kernel/fork.c > index cbbea277b3fb..b7e9e57b71ea 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -785,6 +785,13 @@ static void mm_init_owner(struct mm_struct *mm, struct task_struct *p) > #endif > } > > +static void mm_init_uprobes_state(struct mm_struct *mm) > +{ > +#ifdef CONFIG_UPROBES > + mm->uprobes_state.xol_area = NULL; > +#endif > +} > + > static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, > struct user_namespace *user_ns) > { > @@ -812,6 +819,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, > #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS > mm->pmd_huge_pte = NULL; > #endif > + mm_init_uprobes_state(mm); ACK, but I have cosmetic nit, this doesn't match other uprobe helpers. I'd suggest to add uprobe_init_state() into kernel/events/uprobes.c and the dummy !CONFIG_UPROBES version into include/linux/uprobes.h. Not that I think this will be more clean, personally I would simply add a ifdef(CONFIG_UPROBES) line into mm_init(), but this will be more consistent. Oleg.