stream_open related bits for Linux 5.3

- the first one converts stream_open.cocci to treat all functions that
   start with wait_.* as blocking. Previously it was only wait_event_.*
   functions that were considered as blocking, but this was falsely
   reporting several deadlock cases as only warning. The patch was
   picked by linux-kbuild and entered mainline as 0c4ab18fc3.
   It is thus omitted from hereby pull-request.
 
 - the second one teaches stream_open.cocci to consider files as being
   stream-like even if they use noop_llseek. I posted this patch for
   review 3 weeks ago[1], but got neither feedback nor complaints.
 
   [1] https://lore.kernel.org/lkml/20190623072838.31234-2-kirr@nexedi.com/
 -----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEECVWwJCUO7/z+QjZbZsp4hBP2dUkFAl0rMVkQHGtpcnJAbmV4
 ZWRpLmNvbQAKCRBmyniEE/Z1SU1MD/wKv/EEGzHPXU1vFFBpOAMW4ko06vf/cqxW
 egRFKxKYIw7rVan3T/ONo0Bs2gnw4zGR5bzOmnmFOLqgmpN0OCVjirVVwGj1anxg
 cM0NF9KL/qW06dN2G5/T4eFw8BltdsCuinmmE0uJvSp/2qZ/oxUvb4ZK7oxs5BF8
 kzRF+K/rFiqAklHvkPV7WFQitTzmcxEiCACg9ZZOFRjj1Ryt7kUUh/2NA7OCF7kd
 JKmHIIv1iyN5vDmtXh0gSZiM+hBNwcEyQFOoA9TqMT2nOl5caf56PlefNGAmUTsZ
 TY8dw/g7raU6SZodqZrmMM7HSWp2bnA8hfDx8gIgBbSd01UF6fbg4xBoyM7VXUy1
 4QClRBAI2vlPqjpy7qEeJM7VP605UxQj/6gUd+b/luaWLBUBf0N/pUiNgXjAcCxl
 JkEUDAdwQlUh0RErJIKAfWS7APwptiM5PUF7meKKRWQXMRoFHFU2ayUVHmvleJFR
 /qrfuNTota261XRbN/e4rghkh7M/1vIYuCNYGZVr3Sdd32ehzNKjwFlDo8/co/BS
 s9hC155gxqUZUGp0K86i9WLiuO9bUhD54k0HXZXYXDY65yF0Sp8+6CEMsEoTc6r3
 OckTw3tYxOi895PqLXXB2g4h76Y3cx43K0S4CjCi97ITpEK9fT6sNwq59EX2LsYR
 6NeXFAxYcQ==
 =CWqT
 -----END PGP SIGNATURE-----

Merge tag 'stream_open-5.3' of https://lab.nexedi.com/kirr/linux

Pull stream_open() updates from Kirill Smelkov:
 "This time on stream_open front it is only two small changes:

   - the first one converts stream_open.cocci to treat all functions
     that start with wait_.* as blocking. Previously it was only
     wait_event_.* functions that were considered as blocking, but this
     was falsely reporting several deadlock cases as only warning.

     This was picked by linux-kbuild and entered mainline as commit
     0c4ab18fc3 ("coccinelle: api/stream_open: treat all wait_.*()
     calls as blocking"), and already merged earlier.

   - the second one teaches stream_open.cocci to consider files as being
     stream-like even if they use noop_llseek. It results in two more
     drivers being converted to stream_open() (mousedev.c and
     hid-sensor-custom.c)"

* tag 'stream_open-5.3' of https://lab.nexedi.com/kirr/linux:
  *: convert stream-like files -> stream_open, even if they use noop_llseek
This commit is contained in:
Linus Torvalds 2019-07-14 17:08:08 -07:00
commit fcd98147ac
3 changed files with 10 additions and 3 deletions

View File

@ -687,7 +687,7 @@ static int hid_sensor_custom_open(struct inode *inode, struct file *file)
if (test_and_set_bit(0, &sensor_inst->misc_opened))
return -EBUSY;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static __poll_t hid_sensor_custom_poll(struct file *file,

View File

@ -558,7 +558,7 @@ static int mousedev_open(struct inode *inode, struct file *file)
goto err_free_client;
file->private_data = client;
nonseekable_open(inode, file);
stream_open(inode, file);
return 0;

View File

@ -134,6 +134,13 @@ identifier fops0.fops;
.llseek = no_llseek,
};
@ has_noop_llseek @
identifier fops0.fops;
@@
struct file_operations fops = {
.llseek = noop_llseek,
};
@ has_mmap @
identifier fops0.fops;
identifier mmap_f;
@ -180,7 +187,7 @@ identifier splice_write_f;
//
// XXX for simplicity require no .{read/write}_iter and no .splice_{read/write} for now.
// XXX maybe_steam.fops cannot be used in other rules - it gives "bad rule maybe_stream or bad variable fops".
@ maybe_stream depends on (!has_llseek || has_no_llseek) && !has_mmap && !has_copy_file_range && !has_remap_file_range && !has_read_iter && !has_write_iter && !has_splice_read && !has_splice_write @
@ maybe_stream depends on (!has_llseek || has_no_llseek || has_noop_llseek) && !has_mmap && !has_copy_file_range && !has_remap_file_range && !has_read_iter && !has_write_iter && !has_splice_read && !has_splice_write @
identifier fops0.fops;
@@
struct file_operations fops = {