Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp571124rwd; Wed, 31 May 2023 02:18:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6qHNcNamsSL7ufpWf04CEp6O30xmZtq46SpcJuCRN4Fd4gLWq9p1DBLgnEl5FNuW6QkGs7 X-Received: by 2002:a92:d683:0:b0:33a:3823:bc7a with SMTP id p3-20020a92d683000000b0033a3823bc7amr1789680iln.18.1685524691344; Wed, 31 May 2023 02:18:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685524691; cv=none; d=google.com; s=arc-20160816; b=r77DVH/iMZtGamdO652QHMqN1rxBNJWgi7p0/K8huJdR3nNrhHbbHaNEv/5SApI2Pd PSJJQdQyryCCHX96RT5yyGjZSgMCiULsxHO+zgdCLJt7RVena8Q8RrkUOEYP2e1eoyIm G5WmhcTYhDCF2fKstCfXMZTorUxE6dAivueIo/587UYhXa5TNMz9k7yTGb31gzowbp2R qOHT6kBr0Q8msOj2GYaorb2zJIEnFZJNSqb15KGt+8ptvs507dK91IxqFuqllu2W6t3I U2oB9Q2CoqnzLnvGX8iLgg9bw/PatjGAEuSYplVKyynqKrDVHwGzFyckcEuh94DQWrvg yGyA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=w1M2eBJ7zOxZaIyOH3KoErjAdVSCrveCBN0XVMPEQzU=; b=jSxBI/Ec+/yqGoq80smZFTIrfLrG4G0xIHDerhfsBg4tJ3MJ+EO5HlNwMPSqtUpx0o fOoH5DOYeTX1NRyeJl/e0aZV1THc3cq29ts6+v3CkRQOlrOKGCtve4XFMo7wBFCbvBrC 4Ncuifa825fPPrpoPuu6ShOJqxfIVUGlVu9dwv/OVDePkonl1RFY/oRHx6JxWDB9+6JX uQajs+vph9buLOdsgd6mKSVJ/Y/j/WuIv/B9l2Ax3GCCF3T9CtWrS+M2HRO3S8D7O/aW vbzMGyhLCsTr83sB/oUgpEMsy4fgbf6SL8FZLx0CaqpIx4xi5R8euAZVkWsmvfVspjCc UDMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B0Vk7X0y; 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 q5-20020a170902788500b001ac8cd69347si574428pll.179.2023.05.31.02.17.59; Wed, 31 May 2023 02:18:11 -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=@kernel.org header.s=k20201202 header.b=B0Vk7X0y; 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 S234902AbjEaIxR (ORCPT + 99 others); Wed, 31 May 2023 04:53:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234848AbjEaIwt (ORCPT ); Wed, 31 May 2023 04:52:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58D4AE6; Wed, 31 May 2023 01:52:48 -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 E6AAC62904; Wed, 31 May 2023 08:52:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AEBAC433EF; Wed, 31 May 2023 08:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685523167; bh=7blyzSvGlER5YAULyUBlu+Q1PhLaEhCVvqk8dtsJimE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B0Vk7X0y6o0Ad5WHjFxWvNXl9HBH3lMm8akSXHvdlJxWnRTAYTZTNcC1iCiF4ZhXu kOm8rH8UGetRujQWvbKruaxhIxAY7gZsa/5RK9HEj5d6o0j4wE/a5cg3Uba6Gv8B1x 52NCLmtnT0lujmfJuDcHMFqTLjeGGMVpJjOO6Wo0SIzaxyncv1CUPSzmFLmThgRS+s Q5RSzH3zV5V1NnCX1hwOpRu3FLKjQ4G+wTtvcm8yf6988FBlkNRnQ9Y1+jjR0xp0Br D/lNU7yDYFsKklX+R4LeAWWCthZSIZC9SVcxi+CZJqSdLvadc/phS4Jho70lgg/0tn 5Rj6Jjd0FpduA== Date: Wed, 31 May 2023 09:52:43 +0100 From: Lee Jones To: Dan Carpenter Cc: Jassi Brar , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] mailbox: mailbox-test: fix a locking issue in mbox_test_message_write() Message-ID: <20230531085243.GB449117@google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.3 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,T_SCC_BODY_TEXT_LINE 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 Jassi, On Fri, 05 May 2023, Dan Carpenter wrote: > There was a bug where this code forgot to unlock the tdev->mutex if the > kzalloc() failed. Fix this issue, by moving the allocation outside the > lock. > > Fixes: 2d1e952a2b8e ("mailbox: mailbox-test: Fix potential double-free in mbox_test_message_write()") When are you planning on sending this to the -rcs? > Signed-off-by: Dan Carpenter > --- > drivers/mailbox/mailbox-test.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c > index c4a705c30331..fc6a12a51b40 100644 > --- a/drivers/mailbox/mailbox-test.c > +++ b/drivers/mailbox/mailbox-test.c > @@ -98,6 +98,7 @@ static ssize_t mbox_test_message_write(struct file *filp, > size_t count, loff_t *ppos) > { > struct mbox_test_device *tdev = filp->private_data; > + char *message; > void *data; > int ret; > > @@ -113,12 +114,13 @@ static ssize_t mbox_test_message_write(struct file *filp, > return -EINVAL; > } > > - mutex_lock(&tdev->mutex); > - > - tdev->message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL); > - if (!tdev->message) > + message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL); > + if (!message) > return -ENOMEM; > > + mutex_lock(&tdev->mutex); > + > + tdev->message = message; > ret = copy_from_user(tdev->message, userbuf, count); > if (ret) { > ret = -EFAULT; > -- > 2.39.2 > -- Lee Jones [李琼斯]