ipc,sysv: return -EINVAL upon incorrect id/seqnum
authorDavidlohr Bueso <[email protected]>
Tue, 30 Jun 2015 21:58:48 +0000 (14:58 -0700)
committerLinus Torvalds <[email protected]>
Wed, 1 Jul 2015 02:44:59 +0000 (19:44 -0700)
In ipc_obtain_object_check we return -EIDRM when a bogus sequence number
is detected via ipc_checkid, while the ipc manpages state the following
return codes for such errors:

   EIDRM  <ID> points to a removed identifier.
   EINVAL Invalid <ID> value, or unaligned, etc.

EIDRM should only be returned upon a RMID call (->deleted check), and thus
return EINVAL for wrong seq.  This difference in semantics has also caused
real bugs, ie: https://bugzilla.redhat.com/show_bug.cgi?id=246509

Signed-off-by: Davidlohr Bueso <[email protected]>
Cc: Manfred Spraul <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
ipc/util.c

index b99038699feeb04a5992f7ab345330d8b6b19863..be4230020a1f718c31b02012554600c710b928b9 100644 (file)
@@ -622,7 +622,7 @@ struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id)
                goto out;
 
        if (ipc_checkid(out, id))
-               return ERR_PTR(-EIDRM);
+               return ERR_PTR(-EINVAL);
 out:
        return out;
 }