Message ID | 20240205111917.181490-1-pchelkin@ispras.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-52476-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp807221dyb; Mon, 5 Feb 2024 03:21:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IESC6ghPAJsFp8MHXclkJCCKvxU+af5SccA3mIiDocoPbYq0x2F6ivzY7F19KoP2VThkPgo X-Received: by 2002:aa7:c1c8:0:b0:560:5748:682b with SMTP id d8-20020aa7c1c8000000b005605748682bmr2213920edp.14.1707132095961; Mon, 05 Feb 2024 03:21:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707132095; cv=pass; d=google.com; s=arc-20160816; b=tBK35GMdpZ0KRohgxfvsePIt7FKXtDg14SD3gKrVme1mBl9/sPv8HvkvWLsPuk71At HMyAuq+5fIBJC1VHarFiv9WwlUAgkePf3qC2xUd25qi+VNhLv5NGUZSOBsBvIzWwRVFj aEGTzAC2NHP21A2he1f2XtmHqojHruEf2R9CRQ48I2DSVR4obG6tuM8lrH3Jt2A6t+DH C0V7kk2b7jAU8PMJpyfSC6kEGAo9+T1pnXWl3CApw2k8NRYxEvrGI+YDEiq83ayC7iRK LBdDb9B3sELavLl15pW02clt6rBBSsT+URLp4GLJ/mbli6eSm1ujvBE0d/UrnYEDcsA8 Xi2A== 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:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=8eo/Q0edrb5NcHDsJfOyyWcOMOAMiCdqztmPDVSV+jk=; fh=RvETg/81xXE0HzhDhZ/6D+aPzgyEAYDGSfZqmVc6h90=; b=KMQhnx+D8HH8hX+D1fHMSk356JtFdXhlNtZxo+Ojnmd4P+4p8HxRgJOsatLjKgAnHs sJrxrTbJ6+oyISQbeWN28bfR3t/ufsAo/3p1xZFr+qnNeKkxAOa9xX8DkS5uw7gAGC2p a0dPJTNck2T3173pqLH4O7DUqM5ENP6ih00I0UewnYWeVCTBB+2FnP7d8MK3PAKfvRKH m8MpTtbcPDf70zkOZ7t7bZWEwTllBacioXYYz/wxFLmkW32fuPl71F9uvStvuCimoEFm PfNLVzmioSmbaN/dQgfSN7vMmzva4VzYvqdLw457aZU9ntVaY3ejc8yOnYnB8UaAt9i+ Eavw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=oOH5Lrlj; arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru dmarc=pass fromdomain=ispras.ru); spf=pass (google.com: domain of linux-kernel+bounces-52476-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52476-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru X-Forwarded-Encrypted: i=1; AJvYcCVawIx3ZFuLB4k+EuqdpCFRG/tqHd2HYox7aUz3CQcCZEm2gobtNvz8Zd+nxG3ofVHG8WsNcopbRQDoyF09EpmiIMSnUw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cn1-20020a0564020ca100b0055ef39f3ce3si3925922edb.473.2024.02.05.03.21.35 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 03:21:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52476-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=oOH5Lrlj; arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru dmarc=pass fromdomain=ispras.ru); spf=pass (google.com: domain of linux-kernel+bounces-52476-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52476-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru 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 8D9BD1F2226D for <ouuuleilei@gmail.com>; Mon, 5 Feb 2024 11:21:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13F3718E00; Mon, 5 Feb 2024 11:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="oOH5Lrlj" Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F174118638; Mon, 5 Feb 2024 11:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707132077; cv=none; b=smID9IFiEHRIvgKFhE60QCYgs2KuSr2I21FZytULPs0ALaz6nbJK4C2Hordeidfaly30Y6lA4iEg728iGfr2vQeXQ4BgGwaYzcBDl0owXxvpbyw7jVr1gdF/yHBWoJ4V+c9OZuy4L/8pshncQ3okCYVsgJc94Q0DgOzDY6HmQ4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707132077; c=relaxed/simple; bh=Rz2/NQDtnx9QX45qClLg84vegkmZf2yJfQ2ueKkFnJ4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=H6A76IeshiBHBBnmFYls1TQeY+2SU9R5iPPTh4Bd0l1E832nbd56vqcTSNWJVhYwdsWnEDqg0q2g74fh7i831BMRZb1qz4M0SqyVIREo263iTzyLe9JWambzETj1s0VA681Xdp/SO5DWuBzMjN1fUmdGrduAjPR4i7bQZKZYS74= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=oOH5Lrlj; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Received: from fpc.intra.ispras.ru (unknown [10.10.165.10]) by mail.ispras.ru (Postfix) with ESMTPSA id A8EE940F1DFE; Mon, 5 Feb 2024 11:21:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru A8EE940F1DFE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1707132064; bh=8eo/Q0edrb5NcHDsJfOyyWcOMOAMiCdqztmPDVSV+jk=; h=From:To:Cc:Subject:Date:From; b=oOH5LrljU5KLyfEHokjGu71VmrskUfa4W4Mo8kK4PDSfP0DkgmVDEHSdksDwKTSOE b/wC9ajaHAoHZ0eCGdZgr759DnPsk6koUDbtK/KcQK7zKWchnlg6visFjuz+hHCKeq jjo1LnLOufWl+K5e0WVh/YgZ2Rub8LwDq2NVVYdo= From: Fedor Pchelkin <pchelkin@ispras.ru> To: Namjae Jeon <linkinjeon@kernel.org> Cc: Fedor Pchelkin <pchelkin@ispras.ru>, Steve French <sfrench@samba.org>, Sergey Senozhatsky <senozhatsky@chromium.org>, Tom Talpey <tom@talpey.com>, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov <khoroshilov@ispras.ru>, lvc-project@linuxtesting.org, stable@vger.kernel.org Subject: [PATCH] ksmbd: free aux buffer if ksmbd_iov_pin_rsp_read fails Date: Mon, 5 Feb 2024 14:19:16 +0300 Message-Id: <20240205111917.181490-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790057744337893865 X-GMAIL-MSGID: 1790057744337893865 |
Series |
ksmbd: free aux buffer if ksmbd_iov_pin_rsp_read fails
|
|
Commit Message
Fedor Pchelkin
Feb. 5, 2024, 11:19 a.m. UTC
ksmbd_iov_pin_rsp_read() doesn't free the provided aux buffer if it
fails. Seems to be the caller's responsibility to clear the buffer in
error case.
Found by Linux Verification Center (linuxtesting.org).
Fixes: e2b76ab8b5c9 ("ksmbd: add support for read compound")
Cc: stable@vger.kernel.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
fs/smb/server/smb2pdu.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Comments
2024-02-05 20:19 GMT+09:00, Fedor Pchelkin <pchelkin@ispras.ru>: > ksmbd_iov_pin_rsp_read() doesn't free the provided aux buffer if it > fails. Seems to be the caller's responsibility to clear the buffer in > error case. > > Found by Linux Verification Center (linuxtesting.org). > > Fixes: e2b76ab8b5c9 ("ksmbd: add support for read compound") > Cc: stable@vger.kernel.org > Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Applied it to #ksmbd-for-next-next. Thanks for your patch!
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index ba7a72a6a4f4..0c97d3c86072 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -6173,8 +6173,10 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work) err = ksmbd_iov_pin_rsp_read(work, (void *)rsp, offsetof(struct smb2_read_rsp, Buffer), aux_payload_buf, nbytes); - if (err) + if (err) { + kvfree(aux_payload_buf); goto out; + } kvfree(rpc_resp); } else { err = ksmbd_iov_pin_rsp(work, (void *)rsp, @@ -6384,8 +6386,10 @@ int smb2_read(struct ksmbd_work *work) err = ksmbd_iov_pin_rsp_read(work, (void *)rsp, offsetof(struct smb2_read_rsp, Buffer), aux_payload_buf, nbytes); - if (err) + if (err) { + kvfree(aux_payload_buf); goto out; + } ksmbd_fd_put(work, fp); return 0;