From patchwork Thu Aug 21 21:24:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach Brown X-Patchwork-Id: 4759951 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2B1399F2E8 for ; Thu, 21 Aug 2014 21:24:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 595F22018B for ; Thu, 21 Aug 2014 21:24:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 39A522017A for ; Thu, 21 Aug 2014 21:24:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754822AbaHUVYd (ORCPT ); Thu, 21 Aug 2014 17:24:33 -0400 Received: from tetsuo.zabbo.net ([50.193.208.193]:60720 "EHLO tetsuo.zabbo.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754505AbaHUVYc (ORCPT ); Thu, 21 Aug 2014 17:24:32 -0400 Received: from lenny.home.zabbo.net (lenny.home.zabbo.net [192.168.242.10]) by tetsuo.zabbo.net (Postfix) with ESMTP id B8F407200521 for ; Thu, 21 Aug 2014 14:24:31 -0700 (PDT) From: Zach Brown To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: fix unaligned loads in receive Date: Thu, 21 Aug 2014 14:24:04 -0700 Message-Id: <1408656244-17654-1-git-send-email-zab@zabbo.net> X-Mailer: git-send-email 1.9.3 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_WS_SURBL autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A user reported corruption after receiving subvolumes. Turning up the logging during the receive showed that the commands and string attributes were being received correctly but the u64 attrbutes were sometimes corrupted by having variable number of low order bytes introduced. It turned out they were on a platform that corrupts unaligned userspace loads. Loading the u64s from the unaligned pointers into the received command stream with get_unaligned() fixed the problem. Reported-By: Klaus Holler Tested-By: Klaus Holler Signed-off-by: Zach Brown --- send-stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/send-stream.c b/send-stream.c index 88e18e2..4f8dd83 100644 --- a/send-stream.c +++ b/send-stream.c @@ -204,7 +204,7 @@ out: int __len; \ TLV_GET(s, attr, (void**)&__tmp, &__len); \ TLV_CHECK_LEN(sizeof(*__tmp), __len); \ - *v = le##bits##_to_cpu(*__tmp); \ + *v = get_unaligned_le##bits(__tmp); \ } while (0) #define TLV_GET_U8(s, attr, v) TLV_GET_INT(s, attr, 8, v)