Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

binfmt_flat: add endianess annotations

Most binfmt_flat on-disk fields are big endian. Use the proper __be32
type where applicable.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>

authored by

Christoph Hellwig and committed by
Greg Ungerer
3b977718 34b4664a

+16 -10
+16 -10
fs/binfmt_flat.c
··· 421 421 unsigned long textpos, datapos, realdatastart; 422 422 u32 text_len, data_len, bss_len, stack_len, full_data, flags; 423 423 unsigned long len, memp, memp_size, extra, rlim; 424 - u32 __user *reloc, *rp; 424 + __be32 __user *reloc; 425 + u32 __user *rp; 425 426 struct inode *inode; 426 427 int i, rev, relocs; 427 428 loff_t fpos; ··· 595 594 goto err; 596 595 } 597 596 598 - reloc = (u32 __user *) 597 + reloc = (__be32 __user *) 599 598 (datapos + (ntohl(hdr->reloc_start) - text_len)); 600 599 memp = realdatastart; 601 600 memp_size = len; ··· 620 619 MAX_SHARED_LIBS * sizeof(u32), 621 620 FLAT_DATA_ALIGN); 622 621 623 - reloc = (u32 __user *) 622 + reloc = (__be32 __user *) 624 623 (datapos + (ntohl(hdr->reloc_start) - text_len)); 625 624 memp = textpos; 626 625 memp_size = len; ··· 786 785 u32 __maybe_unused persistent = 0; 787 786 for (i = 0; i < relocs; i++) { 788 787 u32 addr, relval; 788 + __be32 tmp; 789 789 790 790 /* 791 791 * Get the address of the pointer to be 792 792 * relocated (of course, the address has to be 793 793 * relocated first). 794 794 */ 795 - if (get_user(relval, reloc + i)) 795 + if (get_user(tmp, reloc + i)) 796 796 return -EFAULT; 797 - relval = ntohl(relval); 797 + relval = ntohl(tmp); 798 798 addr = flat_get_relocate_addr(relval); 799 799 rp = (u32 __user *)calc_reloc(addr, libinfo, id, 1); 800 800 if (rp == (u32 __user *)RELOC_FAILED) { ··· 814 812 * Do the relocation. PIC relocs in the data section are 815 813 * already in target order 816 814 */ 817 - if ((flags & FLAT_FLAG_GOTPIC) == 0) 818 - addr = ntohl(addr); 815 + if ((flags & FLAT_FLAG_GOTPIC) == 0) { 816 + /* 817 + * Meh, the same value can have a different 818 + * byte order based on a flag.. 819 + */ 820 + addr = ntohl((__force __be32)addr); 821 + } 819 822 addr = calc_reloc(addr, libinfo, id, 0); 820 823 if (addr == RELOC_FAILED) { 821 824 ret = -ENOEXEC; ··· 835 828 } 836 829 } else { 837 830 for (i = 0; i < relocs; i++) { 838 - u32 relval; 831 + __be32 relval; 839 832 if (get_user(relval, reloc + i)) 840 833 return -EFAULT; 841 - relval = ntohl(relval); 842 - old_reloc(relval); 834 + old_reloc(ntohl(relval)); 843 835 } 844 836 } 845 837