1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (c) International Business Machines Corp., 2001 4 * 07/2001 Ported by Wayne Boyer 5 * Copyright (c) 2022 SUSE LLC Avinesh Kumar <avinesh.kumar@suse.com> 6 */ 7 8/*\ 9 * [Description] 10 * 11 * Verify that rename(2) fails with EFAULT, when 12 * oldpath or newpath points outside of accessible address space. 13 */ 14 15#include <stdio.h> 16#include "tst_test.h" 17 18#define MNT_POINT "mntpoint" 19#define TEMP_FILE "tmpfile" 20#define INVALID_PATH ((void *)-1) 21 22static void setup(void) 23{ 24 SAFE_CHDIR(MNT_POINT); 25 SAFE_TOUCH(TEMP_FILE, 0700, NULL); 26} 27 28static void run(void) 29{ 30 TST_EXP_FAIL(rename(INVALID_PATH, TEMP_FILE), 31 EFAULT); 32 TST_EXP_FAIL(rename(TEMP_FILE, INVALID_PATH), 33 EFAULT); 34} 35 36static struct tst_test test = { 37 .setup = setup, 38 .test_all = run, 39 .needs_root = 1, 40 .mount_device = 1, 41 .mntpoint = MNT_POINT, 42 .all_filesystems = 1 43}; 44