Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4204759rwb; Sun, 13 Nov 2022 00:49:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf7P7hSVbzoounnp2BGSPH3KWD9smBgfSu74YN8155mn8bdnaPM/ydEHtkNOM7GWjXBiJCTh X-Received: by 2002:a62:a50a:0:b0:56b:b112:4a16 with SMTP id v10-20020a62a50a000000b0056bb1124a16mr9680805pfm.66.1668329370984; Sun, 13 Nov 2022 00:49:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668329370; cv=none; d=google.com; s=arc-20160816; b=0oJG50qgxc4x9RRH8eAnooNBuXGtduiKrHaJtAnvX4hFM/KmlPAECD9EWHunOMqPiz c6dEmBZJpf9qmNr7CSf1zCq+DP/8fZqGljQfqf2izdXH8ah8Uuzuby4KMNRN8FLC4MJI lgK7ZXpsan4yzQl77jmp5QeKLqD1WeqJGj4Y7SIHgxLTim8hJF+9FYGzZ8quV5TLStBl jWcmxlcxVDtCRdsr4+PkmhIG2KdRcETskH0mW7doV65+zwlsnTobF9giocELqv44h/Ko ywywiU7gI64FNB5Drx4Nj7+uypN00+Ecp7FfygCqrEuhLYgqNog1Il/lF9xDeKbJCx/V H2aA== 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=6zM9r/sE2arMe1ziHsoXHyeiwa3rJRhwbTpoZQenkP0=; b=DnofQBMy+SEHdo0Qp6sow7jJRXPEy6QfHaz380h9jJI7Pfi9tc9SYeD0XcV70ToKA4 o5YLTZEZTp0URyhTIoYbx7Ox/jQ1FuUAmDJAbjJT/xWk64xAx3D1nocYjv4FEq0BzjG1 eR4Pm0pNZyrfjjulJbULacKLRfQUNGY2vyGjgumqVKAJXSPIZnZ7mQRQV2vawGaqXGGY /mlGkZF7TxOiJwPTsywp8Uu25TokIV9muSQw0dxD7G1UmSZ2OBvYwB7j+KGgcM1XBo7/ z2VcbCxwsnx2PEC43XaihSluAnuq2CHycXTqajji69/B1f9RtfOX8MSuowZAf3kaiV73 spfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eZ8puorR; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a056a0024d500b0056bce3dfaa8si7321424pfv.27.2022.11.13.00.49.03; Sun, 13 Nov 2022 00:49:30 -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=@gmail.com header.s=20210112 header.b=eZ8puorR; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235085AbiKMIGH (ORCPT + 89 others); Sun, 13 Nov 2022 03:06:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbiKMIGF (ORCPT ); Sun, 13 Nov 2022 03:06:05 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06D5C1006E; Sun, 13 Nov 2022 00:06:05 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id q71so7786278pgq.8; Sun, 13 Nov 2022 00:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6zM9r/sE2arMe1ziHsoXHyeiwa3rJRhwbTpoZQenkP0=; b=eZ8puorRy851lsvelSzqMSeeLyZ4dV/kj02RSvfxz1CQuX7fx1TxcZtxfNmbGjMJGF +ZI2oYdWVxBDMCpXj0YQrvConklIYJ02MeF8RCBnxAS/3CF2C86NQNdmSNg8FpbuIpy2 QKqg4xH9KvokMAZKtLksRBhc7koYM57D36C3vQFkHeYkVvxR+zriFm5Aw/SnoFFklqPV 2OPFS4DiqmQfxaeB/SEQpfM2Lw7erJQmU+ZqbnyJ1mWTg509s68ce3avOo5e9kzojrmQ rN8MzWbATBEdqg0YAoC5NPb6ixEwkGgSxANFHOhHD6n56sS+QehH7/sDMu/Vgd9VVG6f UNlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6zM9r/sE2arMe1ziHsoXHyeiwa3rJRhwbTpoZQenkP0=; b=NChT5FCNlPH0XW/UQ0UiylJ+VYF1VnRI5oeqelJ0ZhZKv8lhu/UlI3m53jVf9pSFQk HcMT3c8J/CVYutXY8AZOL/BFGzPHZRanB9zsH54M3OjVXp1iwGbJeExL6zgO0I2oNcka aeyGz1yFlLqQ9e7SvtAygVygrvJJBB/Fa+o0yZuO1Nhr97XkKCZ1lZGEr37JxZ5VbuOi gIv2N/u97gh+yUzgo3pFlKY7NESpgVGT+KrbIGRg60rSy192aJf/XH79CEPCFgi1J5Zy //Ygst8R+TvFqGNKYjKJWmsVCTxZ1wluAYc1nZSZW6FJsSsgqX1fjX2EVjKW6IdGpzTQ s17A== X-Gm-Message-State: ANoB5plngP02X9in9q8sCjpqFLyacaqSUM40uoF/WMa5JTR3aFxwmsW8 xKgX21cBNfOY4LAL23+j3No= X-Received: by 2002:a05:6a00:1592:b0:56b:e2db:5b88 with SMTP id u18-20020a056a00159200b0056be2db5b88mr9358474pfk.27.1668326764475; Sun, 13 Nov 2022 00:06:04 -0800 (PST) Received: from ubuntu ([211.193.26.134]) by smtp.gmail.com with ESMTPSA id f193-20020a6238ca000000b0056d2797bf05sm4279947pfa.217.2022.11.13.00.06.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 00:06:04 -0800 (PST) Date: Sun, 13 Nov 2022 00:05:58 -0800 From: Hyunwoo Kim To: Eli Billauer Cc: gregkh@linuxfoundation.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, stern@rowland.harvard.edu, imv4bel@gmail.com Subject: Re: [PATCH v2] char: xillybus: Prevent use-after-free due to race condition Message-ID: <20221113080558.GA5854@ubuntu> References: <20221030094209.65916-1-eli.billauer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221030094209.65916-1-eli.billauer@gmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Dear, Sorry for the late review. This patch cannot prevent the UAF scenario I presented: ``` cpu0 cpu1 1. xillyusb_open() mutex_lock(&kref_mutex); // unaffected lock xillybus_find_inode() mutex_lock(&unit_mutex); unit = iter; mutex_unlock(&unit_mutex); 2. xillyusb_disconnect() xillybus_cleanup_chrdev() mutex_lock(&unit_mutex); kfree(unit); mutex_unlock(&unit_mutex); 3. *private_data = unit->private_data; // UAF ``` This is a UAF for 'unit', not a UAF for 'xdev'. So, the added 'kref_mutex' has no effect. Regards, Hyunwoo Kim