Revision 9c1c2b35f1d94de8325344c2777d7ee67492db3b authored by Jeff Layton on 03 April 2019, 17:16:01 UTC, committed by Ilya Dryomov on 21 January 2020, 18:02:37 UTC
Currently, we just assume that it will stick around by virtue of the
submitter's reference, but later patches will allow the syscall to
return early and we can't rely on that reference at that point.

While I'm not aware of any reports of it, Xiubo pointed out that this
may fix a use-after-free.  If the wait for a reply times out or is
canceled via signal, and then the reply comes in after the syscall
returns, the client can end up trying to access r_parent without a
reference.

Take an extra reference to the inode when setting r_parent and release
it when releasing the request.

Cc: stable@vger.kernel.org
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent def9d27
Raw File
n2_asm.S
/* SPDX-License-Identifier: GPL-2.0 */
/* n2_asm.S: Hypervisor calls for NCS support.
 *
 * Copyright (C) 2009 David S. Miller <davem@davemloft.net>
 */

#include <linux/linkage.h>
#include <asm/hypervisor.h>
#include "n2_core.h"

	/* o0: queue type
	 * o1: RA of queue
	 * o2: num entries in queue
	 * o3: address of queue handle return
	 */
ENTRY(sun4v_ncs_qconf)
	mov	HV_FAST_NCS_QCONF, %o5
	ta	HV_FAST_TRAP
	stx	%o1, [%o3]
	retl
	 nop
ENDPROC(sun4v_ncs_qconf)

	/* %o0: queue handle
	 * %o1: address of queue type return
	 * %o2: address of queue base address return
	 * %o3: address of queue num entries return
	 */
ENTRY(sun4v_ncs_qinfo)
	mov	%o1, %g1
	mov	%o2, %g2
	mov	%o3, %g3
	mov	HV_FAST_NCS_QINFO, %o5
	ta	HV_FAST_TRAP
	stx	%o1, [%g1]
	stx	%o2, [%g2]
	stx	%o3, [%g3]
	retl
	 nop
ENDPROC(sun4v_ncs_qinfo)

	/* %o0: queue handle
	 * %o1: address of head offset return
	 */
ENTRY(sun4v_ncs_gethead)
	mov	%o1, %o2
	mov	HV_FAST_NCS_GETHEAD, %o5
	ta	HV_FAST_TRAP
	stx	%o1, [%o2]
	retl
	 nop
ENDPROC(sun4v_ncs_gethead)

	/* %o0: queue handle
	 * %o1: address of tail offset return
	 */
ENTRY(sun4v_ncs_gettail)
	mov	%o1, %o2
	mov	HV_FAST_NCS_GETTAIL, %o5
	ta	HV_FAST_TRAP
	stx	%o1, [%o2]
	retl
	 nop
ENDPROC(sun4v_ncs_gettail)

	/* %o0: queue handle
	 * %o1: new tail offset
	 */
ENTRY(sun4v_ncs_settail)
	mov	HV_FAST_NCS_SETTAIL, %o5
	ta	HV_FAST_TRAP
	retl
	 nop
ENDPROC(sun4v_ncs_settail)

	/* %o0: queue handle
	 * %o1: address of devino return
	 */
ENTRY(sun4v_ncs_qhandle_to_devino)
	mov	%o1, %o2
	mov	HV_FAST_NCS_QHANDLE_TO_DEVINO, %o5
	ta	HV_FAST_TRAP
	stx	%o1, [%o2]
	retl
	 nop
ENDPROC(sun4v_ncs_qhandle_to_devino)

	/* %o0: queue handle
	 * %o1: new head offset
	 */
ENTRY(sun4v_ncs_sethead_marker)
	mov	HV_FAST_NCS_SETHEAD_MARKER, %o5
	ta	HV_FAST_TRAP
	retl
	 nop
ENDPROC(sun4v_ncs_sethead_marker)
back to top