From: David Laight <David.Laight@ACULAB.COM> To: 'Christoph Hellwig' <hch@lst.de>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Thomas Bogendoerfer <tsbogend@alpha.franken.de>, "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>, Helge Deller <deller@gmx.de>, Michael Ellerman <mpe@ellerman.id.au>, Heiko Carstens <hca@linux.ibm.com>, Vasily Gorbik <gor@linux.ibm.com>, Christian Borntraeger <borntraeger@de.ibm.com>, "David S. Miller" <davem@davemloft.net>, "x86@kernel.org" <x86@kernel.org>, Arnd Bergmann <arnd@arndb.de> Cc: "linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "linux-parisc@vger.kernel.org" <linux-parisc@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>, "sparclinux@vger.kernel.org" <sparclinux@vger.kernel.org>, "linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org> Subject: RE: [PATCH 5/5] compat: consolidate the compat_flock{,64} definition Date: Mon, 12 Apr 2021 09:37:21 +0000 [thread overview] Message-ID: <15be19af19174c7692dd795297884096@AcuMS.aculab.com> (raw) In-Reply-To: <20210412085545.2595431-6-hch@lst.de> From: Christoph Hellwig > Sent: 12 April 2021 09:56 > > Provide a single common definition for the compat_flock and > compat_flock64 structures using the same tricks as for the native > variants. An extra define is added for the packing required on x86. > ... > /* > - * IA32 uses 4 byte alignment for 64 bit quantities, > - * so we need to pack this structure. > + * IA32 uses 4 byte alignment for 64 bit quantities, so we need to pack the > + * compat flock64 structure. > */ > -struct compat_flock64 { > - short l_type; > - short l_whence; > - compat_loff_t l_start; > - compat_loff_t l_len; > - compat_pid_t l_pid; > -} __attribute__((packed)); > +#define __ARCH_NEED_COMPAT_FLOCK64_PACKED That shouldn't need to be packed at all. (Since the 32bit variant isn't packed.) compat_loff_t should itself have __attribute__((aligned(4))) probably inherited from compat_s64. So l_start will be at offset 4 without the __packed. I'm guessing that compat_pid_t is 16 bits? So the native 32bit version has an unnamed 2 byte structure pad. The 'packed' removes this pad from the compat structure. AFAICT (apart from mips) the __ARCH_COMPAT_FLOCK_PAD is just adding an explicit pad for the implicit pad the compiler would generate because compat_pid_t is 16 bits. If the padding need not be named for the 64bit system calls. (Where there is probably rather more padding all over the place.) then it doesn't need to be named for the compat variants. Even the mips extra padding could be removed. F_GETLK might be expected to do a read-write of them, so return EFAULT if not mapped. But nothing should be testing the EFAULT is returned! David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
WARNING: multiple messages have this Message-ID (diff)
From: David Laight <David.Laight@ACULAB.COM> To: 'Christoph Hellwig' <hch@lst.de>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Thomas Bogendoerfer <tsbogend@alpha.franken.de>, "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>, Helge Deller <deller@gmx.de>, Michael Ellerman <mpe@ellerman.id.au>, Heiko Carstens <hca@linux.ibm.com>, Vasily Gorbik <gor@linux.ibm.com>, Christian Borntraeger <borntraeger@de.ibm.com>, "David S. Miller" <davem@davemloft.net>, "x86@kernel.org" <x86@kernel.org>, Arnd Bergmann <arnd@arndb.de> Cc: "linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "linux-parisc@vger.kernel.org" <linux-parisc@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>, "sparclinux@vger.kernel.org" <sparclinux@vger.kernel.org>, "linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org> Subject: RE: [PATCH 5/5] compat: consolidate the compat_flock{,64} definition Date: Mon, 12 Apr 2021 09:37:21 +0000 [thread overview] Message-ID: <15be19af19174c7692dd795297884096@AcuMS.aculab.com> (raw) In-Reply-To: <20210412085545.2595431-6-hch@lst.de> From: Christoph Hellwig > Sent: 12 April 2021 09:56 > > Provide a single common definition for the compat_flock and > compat_flock64 structures using the same tricks as for the native > variants. An extra define is added for the packing required on x86. > ... > /* > - * IA32 uses 4 byte alignment for 64 bit quantities, > - * so we need to pack this structure. > + * IA32 uses 4 byte alignment for 64 bit quantities, so we need to pack the > + * compat flock64 structure. > */ > -struct compat_flock64 { > - short l_type; > - short l_whence; > - compat_loff_t l_start; > - compat_loff_t l_len; > - compat_pid_t l_pid; > -} __attribute__((packed)); > +#define __ARCH_NEED_COMPAT_FLOCK64_PACKED That shouldn't need to be packed at all. (Since the 32bit variant isn't packed.) compat_loff_t should itself have __attribute__((aligned(4))) probably inherited from compat_s64. So l_start will be at offset 4 without the __packed. I'm guessing that compat_pid_t is 16 bits? So the native 32bit version has an unnamed 2 byte structure pad. The 'packed' removes this pad from the compat structure. AFAICT (apart from mips) the __ARCH_COMPAT_FLOCK_PAD is just adding an explicit pad for the implicit pad the compiler would generate because compat_pid_t is 16 bits. If the padding need not be named for the 64bit system calls. (Where there is probably rather more padding all over the place.) then it doesn't need to be named for the compat variants. Even the mips extra padding could be removed. F_GETLK might be expected to do a read-write of them, so return EFAULT if not mapped. But nothing should be testing the EFAULT is returned! David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-04-12 9:45 UTC|newest] Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-12 8:55 consolidate the flock uapi definitions Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 8:55 ` [PATCH 1/5] uapi: remove the unused HAVE_ARCH_STRUCT_FLOCK64 define Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 9:55 ` Arnd Bergmann 2021-04-12 9:55 ` Arnd Bergmann 2021-04-12 9:55 ` Arnd Bergmann 2021-04-14 6:45 ` Stephen Rothwell 2021-04-14 6:45 ` Stephen Rothwell 2021-04-14 6:45 ` Stephen Rothwell 2021-04-12 8:55 ` [PATCH 2/5] uapi: simplify __ARCH_FLOCK{,64}_PAD a little Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 8:55 ` [PATCH 3/5] uapi: merge the 32-bit mips struct flock into the generic one Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 8:55 ` [PATCH 4/5] uapi: always define F_GETLK64/F_SETLK64/F_SETLKW64 in fcntl.h Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-13 15:43 ` Helge Deller 2021-04-13 15:46 ` Christoph Hellwig 2021-04-13 15:58 ` Helge Deller 2021-04-12 8:55 ` [PATCH 5/5] compat: consolidate the compat_flock{,64} definition Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 8:55 ` Christoph Hellwig 2021-04-12 9:37 ` David Laight [this message] 2021-04-12 9:37 ` David Laight 2021-04-12 9:37 ` David Laight 2021-04-12 10:53 ` David Laight 2021-04-12 10:53 ` David Laight 2021-04-12 10:53 ` David Laight 2021-04-12 11:26 ` Arnd Bergmann 2021-04-12 11:26 ` Arnd Bergmann 2021-04-12 11:26 ` Arnd Bergmann 2021-04-12 13:11 ` David Laight 2021-04-12 13:11 ` David Laight 2021-04-12 13:11 ` David Laight 2021-04-12 10:03 ` consolidate the flock uapi definitions Arnd Bergmann 2021-04-12 10:03 ` Arnd Bergmann 2021-04-12 10:03 ` Arnd Bergmann 2021-04-12 10:22 ` David Laight 2021-04-12 10:22 ` David Laight 2021-04-12 10:22 ` David Laight 2021-04-12 11:07 ` Arnd Bergmann 2021-04-12 11:07 ` Arnd Bergmann 2021-04-12 11:07 ` Arnd Bergmann 2021-04-15 12:20 ` Heiko Carstens 2021-04-15 12:20 ` Heiko Carstens 2021-04-15 12:20 ` Heiko Carstens 2022-01-11 8:35 consolidate the compat fcntl definitions Christoph Hellwig 2022-01-11 8:35 ` [PATCH 5/5] compat: consolidate the compat_flock{,64} definition Christoph Hellwig 2022-01-11 8:35 ` Christoph Hellwig 2022-01-11 8:35 ` Christoph Hellwig 2022-01-11 9:52 ` David Laight 2022-01-11 9:52 ` David Laight 2022-01-11 9:52 ` David Laight 2022-01-31 6:49 consolidate the compat fcntl definitions v2 Christoph Hellwig 2022-01-31 6:49 ` [PATCH 5/5] compat: consolidate the compat_flock{,64} definition Christoph Hellwig 2022-01-31 6:49 ` Christoph Hellwig 2022-01-31 6:49 ` Christoph Hellwig
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=15be19af19174c7692dd795297884096@AcuMS.aculab.com \ --to=david.laight@aculab.com \ --cc=James.Bottomley@HansenPartnership.com \ --cc=arnd@arndb.de \ --cc=borntraeger@de.ibm.com \ --cc=catalin.marinas@arm.com \ --cc=davem@davemloft.net \ --cc=deller@gmx.de \ --cc=gor@linux.ibm.com \ --cc=hca@linux.ibm.com \ --cc=hch@lst.de \ --cc=linux-arch@vger.kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mips@vger.kernel.org \ --cc=linux-parisc@vger.kernel.org \ --cc=linux-s390@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mpe@ellerman.id.au \ --cc=sparclinux@vger.kernel.org \ --cc=tsbogend@alpha.franken.de \ --cc=will@kernel.org \ --cc=x86@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.