@@ -662,7 +662,7 @@ static ssize_t msg_print_ext_body(char *buf, size_t size,
662
662
663
663
/* /dev/kmsg - userspace message inject/listen interface */
664
664
struct devkmsg_user {
665
- u64 seq ;
665
+ atomic64_t seq ;
666
666
struct ratelimit_state rs ;
667
667
struct mutex lock ;
668
668
char buf [CONSOLE_EXT_LOG_MAX ];
@@ -763,7 +763,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
763
763
return ret ;
764
764
765
765
logbuf_lock_irq ();
766
- if (!prb_read_valid (prb , user -> seq , r )) {
766
+ if (!prb_read_valid (prb , atomic64_read ( & user -> seq ) , r )) {
767
767
if (file -> f_flags & O_NONBLOCK ) {
768
768
ret = - EAGAIN ;
769
769
logbuf_unlock_irq ();
@@ -772,15 +772,15 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
772
772
773
773
logbuf_unlock_irq ();
774
774
ret = wait_event_interruptible (log_wait ,
775
- prb_read_valid (prb , user -> seq , r ));
775
+ prb_read_valid (prb , atomic64_read ( & user -> seq ) , r ));
776
776
if (ret )
777
777
goto out ;
778
778
logbuf_lock_irq ();
779
779
}
780
780
781
- if (r -> info -> seq != user -> seq ) {
781
+ if (r -> info -> seq != atomic64_read ( & user -> seq ) ) {
782
782
/* our last seen message is gone, return error and reset */
783
- user -> seq = r -> info -> seq ;
783
+ atomic64_set ( & user -> seq , r -> info -> seq ) ;
784
784
ret = - EPIPE ;
785
785
logbuf_unlock_irq ();
786
786
goto out ;
@@ -791,7 +791,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
791
791
& r -> text_buf [0 ], r -> info -> text_len ,
792
792
& r -> info -> dev_info );
793
793
794
- user -> seq = r -> info -> seq + 1 ;
794
+ atomic64_set ( & user -> seq , r -> info -> seq + 1 ) ;
795
795
logbuf_unlock_irq ();
796
796
797
797
if (len > count ) {
@@ -831,19 +831,19 @@ static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)
831
831
switch (whence ) {
832
832
case SEEK_SET :
833
833
/* the first record */
834
- user -> seq = prb_first_valid_seq (prb );
834
+ atomic64_set ( & user -> seq , prb_first_valid_seq (prb ) );
835
835
break ;
836
836
case SEEK_DATA :
837
837
/*
838
838
* The first record after the last SYSLOG_ACTION_CLEAR,
839
839
* like issued by 'dmesg -c'. Reading /dev/kmsg itself
840
840
* changes no global state, and does not clear anything.
841
841
*/
842
- user -> seq = latched_seq_read_nolock (& clear_seq );
842
+ atomic64_set ( & user -> seq , latched_seq_read_nolock (& clear_seq ) );
843
843
break ;
844
844
case SEEK_END :
845
845
/* after the last record */
846
- user -> seq = prb_next_seq (prb );
846
+ atomic64_set ( & user -> seq , prb_next_seq (prb ) );
847
847
break ;
848
848
default :
849
849
ret = - EINVAL ;
@@ -864,9 +864,9 @@ static __poll_t devkmsg_poll(struct file *file, poll_table *wait)
864
864
poll_wait (file , & log_wait , wait );
865
865
866
866
logbuf_lock_irq ();
867
- if (prb_read_valid_info (prb , user -> seq , & info , NULL )) {
867
+ if (prb_read_valid_info (prb , atomic64_read ( & user -> seq ) , & info , NULL )) {
868
868
/* return error when data has vanished underneath us */
869
- if (info .seq != user -> seq )
869
+ if (info .seq != atomic64_read ( & user -> seq ) )
870
870
ret = EPOLLIN |EPOLLRDNORM |EPOLLERR |EPOLLPRI ;
871
871
else
872
872
ret = EPOLLIN |EPOLLRDNORM ;
@@ -905,7 +905,7 @@ static int devkmsg_open(struct inode *inode, struct file *file)
905
905
& user -> text_buf [0 ], sizeof (user -> text_buf ));
906
906
907
907
logbuf_lock_irq ();
908
- user -> seq = prb_first_valid_seq (prb );
908
+ atomic64_set ( & user -> seq , prb_first_valid_seq (prb ) );
909
909
logbuf_unlock_irq ();
910
910
911
911
file -> private_data = user ;
0 commit comments