Skip to content

Commit 59cf0a9

Browse files
keesgregkh
authored andcommitted
ipc/shm.c: use ERR_CAST() for shm_lock() error return
This uses ERR_CAST() instead of an open-coded cast, as it is casting across structure pointers, which upsets __randomize_layout: ipc/shm.c: In function `shm_lock': ipc/shm.c:209:9: note: randstruct: casting between randomized structure pointer types (ssa): `struct shmid_kernel' and `struct kern_ipc_perm' return (void *)ipcp; ^~~~~~~~~~~~ Link: http://lkml.kernel.org/r/20180919180722.GA15073@beast Fixes: 82061c5 ("ipc: drop ipc_lock()") Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Davidlohr Bueso <dbueso@suse.de> Cc: Manfred Spraul <manfred@colorfullife.com> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5189686 commit 59cf0a9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ipc/shm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id)
206206
* Callers of shm_lock() must validate the status of the returned ipc
207207
* object pointer and error out as appropriate.
208208
*/
209-
return (void *)ipcp;
209+
return ERR_CAST(ipcp);
210210
}
211211

212212
static inline void shm_lock_by_ptr(struct shmid_kernel *ipcp)

0 commit comments

Comments
 (0)