Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5225205rwb; Mon, 21 Nov 2022 19:02:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf5aD+/aeja/hxazooO2bMfnRfp+N+Tnjri+dm1KgtOcRpDy70bxdNVsQVEMEG+LVPxUNmJ+ X-Received: by 2002:a17:903:40cb:b0:188:7dca:6f4a with SMTP id t11-20020a17090340cb00b001887dca6f4amr1902131pld.60.1669086175865; Mon, 21 Nov 2022 19:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669086175; cv=none; d=google.com; s=arc-20160816; b=nHVPRcpdF9ryQrlCjmATRES3EmpWqsxgf/tlqtsu8iZQh7S7vP/IgoOtLGV2zq/ha9 +U9yUFILtuT6Uj9oR7y7SFl2z37m9+X8YwFqW6Jpq3HlwYHQUGC9C1ntGEbwGay7IOUM F5bfG3CL9cPPsMbnZnlpRoXQGKfMkWr13WeWZWUWskZNApcirTB1YvEuWuz/WK+YfYoy HnsjvKps2LEvV16qLj1dccdXglwzuj1rrqyLbJKh9q4KZQotUgIgE49jKls5PDQfdFnL zjJ6JscXt7hrcP0GkBvQ2aB5nSHhH6aa3QmgZ/PmyVi8kzwryore2Xfm0gQMOAV7TiiN fkHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=47pnS2+Uhc7HCQJ7l+y7hLEI5W8u2nH/QQLE50wpAS4=; b=h3ZLrovrgZoBLDdoL01jQD+tEgxHn0b8A3w9foY1OqBnta1Xge7fueACmL9Gm3ZgPQ p6ttaLGxF+FZdiQar8i7OpTSinBkqt3gLXfQ05Tw4zgkXQk9/cRg+wItymypq98JM+0o Nb8/ZK5la6QmYtEq8AD5Z6mwHOf7HUnNOp7gvsOFYplkxJ4Zb7Zljwra8o5UwXYP5auh X43lCXREluKRfJGKZ77tCEhgJOBhVUzD5bh7Geth4j0DEoi5kfRIbkEo54OaUAX1xI4x Pum2tKpy+xw5bMyZEbu7qbMyVBEfXMI03HnrAynXEh91JOwWL91KPEtSyX/266FpbKU1 5P2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="gi8ir3+/"; 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 jg9-20020a17090326c900b00188b63f07a5si11204938plb.615.2022.11.21.19.02.44; Mon, 21 Nov 2022 19:02:55 -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=@kernel.org header.s=k20201202 header.b="gi8ir3+/"; 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 S232679AbiKVC0j (ORCPT + 91 others); Mon, 21 Nov 2022 21:26:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232675AbiKVC0W (ORCPT ); Mon, 21 Nov 2022 21:26:22 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64A6AE1235 for ; Mon, 21 Nov 2022 18:23:03 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 35138B818E7 for ; Tue, 22 Nov 2022 02:23:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F244C433D6; Tue, 22 Nov 2022 02:23:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669083781; bh=I7YL3bCCeJLisRqnPwuXs7B4Zp+B67ITumrFT7w6sqg=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=gi8ir3+/8iN5kIl4rz24XcNBNG2WqmFDqg06GajceHVzR0sDg9jmi9lhyYuA65fDE 4cfm5SAdTEY1q/1B1nJv4X/rUvLMWUAdR+TljW3ZjxWnYZpsFMfbf6Nwtgeqm7bGeO QnOhi9dvdfdtP4f8KNPVw+PCgmCJNY+HpgwoXngiQbBaUtUTttlV/UAi7vLUXKdCJr c9xdlDf8nzJw7ClZSDLsOQAjJ0dfLfPMfqU15gtYxKju97fDHx+AJA9YODDPayNRf1 VNtOEwJycXqWe8SQui6NMbfYeNAPvPXdcImVOCrrLxVLC/X0ONswdBp7g0TAvcA4UY x/WsplDl5gEOw== Date: Mon, 21 Nov 2022 18:22:59 -0800 (PST) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: Dominique Martinet cc: Stefano Stabellini , Christian Schoenebeck , v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] 9p/xen: do not memcpy header into req->rc In-Reply-To: <20221122001025.119121-1-asmadeus@codewreck.org> Message-ID: References: <20221122001025.119121-1-asmadeus@codewreck.org> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-7.1 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 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 On Tue, 22 Nov 2022, Dominique Martinet wrote: > while 'h' is packed and can be assumed to match the request payload, > req->rc is a struct p9_fcall which is not packed and that memcpy > could be wrong. > > Fix this by copying each fields individually instead. > > Reported-by: Christian Schoenebeck > Suggested-by: Stefano Stabellini > Link: https://lkml.kernel.org/r/alpine.DEB.2.22.394.2211211454540.1049131@ubuntu-linux-20-04-desktop > Signed-off-by: Dominique Martinet Reviewed-by: Stefano Stabellini > --- > Follow up from the previous xen patch's review. > > This isn't an immediate fix so I don't think this one should be rushed > in with the rest of the overflow fixes -- I'll let this sit a bit in > -next after reviews. > > net/9p/trans_xen.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c > index 4665215bc98b..e8e3f54a837e 100644 > --- a/net/9p/trans_xen.c > +++ b/net/9p/trans_xen.c > @@ -216,7 +216,9 @@ static void p9_xen_response(struct work_struct *work) > goto recv_error; > } > > - memcpy(&req->rc, &h, sizeof(h)); > + req->rc.size = h.size; > + req->rc.id = h.id; > + req->rc.tag = h.tag; > req->rc.offset = 0; > > masked_cons = xen_9pfs_mask(cons, XEN_9PFS_RING_SIZE(ring)); > -- > 2.35.1 >