aboutsummaryrefslogtreecommitdiffstats
path: root/sys/linux/dev_cdrom.txt
blob: 1eec5d0b9b547b3dc6d671d4bcc43bb2c7c94c3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# Copyright 2018 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

# For fuzzing with qemu you need to enable cdrom option and provide an iso image.
# For example: in "vm" section of syzkaller configuration
# "vm" : {
#     ...
#     "cmdline": " -cdrom /.../ubuntu-18.04-desktop-amd64.iso "
# }
# In the kernel CONFIG_CDROM should be enabled.
#
# For more effective fuzzing one might want to disable
# CDROMEJECT && CDROMEJECT_SW.
# "disable_syscalls" : [ "ioctl$CDROMEJECT*" ]

include <linux/cdrom.h>
include <uapi/linux/cdrom.h>

resource fd_cdrom[fd]

openat$cdrom(fd const[AT_FDCWD], file ptr[in, string["/dev/cdrom"]], flags flags[open_flags], mode const[0]) fd_cdrom
openat$cdrom1(fd const[AT_FDCWD], file ptr[in, string["/dev/cdrom1"]], flags flags[open_flags], mode const[0]) fd_cdrom

ioctl$CDROMPAUSE(fd fd_cdrom, cmd const[CDROMPAUSE])
ioctl$CDROMRESUME(fd fd_cdrom, cmd const[CDROMRESUME])
ioctl$CDROMPLAYMSF(fd fd_cdrom, cmd const[CDROMPLAYMSF], arg ptr[in, cdrom_msf])
ioctl$CDROMPLAYTRKIND(fd fd_cdrom, cmd const[CDROMPLAYTRKIND], arg ptr[in, cdrom_ti])
ioctl$CDROMREADTOCHDR(fd fd_cdrom, cmd const[CDROMREADTOCHDR], arg ptr[inout, cdrom_tochdr])
ioctl$CDROMREADTOCENTRY(fd fd_cdrom, cmd const[CDROMREADTOCENTRY], arg ptr[inout, cdrom_tocentry])
ioctl$CDROMSTOP(fd fd_cdrom, cmd const[CDROMSTOP])
ioctl$CDROMSTART(fd fd_cdrom, cmd const[CDROMSTART])
ioctl$CDROMEJECT(fd fd_cdrom, cmd const[CDROMEJECT])
ioctl$CDROMVOLCTRL(fd fd_cdrom, cmd const[CDROMVOLCTRL], arg ptr[in, cdrom_volctrl])
ioctl$CDROMSUBCHNL(fd fd_cdrom, cmd const[CDROMSUBCHNL], arg ptr[inout, cdrom_subchnl])
ioctl$CDROMREADMODE2(fd fd_cdrom, cmd const[CDROMREADMODE2], arg ptr[in, cdrom_msf_out_stub])
ioctl$CDROMREADMODE1(fd fd_cdrom, cmd const[CDROMREADMODE1], arg ptr[in, cdrom_msf_out_stub])
ioctl$CDROMREADAUDIO(fd fd_cdrom, cmd const[CDROMREADAUDIO], arg ptr[in, cdrom_read_audio])
ioctl$CDROMEJECT_SW(fd fd_cdrom, cmd const[CDROMEJECT_SW], arg boolptr)
ioctl$CDROMMULTISESSION(fd fd_cdrom, cmd const[CDROMMULTISESSION], arg ptr[inout, cdrom_multisession])
ioctl$CDROM_GET_MCN(fd fd_cdrom, cmd const[CDROM_GET_MCN], arg ptr[out, cdrom_mcn])
ioctl$CDROMRESET(fd fd_cdrom, cmd const[CDROMRESET])
ioctl$CDROMVOLREAD(fd fd_cdrom, cmd const[CDROMVOLREAD], arg ptr[out, cdrom_volctrl])
ioctl$CDROMREADRAW(fd fd_cdrom, cmd const[CDROMREADRAW], arg ptr[in, cdrom_msf_out_stub])

ioctl$CDROMREADCOOKED(fd fd_cdrom, cmd const[CDROMREADCOOKED], arg ptr[out, cdrom_output_buffer])
ioctl$CDROMSEEK(fd fd_cdrom, cmd const[CDROMSEEK], arg ptr[in, cdrom_msf])

ioctl$CDROMPLAYBLK(fd fd_cdrom, cmd const[CDROMPLAYBLK], arg ptr[in, cdrom_blk])

ioctl$CDROMREADALL(fd fd_cdrom, cmd const[CDROMREADALL], arg ptr[out, cdrom_output_buffer])

ioctl$CDROMGETSPINDOWN(fd fd_cdrom, cmd const[CDROMGETSPINDOWN], arg ptr[out, int8])
ioctl$CDROMSETSPINDOWN(fd fd_cdrom, cmd const[CDROMSETSPINDOWN], arg ptr[in, int8[0:15]])

ioctl$CDROMCLOSETRAY(fd fd_cdrom, cmd const[CDROMCLOSETRAY])

