Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp158667rwb; Tue, 13 Dec 2022 15:34:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXuz4CAss1xfCQjvIkXefYCBfNarDg1oa4D3toTlu2JcKMmqqV62vcEqYX9rsg/XXw1d7a6h X-Received: by 2002:a17:90b:210:b0:223:2edf:857e with SMTP id fy16-20020a17090b021000b002232edf857emr1327147pjb.8.1670974446657; Tue, 13 Dec 2022 15:34:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670974446; cv=none; d=google.com; s=arc-20160816; b=cmKg8891XdM4iLOej6yg1g4OjGxj/hjgM8pz6hnHwbzkM5/10WO59FgigN3FbCviRk cM2gVH0sJRpkJWIoxjaBZD31x81VUx4bKgaia9AVPJOh/yoLriZxMQIYoszdRhQiSg00 MzHO99RCGi0/2Qn/rZ3BkdGwdR2afO1ex4IhbG/mhbqg/w6UB3vMCmtOhSoLU+tdgZTh 8jY9ZTnQ6oYqXSr8LzHorvmL4HcsrW5+zSEvHaFjm6/l/ZuaTIPDP9uWzF6pXDfYzfZT UAEQF8WLaxwkjVracSkl76bEUDdfZcSRNZKu+8BsktsuPyBK2U8dt4AdsMHjj023cisP JXtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=DvJekcslsdK7omBDZdseZHxFwmahCoRb/AUjED6RxSg=; b=m/Rk0Mc8ZVYLgUI7JnWEUllzHzo47EKPI8tm1CMeE/FczZtkKHFF60ED57jwcZGxvk sNHqiobtlpPFh4D0HSrVsqTV0AxVbCz/y/KRtZERT7JJKrDwE++X0AKUT/S5ggLDdzgG ZLTvwF63XZ7YEMgaE7hj6G/Au/OJNM+01yY40V8ap5LmhuJO28tZxzkfNLhKxsjZEu9c vcg9K7/pjxPY9bgGbH/hE3/zRSz4o8ouVtHoq13m4aZpAFzs5O6tPc3S7QzOFVS4JqpN +J2WO41pO940gBVoQK4SlCF3Z6Q+jv9mkCEOrZvH2Opltmc/Sg62Co1zIcGWFIDRslFY T2wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=ED1+EP4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j64-20020a638043000000b0047715c95650si13825811pgd.534.2022.12.13.15.33.54; Tue, 13 Dec 2022 15:34:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=ED1+EP4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236624AbiLMXEF (ORCPT + 72 others); Tue, 13 Dec 2022 18:04:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236149AbiLMXED (ORCPT ); Tue, 13 Dec 2022 18:04:03 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 140FD13D for ; Tue, 13 Dec 2022 15:04:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=DvJekcslsdK7omBDZdseZHxFwmahCoRb/AUjED6RxSg=; b=ED1+EP4spiuK29WJRfp7tfP2QW cWWqccGfEx/OndvHrE/e9PkVFivUuk+NCSvxpiuDamWVgfcqF2xTiubqU/s6dTwY1wozRhT8Ays+e Wq0heAWA8Ma8s1LYMDXazPXz/H//ln91ah4/mRbBtACIdkqdpe0ykvmh9c8QZdfldEBVuoV7GMluX z3AfQNaMtgyKUm9BzZYYjhDCTpoarPtEbZUBSneVqHk4220iB+zFrrDdETqL2DX/88Qustls5D7Av ABBdzY+CwLMb8WSPHnVPtOuMTWFdPasAgQRv7lq5VNwSeDMPkG+lPAYbAxdieHMkj17V2C6lIPYD6 q3Mndh0Q==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1p5EJV-0084bf-IE; Tue, 13 Dec 2022 23:03:53 +0000 Date: Tue, 13 Dec 2022 15:03:53 -0800 From: Luis Chamberlain To: Schspa Shi Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org, syzbot+10d19d528d9755d9af22@syzkaller.appspotmail.com, syzbot+70d5d5d83d03db2c813d@syzkaller.appspotmail.com, syzbot+83cb0411d0fcf0a30fc1@syzkaller.appspotmail.com Subject: Re: [PATCH] umh: fix UAF when the process is being killed Message-ID: References: <20221115140233.21981-1-schspa@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 12, 2022 at 09:38:31PM +0800, Schspa Shi wrote: > I'd like to upload a V2 patch with the new solution if you prefer the > following way. > > diff --git a/kernel/umh.c b/kernel/umh.c > index 850631518665..8023f11fcfc0 100644 > --- a/kernel/umh.c > +++ b/kernel/umh.c > @@ -452,6 +452,11 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) > /* umh_complete() will see NULL and free sub_info */ > if (xchg(&sub_info->complete, NULL)) > goto unlock; > + /* > + * kthreadd (or new kernel thread) will call complete() > + * shortly. > + */ > + wait_for_completion(&done); > } Yes much better. Did you verify it fixes the splat found by the bots? Luis