Skip to content

Commit d0edd85

Browse files
Davidlohr Buesotorvalds
authored andcommitted
ipc: convert invalid scenarios to use WARN_ON
Considering Linus' past rants about the (ab)use of BUG in the kernel, I took a look at how we deal with such calls in ipc. Given that any errors or corruption in ipc code are most likely contained within the set of processes participating in the broken mechanisms, there aren't really many strong fatal system failure scenarios that would require a BUG call. Also, if something is seriously wrong, ipc might not be the place for such a BUG either. 1. For example, recently, a customer hit one of these BUG_ONs in shm after failing shm_lock(). A busted ID imho does not merit a BUG_ON, and WARN would have been better. 2. MSG_COPY functionality of posix msgrcv(2) for checkpoint/restore. I don't see how we can hit this anyway -- at least it should be IS_ERR. The 'copy' arg from do_msgrcv is always set by calling prepare_copy() first and foremost. We could also probably drop this check altogether. Either way, it does not merit a BUG_ON. 3. No ->fault() callback for the fs getting the corresponding page -- seems selfish to make the system unusable. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Cc: Manfred Spraul <manfred@colorfullife.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 8b235f2 commit d0edd85

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎ipc/msgutil.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst)
123123
size_t len = src->m_ts;
124124
size_t alen;
125125

126-
BUG_ON(dst == NULL);
126+
WARN_ON(dst == NULL);
127127
if (src->m_ts > dst->m_ts)
128128
return ERR_PTR(-EINVAL);
129129

‎ipc/shm.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id)
159159
* We raced in the idr lookup or with shm_destroy(). Either way, the
160160
* ID is busted.
161161
*/
162-
BUG_ON(IS_ERR(ipcp));
162+
WARN_ON(IS_ERR(ipcp));
163163

164164
return container_of(ipcp, struct shmid_kernel, shm_perm);
165165
}
@@ -393,7 +393,7 @@ static int shm_mmap(struct file *file, struct vm_area_struct *vma)
393393
return ret;
394394
sfd->vm_ops = vma->vm_ops;
395395
#ifdef CONFIG_MMU
396-
BUG_ON(!sfd->vm_ops->fault);
396+
WARN_ON(!sfd->vm_ops->fault);
397397
#endif
398398
vma->vm_ops = &shm_vm_ops;
399399
shm_open(vma);

0 commit comments

Comments
 (0)