From patchwork Tue Nov 22 00:10:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 24057 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1909050wrr; Mon, 21 Nov 2022 16:13:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ntQ7bzr4YUtHqThMoPkmMYLBWdHphmSKbjWTEL5L94F4wvnROVDpv8N8TdWqNWZOnGNtf X-Received: by 2002:a62:15d3:0:b0:562:3add:37e1 with SMTP id 202-20020a6215d3000000b005623add37e1mr1794989pfv.80.1669075988739; Mon, 21 Nov 2022 16:13:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669075988; cv=none; d=google.com; s=arc-20160816; b=xaZ4wIsG4NbaSuPrQP5vCW9FB9LfQCcOJVMEB3opV8I9GLvgO1WZjfZaBpmjeFgKbM /LRkvXVoeLZ17xsWrt46xgFphiXXLR3jNP0kUoIopKTsb0wT7PQP7xownyq2TaQWbtYe XLoL9P1CSCJCjXbzhcCPOPST3stwt4RIgNhPhXHZYAxcIdFIJ2vV9UPMNonCrCr76TPd PU4lAXgVCFiCzHeFxlIvNCAvRMG2UomYldsvkSC+rtoWPIXY4i8dLPiMzrj6+KAxavAN uWOLVB7BUPy5jxhrTf9bvgKNhGxuXosZ3vAtdzQ+uLGtDqZdL/0qoxcIBkL2l93lJTNF /tAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=QzhrOUAQP1dDRAYbRqs4t/e9Y2uqBB20wcovyN9kH70=; b=QYX/pWEUi/74hRBcA1+RxrpyVhazuK9CLDu6C/DHLcs1L9cgkyjGv48NCc3reY1tAD lTNCA1hiFFkhJaYXDpp0iwbRpcwYmU42y2XCdwttBeudlLDkmytkS8H0WQPl7BENl29J 5k3M2g3CdOBZu47D/xwOFXhr7n53t7H/pxG7JHWju57lKgeT4l4iHccMieT1+nJuw98B /j8cEFUvRIta3bHJpP82MSp9a+onTyb1sdb5AKxRafFw+3s28/1jS9A1OrDv4f6cvjb0 dEumBYQ+YCZPZuXqKQVgcVfjaLQE1eYdQ6uhyVNK2ai7/n7zd4ls0Qqr3WFGVlHBWm4n HeMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=zHlCKufG; dkim=pass header.i=@codewreck.org header.s=2 header.b=zHlCKufG; 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=codewreck.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a656944000000b0045ceafe40cesi11233483pgq.395.2022.11.21.16.12.55; Mon, 21 Nov 2022 16:13:08 -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=@codewreck.org header.s=2 header.b=zHlCKufG; dkim=pass header.i=@codewreck.org header.s=2 header.b=zHlCKufG; 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=codewreck.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232031AbiKVAK7 (ORCPT + 99 others); Mon, 21 Nov 2022 19:10:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbiKVAKu (ORCPT ); Mon, 21 Nov 2022 19:10:50 -0500 Received: from nautica.notk.org (ipv6.notk.org [IPv6:2001:41d0:1:7a93::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D0E92B49 for ; Mon, 21 Nov 2022 16:10:47 -0800 (PST) Received: by nautica.notk.org (Postfix, from userid 108) id EB1BEC01B; Tue, 22 Nov 2022 01:10:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1669075851; bh=QzhrOUAQP1dDRAYbRqs4t/e9Y2uqBB20wcovyN9kH70=; h=From:To:Cc:Subject:Date:From; b=zHlCKufGNvI4Xksi9kl1ZNwMiMPmJsegF7rbq9KZAYBSn3hpeHGnZKQ9BIRnoyXFM 9lOO9XcrHbJlPZzH7/5vyHrikq2bObB7Iaa/BZvlxNpy/vKIzobjlv0S+aCvZIt9gU y5jhnOVbYTJfSAzlbz14q99/YGhBs+v0gA/HloLNr1IW/lAg1zZVHzmFs9mubM+tEO QPKfhcUgLip0NL/WZevnmlGlgtnbc74AKp74GlJ8X8RcTSkZEdKZpP52IjVcYWJyAy /HNJfOaxycYPHRybzt+OWUofWEMbTpybtExNDSQX/K+9z8+OgsFLl3jXlwhS1ngRAz gC07QcDRfpRdA== X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from odin.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id AD670C009; Tue, 22 Nov 2022 01:10:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1669075851; bh=QzhrOUAQP1dDRAYbRqs4t/e9Y2uqBB20wcovyN9kH70=; h=From:To:Cc:Subject:Date:From; b=zHlCKufGNvI4Xksi9kl1ZNwMiMPmJsegF7rbq9KZAYBSn3hpeHGnZKQ9BIRnoyXFM 9lOO9XcrHbJlPZzH7/5vyHrikq2bObB7Iaa/BZvlxNpy/vKIzobjlv0S+aCvZIt9gU y5jhnOVbYTJfSAzlbz14q99/YGhBs+v0gA/HloLNr1IW/lAg1zZVHzmFs9mubM+tEO QPKfhcUgLip0NL/WZevnmlGlgtnbc74AKp74GlJ8X8RcTSkZEdKZpP52IjVcYWJyAy /HNJfOaxycYPHRybzt+OWUofWEMbTpybtExNDSQX/K+9z8+OgsFLl3jXlwhS1ngRAz gC07QcDRfpRdA== Received: from localhost (odin.codewreck.org [local]) by odin.codewreck.org (OpenSMTPD) with ESMTPA id 9b56555b; Tue, 22 Nov 2022 00:10:39 +0000 (UTC) From: Dominique Martinet To: Stefano Stabellini , Christian Schoenebeck Cc: v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Dominique Martinet Subject: [PATCH] 9p/xen: do not memcpy header into req->rc Date: Tue, 22 Nov 2022 09:10:25 +0900 Message-Id: <20221122001025.119121-1-asmadeus@codewreck.org> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750153024230748170?= X-GMAIL-MSGID: =?utf-8?q?1750153024230748170?= 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 Reviewed-by: Christian Schoenebeck --- 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));