Commit 98818189ea9a8e7abd4d8699289da6b14d8190ee
Committed by
Riku Voipio
1 parent
784ccfdb
64-bit clean socketcall syscall
makes socketcall 64-bit clean so it works on 64-bit big-endian systems Signed-off-by: Ulrich Hecht <uli@suse.de> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Showing
1 changed file
with
65 additions
and
65 deletions
linux-user/syscall.c
... | ... | @@ -1777,11 +1777,11 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1777 | 1777 | switch(num) { |
1778 | 1778 | case SOCKOP_socket: |
1779 | 1779 | { |
1780 | - int domain, type, protocol; | |
1780 | + abi_ulong domain, type, protocol; | |
1781 | 1781 | |
1782 | - if (get_user_s32(domain, vptr) | |
1783 | - || get_user_s32(type, vptr + n) | |
1784 | - || get_user_s32(protocol, vptr + 2 * n)) | |
1782 | + if (get_user_ual(domain, vptr) | |
1783 | + || get_user_ual(type, vptr + n) | |
1784 | + || get_user_ual(protocol, vptr + 2 * n)) | |
1785 | 1785 | return -TARGET_EFAULT; |
1786 | 1786 | |
1787 | 1787 | ret = do_socket(domain, type, protocol); |
... | ... | @@ -1789,13 +1789,13 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1789 | 1789 | break; |
1790 | 1790 | case SOCKOP_bind: |
1791 | 1791 | { |
1792 | - int sockfd; | |
1792 | + abi_ulong sockfd; | |
1793 | 1793 | abi_ulong target_addr; |
1794 | 1794 | socklen_t addrlen; |
1795 | 1795 | |
1796 | - if (get_user_s32(sockfd, vptr) | |
1796 | + if (get_user_ual(sockfd, vptr) | |
1797 | 1797 | || get_user_ual(target_addr, vptr + n) |
1798 | - || get_user_u32(addrlen, vptr + 2 * n)) | |
1798 | + || get_user_ual(addrlen, vptr + 2 * n)) | |
1799 | 1799 | return -TARGET_EFAULT; |
1800 | 1800 | |
1801 | 1801 | ret = do_bind(sockfd, target_addr, addrlen); |
... | ... | @@ -1803,13 +1803,13 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1803 | 1803 | break; |
1804 | 1804 | case SOCKOP_connect: |
1805 | 1805 | { |
1806 | - int sockfd; | |
1806 | + abi_ulong sockfd; | |
1807 | 1807 | abi_ulong target_addr; |
1808 | 1808 | socklen_t addrlen; |
1809 | 1809 | |
1810 | - if (get_user_s32(sockfd, vptr) | |
1810 | + if (get_user_ual(sockfd, vptr) | |
1811 | 1811 | || get_user_ual(target_addr, vptr + n) |
1812 | - || get_user_u32(addrlen, vptr + 2 * n)) | |
1812 | + || get_user_ual(addrlen, vptr + 2 * n)) | |
1813 | 1813 | return -TARGET_EFAULT; |
1814 | 1814 | |
1815 | 1815 | ret = do_connect(sockfd, target_addr, addrlen); |
... | ... | @@ -1817,10 +1817,10 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1817 | 1817 | break; |
1818 | 1818 | case SOCKOP_listen: |
1819 | 1819 | { |
1820 | - int sockfd, backlog; | |
1820 | + abi_ulong sockfd, backlog; | |
1821 | 1821 | |
1822 | - if (get_user_s32(sockfd, vptr) | |
1823 | - || get_user_s32(backlog, vptr + n)) | |
1822 | + if (get_user_ual(sockfd, vptr) | |
1823 | + || get_user_ual(backlog, vptr + n)) | |
1824 | 1824 | return -TARGET_EFAULT; |
1825 | 1825 | |
1826 | 1826 | ret = get_errno(listen(sockfd, backlog)); |
... | ... | @@ -1828,12 +1828,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1828 | 1828 | break; |
1829 | 1829 | case SOCKOP_accept: |
1830 | 1830 | { |
1831 | - int sockfd; | |
1831 | + abi_ulong sockfd; | |
1832 | 1832 | abi_ulong target_addr, target_addrlen; |
1833 | 1833 | |
1834 | - if (get_user_s32(sockfd, vptr) | |
1834 | + if (get_user_ual(sockfd, vptr) | |
1835 | 1835 | || get_user_ual(target_addr, vptr + n) |
1836 | - || get_user_u32(target_addrlen, vptr + 2 * n)) | |
1836 | + || get_user_ual(target_addrlen, vptr + 2 * n)) | |
1837 | 1837 | return -TARGET_EFAULT; |
1838 | 1838 | |
1839 | 1839 | ret = do_accept(sockfd, target_addr, target_addrlen); |
... | ... | @@ -1841,12 +1841,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1841 | 1841 | break; |
1842 | 1842 | case SOCKOP_getsockname: |
1843 | 1843 | { |
1844 | - int sockfd; | |
1844 | + abi_ulong sockfd; | |
1845 | 1845 | abi_ulong target_addr, target_addrlen; |
1846 | 1846 | |
1847 | - if (get_user_s32(sockfd, vptr) | |
1847 | + if (get_user_ual(sockfd, vptr) | |
1848 | 1848 | || get_user_ual(target_addr, vptr + n) |
1849 | - || get_user_u32(target_addrlen, vptr + 2 * n)) | |
1849 | + || get_user_ual(target_addrlen, vptr + 2 * n)) | |
1850 | 1850 | return -TARGET_EFAULT; |
1851 | 1851 | |
1852 | 1852 | ret = do_getsockname(sockfd, target_addr, target_addrlen); |
... | ... | @@ -1854,12 +1854,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1854 | 1854 | break; |
1855 | 1855 | case SOCKOP_getpeername: |
1856 | 1856 | { |
1857 | - int sockfd; | |
1857 | + abi_ulong sockfd; | |
1858 | 1858 | abi_ulong target_addr, target_addrlen; |
1859 | 1859 | |
1860 | - if (get_user_s32(sockfd, vptr) | |
1860 | + if (get_user_ual(sockfd, vptr) | |
1861 | 1861 | || get_user_ual(target_addr, vptr + n) |
1862 | - || get_user_u32(target_addrlen, vptr + 2 * n)) | |
1862 | + || get_user_ual(target_addrlen, vptr + 2 * n)) | |
1863 | 1863 | return -TARGET_EFAULT; |
1864 | 1864 | |
1865 | 1865 | ret = do_getpeername(sockfd, target_addr, target_addrlen); |
... | ... | @@ -1867,12 +1867,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1867 | 1867 | break; |
1868 | 1868 | case SOCKOP_socketpair: |
1869 | 1869 | { |
1870 | - int domain, type, protocol; | |
1870 | + abi_ulong domain, type, protocol; | |
1871 | 1871 | abi_ulong tab; |
1872 | 1872 | |
1873 | - if (get_user_s32(domain, vptr) | |
1874 | - || get_user_s32(type, vptr + n) | |
1875 | - || get_user_s32(protocol, vptr + 2 * n) | |
1873 | + if (get_user_ual(domain, vptr) | |
1874 | + || get_user_ual(type, vptr + n) | |
1875 | + || get_user_ual(protocol, vptr + 2 * n) | |
1876 | 1876 | || get_user_ual(tab, vptr + 3 * n)) |
1877 | 1877 | return -TARGET_EFAULT; |
1878 | 1878 | |
... | ... | @@ -1881,15 +1881,15 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1881 | 1881 | break; |
1882 | 1882 | case SOCKOP_send: |
1883 | 1883 | { |
1884 | - int sockfd; | |
1884 | + abi_ulong sockfd; | |
1885 | 1885 | abi_ulong msg; |
1886 | 1886 | size_t len; |
1887 | - int flags; | |
1887 | + abi_ulong flags; | |
1888 | 1888 | |
1889 | - if (get_user_s32(sockfd, vptr) | |
1889 | + if (get_user_ual(sockfd, vptr) | |
1890 | 1890 | || get_user_ual(msg, vptr + n) |
1891 | 1891 | || get_user_ual(len, vptr + 2 * n) |
1892 | - || get_user_s32(flags, vptr + 3 * n)) | |
1892 | + || get_user_ual(flags, vptr + 3 * n)) | |
1893 | 1893 | return -TARGET_EFAULT; |
1894 | 1894 | |
1895 | 1895 | ret = do_sendto(sockfd, msg, len, flags, 0, 0); |
... | ... | @@ -1897,15 +1897,15 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1897 | 1897 | break; |
1898 | 1898 | case SOCKOP_recv: |
1899 | 1899 | { |
1900 | - int sockfd; | |
1900 | + abi_ulong sockfd; | |
1901 | 1901 | abi_ulong msg; |
1902 | 1902 | size_t len; |
1903 | - int flags; | |
1903 | + abi_ulong flags; | |
1904 | 1904 | |
1905 | - if (get_user_s32(sockfd, vptr) | |
1905 | + if (get_user_ual(sockfd, vptr) | |
1906 | 1906 | || get_user_ual(msg, vptr + n) |
1907 | 1907 | || get_user_ual(len, vptr + 2 * n) |
1908 | - || get_user_s32(flags, vptr + 3 * n)) | |
1908 | + || get_user_ual(flags, vptr + 3 * n)) | |
1909 | 1909 | return -TARGET_EFAULT; |
1910 | 1910 | |
1911 | 1911 | ret = do_recvfrom(sockfd, msg, len, flags, 0, 0); |
... | ... | @@ -1913,19 +1913,19 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1913 | 1913 | break; |
1914 | 1914 | case SOCKOP_sendto: |
1915 | 1915 | { |
1916 | - int sockfd; | |
1916 | + abi_ulong sockfd; | |
1917 | 1917 | abi_ulong msg; |
1918 | 1918 | size_t len; |
1919 | - int flags; | |
1919 | + abi_ulong flags; | |
1920 | 1920 | abi_ulong addr; |
1921 | 1921 | socklen_t addrlen; |
1922 | 1922 | |
1923 | - if (get_user_s32(sockfd, vptr) | |
1923 | + if (get_user_ual(sockfd, vptr) | |
1924 | 1924 | || get_user_ual(msg, vptr + n) |
1925 | 1925 | || get_user_ual(len, vptr + 2 * n) |
1926 | - || get_user_s32(flags, vptr + 3 * n) | |
1926 | + || get_user_ual(flags, vptr + 3 * n) | |
1927 | 1927 | || get_user_ual(addr, vptr + 4 * n) |
1928 | - || get_user_u32(addrlen, vptr + 5 * n)) | |
1928 | + || get_user_ual(addrlen, vptr + 5 * n)) | |
1929 | 1929 | return -TARGET_EFAULT; |
1930 | 1930 | |
1931 | 1931 | ret = do_sendto(sockfd, msg, len, flags, addr, addrlen); |
... | ... | @@ -1933,19 +1933,19 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1933 | 1933 | break; |
1934 | 1934 | case SOCKOP_recvfrom: |
1935 | 1935 | { |
1936 | - int sockfd; | |
1936 | + abi_ulong sockfd; | |
1937 | 1937 | abi_ulong msg; |
1938 | 1938 | size_t len; |
1939 | - int flags; | |
1939 | + abi_ulong flags; | |
1940 | 1940 | abi_ulong addr; |
1941 | 1941 | socklen_t addrlen; |
1942 | 1942 | |
1943 | - if (get_user_s32(sockfd, vptr) | |
1943 | + if (get_user_ual(sockfd, vptr) | |
1944 | 1944 | || get_user_ual(msg, vptr + n) |
1945 | 1945 | || get_user_ual(len, vptr + 2 * n) |
1946 | - || get_user_s32(flags, vptr + 3 * n) | |
1946 | + || get_user_ual(flags, vptr + 3 * n) | |
1947 | 1947 | || get_user_ual(addr, vptr + 4 * n) |
1948 | - || get_user_u32(addrlen, vptr + 5 * n)) | |
1948 | + || get_user_ual(addrlen, vptr + 5 * n)) | |
1949 | 1949 | return -TARGET_EFAULT; |
1950 | 1950 | |
1951 | 1951 | ret = do_recvfrom(sockfd, msg, len, flags, addr, addrlen); |
... | ... | @@ -1953,10 +1953,10 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1953 | 1953 | break; |
1954 | 1954 | case SOCKOP_shutdown: |
1955 | 1955 | { |
1956 | - int sockfd, how; | |
1956 | + abi_ulong sockfd, how; | |
1957 | 1957 | |
1958 | - if (get_user_s32(sockfd, vptr) | |
1959 | - || get_user_s32(how, vptr + n)) | |
1958 | + if (get_user_ual(sockfd, vptr) | |
1959 | + || get_user_ual(how, vptr + n)) | |
1960 | 1960 | return -TARGET_EFAULT; |
1961 | 1961 | |
1962 | 1962 | ret = get_errno(shutdown(sockfd, how)); |
... | ... | @@ -1965,13 +1965,13 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1965 | 1965 | case SOCKOP_sendmsg: |
1966 | 1966 | case SOCKOP_recvmsg: |
1967 | 1967 | { |
1968 | - int fd; | |
1968 | + abi_ulong fd; | |
1969 | 1969 | abi_ulong target_msg; |
1970 | - int flags; | |
1970 | + abi_ulong flags; | |
1971 | 1971 | |
1972 | - if (get_user_s32(fd, vptr) | |
1972 | + if (get_user_ual(fd, vptr) | |
1973 | 1973 | || get_user_ual(target_msg, vptr + n) |
1974 | - || get_user_s32(flags, vptr + 2 * n)) | |
1974 | + || get_user_ual(flags, vptr + 2 * n)) | |
1975 | 1975 | return -TARGET_EFAULT; |
1976 | 1976 | |
1977 | 1977 | ret = do_sendrecvmsg(fd, target_msg, flags, |
... | ... | @@ -1980,17 +1980,17 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1980 | 1980 | break; |
1981 | 1981 | case SOCKOP_setsockopt: |
1982 | 1982 | { |
1983 | - int sockfd; | |
1984 | - int level; | |
1985 | - int optname; | |
1983 | + abi_ulong sockfd; | |
1984 | + abi_ulong level; | |
1985 | + abi_ulong optname; | |
1986 | 1986 | abi_ulong optval; |
1987 | 1987 | socklen_t optlen; |
1988 | 1988 | |
1989 | - if (get_user_s32(sockfd, vptr) | |
1990 | - || get_user_s32(level, vptr + n) | |
1991 | - || get_user_s32(optname, vptr + 2 * n) | |
1989 | + if (get_user_ual(sockfd, vptr) | |
1990 | + || get_user_ual(level, vptr + n) | |
1991 | + || get_user_ual(optname, vptr + 2 * n) | |
1992 | 1992 | || get_user_ual(optval, vptr + 3 * n) |
1993 | - || get_user_u32(optlen, vptr + 4 * n)) | |
1993 | + || get_user_ual(optlen, vptr + 4 * n)) | |
1994 | 1994 | return -TARGET_EFAULT; |
1995 | 1995 | |
1996 | 1996 | ret = do_setsockopt(sockfd, level, optname, optval, optlen); |
... | ... | @@ -1998,17 +1998,17 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
1998 | 1998 | break; |
1999 | 1999 | case SOCKOP_getsockopt: |
2000 | 2000 | { |
2001 | - int sockfd; | |
2002 | - int level; | |
2003 | - int optname; | |
2001 | + abi_ulong sockfd; | |
2002 | + abi_ulong level; | |
2003 | + abi_ulong optname; | |
2004 | 2004 | abi_ulong optval; |
2005 | 2005 | socklen_t optlen; |
2006 | 2006 | |
2007 | - if (get_user_s32(sockfd, vptr) | |
2008 | - || get_user_s32(level, vptr + n) | |
2009 | - || get_user_s32(optname, vptr + 2 * n) | |
2007 | + if (get_user_ual(sockfd, vptr) | |
2008 | + || get_user_ual(level, vptr + n) | |
2009 | + || get_user_ual(optname, vptr + 2 * n) | |
2010 | 2010 | || get_user_ual(optval, vptr + 3 * n) |
2011 | - || get_user_u32(optlen, vptr + 4 * n)) | |
2011 | + || get_user_ual(optlen, vptr + 4 * n)) | |
2012 | 2012 | return -TARGET_EFAULT; |
2013 | 2013 | |
2014 | 2014 | ret = do_getsockopt(sockfd, level, optname, optval, optlen); | ... | ... |