lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210330071958.3788214-3-slyfox@gentoo.org>
Date:   Tue, 30 Mar 2021 08:19:58 +0100
From:   Sergei Trofimovich <slyfox@...too.org>
To:     "Martin K. Petersen" <martin.petersen@...cle.com>,
        Arnd Bergmann <arnd@...nel.org>,
        John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>,
        Don Brace <don.brace@...rochip.com>,
        linux-ia64@...r.kernel.org, storagedev@...rochip.com,
        linux-scsi <linux-scsi@...r.kernel.org>, jszczype@...hat.com,
        Scott Benesh <scott.benesh@...rochip.com>,
        Scott Teel <scott.teel@...rochip.com>, thenzl@...hat.com
Cc:     linux-kernel@...r.kernel.org,
        Sergei Trofimovich <slyfox@...too.org>
Subject: [PATCH v2 3/3] hpsa: add an assert to prevent from __packed reintroduction

CC: linux-ia64@...r.kernel.org
CC: storagedev@...rochip.com
CC: linux-scsi@...r.kernel.org
CC: Joe Szczypek <jszczype@...hat.com>
CC: Scott Benesh <scott.benesh@...rochip.com>
CC: Scott Teel <scott.teel@...rochip.com>
CC: Tomas Henzl <thenzl@...hat.com>
CC: "Martin K. Petersen" <martin.petersen@...cle.com>
CC: Don Brace <don.brace@...rochip.com>
Reported-by: John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>
Suggested-by: Don Brace <don.brace@...rochip.com>
Fixes: f749d8b7a "scsi: hpsa: Correct dev cmds outstanding for retried cmds"
Signed-off-by: Sergei Trofimovich <slyfox@...too.org>
---
 drivers/scsi/hpsa_cmd.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index 885b1f1fb20a..ba6a3aa8d954 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -22,6 +22,9 @@
 
 #include <linux/compiler.h>
 
+#include <linux/build_bug.h> /* static_assert */
+#include <linux/stddef.h> /* offsetof */
+
 /* general boundary defintions */
 #define SENSEINFOBYTES          32 /* may vary between hbas */
 #define SG_ENTRIES_IN_CMD	32 /* Max SG entries excluding chain blocks */
@@ -454,6 +457,15 @@ struct CommandList {
 	atomic_t refcount; /* Must be last to avoid memset in hpsa_cmd_init() */
 } __aligned(COMMANDLIST_ALIGNMENT);
 
+/*
+ * Make sure our embedded atomic variable is aligned. Otherwise we break atomic
+ * operations on architectures that don't support unaligned atomics like IA64.
+ *
+ * The assert guards against reintroductin against unwanted __packed to
+ * the struct CommandList.
+ */
+static_assert(offsetof(struct CommandList, refcount) % __alignof__(atomic_t) == 0);
+
 /* Max S/G elements in I/O accelerator command */
 #define IOACCEL1_MAXSGENTRIES           24
 #define IOACCEL2_MAXSGENTRIES		28
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