Monday, February 28, 2011

glibc-git and audio_setup

$ glibc
git pull
[..]

Starting, for example, mplayer [..] with audio device being busy, results in:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7de7be1 in do_lookup_x () from /lib/ld-linux-x86-64.so.2
(gdb) bt
#0  0x00007ffff7de7be1 in do_lookup_x () from /lib/ld-linux-x86-64.so.2
#1  0x00007ffff7de84d2 in _dl_lookup_symbol_x () from /lib/ld-linux-x86-64.so.2
#2  0x00007fffefb0d035 in ?? () from /lib/libc.so.6
#3  0x00007ffff6151014 in ?? () from /lib/libdl.so.2
#4  0x00007ffff7dec736 in _dl_catch_error () from /lib/ld-linux-x86-64.so.2
#5  0x00007ffff615149c in ?? () from /lib/libdl.so.2
#6  0x00007ffff615106a in dlsym () from /lib/libdl.so.2
#7  0x00007ffff638c533 in ?? () from /usr/lib/libasound.so.2
#8  0x00007ffff638c61d in snd_dlsym () from /usr/lib/libasound.so.2
#9  0x00007ffff6387a04 in ?? () from /usr/lib/libasound.so.2
#10 0x00007ffff6385cc1 in ?? () from /usr/lib/libasound.so.2
#11 0x00007ffff6385d24 in ?? () from /usr/lib/libasound.so.2
#12 0x00007ffff6386ed1 in snd_config_expand () from /usr/lib/libasound.so.2
#13 0x00007ffff63877df in snd_config_search_definition () from /usr/lib/libasound.so.2
#14 0x00007ffff63a306a in ?? () from /usr/lib/libasound.so.2
#15 0x00000000004e9843 in ?? ()
#16 0x00000000004e474f in init_best_audio_out ()
#17 0x00000000004d8b6b in reinit_audio_chain ()
#18 0x00000000004da811 in main ()


(even with -ao alsa).

