Commit 2152390dca9975b1aaaa6f0518ebdd359477905b
Merge commit 'linux-user/linux-user-for-upstream' into tmp-staging
Showing
4 changed files
with
116 additions
and
92 deletions
configure
| ... | ... | @@ -1249,8 +1249,7 @@ fi |
| 1249 | 1249 | # have syscall stubs for these implemented. |
| 1250 | 1250 | # |
| 1251 | 1251 | atfile=no |
| 1252 | -if [ "$linux_user" = "yes" ] ; then | |
| 1253 | - cat > $TMPC << EOF | |
| 1252 | +cat > $TMPC << EOF | |
| 1254 | 1253 | #define _ATFILE_SOURCE |
| 1255 | 1254 | #include <sys/types.h> |
| 1256 | 1255 | #include <fcntl.h> |
| ... | ... | @@ -1263,9 +1262,8 @@ main(void) |
| 1263 | 1262 | return (unlinkat(AT_FDCWD, "nonexistent_file", 0)); |
| 1264 | 1263 | } |
| 1265 | 1264 | EOF |
| 1266 | - if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then | |
| 1267 | - atfile=yes | |
| 1268 | - fi | |
| 1265 | +if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then | |
| 1266 | + atfile=yes | |
| 1269 | 1267 | fi |
| 1270 | 1268 | |
| 1271 | 1269 | # Check for inotify functions when we are building linux-user |
| ... | ... | @@ -1274,8 +1272,7 @@ fi |
| 1274 | 1272 | # don't provide them even if kernel supports them. |
| 1275 | 1273 | # |
| 1276 | 1274 | inotify=no |
| 1277 | -if [ "$linux_user" = "yes" ] ; then | |
| 1278 | - cat > $TMPC << EOF | |
| 1275 | +cat > $TMPC << EOF | |
| 1279 | 1276 | #include <sys/inotify.h> |
| 1280 | 1277 | |
| 1281 | 1278 | int |
| ... | ... | @@ -1285,9 +1282,8 @@ main(void) |
| 1285 | 1282 | return inotify_init(); |
| 1286 | 1283 | } |
| 1287 | 1284 | EOF |
| 1288 | - if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then | |
| 1289 | - inotify=yes | |
| 1290 | - fi | |
| 1285 | +if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then | |
| 1286 | + inotify=yes | |
| 1291 | 1287 | fi |
| 1292 | 1288 | |
| 1293 | 1289 | # check if utimensat and futimens are supported | ... | ... |
linux-user/main.c
| ... | ... | @@ -2432,6 +2432,7 @@ int main(int argc, char **argv, char **envp) |
| 2432 | 2432 | envlist_t *envlist = NULL; |
| 2433 | 2433 | const char *argv0 = NULL; |
| 2434 | 2434 | int i; |
| 2435 | + int ret; | |
| 2435 | 2436 | |
| 2436 | 2437 | if (argc <= 1) |
| 2437 | 2438 | usage(); |
| ... | ... | @@ -2636,9 +2637,10 @@ int main(int argc, char **argv, char **envp) |
| 2636 | 2637 | env->opaque = ts; |
| 2637 | 2638 | task_settid(ts); |
| 2638 | 2639 | |
| 2639 | - if (loader_exec(filename, target_argv, target_environ, regs, | |
| 2640 | - info, &bprm) != 0) { | |
| 2641 | - printf("Error loading %s\n", filename); | |
| 2640 | + ret = loader_exec(filename, target_argv, target_environ, regs, | |
| 2641 | + info, &bprm); | |
| 2642 | + if (ret != 0) { | |
| 2643 | + printf("Error %d while loading %s\n", ret, filename); | |
| 2642 | 2644 | _exit(1); |
| 2643 | 2645 | } |
| 2644 | 2646 | ... | ... |
linux-user/qemu.h
| ... | ... | @@ -140,7 +140,7 @@ extern const char *qemu_uname_release; |
| 140 | 140 | * and envelope for the new program. 32 should suffice, this gives |
| 141 | 141 | * a maximum env+arg of 128kB w/4KB pages! |
| 142 | 142 | */ |
| 143 | -#define MAX_ARG_PAGES 32 | |
| 143 | +#define MAX_ARG_PAGES 33 | |
| 144 | 144 | |
| 145 | 145 | /* |
| 146 | 146 | * This structure is used to hold the arguments that are | ... | ... |
linux-user/syscall.c
| ... | ... | @@ -953,7 +953,7 @@ static abi_long do_pipe2(int host_pipe[], int flags) |
| 953 | 953 | #endif |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | -static abi_long do_pipe(void *cpu_env, int pipedes, int flags) | |
| 956 | +static abi_long do_pipe(void *cpu_env, abi_ulong pipedes, int flags) | |
| 957 | 957 | { |
| 958 | 958 | int host_pipe[2]; |
| 959 | 959 | abi_long ret; |
| ... | ... | @@ -1498,13 +1498,17 @@ static abi_long do_bind(int sockfd, abi_ulong target_addr, |
| 1498 | 1498 | socklen_t addrlen) |
| 1499 | 1499 | { |
| 1500 | 1500 | void *addr; |
| 1501 | + abi_long ret; | |
| 1501 | 1502 | |
| 1502 | 1503 | if (addrlen < 0) |
| 1503 | 1504 | return -TARGET_EINVAL; |
| 1504 | 1505 | |
| 1505 | 1506 | addr = alloca(addrlen+1); |
| 1506 | 1507 | |
| 1507 | - target_to_host_sockaddr(addr, target_addr, addrlen); | |
| 1508 | + ret = target_to_host_sockaddr(addr, target_addr, addrlen); | |
| 1509 | + if (ret) | |
| 1510 | + return ret; | |
| 1511 | + | |
| 1508 | 1512 | return get_errno(bind(sockfd, addr, addrlen)); |
| 1509 | 1513 | } |
| 1510 | 1514 | |
| ... | ... | @@ -1513,13 +1517,17 @@ static abi_long do_connect(int sockfd, abi_ulong target_addr, |
| 1513 | 1517 | socklen_t addrlen) |
| 1514 | 1518 | { |
| 1515 | 1519 | void *addr; |
| 1520 | + abi_long ret; | |
| 1516 | 1521 | |
| 1517 | 1522 | if (addrlen < 0) |
| 1518 | 1523 | return -TARGET_EINVAL; |
| 1519 | 1524 | |
| 1520 | 1525 | addr = alloca(addrlen); |
| 1521 | 1526 | |
| 1522 | - target_to_host_sockaddr(addr, target_addr, addrlen); | |
| 1527 | + ret = target_to_host_sockaddr(addr, target_addr, addrlen); | |
| 1528 | + if (ret) | |
| 1529 | + return ret; | |
| 1530 | + | |
| 1523 | 1531 | return get_errno(connect(sockfd, addr, addrlen)); |
| 1524 | 1532 | } |
| 1525 | 1533 | |
| ... | ... | @@ -1543,8 +1551,12 @@ static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, |
| 1543 | 1551 | if (msgp->msg_name) { |
| 1544 | 1552 | msg.msg_namelen = tswap32(msgp->msg_namelen); |
| 1545 | 1553 | msg.msg_name = alloca(msg.msg_namelen); |
| 1546 | - target_to_host_sockaddr(msg.msg_name, tswapl(msgp->msg_name), | |
| 1554 | + ret = target_to_host_sockaddr(msg.msg_name, tswapl(msgp->msg_name), | |
| 1547 | 1555 | msg.msg_namelen); |
| 1556 | + if (ret) { | |
| 1557 | + unlock_user_struct(msgp, target_msg, send ? 0 : 1); | |
| 1558 | + return ret; | |
| 1559 | + } | |
| 1548 | 1560 | } else { |
| 1549 | 1561 | msg.msg_name = NULL; |
| 1550 | 1562 | msg.msg_namelen = 0; |
| ... | ... | @@ -1586,12 +1598,19 @@ static abi_long do_accept(int fd, abi_ulong target_addr, |
| 1586 | 1598 | void *addr; |
| 1587 | 1599 | abi_long ret; |
| 1588 | 1600 | |
| 1601 | + if (target_addr == 0) | |
| 1602 | + return get_errno(accept(fd, NULL, NULL)); | |
| 1603 | + | |
| 1604 | + /* linux returns EINVAL if addrlen pointer is invalid */ | |
| 1589 | 1605 | if (get_user_u32(addrlen, target_addrlen_addr)) |
| 1590 | - return -TARGET_EFAULT; | |
| 1606 | + return -TARGET_EINVAL; | |
| 1591 | 1607 | |
| 1592 | 1608 | if (addrlen < 0) |
| 1593 | 1609 | return -TARGET_EINVAL; |
| 1594 | 1610 | |
| 1611 | + if (!access_ok(VERIFY_WRITE, target_addr, addrlen)) | |
| 1612 | + return -TARGET_EINVAL; | |
| 1613 | + | |
| 1595 | 1614 | addr = alloca(addrlen); |
| 1596 | 1615 | |
| 1597 | 1616 | ret = get_errno(accept(fd, addr, &addrlen)); |
| ... | ... | @@ -1617,6 +1636,9 @@ static abi_long do_getpeername(int fd, abi_ulong target_addr, |
| 1617 | 1636 | if (addrlen < 0) |
| 1618 | 1637 | return -TARGET_EINVAL; |
| 1619 | 1638 | |
| 1639 | + if (!access_ok(VERIFY_WRITE, target_addr, addrlen)) | |
| 1640 | + return -TARGET_EFAULT; | |
| 1641 | + | |
| 1620 | 1642 | addr = alloca(addrlen); |
| 1621 | 1643 | |
| 1622 | 1644 | ret = get_errno(getpeername(fd, addr, &addrlen)); |
| ... | ... | @@ -1636,15 +1658,15 @@ static abi_long do_getsockname(int fd, abi_ulong target_addr, |
| 1636 | 1658 | void *addr; |
| 1637 | 1659 | abi_long ret; |
| 1638 | 1660 | |
| 1639 | - if (target_addr == 0) | |
| 1640 | - return get_errno(accept(fd, NULL, NULL)); | |
| 1641 | - | |
| 1642 | 1661 | if (get_user_u32(addrlen, target_addrlen_addr)) |
| 1643 | 1662 | return -TARGET_EFAULT; |
| 1644 | 1663 | |
| 1645 | 1664 | if (addrlen < 0) |
| 1646 | 1665 | return -TARGET_EINVAL; |
| 1647 | 1666 | |
| 1667 | + if (!access_ok(VERIFY_WRITE, target_addr, addrlen)) | |
| 1668 | + return -TARGET_EFAULT; | |
| 1669 | + | |
| 1648 | 1670 | addr = alloca(addrlen); |
| 1649 | 1671 | |
| 1650 | 1672 | ret = get_errno(getsockname(fd, addr, &addrlen)); |
| ... | ... | @@ -1688,7 +1710,11 @@ static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags, |
| 1688 | 1710 | return -TARGET_EFAULT; |
| 1689 | 1711 | if (target_addr) { |
| 1690 | 1712 | addr = alloca(addrlen); |
| 1691 | - target_to_host_sockaddr(addr, target_addr, addrlen); | |
| 1713 | + ret = target_to_host_sockaddr(addr, target_addr, addrlen); | |
| 1714 | + if (ret) { | |
| 1715 | + unlock_user(host_msg, msg, 0); | |
| 1716 | + return ret; | |
| 1717 | + } | |
| 1692 | 1718 | ret = get_errno(sendto(fd, host_msg, len, flags, addr, addrlen)); |
| 1693 | 1719 | } else { |
| 1694 | 1720 | ret = get_errno(send(fd, host_msg, len, flags)); |
| ... | ... | @@ -1751,11 +1777,11 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1751 | 1777 | switch(num) { |
| 1752 | 1778 | case SOCKOP_socket: |
| 1753 | 1779 | { |
| 1754 | - int domain, type, protocol; | |
| 1780 | + abi_ulong domain, type, protocol; | |
| 1755 | 1781 | |
| 1756 | - if (get_user_s32(domain, vptr) | |
| 1757 | - || get_user_s32(type, vptr + n) | |
| 1758 | - || 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)) | |
| 1759 | 1785 | return -TARGET_EFAULT; |
| 1760 | 1786 | |
| 1761 | 1787 | ret = do_socket(domain, type, protocol); |
| ... | ... | @@ -1763,13 +1789,13 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1763 | 1789 | break; |
| 1764 | 1790 | case SOCKOP_bind: |
| 1765 | 1791 | { |
| 1766 | - int sockfd; | |
| 1792 | + abi_ulong sockfd; | |
| 1767 | 1793 | abi_ulong target_addr; |
| 1768 | 1794 | socklen_t addrlen; |
| 1769 | 1795 | |
| 1770 | - if (get_user_s32(sockfd, vptr) | |
| 1796 | + if (get_user_ual(sockfd, vptr) | |
| 1771 | 1797 | || get_user_ual(target_addr, vptr + n) |
| 1772 | - || get_user_u32(addrlen, vptr + 2 * n)) | |
| 1798 | + || get_user_ual(addrlen, vptr + 2 * n)) | |
| 1773 | 1799 | return -TARGET_EFAULT; |
| 1774 | 1800 | |
| 1775 | 1801 | ret = do_bind(sockfd, target_addr, addrlen); |
| ... | ... | @@ -1777,13 +1803,13 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1777 | 1803 | break; |
| 1778 | 1804 | case SOCKOP_connect: |
| 1779 | 1805 | { |
| 1780 | - int sockfd; | |
| 1806 | + abi_ulong sockfd; | |
| 1781 | 1807 | abi_ulong target_addr; |
| 1782 | 1808 | socklen_t addrlen; |
| 1783 | 1809 | |
| 1784 | - if (get_user_s32(sockfd, vptr) | |
| 1810 | + if (get_user_ual(sockfd, vptr) | |
| 1785 | 1811 | || get_user_ual(target_addr, vptr + n) |
| 1786 | - || get_user_u32(addrlen, vptr + 2 * n)) | |
| 1812 | + || get_user_ual(addrlen, vptr + 2 * n)) | |
| 1787 | 1813 | return -TARGET_EFAULT; |
| 1788 | 1814 | |
| 1789 | 1815 | ret = do_connect(sockfd, target_addr, addrlen); |
| ... | ... | @@ -1791,10 +1817,10 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1791 | 1817 | break; |
| 1792 | 1818 | case SOCKOP_listen: |
| 1793 | 1819 | { |
| 1794 | - int sockfd, backlog; | |
| 1820 | + abi_ulong sockfd, backlog; | |
| 1795 | 1821 | |
| 1796 | - if (get_user_s32(sockfd, vptr) | |
| 1797 | - || get_user_s32(backlog, vptr + n)) | |
| 1822 | + if (get_user_ual(sockfd, vptr) | |
| 1823 | + || get_user_ual(backlog, vptr + n)) | |
| 1798 | 1824 | return -TARGET_EFAULT; |
| 1799 | 1825 | |
| 1800 | 1826 | ret = get_errno(listen(sockfd, backlog)); |
| ... | ... | @@ -1802,12 +1828,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1802 | 1828 | break; |
| 1803 | 1829 | case SOCKOP_accept: |
| 1804 | 1830 | { |
| 1805 | - int sockfd; | |
| 1831 | + abi_ulong sockfd; | |
| 1806 | 1832 | abi_ulong target_addr, target_addrlen; |
| 1807 | 1833 | |
| 1808 | - if (get_user_s32(sockfd, vptr) | |
| 1834 | + if (get_user_ual(sockfd, vptr) | |
| 1809 | 1835 | || get_user_ual(target_addr, vptr + n) |
| 1810 | - || get_user_u32(target_addrlen, vptr + 2 * n)) | |
| 1836 | + || get_user_ual(target_addrlen, vptr + 2 * n)) | |
| 1811 | 1837 | return -TARGET_EFAULT; |
| 1812 | 1838 | |
| 1813 | 1839 | ret = do_accept(sockfd, target_addr, target_addrlen); |
| ... | ... | @@ -1815,12 +1841,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1815 | 1841 | break; |
| 1816 | 1842 | case SOCKOP_getsockname: |
| 1817 | 1843 | { |
| 1818 | - int sockfd; | |
| 1844 | + abi_ulong sockfd; | |
| 1819 | 1845 | abi_ulong target_addr, target_addrlen; |
| 1820 | 1846 | |
| 1821 | - if (get_user_s32(sockfd, vptr) | |
| 1847 | + if (get_user_ual(sockfd, vptr) | |
| 1822 | 1848 | || get_user_ual(target_addr, vptr + n) |
| 1823 | - || get_user_u32(target_addrlen, vptr + 2 * n)) | |
| 1849 | + || get_user_ual(target_addrlen, vptr + 2 * n)) | |
| 1824 | 1850 | return -TARGET_EFAULT; |
| 1825 | 1851 | |
| 1826 | 1852 | ret = do_getsockname(sockfd, target_addr, target_addrlen); |
| ... | ... | @@ -1828,12 +1854,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1828 | 1854 | break; |
| 1829 | 1855 | case SOCKOP_getpeername: |
| 1830 | 1856 | { |
| 1831 | - int sockfd; | |
| 1857 | + abi_ulong sockfd; | |
| 1832 | 1858 | abi_ulong target_addr, target_addrlen; |
| 1833 | 1859 | |
| 1834 | - if (get_user_s32(sockfd, vptr) | |
| 1860 | + if (get_user_ual(sockfd, vptr) | |
| 1835 | 1861 | || get_user_ual(target_addr, vptr + n) |
| 1836 | - || get_user_u32(target_addrlen, vptr + 2 * n)) | |
| 1862 | + || get_user_ual(target_addrlen, vptr + 2 * n)) | |
| 1837 | 1863 | return -TARGET_EFAULT; |
| 1838 | 1864 | |
| 1839 | 1865 | ret = do_getpeername(sockfd, target_addr, target_addrlen); |
| ... | ... | @@ -1841,12 +1867,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1841 | 1867 | break; |
| 1842 | 1868 | case SOCKOP_socketpair: |
| 1843 | 1869 | { |
| 1844 | - int domain, type, protocol; | |
| 1870 | + abi_ulong domain, type, protocol; | |
| 1845 | 1871 | abi_ulong tab; |
| 1846 | 1872 | |
| 1847 | - if (get_user_s32(domain, vptr) | |
| 1848 | - || get_user_s32(type, vptr + n) | |
| 1849 | - || 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) | |
| 1850 | 1876 | || get_user_ual(tab, vptr + 3 * n)) |
| 1851 | 1877 | return -TARGET_EFAULT; |
| 1852 | 1878 | |
| ... | ... | @@ -1855,15 +1881,15 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1855 | 1881 | break; |
| 1856 | 1882 | case SOCKOP_send: |
| 1857 | 1883 | { |
| 1858 | - int sockfd; | |
| 1884 | + abi_ulong sockfd; | |
| 1859 | 1885 | abi_ulong msg; |
| 1860 | 1886 | size_t len; |
| 1861 | - int flags; | |
| 1887 | + abi_ulong flags; | |
| 1862 | 1888 | |
| 1863 | - if (get_user_s32(sockfd, vptr) | |
| 1889 | + if (get_user_ual(sockfd, vptr) | |
| 1864 | 1890 | || get_user_ual(msg, vptr + n) |
| 1865 | 1891 | || get_user_ual(len, vptr + 2 * n) |
| 1866 | - || get_user_s32(flags, vptr + 3 * n)) | |
| 1892 | + || get_user_ual(flags, vptr + 3 * n)) | |
| 1867 | 1893 | return -TARGET_EFAULT; |
| 1868 | 1894 | |
| 1869 | 1895 | ret = do_sendto(sockfd, msg, len, flags, 0, 0); |
| ... | ... | @@ -1871,15 +1897,15 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1871 | 1897 | break; |
| 1872 | 1898 | case SOCKOP_recv: |
| 1873 | 1899 | { |
| 1874 | - int sockfd; | |
| 1900 | + abi_ulong sockfd; | |
| 1875 | 1901 | abi_ulong msg; |
| 1876 | 1902 | size_t len; |
| 1877 | - int flags; | |
| 1903 | + abi_ulong flags; | |
| 1878 | 1904 | |
| 1879 | - if (get_user_s32(sockfd, vptr) | |
| 1905 | + if (get_user_ual(sockfd, vptr) | |
| 1880 | 1906 | || get_user_ual(msg, vptr + n) |
| 1881 | 1907 | || get_user_ual(len, vptr + 2 * n) |
| 1882 | - || get_user_s32(flags, vptr + 3 * n)) | |
| 1908 | + || get_user_ual(flags, vptr + 3 * n)) | |
| 1883 | 1909 | return -TARGET_EFAULT; |
| 1884 | 1910 | |
| 1885 | 1911 | ret = do_recvfrom(sockfd, msg, len, flags, 0, 0); |
| ... | ... | @@ -1887,19 +1913,19 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1887 | 1913 | break; |
| 1888 | 1914 | case SOCKOP_sendto: |
| 1889 | 1915 | { |
| 1890 | - int sockfd; | |
| 1916 | + abi_ulong sockfd; | |
| 1891 | 1917 | abi_ulong msg; |
| 1892 | 1918 | size_t len; |
| 1893 | - int flags; | |
| 1919 | + abi_ulong flags; | |
| 1894 | 1920 | abi_ulong addr; |
| 1895 | 1921 | socklen_t addrlen; |
| 1896 | 1922 | |
| 1897 | - if (get_user_s32(sockfd, vptr) | |
| 1923 | + if (get_user_ual(sockfd, vptr) | |
| 1898 | 1924 | || get_user_ual(msg, vptr + n) |
| 1899 | 1925 | || get_user_ual(len, vptr + 2 * n) |
| 1900 | - || get_user_s32(flags, vptr + 3 * n) | |
| 1926 | + || get_user_ual(flags, vptr + 3 * n) | |
| 1901 | 1927 | || get_user_ual(addr, vptr + 4 * n) |
| 1902 | - || get_user_u32(addrlen, vptr + 5 * n)) | |
| 1928 | + || get_user_ual(addrlen, vptr + 5 * n)) | |
| 1903 | 1929 | return -TARGET_EFAULT; |
| 1904 | 1930 | |
| 1905 | 1931 | ret = do_sendto(sockfd, msg, len, flags, addr, addrlen); |
| ... | ... | @@ -1907,19 +1933,19 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1907 | 1933 | break; |
| 1908 | 1934 | case SOCKOP_recvfrom: |
| 1909 | 1935 | { |
| 1910 | - int sockfd; | |
| 1936 | + abi_ulong sockfd; | |
| 1911 | 1937 | abi_ulong msg; |
| 1912 | 1938 | size_t len; |
| 1913 | - int flags; | |
| 1939 | + abi_ulong flags; | |
| 1914 | 1940 | abi_ulong addr; |
| 1915 | 1941 | socklen_t addrlen; |
| 1916 | 1942 | |
| 1917 | - if (get_user_s32(sockfd, vptr) | |
| 1943 | + if (get_user_ual(sockfd, vptr) | |
| 1918 | 1944 | || get_user_ual(msg, vptr + n) |
| 1919 | 1945 | || get_user_ual(len, vptr + 2 * n) |
| 1920 | - || get_user_s32(flags, vptr + 3 * n) | |
| 1946 | + || get_user_ual(flags, vptr + 3 * n) | |
| 1921 | 1947 | || get_user_ual(addr, vptr + 4 * n) |
| 1922 | - || get_user_u32(addrlen, vptr + 5 * n)) | |
| 1948 | + || get_user_ual(addrlen, vptr + 5 * n)) | |
| 1923 | 1949 | return -TARGET_EFAULT; |
| 1924 | 1950 | |
| 1925 | 1951 | ret = do_recvfrom(sockfd, msg, len, flags, addr, addrlen); |
| ... | ... | @@ -1927,10 +1953,10 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1927 | 1953 | break; |
| 1928 | 1954 | case SOCKOP_shutdown: |
| 1929 | 1955 | { |
| 1930 | - int sockfd, how; | |
| 1956 | + abi_ulong sockfd, how; | |
| 1931 | 1957 | |
| 1932 | - if (get_user_s32(sockfd, vptr) | |
| 1933 | - || get_user_s32(how, vptr + n)) | |
| 1958 | + if (get_user_ual(sockfd, vptr) | |
| 1959 | + || get_user_ual(how, vptr + n)) | |
| 1934 | 1960 | return -TARGET_EFAULT; |
| 1935 | 1961 | |
| 1936 | 1962 | ret = get_errno(shutdown(sockfd, how)); |
| ... | ... | @@ -1939,13 +1965,13 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1939 | 1965 | case SOCKOP_sendmsg: |
| 1940 | 1966 | case SOCKOP_recvmsg: |
| 1941 | 1967 | { |
| 1942 | - int fd; | |
| 1968 | + abi_ulong fd; | |
| 1943 | 1969 | abi_ulong target_msg; |
| 1944 | - int flags; | |
| 1970 | + abi_ulong flags; | |
| 1945 | 1971 | |
| 1946 | - if (get_user_s32(fd, vptr) | |
| 1972 | + if (get_user_ual(fd, vptr) | |
| 1947 | 1973 | || get_user_ual(target_msg, vptr + n) |
| 1948 | - || get_user_s32(flags, vptr + 2 * n)) | |
| 1974 | + || get_user_ual(flags, vptr + 2 * n)) | |
| 1949 | 1975 | return -TARGET_EFAULT; |
| 1950 | 1976 | |
| 1951 | 1977 | ret = do_sendrecvmsg(fd, target_msg, flags, |
| ... | ... | @@ -1954,17 +1980,17 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1954 | 1980 | break; |
| 1955 | 1981 | case SOCKOP_setsockopt: |
| 1956 | 1982 | { |
| 1957 | - int sockfd; | |
| 1958 | - int level; | |
| 1959 | - int optname; | |
| 1983 | + abi_ulong sockfd; | |
| 1984 | + abi_ulong level; | |
| 1985 | + abi_ulong optname; | |
| 1960 | 1986 | abi_ulong optval; |
| 1961 | 1987 | socklen_t optlen; |
| 1962 | 1988 | |
| 1963 | - if (get_user_s32(sockfd, vptr) | |
| 1964 | - || get_user_s32(level, vptr + n) | |
| 1965 | - || 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) | |
| 1966 | 1992 | || get_user_ual(optval, vptr + 3 * n) |
| 1967 | - || get_user_u32(optlen, vptr + 4 * n)) | |
| 1993 | + || get_user_ual(optlen, vptr + 4 * n)) | |
| 1968 | 1994 | return -TARGET_EFAULT; |
| 1969 | 1995 | |
| 1970 | 1996 | ret = do_setsockopt(sockfd, level, optname, optval, optlen); |
| ... | ... | @@ -1972,17 +1998,17 @@ static abi_long do_socketcall(int num, abi_ulong vptr) |
| 1972 | 1998 | break; |
| 1973 | 1999 | case SOCKOP_getsockopt: |
| 1974 | 2000 | { |
| 1975 | - int sockfd; | |
| 1976 | - int level; | |
| 1977 | - int optname; | |
| 2001 | + abi_ulong sockfd; | |
| 2002 | + abi_ulong level; | |
| 2003 | + abi_ulong optname; | |
| 1978 | 2004 | abi_ulong optval; |
| 1979 | 2005 | socklen_t optlen; |
| 1980 | 2006 | |
| 1981 | - if (get_user_s32(sockfd, vptr) | |
| 1982 | - || get_user_s32(level, vptr + n) | |
| 1983 | - || 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) | |
| 1984 | 2010 | || get_user_ual(optval, vptr + 3 * n) |
| 1985 | - || get_user_u32(optlen, vptr + 4 * n)) | |
| 2011 | + || get_user_ual(optlen, vptr + 4 * n)) | |
| 1986 | 2012 | return -TARGET_EFAULT; |
| 1987 | 2013 | |
| 1988 | 2014 | ret = do_getsockopt(sockfd, level, optname, optval, optlen); |
| ... | ... | @@ -2215,7 +2241,7 @@ static inline abi_long do_semctl(int semid, int semnum, int cmd, |
| 2215 | 2241 | { |
| 2216 | 2242 | union semun arg; |
| 2217 | 2243 | struct semid_ds dsarg; |
| 2218 | - unsigned short *array; | |
| 2244 | + unsigned short *array = NULL; | |
| 2219 | 2245 | struct seminfo seminfo; |
| 2220 | 2246 | abi_long ret = -TARGET_EINVAL; |
| 2221 | 2247 | abi_long err; |
| ... | ... | @@ -4529,7 +4555,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, |
| 4529 | 4555 | case TARGET_NR_access: |
| 4530 | 4556 | if (!(p = lock_user_string(arg1))) |
| 4531 | 4557 | goto efault; |
| 4532 | - ret = get_errno(access(p, arg2)); | |
| 4558 | + ret = get_errno(access(path(p), arg2)); | |
| 4533 | 4559 | unlock_user(p, arg1, 0); |
| 4534 | 4560 | break; |
| 4535 | 4561 | #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) |
| ... | ... | @@ -5021,8 +5047,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, |
| 5021 | 5047 | if (!is_error(ret)) { |
| 5022 | 5048 | if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) |
| 5023 | 5049 | goto efault; |
| 5024 | - rlim.rlim_cur = tswapl(target_rlim->rlim_cur); | |
| 5025 | - rlim.rlim_max = tswapl(target_rlim->rlim_max); | |
| 5050 | + target_rlim->rlim_cur = tswapl(rlim.rlim_cur); | |
| 5051 | + target_rlim->rlim_max = tswapl(rlim.rlim_max); | |
| 5026 | 5052 | unlock_user_struct(target_rlim, arg2, 1); |
| 5027 | 5053 | } |
| 5028 | 5054 | } | ... | ... |