ioctl$CDROM_SET_OPTIONS(fd fd_cdrom, cmd const[CDROM_SET_OPTIONS], arg flags[cdrom_options])
ioctl$CDROM_CLEAR_OPTIONS(fd fd_cdrom, cmd const[CDROM_CLEAR_OPTIONS], arg flags[cdrom_options])
ioctl$CDROM_SELECT_SPEED(fd fd_cdrom, cmd const[CDROM_SELECT_SPEED], speed intptr)
ioctl$CDROM_SELECT_DISK(fd fd_cdrom, cmd const[CDROM_SELECT_SPEED], disk intptr)
ioctl$CDROM_MEDIA_CHANGED(fd fd_cdrom, cmd const[CDROM_MEDIA_CHANGED], slot intptr)
ioctl$CDROM_DISC_STATUS(fd fd_cdrom, cmd const[CDROM_DISC_STATUS])
ioctl$CDROM_CHANGER_NSLOTS(fd fd_cdrom, cmd const[CDROM_CHANGER_NSLOTS])
ioctl$CDROM_LOCKDOOR(fd fd_cdrom, cmd const[CDROM_LOCKDOOR], lock boolptr)
ioctl$CDROM_DEBUG(fd fd_cdrom, cmd const[CDROM_DEBUG], debug boolptr)
ioctl$CDROM_GET_CAPABILITY(fd fd_cdrom, cmd const[CDROM_GET_CAPABILITY])

ioctl$DVD_READ_STRUCT(fd fd_cdrom, cmd const[DVD_READ_STRUCT], arg ptr[inout, dvd_struct])
ioctl$DVD_WRITE_STRUCT(fd fd_cdrom, cmd const[DVD_READ_STRUCT], arg ptr[in, dvd_struct])
ioctl$DVD_AUTH(fd fd_cdrom, cmd const[DVD_READ_STRUCT], arg ptr[inout, dvd_authinfo])

ioctl$CDROM_SEND_PACKET(fd fd_cdrom, cmd const[CDROM_SEND_PACKET], arg ptr[inout, cdrom_generic_command])

ioctl$CDROM_NEXT_WRITABLE(fd fd_cdrom, cmd const[CDROM_NEXT_WRITABLE], arg ptr[out, int64])
ioctl$CDROM_LAST_WRITTEN(fd fd_cdrom, cmd const[CDROM_LAST_WRITTEN], arg ptr[out, int64])

type cdrom_output_buffer array[int8, CD_FRAMESIZE_RAWER]

cdrom_msf {
	cdmsf_min0	int8
	cdmsf_sec0	int8
	cdmsf_frame0	int8
	cdmsf_min1	int8
	cdmsf_sec1	int8
	cdmsf_frame1	int8
}

cdrom_msf_out_stub {
	cdmsf_min0	int8
	cdmsf_sec0	int8
	cdmsf_frame0	int8
	cdmsf_min1	int8
	cdmsf_sec1	int8
	cdmsf_frame1	int8
	reserved	array[const[0, int8], CDROM_MSF_OUT_STUB_SIZE]
}

cdrom_ti {
	cdti_trk0	int8
	cdti_int0	int8
	cdti_trk1	int8
	cdti_ind1	int8
}

cdrom_tochdr {
	cdth_trk0	int8
	cdth_trk1	int8
}

cdrom_tocentry {
	cdte_track	int8
	cdte_adr	int8:4
	cdte_ctrl	int8:4
	cdte_format	flags[cdrom_format, int8]
	cdte_addr	cdrom_addr
	cdte_datamode	int8
}

cdrom_addr [
	msf	cdrom_msf0
	lba	int32
]

cdrom_msf0 {
	minute	int8
	second	int8
	frame	int8
}

cdrom_read_audio {
	addr		cdrom_addr
	addr_format	flags[cdrom_format, int8]
	nframes		bytesize[buf, int32]
	buf		ptr[out, array[int8, 1:CD_FRAMES]]
}

cdrom_volctrl {
	channel0	int8
	channel1	int8
	channel2	int8
	channel3	int8
}

cdrom_subchnl {
	cdsc_format		flags[cdrom_format, int8]
	cdsc_audiostatus	int8
	cdsc_adr		int8:4
	cdsc_ctrl		int8:4
	cdsc_trk		int8
	cdsc_ind		int8
	cdsc_absaddr		cdrom_addr
	cdsc_reladdr		cdrom_addr
}

cdrom_multisession {
	addr		cdrom_addr
	xa_flag		bool8
	addr_format	flags[cdrom_format, int8]
}

cdrom_mcn {
	medium_catalog_number	array[int8, 14]
}

cdrom_blk {
	from	int32
	len	int16
}

dvd_struct [
	type		flags[dvd_struct_type, int8]

	physical	dvd_physical
	copyright	dvd_copyright
	disckey		dvd_disckey
	bca		dvd_bca
	manufact	dvd_manufact
]

dvd_physical {
	type		const[DVD_STRUCT_PHYSICAL, int8]
	layer_num	int8[0:3]
	layer		array[dvd_layer, DVD_LAYERS]
}

