Home | History | Annotate | Download | only in solaris
      1 /* Basic ioctl scalar tests. */
      2 
      3 #define __EXTENSIONS__ 1
      4 
      5 #include "scalar.h"
      6 
      7 #include <net/if.h>
      8 #include <sys/crypto/ioctl.h>
      9 #include <sys/dtrace.h>
     10 #include <sys/filio.h>
     11 #include <sys/stat.h>		/* for _ST_FSTYPSZ */
     12 #include <sys/mntio.h>
     13 #include <sys/mnttab.h>
     14 #include <sys/pool_impl.h>
     15 #include <sys/sockio.h>
     16 #include <sys/stropts.h>
     17 #include <sys/termios.h>
     18 
     19 /* pools */
     20 __attribute__((noinline))
     21 static void sys_ioctl_POOL_STATUSQ(void)
     22 {
     23    GO(SYS_ioctl, "(POOL_STATUSQ) 3s 1m");
     24    SY(SYS_ioctl, x0 - 1, x0 + POOL_STATUSQ, x0); FAIL;
     25 }
     26 
     27 /* mntio */
     28 __attribute__((noinline))
     29 static void sys_ioctl_MNTIOC_GETMNTANY(void)
     30 {
     31    GO(SYS_ioctl, "(MNTIOC_GETMNTANY) 3s 1m");
     32    SY(SYS_ioctl, x0 - 1, x0 + MNTIOC_GETMNTANY, x0 + 1); FAIL;
     33 }
     34 
     35 __attribute__((noinline))
     36 static void sys_ioctl_MNTIOC_GETMNTANY_2(void)
     37 {
     38    struct mntentbuf embuf;
     39 
     40    embuf.mbuf_emp = (void *) (x0 + 1);
     41    embuf.mbuf_buf = (void *) (x0 + 1);
     42    embuf.mbuf_bufsize = x0 + 1;
     43 
     44    GO(SYS_ioctl, "(MNTIOC_GETMNTANY) 4s 2m");
     45    SY(SYS_ioctl, x0 - 1, x0 + MNTIOC_GETMNTANY, &embuf + x0); FAIL;
     46 }
     47 
     48 __attribute__((noinline))
     49 static void sys_ioctl_MNTIOC_GETMNTANY_3(void)
     50 {
     51    struct mnttab mnt;
     52    struct mntentbuf embuf;
     53 
     54    mnt.mnt_special = (void *) (x0 + 1);
     55    mnt.mnt_mountp = (void *) (x0 + 1);
     56    mnt.mnt_fstype = (void *) (x0 + 1);
     57    mnt.mnt_mntopts = (void *) (x0 + 1);
     58    mnt.mnt_time = (void *) (x0 + 1);
     59 
     60    embuf.mbuf_emp = x0 + (struct extmnttab *) &mnt;
     61    embuf.mbuf_buf = (void *) (x0 + 1);
     62    embuf.mbuf_bufsize = x0 + 1;
     63 
     64    GO(SYS_ioctl, "(MNTIOC_GETMNTANY) 5s 6m");
     65    SY(SYS_ioctl, x0 - 1, x0 + MNTIOC_GETMNTANY, &embuf + x0); FAIL;
     66 }
     67 
     68 /* termio/termios */
     69 __attribute__((noinline))
     70 static void sys_ioctl_TCGETA(void)
     71 {
     72    GO(SYS_ioctl, "(TCGETA) 3s 1m");
     73    SY(SYS_ioctl, x0 - 1, x0 + TCGETA, x0); FAIL;
     74 }
     75 
     76 __attribute__((noinline))
     77 static void sys_ioctl_TCGETS(void)
     78 {
     79    GO(SYS_ioctl, "(TCGETS) 3s 1m");
     80    SY(SYS_ioctl, x0 - 1, x0 + TCGETS, x0); FAIL;
     81 }
     82 
     83 __attribute__((noinline))
     84 static void sys_ioctl_TCSETS(void)
     85 {
     86    GO(SYS_ioctl, "(TCSETS) 3s 1m");
     87    SY(SYS_ioctl, x0 - 1, x0 + TCSETS, x0); FAIL;
     88 }
     89 
     90 __attribute__((noinline))
     91 static void sys_ioctl_TCSETSW(void)
     92 {
     93    GO(SYS_ioctl, "(TCSETSW) 3s 1m");
     94    SY(SYS_ioctl, x0 - 1, x0 + TCSETSW, x0); FAIL;
     95 }
     96 
     97 __attribute__((noinline))
     98 static void sys_ioctl_TCSETSF(void)
     99 {
    100    GO(SYS_ioctl, "(TCSETSF) 3s 1m");
    101    SY(SYS_ioctl, x0 - 1, x0 + TCSETSF, x0); FAIL;
    102 }
    103 
    104 __attribute__((noinline))
    105 static void sys_ioctl_TIOCGWINSZ(void)
    106 {
    107    GO(SYS_ioctl, "(TIOCGWINSZ) 3s 1m");
    108    SY(SYS_ioctl, x0 - 1, x0 + TIOCGWINSZ, x0); FAIL;
    109 }
    110 
    111 __attribute__((noinline))
    112 static void sys_ioctl_TIOCSWINSZ(void)
    113 {
    114    GO(SYS_ioctl, "(TIOCSWINSZ) 3s 1m");
    115    SY(SYS_ioctl, x0 - 1, x0 + TIOCSWINSZ, x0); FAIL;
    116 }
    117 
    118 __attribute__((noinline))
    119 static void sys_ioctl_TIOCGPGRP(void)
    120 {
    121    GO(SYS_ioctl, "(TIOCGPGRP) 3s 1m");
    122    SY(SYS_ioctl, x0 - 1, x0 + TIOCGPGRP, x0); FAIL;
    123 }
    124 
    125 __attribute__((noinline))
    126 static void sys_ioctl_TIOCSPGRP(void)
    127 {
    128    GO(SYS_ioctl, "(TIOCSPGRP) 3s 1m");
    129    SY(SYS_ioctl, x0 - 1, x0 + TIOCSPGRP, x0); FAIL;
    130 }
    131 
    132 __attribute__((noinline))
    133 static void sys_ioctl_TIOCGSID(void)
    134 {
    135    GO(SYS_ioctl, "(TIOCGSID) 3s 1m");
    136    SY(SYS_ioctl, x0 - 1, x0 + TIOCGSID, x0); FAIL;
    137 }
    138 
    139 __attribute__((noinline))
    140 static void sys_ioctl_TIOCNOTTY(void)
    141 {
    142    GO(SYS_ioctl, "(TIOCNOTTY) 2s 0m");
    143    SY(SYS_ioctl, x0 - 1, x0 + TIOCNOTTY); FAIL;
    144 }
    145 
    146 __attribute__((noinline))
    147 static void sys_ioctl_TIOCSCTTY(void)
    148 {
    149    GO(SYS_ioctl, "(TIOCSCTTY) 2s 0m");
    150    SY(SYS_ioctl, x0 - 1, x0 + TIOCSCTTY); FAIL;
    151 }
    152 
    153 /* STREAMS */
    154 __attribute__((noinline))
    155 static void sys_ioctl_I_PUSH(void)
    156 {
    157    GO(SYS_ioctl, "(I_PUSH) 3s 1m");
    158    SY(SYS_ioctl, x0 - 1, x0 + I_PUSH, x0 + 1); FAIL;
    159 }
    160 
    161 __attribute__((noinline))
    162 static void sys_ioctl_I_STR(void)
    163 {
    164    GO(SYS_ioctl, "(I_STR) 3s 1m");
    165    SY(SYS_ioctl, x0 - 1, x0 + I_STR, x0 + 1); FAIL;
    166 }
    167 
    168 __attribute__((noinline))
    169 static void sys_ioctl_I_STR_2(void)
    170 {
    171    struct strioctl str;
    172 
    173    str.ic_cmd = x0;
    174    str.ic_timout = x0;
    175    str.ic_len = x0 + 1;
    176    str.ic_dp = (void *) (x0 + 1);
    177 
    178    GO(SYS_ioctl, "(I_STR) 4s 1m");
    179    SY(SYS_ioctl, x0 - 1, x0 + I_STR, &str + x0); FAIL;
    180 }
    181 
    182 __attribute__((noinline))
    183 static void sys_ioctl_I_PEEK(void)
    184 {
    185    GO(SYS_ioctl, "(I_PEEK) 3s 7m");
    186    SY(SYS_ioctl, x0 - 1, x0 + I_PEEK, x0 + 1); FAIL;
    187 }
    188 
    189 __attribute__((noinline))
    190 static void sys_ioctl_I_PEEK_2(void)
    191 {
    192    struct strpeek peek;
    193 
    194    peek.ctlbuf.maxlen = x0 + 1;
    195    peek.ctlbuf.len = x0;
    196    peek.ctlbuf.buf = (void*)(x0 + 1);
    197    peek.databuf.maxlen = x0 + 1;
    198    peek.databuf.len = x0;
    199    peek.databuf.buf = (void*)(x0 + 1);
    200    peek.flags = x0;
    201 
    202    GO(SYS_ioctl, "(I_PEEK) 3s 7m");
    203    SY(SYS_ioctl, x0 - 1, x0 + I_PEEK, &peek + x0); FAIL;
    204 }
    205 
    206 __attribute__((noinline))
    207 static void sys_ioctl_I_CANPUT(void)
    208 {
    209    GO(SYS_ioctl, "(I_CANPUT) 3s 0m");
    210    SY(SYS_ioctl, x0 - 1, x0 + I_CANPUT, x0); FAIL;
    211 }
    212 
    213 /* sockio */
    214 __attribute__((noinline))
    215 static void sys_ioctl_SIOCGIFCONF(void)
    216 {
    217    GO(SYS_ioctl, "(SIOCGIFCONF), 3s 2m");
    218    SY(SYS_ioctl, x0 - 1, x0 + SIOCGIFCONF, x0 - 1); FAIL;
    219 }
    220 
    221 __attribute__((noinline))
    222 static void sys_ioctl_SIOCGIFCONF_2(void)
    223 {
    224    struct ifconf ifc;
    225    char buf[] = "";
    226 
    227    ifc.ifc_len = x0 + 1;
    228    ifc.ifc_buf = (void *) (x0 + buf);
    229 
    230    GO(SYS_ioctl, "(SIOCGIFCONF), 5s 0m");
    231    SY(SYS_ioctl, x0 - 1, x0 + SIOCGIFCONF, &ifc + x0); FAIL;
    232 }
    233 
    234 __attribute__((noinline))
    235 static void sys_ioctl_SIOCGIFFLAGS(void)
    236 {
    237    GO(SYS_ioctl, "(SIOCGIFFLAGS) 3s 2m");
    238    SY(SYS_ioctl, x0 - 1, x0 + SIOCGIFFLAGS, x0 - 1); FAIL;
    239 }
    240 
    241 __attribute__((noinline))
    242 static void sys_ioctl_SIOCGIFFLAGS_2(void)
    243 {
    244    struct ifreq ifr;
    245 
    246    ifr.ifr_name[0] = x0 + 'l';
    247    ifr.ifr_name[1] = x0 + 'o';
    248    ifr.ifr_name[2] = x0 + '0';
    249    ifr.ifr_name[3] = x0 + '\0';
    250 
    251    GO(SYS_ioctl, "(SIOCGIFFLAGS), 4s 0m");
    252    SY(SYS_ioctl, x0 - 1, x0 + SIOCGIFFLAGS, &ifr + x0); FAIL;
    253 }
    254 
    255 __attribute__((noinline))
    256 static void sys_ioctl_SIOCGIFNETMASK(void)
    257 {
    258    GO(SYS_ioctl, "(SIOCGIFNETMASK) 3s 2m");
    259    SY(SYS_ioctl, x0 - 1, x0 + SIOCGIFNETMASK, x0 - 1); FAIL;
    260 }
    261 
    262 __attribute__((noinline))
    263 static void sys_ioctl_SIOCGIFNETMASK_2(void)
    264 {
    265    struct ifreq ifr;
    266 
    267    ifr.ifr_name[0] = x0 + 'l';
    268    ifr.ifr_name[1] = x0 + 'o';
    269    ifr.ifr_name[2] = x0 + '0';
    270    ifr.ifr_name[3] = x0 + '\0';
    271 
    272    GO(SYS_ioctl, "(SIOCGIFNETMASK), 4s 0m");
    273    SY(SYS_ioctl, x0 - 1, x0 + SIOCGIFNETMASK, &ifr + x0); FAIL;
    274 }
    275 
    276 __attribute__((noinline))
    277 static void sys_ioctl_SIOCGIFNUM(void)
    278 {
    279    int ifnum;
    280 
    281    GO(SYS_ioctl, "(SIOCGIFNUM) 3s 0m");
    282    SY(SYS_ioctl, x0 - 1, x0 + SIOCGIFNUM, &ifnum + x0); FAIL;
    283 }
    284 
    285 __attribute__((noinline))
    286 static void sys_ioctl_SIOCGIFNUM_2(void)
    287 {
    288    GO(SYS_ioctl, "(SIOCGIFNUM) 3s 1m");
    289    SY(SYS_ioctl, x0 - 1, x0 + SIOCGIFNUM, x0 - 1); FAIL;
    290 }
    291 
    292 __attribute__((noinline))
    293 static void sys_ioctl_SIOCGLIFBRDADDR(void)
    294 {
    295    GO(SYS_ioctl, "(SIOCGLIFBRDADDR) 3s 2m");
    296    SY(SYS_ioctl, x0 - 1, x0 + SIOCGLIFBRDADDR, x0 - 1); FAIL;
    297 }
    298 
    299 __attribute__((noinline))
    300 static void sys_ioctl_SIOCGLIFBRDADDR_2(void)
    301 {
    302    struct lifreq lifr;
    303 
    304    lifr.lifr_name[0] = x0 + 'l';
    305    lifr.lifr_name[1] = x0 + 'o';
    306    lifr.lifr_name[2] = x0 + '0';
    307    lifr.lifr_name[3] = x0 + '\0';
    308 
    309    GO(SYS_ioctl, "(SIOCGLIFBRDADDR), 4s 0m");
    310    SY(SYS_ioctl, x0 - 1, x0 + SIOCGLIFBRDADDR, &lifr + x0); FAIL;
    311 }
    312 
    313 __attribute__((noinline))
    314 static void sys_ioctl_SIOCGLIFCONF(void)
    315 {
    316    GO(SYS_ioctl, "(SIOCGLIFCONF), 3s 4m");
    317    SY(SYS_ioctl, x0 - 1, x0 + SIOCGLIFCONF, x0 - 1); FAIL;
    318 }
    319 
    320 __attribute__((noinline))
    321 static void sys_ioctl_SIOCGLIFCONF_2(void)
    322 {
    323    struct lifconf lifc;
    324    char buf[] = "";
    325 
    326    lifc.lifc_len = x0 + 1;
    327    lifc.lifc_buf = (void *) (x0 + buf);
    328    lifc.lifc_family = x0 + 1;
    329    lifc.lifc_flags = x0 + 0;
    330 
    331    GO(SYS_ioctl, "(SIOCGLIFCONF), 7s 0m");
    332    SY(SYS_ioctl, x0 - 1, x0 + SIOCGLIFCONF, &lifc + x0); FAIL;
    333 }
    334 
    335 __attribute__((noinline))
    336 static void sys_ioctl_SIOCGLIFFLAGS(void)
    337 {
    338    GO(SYS_ioctl, "(SIOCGLIFFLAGS) 3s 2m");
    339    SY(SYS_ioctl, x0 - 1, x0 + SIOCGLIFFLAGS, x0 - 1); FAIL;
    340 }
    341 
    342 __attribute__((noinline))
    343 static void sys_ioctl_SIOCGLIFFLAGS_2(void)
    344 {
    345    struct lifreq lifr;
    346 
    347    lifr.lifr_name[0] = x0 + 'l';
    348    lifr.lifr_name[1] = x0 + 'o';
    349    lifr.lifr_name[2] = x0 + '0';
    350    lifr.lifr_name[3] = x0 + '\0';
    351 
    352    GO(SYS_ioctl, "(SIOCGLIFFLAGS), 4s 0m");
    353    SY(SYS_ioctl, x0 - 1, x0 + SIOCGLIFFLAGS, &lifr + x0); FAIL;
    354 }
    355 
    356 __attribute__((noinline))
    357 static void sys_ioctl_SIOCGLIFNETMASK(void)
    358 {
    359    GO(SYS_ioctl, "(SIOCGLIFNETMASK) 3s 2m");
    360    SY(SYS_ioctl, x0 - 1, x0 + SIOCGLIFNETMASK, x0 - 1); FAIL;
    361 }
    362 
    363 __attribute__((noinline))
    364 static void sys_ioctl_SIOCGLIFNETMASK_2(void)
    365 {
    366    struct lifreq lifr;
    367 
    368    lifr.lifr_name[0] = x0 + 'l';
    369    lifr.lifr_name[1] = x0 + 'o';
    370    lifr.lifr_name[2] = x0 + '0';
    371    lifr.lifr_name[3] = x0 + '\0';
    372 
    373    GO(SYS_ioctl, "(SIOCGLIFNETMASK), 4s 0m");
    374    SY(SYS_ioctl, x0 - 1, x0 + SIOCGLIFNETMASK, &lifr + x0); FAIL;
    375 }
    376 
    377 __attribute__((noinline))
    378 static void sys_ioctl_SIOCGLIFNUM(void)
    379 {
    380    struct lifnum lifn;
    381 
    382    lifn.lifn_family = x0;
    383    lifn.lifn_flags = x0;
    384 
    385    GO(SYS_ioctl, "(SIOCGLIFNUM) 4s 0m");
    386    SY(SYS_ioctl, x0 - 1, x0 + SIOCGLIFNUM, &lifn + x0); FAIL;
    387 }
    388 
    389 /* filio */
    390 __attribute__((noinline))
    391 static void sys_ioctl_FIOSETOWN(void)
    392 {
    393    pid_t pid;
    394 
    395    GO(SYS_ioctl, "(FIOSETOWN) 4s 0m");
    396    SY(SYS_ioctl, x0 - 1, x0 + FIOSETOWN, &pid + x0); FAIL;
    397 }
    398 
    399 __attribute__((noinline))
    400 static void sys_ioctl_FIOGETOWN(void)
    401 {
    402    GO(SYS_ioctl, "(FIOGETOWN) 3s 1m");
    403    SY(SYS_ioctl, x0 - 1, x0 + FIOGETOWN, x0 + 1); FAIL;
    404 }
    405 
    406 /* crypto */
    407 __attribute__((noinline))
    408 static void sys_ioctl_CRYPTO_GET_PROVIDER_LIST(void)
    409 {
    410    GO(SYS_ioctl, "(CRYPTO_GET_PROVIDER_LIST) 3s 1m");
    411    SY(SYS_ioctl, x0 - 1, x0 + CRYPTO_GET_PROVIDER_LIST, x0 + 1); FAIL;
    412 }
    413 
    414 __attribute__((noinline))
    415 static void sys_ioctl_CRYPTO_GET_PROVIDER_LIST_2(void)
    416 {
    417    crypto_get_provider_list_t pl;
    418 
    419    pl.pl_count = x0 + 1;
    420 
    421    GO(SYS_ioctl, "(CRYPTO_GET_PROVIDER_LIST) 4s 0m");
    422    SY(SYS_ioctl, x0 - 1, x0 + CRYPTO_GET_PROVIDER_LIST, &pl + x0); FAIL;
    423 }
    424 
    425 /* dtrace */
    426 __attribute__((noinline))
    427 static void sys_ioctl_DTRACEHIOC_REMOVE(void)
    428 {
    429    GO(SYS_ioctl, "(DTRACEHIOC_REMOVE) 3s 0m");
    430    SY(SYS_ioctl, x0 - 1, x0 + DTRACEHIOC_REMOVE, x0); FAIL;
    431 }
    432 
    433 __attribute__((noinline))
    434 static void sys_ioctl_DTRACEHIOC_ADDDOF(void)
    435 {
    436    dof_helper_t dh;
    437 
    438    dh.dofhp_mod[0] = x0 + 'D';
    439    dh.dofhp_mod[1] = x0 + '\0';
    440    dh.dofhp_addr = x0;
    441    dh.dofhp_dof = x0;
    442 
    443    GO(SYS_ioctl, "(DTRACEHIOC_ADDDOF) 6s 0m");
    444    SY(SYS_ioctl, x0 - 1, x0 + DTRACEHIOC_ADDDOF, x0 + &dh); FAIL;
    445 }
    446 
    447 int main(void)
    448 {
    449    /* Uninitialised, but we know px[0] is 0x0. */
    450    long *px = malloc(sizeof(long));
    451    x0 = px[0];
    452 
    453    /* pools */
    454    sys_ioctl_POOL_STATUSQ();
    455 
    456    /* mntio */
    457    sys_ioctl_MNTIOC_GETMNTANY();
    458    sys_ioctl_MNTIOC_GETMNTANY_2();
    459    sys_ioctl_MNTIOC_GETMNTANY_3();
    460 
    461    /* termio/termios */
    462    sys_ioctl_TCGETA();
    463    sys_ioctl_TCGETS();
    464    sys_ioctl_TCSETS();
    465    sys_ioctl_TCSETSW();
    466    sys_ioctl_TCSETSF();
    467    sys_ioctl_TIOCGWINSZ();
    468    sys_ioctl_TIOCSWINSZ();
    469    sys_ioctl_TIOCGPGRP();
    470    sys_ioctl_TIOCSPGRP();
    471    sys_ioctl_TIOCGSID();
    472    sys_ioctl_TIOCNOTTY();
    473    sys_ioctl_TIOCSCTTY();
    474 
    475    /* STREAMS */
    476    sys_ioctl_I_PUSH();
    477    sys_ioctl_I_STR();
    478    sys_ioctl_I_STR_2();
    479    sys_ioctl_I_PEEK();
    480    sys_ioctl_I_PEEK_2();
    481    sys_ioctl_I_CANPUT();
    482 
    483    /* sockio */
    484    sys_ioctl_SIOCGIFCONF();
    485    sys_ioctl_SIOCGIFCONF_2();
    486    sys_ioctl_SIOCGIFFLAGS();
    487    sys_ioctl_SIOCGIFFLAGS_2();
    488    sys_ioctl_SIOCGIFNETMASK();
    489    sys_ioctl_SIOCGIFNETMASK_2();
    490    sys_ioctl_SIOCGIFNUM();
    491    sys_ioctl_SIOCGIFNUM_2();
    492    sys_ioctl_SIOCGLIFBRDADDR();
    493    sys_ioctl_SIOCGLIFBRDADDR_2();
    494    sys_ioctl_SIOCGLIFCONF();
    495    sys_ioctl_SIOCGLIFCONF_2();
    496    sys_ioctl_SIOCGLIFFLAGS();
    497    sys_ioctl_SIOCGLIFFLAGS_2();
    498    sys_ioctl_SIOCGLIFNETMASK();
    499    sys_ioctl_SIOCGLIFNETMASK_2();
    500    sys_ioctl_SIOCGLIFNUM();
    501 
    502    /* filio */
    503    sys_ioctl_FIOSETOWN();
    504    sys_ioctl_FIOGETOWN();
    505 
    506    /* crypto */
    507    sys_ioctl_CRYPTO_GET_PROVIDER_LIST();
    508    sys_ioctl_CRYPTO_GET_PROVIDER_LIST_2();
    509 
    510    /* dtrace */
    511    sys_ioctl_DTRACEHIOC_REMOVE();
    512    sys_ioctl_DTRACEHIOC_ADDDOF();
    513 
    514    return 0;
    515 }
    516 
    517