Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1251942

Re: [RFC v3 8/9] kmsg: add predefined _PID, _TID, _COMM keywords to kmsg* log dict

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [RFC v3 8/9] kmsg: add predefined _PID, _TID, _COMM keywords to kmsg* log dict
Date 2015-10-20 20:30 +0200
Message-ID <qlJPA-3lo-19@gated-at.bofh.it> (permalink)
References <qlicF-4P7-7@gated-at.bofh.it> <qlicF-4P7-5@gated-at.bofh.it> <qlmJk-35z-21@gated-at.bofh.it> <qlD7s-258-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Oct 20, 2015 at 4:16 AM, Paul Osmialowski
<p.osmialowsk@samsung.com> wrote:
> Hi Andy,
>
> On Mon, 19 Oct 2015, Andy Lutomirski wrote:
>
>> On Mon, Oct 19, 2015 at 5:58 AM, Paul Osmialowski
>> <p.osmialowsk@samsung.com> wrote:
>>>
>>> From: Marcin Niesluchowski <m.niesluchow@samsung.com>
>>>
>>> kmsg* devices write operation wrote no dict along with message
>>> Due to usage of kmsg devices in userspace dict has been added
>>> identifying pid, tid and comm of writing process.
>>
>>
>> Does this affect even the normal /dev/kmsg?
>
>
> Yes.

Is this okay?  Comm at least is a bit odd.

>
>>
>>> -static int kmsg_sys_write(int minor, int level, const char *fmt, ...)
>>> +static size_t set_kmsg_dict(char *buf)
>>> +{
>>> +       size_t len;
>>> +
>>> +       len = sprintf(buf, "_PID=%d", task_tgid_nr(current)) + 1;
>>> +       len += sprintf(buf + len, "_TID=%d", task_pid_nr(current)) + 1;
>>> +       memcpy(buf + len, "_COMM=", 6);
>>> +       len += 6;
>>> +       get_task_comm(buf + len, current);
>>> +       while (buf[len] != '\0')
>>> +               len++;
>>
>>
>> len += strlen(buf); ?
>>
>> Is it obvious for some reason that this doesn't overflow buf?
>>
>
> KMSG_DICT_MAX_LEN sets architecture-intepentent max size.

And how many things are written and what asserts that it's big enough?

>
>> Why is task_pid_nr acceptable here?  Isn't this intended for use in
>> namespaces?
>>
>
> task_tgid_nr - process id (pid as seen in userspace),
> task_pid_nr - thread id

These are the ids as seen by the global namespace.  If the goal is to
create one of these nodes in some other namespace, then this is the
wrong thing to do.

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[RFC v3 8/9] kmsg: add predefined _PID, _TID,  _COMM keywords to kmsg* log dict Paul Osmialowski <p.osmialowsk@samsung.com> - 2015-10-19 15:00 +0200
  Re: [RFC v3 8/9] kmsg: add predefined _PID, _TID, _COMM keywords to  kmsg* log dict kbuild test robot <lkp@intel.com> - 2015-10-19 16:20 +0200
  Re: [RFC v3 8/9] kmsg: add predefined _PID, _TID, _COMM keywords to  kmsg* log dict Andy Lutomirski <luto@amacapital.net> - 2015-10-19 19:50 +0200
    Re: [RFC v3 8/9] kmsg: add predefined _PID, _TID,  _COMM keywords to kmsg* log dict Paul Osmialowski <p.osmialowsk@samsung.com> - 2015-10-20 13:20 +0200
      Re: [RFC v3 8/9] kmsg: add predefined _PID, _TID, _COMM keywords to  kmsg* log dict Andy Lutomirski <luto@amacapital.net> - 2015-10-20 20:30 +0200

csiph-web