media: rc: bpf attach/detach requires write permission
Subsystems (3)
Sean Young
maintainerPATCH v2 1/1 media: rc: bpf attach/detach requires write permission
Note that bpf attach/detach also requires CAP_NET_ADMIN.
--- drivers/media/rc/bpf-lirc.c | 6 +++--- drivers/media/rc/lirc_dev.c | 5 ++++- drivers/media/rc/rc-core-priv.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/media/rc/bpf-lirc.c +3 -3
@@ -253,7 +253,7 @@ int lirc_prog_attach(const union bpf_attr *attr, struct bpf_prog *prog)if (attr->attach_flags)return -EINVAL ; - rcdev =rc_dev_get_from_fd (attr->target_fd); + rcdev =rc_dev_get_from_fd (attr->target_fd, true);if (IS_ERR (rcdev))return PTR_ERR (rcdev);
@@ -278,7 +278,7 @@ int lirc_prog_detach(const union bpf_attr *attr)if (IS_ERR (prog))return PTR_ERR (prog); - rcdev =rc_dev_get_from_fd (attr->target_fd); + rcdev =rc_dev_get_from_fd (attr->target_fd, true);if (IS_ERR (rcdev)) {bpf_prog_put (prog);return PTR_ERR (rcdev);
@@ -303,7 +303,7 @@ int lirc_prog_query(const union bpf_attr *attr, union bpf_attr __user *uattr)if (attr->query.query_flags)return -EINVAL ; - rcdev =rc_dev_get_from_fd (attr->query.target_fd); + rcdev =rc_dev_get_from_fd (attr->query.target_fd, false);if (IS_ERR (rcdev))return PTR_ERR (rcdev);
drivers/media/rc/lirc_dev.c +4 -1
@@ -810,7 +810,7 @@ void __exit lirc_dev_exit(void)unregister_chrdev_region (lirc_base_dev,RC_DEV_MAX ); } -struct rc_dev *rc_dev_get_from_fd (int fd) +struct rc_dev *rc_dev_get_from_fd (int fd,bool write) {struct fd f =fdget (fd);struct lirc_fh *fh;
@@ -824,6 +824,9 @@ struct rc_dev *rc_dev_get_from_fd(int fd)return ERR_PTR (-EINVAL ); } +if (write && !(f.file->f_mode &FMODE_WRITE )) +return ERR_PTR (-EPERM ); + fh = f.file->private_data; dev = fh->rc;
drivers/media/rc/rc-core-priv.h +1 -1
@@ -325,7 +325,7 @@ void lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev);void lirc_scancode_event (struct rc_dev *dev,struct lirc_scancode *lsc);int lirc_register (struct rc_dev *dev);void lirc_unregister (struct rc_dev *dev); -struct rc_dev *rc_dev_get_from_fd (int fd); +struct rc_dev *rc_dev_get_from_fd (int fd,bool write);#else static inline int lirc_dev_init (void ) {return 0 ; }static inline void lirc_dev_exit (void ) {}
Signature · 1 line
2.39.2
Greg KH
maintainerQuoted 10 lines · Sean Young
Note that bpf attach/detach also requires
CAP_NET_ADMIN.Signed-off-by Sean Young <[email protected]>--- drivers/media/rc/bpf-lirc.c | 6 +++--- drivers/media/rc/lirc_dev.c | 5 ++++- drivers/media/rc/rc-core-priv.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-)
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.
You are receiving this message because of the following common error(s) as indicated below:
- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this.
If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.
thanks,
greg k-h's patch email bot