Re: [PATCH] bcache: avoid a dangerous addressing in closure_queue

2017-07-05 Thread Christoph Hellwig
On Thu, Jul 06, 2017 at 08:18:02AM +0800, Liang Chen wrote: > But as you pointed out, explicit casting is still bad too (was hoping it can > be > considered less bad at this situation). I will think of a better idea > to handle this > issue unless people agree that the current behaviour is safe.

Re: [PATCH] bcache: avoid a dangerous addressing in closure_queue

2017-07-05 Thread Liang Chen
I had the same feeling, and was reluctant to do so. The reason for making this change was that current code implicitly converts work_func_t to closure_fn, and it also depends on the offset and size of a few struct not being changed. So the patch was introduced essentially to solve that, and keep th

Re: [PATCH] bcache: avoid a dangerous addressing in closure_queue

2017-07-05 Thread Christoph Hellwig
On Wed, Jul 05, 2017 at 08:53:19PM +0800, Liang Chen wrote: > The use of the union reduces the size of closure struct by taking advantage > of the current size of its members. The offset of func in work_struct equals > the size of the first three members, so that work.work_func will just > referenc

[PATCH] bcache: avoid a dangerous addressing in closure_queue

2017-07-05 Thread Liang Chen
The use of the union reduces the size of closure struct by taking advantage of the current size of its members. The offset of func in work_struct equals the size of the first three members, so that work.work_func will just reference the forth member - the pointer to closure_fn. This is smart but d