Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1858633lqg; Mon, 4 Mar 2024 06:09:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdo4J0N6g8q7Sy1080HpmWB63/J7oQB5/lD94pWl/R/UcepkM5tL1y0o0QIKakW7dm9h4PnlCMFBpjNf+eHnXV1TIsY/uAeTRsHnSoTQ== X-Google-Smtp-Source: AGHT+IEbjV4EndWXM0H/SAXDM6do313pToJrBdyZ/f0rJ3QRTU1f2NEZSkQnIm7yx2xU+cIQewPZ X-Received: by 2002:a17:906:b7c7:b0:a43:9fb0:bb4d with SMTP id fy7-20020a170906b7c700b00a439fb0bb4dmr5849400ejb.63.1709561344405; Mon, 04 Mar 2024 06:09:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709561344; cv=pass; d=google.com; s=arc-20160816; b=oNeXeMTrQcmUu95slHn22p/FGu08sd5/CxwgxY9cfh5DhjeyKMgs8UWZrho7fiCWDi GrjMuEQVzj9IWyQNv2jFEvytVMgs881SlwqeQCpZ/e4thRacvx5GIb2ArsVAoz2c5Nqu jSG79Wz8q2X+TIeEE+QvzaW8cwmIcRHQNd6guosLtJ7mfCoQcz/U3SefRctCyZ9xVSP8 LZPgdcFP7pGyrNCiWEAqxxHEPF6M9Kr64n7DXmPKjVU7UAVm1Er69RW44B/xG20Q68Ph qKCHoInPuXS99iOAXHL25sk6an5DuCdOuyrtDJkkEVLU1SFuCunBLu7zGGYTabcZh03v 5rFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=qDcz28eDsFeAP3RGXY0dV266nU2u3nvB4iCqSXkgm34=; fh=G5noQSpm/gwkfVnWeMQM+Y6lls5amIjMr33VvcBrD6A=; b=026TnIPGOF/Zo+0ZaI8OA8EKtw/SGHuGET5ZU7KPb1Er+nZYfE5hsoAMcl2ZeavgKk Nmmy7Pti+TRY/gNY9YRO9i5w2oLrDeDWze8Kj4e7NQeKeq/4T4pR5DZaQMRL3CJyXR52 8i5BDyeWPE8gowOtpq9AvdAocKSlvJGaEzil6Q7JqTl7HqHSqkGO2m1Xd54jPD3PHRU6 xC+vk+nrEVXIp0aM2U31pX4ww3EiTqFTBCnxQtwP8gAMRpOz2A4tsMdBPFrpLQqCATPP uhlhkdEo4jQ/xgNo9/XmIqfBxQpXzj8iQJONH0Wf1RBIqlxO2zdEtRXz1qYVFxsXELyi epKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-90707-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90707-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a24-20020a1709064a5800b00a43838cbd7csi3862238ejv.148.2024.03.04.06.09.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 06:09:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90707-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-90707-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90707-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0AA5D1F27503 for ; Mon, 4 Mar 2024 14:08:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEA4F3FB1D; Mon, 4 Mar 2024 14:08:07 +0000 (UTC) Received: from mail115-76.sinamail.sina.com.cn (mail115-76.sinamail.sina.com.cn [218.30.115.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13EA33F9FC for ; Mon, 4 Mar 2024 14:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709561287; cv=none; b=sPPOOw8XJlB4f5aq5IfzFyxdI2D2UemFhTJR+75va1MZBs4GcYyCb30lITl9cpAxLlNzmGJQg01VwT5yLJLO3dtSJZ/Va4FdRkMBFUVwARdzrcWke4uuKIqmbM5GuJvnrgonRnDJtDnL43mDerBQgxIHnTwkOzxe9qaonaWeXLM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709561287; c=relaxed/simple; bh=RTTjJrKbQGC+to+9CcT3Rjd8f3nh2/o7sz3wwy6ugbI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OFntVRDCBTmvSP5R4tnZOJt+pBjWjRp/WiwjR0c7miNT1WT/3hD8ZofgIem/3NacSEW4S9STn/oKF9h8T5j4LtevLizpXvMQUa5HeWkONBU/1KWunS7P1rbnbGi3U329+kV6e/FjRbv3+CP/X5PC/liIWesbE7k/CSx/zKQ9AMQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.66.159]) by sina.com (10.75.12.45) with ESMTP id 65E5D58D000033AD; Mon, 4 Mar 2024 22:07:15 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 4786531458218 X-SMAIL-UIID: 51EAB7993DE54EFFBB1471E35B6BB18F-20240304-220715-1 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [fs?] KASAN: slab-use-after-free Read in sys_io_cancel Date: Mon, 4 Mar 2024 22:07:02 +0800 Message-Id: <20240304140702.1457-1-hdanton@sina.com> In-Reply-To: <0000000000006945730612bc9173@google.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Sat, 02 Mar 2024 23:29:23 -0800 > syzbot found the following issue on: > > HEAD commit: 5ad3cb0ed525 Merge tag 'for-v6.8-rc2' of git://git.kernel... > git tree: upstream > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13877412180000 #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master --- x/fs/aio.c +++ y/fs/aio.c @@ -2194,6 +2194,8 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t list_for_each_entry(kiocb, &ctx->active_reqs, ki_list) { if (kiocb->ki_res.obj == obj) { ret = kiocb->ki_cancel(&kiocb->rw); + if (ret == 0) + refcount_inc(&kiocb->ki_refcnt); list_del_init(&kiocb->ki_list); break; } @@ -2204,8 +2206,11 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t * The result argument is no longer used - the io_event is always * delivered via the ring buffer. */ - if (ret == 0 && kiocb->rw.ki_flags & IOCB_AIO_RW) - aio_complete_rw(&kiocb->rw, -EINTR); + if (ret == 0) + if (kiocb->rw.ki_flags & IOCB_AIO_RW) + aio_complete_rw(&kiocb->rw, -EINTR); + else + iocb_put(kiocb); percpu_ref_put(&ctx->users); --