dvd_layer {
	book_version	int8:4
	book_type	int8:4
	min_rate	int8:4
	disc_size	int8:4
	layer_type	int8:4
	track_path	int8:1
	nlayers		int8:2
	track_density	int8:4
	linear_density	int8:4
	bca		int8:1
	start_sector	int32
	end_sector	int32
	end_sector_l0	int32
}

dvd_copyright {
	type		const[DVD_STRUCT_COPYRIGHT, int8]

	layer_num	int8[0:3]
	cpst		int8
	rmi		int8
}

dvd_disckey {
	type	const[DVD_STRUCT_DISCKEY, int8]

	agid	int32:2
	value	array[int8, 2048]
}

dvd_bca {
	type	const[DVD_STRUCT_BCA, int8]

	len	len[value, int32]
	value	array[int8, 188]
}

dvd_manufact {
	type		const[DVD_STRUCT_MANUFACT, int8]

	layer_num	int8[0:3]
	len		len[value, int32]
	value		array[int8, 2048]
}

dvd_authinfo [
	type	flags[dvd_authinfo_type, int8]

	lsa	dvd_lu_send_agid
	hsc	dvd_host_send_challenge
	lsk	dvd_send_key
	lsc	dvd_lu_send_challenge
	hsk	dvd_send_key
	lstk	dvd_lu_send_title_key
	lsasf	dvd_lu_send_asf
	hrpcs	dvd_host_send_rpcstate
	lrpcs	dvd_lu_send_rpcstate
]

type dvd_key array[int8, 5]
type dvd_challenge array[int8, 10]

dvd_lu_send_agid {
	type	const[DVD_LU_SEND_AGID, int8]
	agid	int32:2
}

dvd_host_send_challenge {
	type	const[DVD_HOST_SEND_CHALLENGE, int8]
	agid	int32:2

	chal	dvd_challenge
}

dvd_send_key_type = DVD_LU_SEND_KEY1, DVD_HOST_SEND_KEY2

dvd_send_key {
	type	flags[dvd_send_key_type, int8]
	agid	int32:2

	key	dvd_key
}

dvd_lu_send_challenge {
	type	const[DVD_LU_SEND_CHALLENGE, int8]
	agid	int32:2

	chal	dvd_challenge
}

dvd_lu_send_title_key {
	type		const[DVD_LU_SEND_TITLE_KEY, int8]
	agid		int32:2

	title_key	dvd_key
	lba		int32
	cpm		int32:1
	cp_sec		int32:1
	cgms		int32:2
}

dvd_lu_send_asf {
	type	const[DVD_LU_SEND_ASF, int8]
	agid	int32:2

	asf	int32:1
}

dvd_host_send_rpcstate {
	type	const[DVD_HOST_SEND_RPC_STATE, int8]
	pdrc	int8
}

dvd_lu_send_rpcstate {
	type		int8:2
	vra		int8:3
	ucca		int8:3
	region_mask	int8
	rpc_scheme	int8
}

cdrom_generic_command {
	cmd		array[int8, CDROM_PACKET_SIZE]
	buffer		ptr[inout, array[int8]]
	buflen		len[buffer, int32]
	stat		int32
	sense		ptr[inout, request_sense]
	data_direction	flags[cdrom_data_direction, int8]
	quiet		int32
	timeout		int32
	reserved	ptr[out, array[intptr, 1]]
}

request_sense {
	error_code	int8:7
	valid		int8:1
	segment_number	int8
	sense_key	int8:4
	reserved2	const[0, int8:1]
	ili		int8:1
	reserved1	const[0, int8:2]
	information	array[int8, 4]
	add_sense_len	int8
	command_info	array[int8, 4]
	asc		int8
	ascq		int8
	fruc		int8
	sks		array[int8, 3]
	asb		array[int8, 46]
}

cdrom_options = CDO_AUTO_CLOSE, CDO_AUTO_EJECT, CDO_USE_FFLAGS, CDO_LOCK, CDO_CHECK_TYPE
cdrom_format = CDROM_MSF, CDROM_LBA
dvd_struct_type = DVD_STRUCT_PHYSICAL, DVD_STRUCT_COPYRIGHT, DVD_STRUCT_DISCKEY, DVD_STRUCT_BCA, DVD_STRUCT_MANUFACT
dvd_authinfo_type = DVD_LU_SEND_AGID, DVD_LU_SEND_KEY1, DVD_LU_SEND_CHALLENGE, DVD_LU_SEND_TITLE_KEY, DVD_LU_SEND_ASF, DVD_HOST_SEND_CHALLENGE, DVD_HOST_SEND_KEY2, DVD_INVALIDATE_AGID, DVD_LU_SEND_RPC_STATE, DVD_LU_SEND_RPC_STATE
cdrom_data_direction = CGC_DATA_UNKNOWN, CGC_DATA_WRITE, CGC_DATA_READ, CGC_DATA_NONE

define CDROM_MSF_OUT_STUB_SIZE	CD_FRAMESIZE_RAWER-6