From patchwork Wed Jun 20 15:32:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139357 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp933415lji; Wed, 20 Jun 2018 08:34:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLDMyHYc6hxPd6DfWmP8QrlsiHzd9hrGJ+bMhP1im++2ZEf41GNUNC76fUIBj89J4mLS6V/ X-Received: by 2002:a65:52cd:: with SMTP id z13-v6mr8199824pgp.357.1529508858198; Wed, 20 Jun 2018 08:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529508858; cv=none; d=google.com; s=arc-20160816; b=IsKw6+z5kxqvFUzrmeBUrXArWTFIcaNZpE2k2KaooX/VtxoN7WatIGFdh5BnWPyqLc 9Ni5ydwJKggdw9MYjwsgv5RKt3Bu8CHf/jO7G1NcWK1tRUzrg/3MGAJ2obaMEL1jfuMH Cb5qZXxz3WSa6YpY0Wrf1hwbuZmZPMccsKyaqO41d8B178ROU5cK0LWLCIp6a87TDvNN KjYLTogbPK0YQJU/HavjIXJ2cvMLxzaSm/hBe2rcZQKO4cUYZ/GHfetsY6fdEqxHxO0t f3m+c+dBXzPgwBZpNkHzf6lBIAcmNbL/OA0uf1ypbnqeVR/UEiG+1blnWpT8CNYATch/ HIUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NGbRtGhS2om3utDVWsvHCCeO4+r1sh53+w5XOZasTvg=; b=BDAUcxDwtuzv6OaBwpEYz76wSgwm+VHH9lFnjbd/rRmyMv+CDPUKBYBKld+aPA/9KL Z/DjT3lxz6z0EaBeq1ELz+/ClmkeclChicDQdUPZwvDH8By+pDYalNE7X9u1cyOGRuUq tkcgIwMS4vAGuSY9sU7xb0LLyC89+RZYolRlrB/v2FRf9GyPuXGK/VSxKNzxMM9O+b1i Lo9ovNsd+dK+hqyOT3LGvLPYxcpQ14yeWDKk/K/FTwDp5b9VPxsTdzs+4YCvfaf4aXjv BTkec15iSuk2XzMvue6RtS0hEV0Bad4lxNf3aXr4RNr6nYZ7a7GHT840CGLKkVAAUDEn mLIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si2551378pfl.87.2018.06.20.08.34.17; Wed, 20 Jun 2018 08:34:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754236AbeFTPeO (ORCPT + 30 others); Wed, 20 Jun 2018 11:34:14 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:51825 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753938AbeFTPeM (ORCPT ); Wed, 20 Jun 2018 11:34:12 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0LscDB-1gBm9K477x-012Gb0; Wed, 20 Jun 2018 17:33:24 +0200 From: Arnd Bergmann To: Theodore Ts'o , Andreas Dilger , Jan Kara Cc: y2038@lists.linaro.org, linux-ext4@vger.kernel.org, Arnd Bergmann , stable@vger.kernel.org, Tyson Nottingham , Riccardo Schirone , linux-kernel@vger.kernel.org Subject: [PATCH 1/6] ext4: sysfs: print ext4_super_block fields as little-endian Date: Wed, 20 Jun 2018 17:32:58 +0200 Message-Id: <20180620153322.54221-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:VkaJ/Z/IFyPmmUhGam8Uo0ZjIddzhfasuzSoRXgb5ck7jeePMGP cPe0Cer7D4lQe0ATfH2R+BlufNPhJYBHWT5rJ2ssZNspITM7/Mo3mGmQzzDwaF/FuVKGMDO 2wX5LkUhd4mBEzKGir+hm5M9XnnOaJVLEglf24SOtC8+L/DaRR9wok5sSDx4Vd6pJUIFpZ5 g5oR50P2YDIcMExtXAniw== X-UI-Out-Filterresults: notjunk:1; V01:K0:3djHRb4JBDA=:TaGLgNG07MzmDY/TEQwZ7D YkOiSeaGOyno27Vfc03eESxrIIzO1TrCLdHcAJK1KEBPhk644SYDG/kKlVkwl0ABOCi8fdKO8 R0V1+KA+vHrMhylHKECjwXO8FE+dfXS1XVzZDEgYZOJAV2+wG6m9McdYUNl1Yo8nLu0mIt46s UnQzBXZ2Oe8/e1xuMaGm2pbHT02iXoa3qVu/18VNrJf7nSGEt+3QzGd8c+Y/FnAUmOT/UYin/ iB7t9G2X9LNIypCmXBkf3VeZBOjaZtx9Uzg6uquVTir1p57jHauCKgTLY5DJkgtLer0Z9u12A +ODeP/zSGM09s8OlObMqKhhgWVrfA2DtU0F6vky8+1nF38siHpJd+umpmF63vRY1MiXyl82Vj 50Ks9stakws3h+cGCDwZeRKjpMkGJHSKWAfFigVVkDz8f+QE3kKBjHZSFkK0rNP75vheHEsJ0 d+nG1Hf0Ln/+U4A1FqBJCsixu3q5LCVWQRR39v359cRwxYX72JcAVnL6A8hDvuNU8P2kzGuot 3wsHT92WG57ACUdN/Og8dAnZDvV9OzT1yO4dm930SfEEEUg1k9j0anQzfwd2vWIBiNxplFWHi F6UQNz9ywICkKKrYtP6tzo6nMuTug6bC/R3t/6aCz4EQ7H1Qo9qJufzxohF8f8/ADbpgoNy+g VLshcMlPQ5X6J4HoKMPGbwkMGQf/f5becrT8UH809bq3DdvzXXuIB2tE4kRpyPOHSqKQ= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While working on extended rand for last_error/first_error timestamps, I noticed that the endianess is wrong, we access the little-endian fields in struct ext4_super_block as native-endian when we print them. This adds a special case in ext4_attr_show() and ext4_attr_store() to byteswap the superblock fields if needed. In older kernels, this code was part of super.c, it got moved to sysfs.c in linux-4.4. Cc: stable@vger.kernel.org Fixes: 52c198c6820f ("ext4: add sysfs entry showing whether the fs contains errors") Signed-off-by: Arnd Bergmann --- fs/ext4/sysfs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index f34da0bb8f17..b970a200f20c 100644 --- a/fs/ext4/sysfs.c +++ b/fs/ext4/sysfs.c @@ -274,8 +274,12 @@ static ssize_t ext4_attr_show(struct kobject *kobj, case attr_pointer_ui: if (!ptr) return 0; - return snprintf(buf, PAGE_SIZE, "%u\n", - *((unsigned int *) ptr)); + if (a->attr_ptr == ptr_ext4_super_block_offset) + return snprintf(buf, PAGE_SIZE, "%u\n", + le32_to_cpup(ptr)); + else + return snprintf(buf, PAGE_SIZE, "%u\n", + *((unsigned int *) ptr)); case attr_pointer_atomic: if (!ptr) return 0; @@ -308,7 +312,10 @@ static ssize_t ext4_attr_store(struct kobject *kobj, ret = kstrtoul(skip_spaces(buf), 0, &t); if (ret) return ret; - *((unsigned int *) ptr) = t; + if (a->attr_ptr == ptr_ext4_super_block_offset) + *((__le32 *) ptr) = cpu_to_le32(t); + else + *((unsigned int *) ptr) = t; return len; case attr_inode_readahead: return inode_readahead_blks_store(sbi, buf, len);