Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1490593imi; Sat, 23 Jul 2022 07:16:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tk43zeOIjfZqqgEf3QrePBn23n7VXb349JPPyYNPLaaEw3lrf1Y0zTPY9GXVgJm0//HMvg X-Received: by 2002:a17:903:3283:b0:16d:43f8:d971 with SMTP id jh3-20020a170903328300b0016d43f8d971mr4139779plb.171.1658585795949; Sat, 23 Jul 2022 07:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585795; cv=none; d=google.com; s=arc-20160816; b=hdI/XgLFrcJ8sHvUX2zlKdhGtJ/SEAuTzLHfZ6U8UQOAxk8bgDTQ+Rwt3miFvzyjFC LXMH/dJVfzoheqF5WFcQTEFphWu4pZCR9Ap3sqtwmTtOhxO30C/tB+tKLoOXiJJZ+qSe eomLiIwXHDcVS999eb9NeKOzKgL/VcZjj5LKluNDSbWFvPgJ7FJzZ7OQ2Yr2POiYRorB SpfCsvrNHfxPY+cl1vo9e1sEWmAmFcADCGpJzj7YhvzqfsSfr2jCsafibdaWt0T6N7rF t9JFBz17ySncczgSr1kYWeYGB3UAYi/AbKkWrbgSgQlfpCcEoQU8BNr+DiSH460j08f7 IrOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6qHF7bUG2P1cdTplFbZ2QgD+bhfjZcmIimJ2W0pBEQI=; b=qAQQ+5gQ9jRMfv/0fzBNihoxotBLa7VD/6nWS5VQGqJQEAz7yQPcyMs7gEUzPPaIK7 HxLBpoC1/98xqx8I0oCzRDRADS7jYPi24gQvHd2fFuI4gkxLXc5DWuYNcXY4GsxxCMse aOQmPesuOv5cERLn35Vg49OFD9jbPvA8XOCxoJkFB91xLASAYPPEvwJArvwBRDyGb4nO akFpgvEir5k9cf0IwDvo+oc29u+Ti9ba2Tb1Dc75A8clDHwAM8o86lj7R4OQRv40R82Y WPUTszWWFz/tY4JjKTSqxRFFFWTWz1i7sQ9aj4bO36nODP3ztxlcQTenhLBwBD7qiqme Yq+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bM4kEy1U; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c12-20020a056a000acc00b00525acf11338si9636532pfl.66.2022.07.23.07.16.20; Sat, 23 Jul 2022 07:16:35 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=bM4kEy1U; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237283AbiGWOEY (ORCPT + 99 others); Sat, 23 Jul 2022 10:04:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236970AbiGWOEW (ORCPT ); Sat, 23 Jul 2022 10:04:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93BA317070; Sat, 23 Jul 2022 07:04:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2F6F76142E; Sat, 23 Jul 2022 14:04:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C049C341C0; Sat, 23 Jul 2022 14:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658585060; bh=i1hxM7Ujsdhm0k5s+lkC/ZUWIW+MTz2oWW+dSJcQLC8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bM4kEy1UjIF7GQ2Cqma5PvVIa4l9Ycx641e8SXLbUQjuzhfNV56YWb8GsGgVDVbPn UD+qsJz0rlBCL23S82Ol4/5NHIVKM6lLBE8KEJ2VpZm0LZwd7qrTvDEcnFQqXYNB0T M8EUJwv32dszihD48D1JbVOhmHUcB4tpWGYhCUPM= Date: Sat, 23 Jul 2022 16:04:17 +0200 From: Greg KH To: Siddh Raman Pant Cc: David Howells , Christophe JAILLET , Eric Dumazet , "Fabio M. De Francesco" , linux-security-modules , linux-kernel-mentees , linux-kernel , syzbot+c70d87ac1d001f29a058@syzkaller.appspotmail.com Subject: Re: [PATCH] kernel/watch_queue: Make pipe NULL while clearing watch_queue Message-ID: References: <20220723135447.199557-1-code@siddh.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220723135447.199557-1-code@siddh.me> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Sat, Jul 23, 2022 at 07:24:47PM +0530, Siddh Raman Pant via Linux-kernel-mentees wrote: > If not done, a reference to a freed pipe remains in the watch_queue, > as this function is called before freeing a pipe in free_pipe_info() > (see line 834 of fs/pipe.c). > > This causes a UAF when post_one_notification tries to access the pipe on > a key update, which is reported by syzbot. > > Bug report: https://syzkaller.appspot.com/bug?id=1870dd7791ba05f2ea7f47f7cbdde701173973fc > Reported-and-tested-by: syzbot+c70d87ac1d001f29a058@syzkaller.appspotmail.com > > Signed-off-by: Siddh Raman Pant > --- > kernel/watch_queue.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c > index bb9962b33f95..bab9e09c74cf 100644 > --- a/kernel/watch_queue.c > +++ b/kernel/watch_queue.c > @@ -637,8 +637,17 @@ void watch_queue_clear(struct watch_queue *wqueue) > spin_lock_bh(&wqueue->lock); > } > > - spin_unlock_bh(&wqueue->lock); > rcu_read_unlock(); Also you now have a spinlock held when calling rcu_read_unlock(), are you sure that's ok?