Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1231304
| From | Vladimir Davydov <vdavydov@parallels.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [patch] mm, oom: remove task_lock protecting comm printing |
| Date | 2015-09-23 12:10 +0200 |
| Message-ID | <qbP9T-Z0-17@gated-at.bofh.it> (permalink) |
| References | (1 earlier) <qbNhL-6K3-3@gated-at.bofh.it> <qbOnw-8gf-13@gated-at.bofh.it> <qbOGS-bd-39@gated-at.bofh.it> <qbOQy-mP-15@gated-at.bofh.it> <qbOQy-mP-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Sep 23, 2015 at 06:50:22PM +0900, Sergey Senozhatsky wrote: > On (09/23/15 11:43), Michal Hocko wrote: > [..] > > > > the previous name was already null terminated, > > > > > > Yeah, but if the old name is shorter than the new one, set_task_comm() > > > overwrites the terminating null of the old name before writing the new > > > terminating null, so there is a short time window during which tsk->comm > > > might be not null-terminated, no? > > > > Not really: > > case PR_SET_NAME: > > comm[sizeof(me->comm) - 1] = 0; > > if (strncpy_from_user(comm, (char __user *)arg2, > > sizeof(me->comm) - 1) < 0) > > return -EFAULT; > > > > So it first writes the terminating 0 and only then starts copying. It writes 0 to a temporary buffer, not to tsk->comm, so I don't think it's related. However, reading tsk->comm w/o locking must be safe anyway, because tsk->comm[TASK_COMM_LEN-1] is always 0 (inherited from init_task) and it never gets overwritten, because __set_task_comm() uses strlcpy(). > > right. > > hm, shouldn't set_task_comm()->__set_task_comm() do the same? I don't think so - see above. Thanks, Vladimir -- 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 | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[patch] mm, oom: remove task_lock protecting comm printing David Rientjes <rientjes@google.com> - 2015-09-23 01:40 +0200
Re: [patch] mm, oom: remove task_lock protecting comm printing Michal Hocko <mhocko@kernel.org> - 2015-09-23 09:50 +0200
Re: [patch] mm, oom: remove task_lock protecting comm printing Vladimir Davydov <vdavydov@parallels.com> - 2015-09-23 10:10 +0200
Re: [patch] mm, oom: remove task_lock protecting comm printing Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-09-23 11:20 +0200
Re: [patch] mm, oom: remove task_lock protecting comm printing Vladimir Davydov <vdavydov@parallels.com> - 2015-09-23 11:40 +0200
Re: [patch] mm, oom: remove task_lock protecting comm printing Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-09-23 11:50 +0200
Re: [patch] mm, oom: remove task_lock protecting comm printing Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-09-23 12:00 +0200
Re: [patch] mm, oom: remove task_lock protecting comm printing Vladimir Davydov <vdavydov@parallels.com> - 2015-09-23 12:10 +0200
Re: [patch] mm, oom: remove task_lock protecting comm printing Michal Hocko <mhocko@kernel.org> - 2015-09-23 12:50 +0200
Re: [patch] mm, oom: remove task_lock protecting comm printing Michal Hocko <mhocko@kernel.org> - 2015-09-23 11:50 +0200
Re: [patch] mm, oom: remove task_lock protecting comm printing Johannes Weiner <hannes@cmpxchg.org> - 2015-09-24 21:50 +0200
csiph-web