Which is:
 76 static int
 77 __attribute_noinline__
 78 do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
 79          unsigned long int *old_hash, const ElfW(Sym) *ref,
 80          struct sym_val *result, struct r_scope_elem *scope, size_t i,
 81          const struct r_found_version *const version, int flags,
 82          struct link_map *skip, int type_class, struct link_map *undef_map)
 83 {
 84   size_t n = scope->r_nlist;
 85   /* Make sure we read the value before proceeding.  Otherwise we
 86      might use r_list pointing to the initial scope and r_nlist being
 87      the value after a resize.  That is the only path in dl-open.c not
 88      protected by GSCOPE.  A read barrier here might be to expensive.  */
 89   __asm volatile ("" : "+r" (n), "+m" (scope->r_list));
 90   struct link_map **list = scope->r_list;
 91
 92   do
 93     {
 94       /* These variables are used in the nested function.  */
 95       Elf_Symndx symidx;
 96       int num_versions = 0;
 97       const ElfW(Sym) *versioned_sym = NULL;
 98                                                                                                                                                       
 99       const struct link_map *map = list[i]->l_real;
 100
 101  [..]

Tuesday, February 22, 2011

btrfs and cp

Chris Mason wrote to linux-btrfs:

"[..] Looks like the latest versions of cp use fiemap to decide if a file is
sparse, which is a great way to avoid doing memcmp, but only if your
fiemap is really accurate about which ranges in the file have holes.

Our fiemap tends to return holes for delalloc bytes, and has a few other
bugs along the way.  The end result is a bunch of zeros instead of good
data when you copy the file. [..]"

patch is available here

Saturday, February 19, 2011

London Stock Exchange

"Within the first 20 seconds of the London Stock Exchange's new matching engine going live on Monday, price data vendors began displaying incorrect prices, blank prices and wrong trading volumes, according to Computerworld UK sources. Thomson Reuters, Interactive Data and Netbuilder are among the largest data vendors, providing share prices to traders, that have been displaying pricing problems on some stocks throughout the week. Even the LSE's own data vendor, ProQuote, experienced problems. Concerns are being raised that there could be mistakenly setup connections or incorrect software interfaces at some of the large data vendors. Alternatively, there may be a data caching issue at the LSE that means data going out is not properly synchronised between different systems."

via Slashdot

Jesus... guys, are you kidding?

Thursday, February 17, 2011

2.6.38-rc5 -- radeon hd 5470

As per phoronix Linux 2.6.38-rc5 Brings Radeon, Intel, EXT4 Fixes

And I finally managed to boot it:
git bisect start '--' 'drivers/gpu/drm/radeon/'
# bad: [e53b2057d8fccc3394cc38463171df948ce43aaa] Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
git bisect bad e53b2057d8fccc3394cc38463171df948ce43aaa
# good: [87364760de5d631390c478fcbac8db1b926e0adf] drm/radeon/kms: fix s/r issues with bios scratch regs
git bisect good 87364760de5d631390c478fcbac8db1b926e0adf
# good: [4eace7fdfa1f8ac2f0a833e12bd07eeb453ec9ef] drm/radeon/kms: 6xx/7xx big endian fixes
git bisect good 4eace7fdfa1f8ac2f0a833e12bd07eeb453ec9ef
# good: [501834349e872ed4115eea3beef65ca9eeb5528e] drm/radeon/kms: fix tracking of BLENDCNTL, COLOR_CHANNEL_MASK, and GB_Z on r300
git bisect good 501834349e872ed4115eea3beef65ca9eeb5528e
# good: [c2049b3d29f47ed3750226dc51251a3404c85876] drm/radeon/kms: improve 6xx/7xx CS error output
git bisect good c2049b3d29f47ed3750226dc51251a3404c85876
# good: [265aa6c8d8822c9074a2174e8c9f31a37fa02e50] drm/radeon/kms: fix a few more atombios endian issues
git bisect good 265aa6c8d8822c9074a2174e8c9f31a37fa02e50
# good: [a4b40d5d97f5c9ad0b7f4bf2818291ca184bb433] drm/radeon/kms: add bounds checking to avivo pll algo
git bisect good a4b40d5d97f5c9ad0b7f4bf2818291ca184bb433
# bad: [5b40ddf888398ce4cccbf3b9d0a18d90149ed7ff] drm/radeon/kms: hopefully fix pll issues for real (v3)
git bisect bad 5b40ddf888398ce4cccbf3b9d0a18d90149ed7ff

5b40ddf888398ce4cccbf3b9d0a18d90149ed7ff is the first bad commit
commit 5b40ddf888398ce4cccbf3b9d0a18d90149ed7ff
Author: Alex Deucher
Date:   Mon Feb 14 11:43:11 2011 -0500

    drm/radeon/kms: hopefully fix pll issues for real (v3)
   
    The problematic boards have a recommended reference divider
    to be used when spread spectrum is enabled on the laptop panel.
    Enable the use of the recommended reference divider along with
    the new pll algo.
   
    v2: testing options
   
    v3: When using the fixed reference divider with LVDS, prefer
    min m to max p and use fractional feedback dividers.
   
    Fixes:
    https://bugzilla.kernel.org/show_bug.cgi?id=28852
    https://bugzilla.kernel.org/show_bug.cgi?id=24462
    https://bugzilla.kernel.org/show_bug.cgi?id=26552
    MacbookPro issues reported by Justin Mattock


Have to revert `radeon fixes'.

Wednesday, February 9, 2011

Thursday, February 3, 2011

syslog-ng and CAP_SYSLOG. part 2

Gergely Nagy wrote:
Good news!

It looks like this will be dealt with on kernel side: for 2.6.38, CAP_SYS_ADMIN will continue working, later on, a sysctl will be set, which controls whether
we need CAP_SYSLOG or CAP_SYS_ADMIN, and that's reasonably easy to query, and adapt to.
Once the kernel folk figure this out and the patch lands in the kernel, I will prepare a syslog-ng patch that checks the sysctl setting, and acts accordingly.

Tuesday, February 1, 2011

syslog-ng CAP_SYSLOG support

I've contacted syslong-ng developers on CAP_SYSLOG capability in 2.6.38.

> During 2.6.38 development CAP_SYSLOG has been introduced to perform syslog
> operations, older CAP_SYS_ADMIN is not sufficient anymore.
> [..]

Gergely Nagy wrote:
It's a known issue, but no suitable solution (that doesn't break in
interesting ways under pressure) has been found yet.

Since CAP_SYSLOG breaks userspace, I'm hoping that this will be reverted
before the 2.6.38 release. Though, looking at recent lkml traffic, I'll
have to Cc a few more people regarding the issue.

Hope they"ll come up with the fix.

For me worked the following one. No-brainer, just to make it work.
This is obviously wrong, since brakes portability.

---

diff --git a/modules/affile/affile.c b/modules/affile/affile.c
index e145324..3269c1c 100644
--- a/modules/affile/affile.c
+++ b/modules/affile/affile.c
@@ -60,6 +60,7 @@ affile_open_file(gchar *name, gint flags,
     {
       g_process_cap_modify(CAP_DAC_READ_SEARCH, TRUE);
       g_process_cap_modify(CAP_SYS_ADMIN, TRUE);
+      g_process_cap_modify(CAP_SYSLOG, TRUE);
     }
   else
     {
diff --git a/syslog-ng/main.c b/syslog-ng/main.c
index 9880c1f..6904e6b 100644
--- a/syslog-ng/main.c
+++ b/syslog-ng/main.c
@@ -378,9 +378,11 @@ main(int argc, char *argv[])
   /* NOTE: polling /proc/kmsg requires cap_sys_admin, otherwise it'll always
    * indicate readability. Enabling/disabling cap_sys_admin on every poll
    * invocation seems to be too expensive. So I enable it for now. */

+
+  /* NOTE: Since commit 38ef4c2e437d11b5922723504b62824e96761459 syslog
+   * operations require new CAP_SYSLOG capability, not CAP_SYS_ADMIN. */
   g_process_set_caps("cap_net_bind_service,cap_net_broadcast,cap_net_raw,"
-                     "cap_dac_read_search,cap_dac_override,cap_chown,cap_fowner=p "
+                     "cap_dac_read_search,cap_dac_override,cap_chown,cap_syslog,cap_fowner=p "
                      "cap_sys_admin=ep");
   ctx = g_option_context_new("syslog-ng");
   g_process_add_option_group(ctx);

Friday, January 28, 2011

qemu Ctrl-Alt

While have to work with qemu, I noticed nasty thing - when one often
switches backward-and-forward between guest and host, qemu (or guest?)
goes insane about Left Ctrl key and assumes it's pressed constantly.
Boom, believe me or not, guest becomes totally unusable.

By default qemu use LCtrl-LAlt to grab/release input. I changed it
to RALT - it's not that I use this key much anyway, I'm not even sure I
ever did.

"If you can't live with it - patch it!"

---

diff --git a/ui/sdl.c b/ui/sdl.c
index f599d42..606cc36 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -49,7 +49,7 @@ static int gui_noframe;
 static int gui_key_modifier_pressed;
 static int gui_keysym;
 static int gui_fullscreen_initial_grab;
-static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
+static int gui_grab_code = KMOD_RALT; //KMOD_LALT | KMOD_LCTRL;
 static uint8_t modifiers_state[256];
 static int width, height;
 static SDL_Cursor *sdl_cursor_normal;
@@ -425,7 +425,7 @@ static void sdl_update_caption(void)
         else if (ctrl_grab)
             status = " - Press Right-Ctrl to exit mouse grab";
         else
-            status = " - Press Ctrl-Alt to exit mouse grab";
+            status = " - Press RALT to exit mouse grab"; //" - Press Ctrl-Alt to exit mouse grab";
     }

     if (qemu_name) {

Thursday, January 27, 2011

Fox News "The Internet Is Nearly Out of IP Addresses"

Sometimes you just can't walk around.

The Internet Is Nearly Out of IP Addresses


It's the end of the web as we know it. 
Every Internet-connected computer, smartphone, car, gadget and gizmo is assigned a four-digit IP address that lets it communicate with the net, thanks to a system known as IPv4 (Internet Protocol version 4). And the flood of new gadgets means we're running out of those addresses.
[..]
Web developers have tried to compensate for this problem by creating IPv6 -- a system that recognizes six-digit IP addresses rather than four-digit ones.
[..]
But IPv6 isn't backwards-compatible with IPv4, meaning that it's not able to read most content that operates on an IPv4 system. At best, the user experience will be clunky and slow. At worst, instead of a webpage, all users will be able to view is a blank page.

via Fox News

thanks avva

Make it fun again!

Wednesday, January 26, 2011

gcc-4.6 status report

Jakub Jelinek has published gcc-4.6 status report for 2011-01-26

 

Quality Data
============


Priority # Change from Last Report
-------- --- -----------------------
P1 10 - 21
P2 101 - 8
P3 21 - 7
-------- --- -----------------------
Total 132 - 36


Promising 4.6 features list

Wednesday, January 19, 2011

libcap 2.20

libcap 2.20 just has been released (release notes) by Andrew G Morgan.

  • Latest kernel capabilites supported: now includes CAP_SYSLOG
  • $(CFLAGS) Makefile fixes from Torsten Werner
  • Default to installing setcap with an inheritable capability.
    • You can disable this feature with: make RAISE_SETFCAP=no install

Thursday, January 13, 2011

CAP_SYSLOG

Patches

commit 38ef4c2e437d11b5922723504b62824e96761459
Author: Serge E. Hallyn
Date:   Wed Dec 8 15:19:01 2010 +0000

    syslog: check cap_syslog when dmesg_restrict
   
    Eric Paris pointed out that it doesn't make sense to require
    both CAP_SYS_ADMIN and CAP_SYSLOG for certain syslog actions.
    So require CAP_SYSLOG, not CAP_SYS_ADMIN, when dmesg_restrict
    is set.
   
    (I'm also consolidating the now common error path)
   

commit ce6ada35bdf710d16582cc4869c26722547e6f11
Author: Serge E. Hallyn
Date:   Thu Nov 25 17:11:32 2010 +0000

    security: Define CAP_SYSLOG
   
    Privileged syslog operations currently require CAP_SYS_ADMIN.  Split
    this off into a new CAP_SYSLOG privilege which we can sanely take away
    from a container through the capability bounding set.
   
    With this patch, an lxc container can be prevented from messing with
    the host's syslog (i.e. dmesg -c).
   
    Changelog: mar 12 2010: add selinux capability2:cap_syslog perm
    Changelog: nov 22 2010:
        . port to new kernel
        . add a WARN_ONCE if userspace isn't using CAP_SYSLOG
   

introduced new CAP_SYSLOG capability and changed required capability
for syslog operations from CAP_SYS_ADMIN to CAP_SYSLOG:

int do_syslog(int type, char __user *buf, int len, bool from_file)
{
    [..]
    if (type == SYSLOG_ACTION_OPEN || !from_file) {
        if (dmesg_restrict && !capable(CAP_SYSLOG))
            goto warn; /* switch to return -EPERM after 2.6.39 */
        if ((type != SYSLOG_ACTION_READ_ALL &&
             type != SYSLOG_ACTION_SIZE_BUFFER) &&
            !capable(CAP_SYSLOG))
            goto warn; /* switch to return -EPERM after 2.6.39 */
    }

[...]

It also broke my syslog-ng
[   22.387886] ------------[ cut here ]------------
[   22.387899] WARNING: at kernel/printk.c:429 do_syslog+0x427/0x452()
[   22.387903] Hardware name: Aspire 5741G   
[   22.387905] Attempt to access syslog with CAP_SYS_ADMIN but no CAP_SYSLOG (deprecated and denied).
[..] Call Trace [..]



The problem, is that setcap still don't know about CAP_SYSLOG

# setcap  'cap_sys_admin=+pe' syslog-ng
# setcap  'cap_syslog=+pe' syslog-ng
fatal error: Invalid argument
usage: setcap [-q] [-v] (-r|-|) [ ... (-r|-|) ]

 Note must be a regular (non-symlink) file.

Tuesday, January 4, 2011

Throwing non-throwing operator new

When we write
foo *p = new(std::nothrow) foo;

we still have probability of uncatched bad_alloc.
The following code may look confusing (and it does),
though it works perfect

try {
        p = new(std::nothrow) foo;
} catch (std::bad_alloc&) {
        exit(0); //nevermind
}


The `problem' could be in foo::foo, e.g.
foo::foo() {
        member = new int[0x7fffffff];
}


since nothrow_t works only for outer allocation and
leaves room for bad_alloc in .ctor.

operator new (std::size_t sz, const std::nothrow_t&) throw()
{
  void *p;

  /* malloc (0) is unpredictable; avoid it.  */
  if (sz == 0)
    sz = 1;
  p = (void *) malloc (sz);
  while (p == 0)
    {
      new_handler handler = __new_handler;
      if (! handler)
        return 0;
      __try
        {
          handler ();
        }
      __catch(const bad_alloc&)
        {
          return 0;
        }

      p = (void *) malloc (sz);
    }

  return p;
}