Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp518255pxf; Thu, 18 Mar 2021 06:17:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUXF3bu/5NY/2ulC6xQtyOMj6D0i+H3jXpGrfiyQHnGt2AIGvjQBSJIW8ao3ZVMsUw5Oid X-Received: by 2002:a05:6402:3122:: with SMTP id dd2mr3524860edb.253.1616073434405; Thu, 18 Mar 2021 06:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616073434; cv=none; d=google.com; s=arc-20160816; b=hMXa9uik2DFhqDLWGftX+5IaIQl7VkGJ1mCwv8u+w87xvi7nydCVcvfI55DzqjVTAB P+9vEdPnlM07pNySD+/EHGUtaNq/A9UphzQV1tI5VL6PZFckvSx5yyt7WbVnuqSlVwlI F6bquihgSwz+7JlLamLKP+6UN2v01Dsb9DCIr44DGUnQZ399dwMlG/A57tRoWqN6eEWR ruhBUer00wqhzBETmvqneBB7oze6yXjPVu3i7+M2Q+Ex4cSe7WUigEDd8pKaud3kNM7x FSJiM5YPjVnRqeETn3U7A73VLTd8LzbjHVRfeEfxqMkS0v7yr33Lf1Rur/lGzVlCl8pw P4Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=+tUwRkRkP6+qKsssbeUlFdzu5XVDSTuMZvkAUVRnHI0=; b=xhdDwsRzM0s+b511HmgcfSA/j3PJzn2z0iMp1qqauY+ETsPZlLnUB4srMtIyCzcZZc L31SxADiSTY2FYOjxeoIuqjhgMDLhZ7DNzhy+H51I7RD408tDZYyativALc25dzG0cHs Ase98W9b9qY178eoQtFrb4KJTxDbLH3CroQIYak7fSIhUDSfEu9NwCRa213OsFVkuQFQ UOGTcIrNe37ngg3yeg5OFM09WTjvxxkf/JjN/mYECj2/XwAeFhjcZfKUfvlohxKdBID9 zXvR2KH8/nXTBr7AK4tAqSPC/uozKWwV8iXEBrsvexL8MSGTr4q34pyXpHLvRG6fpabc jVbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Sra8zmze; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay3si1566435edb.106.2021.03.18.06.16.50; Thu, 18 Mar 2021 06:17:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Sra8zmze; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbhCRNNg (ORCPT + 99 others); Thu, 18 Mar 2021 09:13:36 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:49180 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231238AbhCRNNM (ORCPT ); Thu, 18 Mar 2021 09:13:12 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IDC9v3153476; Thu, 18 Mar 2021 13:13:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=+tUwRkRkP6+qKsssbeUlFdzu5XVDSTuMZvkAUVRnHI0=; b=Sra8zmzealkZeIUYDv8UCSXaCiMxSDv1fAcuBczmkXOiH2OTitMOgwTehdo0Ahk+II9K /WTX3HEfmame0j64Dswni9rzh3rniYSPs09L5zY3VYNf1xLNnCp0ODDu1A89j8a3Sp7O 5N3pH0g2oQeHOYW84DIkVULGlFkCxR/MkoIsNctVU3OMK9ozbIiFFidRhr9n6PRPZdKD DBfQWAWKeNv6ANUbI7ssfAqgUmcIUFqL1+i7vQJIEl/NyCnMMdSBBh9v2anaUxYvxlkc z61vHo/VVfPlStQTPTRyiWj+ezeUIuKvzcIMkWaIUHAClgZGxGsL74UfCdDH+4rb2/G1 Qg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 378p1nyd91-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 13:13:05 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12ID5xbI103145; Thu, 18 Mar 2021 13:13:03 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 3797a3xjwu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 13:13:03 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 12IDD2td022650; Thu, 18 Mar 2021 13:13:02 GMT Received: from mwanda (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 18 Mar 2021 06:13:02 -0700 Date: Thu, 18 Mar 2021 16:12:54 +0300 From: Dan Carpenter To: Namjae Jeon Cc: Hyunchul Lee , Steve French , Sergey Senozhatsky , Ronnie Sahlberg , linux-kernel@vger.kernel.org, linux-cifs@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] cifsd: Fix a use after free on error path Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-IMR: 1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9926 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180097 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9926 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 adultscore=0 spamscore=0 clxscore=1015 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 mlxlogscore=976 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180097 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ksmbd_free_work_struct() frees "work" so we need to swap the order of these two function calls to avoid a use after free. Fixes: cabcebc31de4 ("cifsd: introduce SMB3 kernel server") Signed-off-by: Dan Carpenter --- fs/cifsd/oplock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cifsd/oplock.c b/fs/cifsd/oplock.c index 6c3dbc71134e..f694c14be0df 100644 --- a/fs/cifsd/oplock.c +++ b/fs/cifsd/oplock.c @@ -638,8 +638,8 @@ static void __smb2_oplock_break_noti(struct work_struct *wk) if (allocate_oplock_break_buf(work)) { ksmbd_err("smb2_allocate_rsp_buf failed! "); atomic_dec(&conn->r_count); - ksmbd_free_work_struct(work); ksmbd_fd_put(work, fp); + ksmbd_free_work_struct(work); return; } -- 2.30.2